Mercurial > libavcodec.hg
comparison h263.c @ 815:78accc54493b libavcodec
put a few large tables under #ifdef CONFIG_ENCODERS or dynamically allocate them
author | michaelni |
---|---|
date | Thu, 31 Oct 2002 16:11:03 +0000 |
parents | d1770a34e4f6 |
children | f5f2e162331c |
comparison
equal
deleted
inserted
replaced
814:8f31ed5bacd1 | 815:78accc54493b |
---|---|
47 #define DC_VLC_BITS 9 | 47 #define DC_VLC_BITS 9 |
48 #define SPRITE_TRAJ_VLC_BITS 6 | 48 #define SPRITE_TRAJ_VLC_BITS 6 |
49 #define MB_TYPE_B_VLC_BITS 4 | 49 #define MB_TYPE_B_VLC_BITS 4 |
50 #define TEX_VLC_BITS 9 | 50 #define TEX_VLC_BITS 9 |
51 | 51 |
52 #ifdef CONFIG_ENCODERS | |
52 static void h263_encode_block(MpegEncContext * s, DCTELEM * block, | 53 static void h263_encode_block(MpegEncContext * s, DCTELEM * block, |
53 int n); | 54 int n); |
54 static void h263_encode_motion(MpegEncContext * s, int val, int fcode); | 55 static void h263_encode_motion(MpegEncContext * s, int val, int fcode); |
55 static void h263p_encode_umotion(MpegEncContext * s, int val); | 56 static void h263p_encode_umotion(MpegEncContext * s, int val); |
56 static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, | 57 static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, |
57 int n, int dc, UINT8 *scan_table, | 58 int n, int dc, UINT8 *scan_table, |
58 PutBitContext *dc_pb, PutBitContext *ac_pb); | 59 PutBitContext *dc_pb, PutBitContext *ac_pb); |
60 #endif | |
61 | |
59 static int h263_decode_motion(MpegEncContext * s, int pred, int fcode); | 62 static int h263_decode_motion(MpegEncContext * s, int pred, int fcode); |
60 static int h263p_decode_umotion(MpegEncContext * s, int pred); | 63 static int h263p_decode_umotion(MpegEncContext * s, int pred); |
61 static int h263_decode_block(MpegEncContext * s, DCTELEM * block, | 64 static int h263_decode_block(MpegEncContext * s, DCTELEM * block, |
62 int n, int coded); | 65 int n, int coded); |
63 static inline int mpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr); | 66 static inline int mpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr); |
67 static void mpeg4_inv_pred_ac(MpegEncContext * s, INT16 *block, int n, | 70 static void mpeg4_inv_pred_ac(MpegEncContext * s, INT16 *block, int n, |
68 int dir); | 71 int dir); |
69 static void mpeg4_decode_sprite_trajectory(MpegEncContext * s); | 72 static void mpeg4_decode_sprite_trajectory(MpegEncContext * s); |
70 static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, UINT16 **dc_val_ptr, int *dir_ptr); | 73 static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, UINT16 **dc_val_ptr, int *dir_ptr); |
71 | 74 |
72 | |
73 extern UINT32 inverse[256]; | 75 extern UINT32 inverse[256]; |
74 | 76 |
75 static UINT16 mv_penalty[MAX_FCODE+1][MAX_MV*2+1]; | 77 static UINT16 uni_DCtab_lum [512][2]; |
78 static UINT16 uni_DCtab_chrom[512][2]; | |
79 | |
80 #ifdef CONFIG_ENCODERS | |
81 static UINT16 (*mv_penalty)[MAX_MV*2+1]= NULL; | |
76 static UINT8 fcode_tab[MAX_MV*2+1]; | 82 static UINT8 fcode_tab[MAX_MV*2+1]; |
77 static UINT8 umv_fcode_tab[MAX_MV*2+1]; | 83 static UINT8 umv_fcode_tab[MAX_MV*2+1]; |
78 | 84 |
79 static UINT16 uni_DCtab_lum [512][2]; | |
80 static UINT16 uni_DCtab_chrom[512][2]; | |
81 static UINT32 uni_mpeg4_intra_rl_bits[64*64*2*2]; | 85 static UINT32 uni_mpeg4_intra_rl_bits[64*64*2*2]; |
82 static UINT8 uni_mpeg4_intra_rl_len [64*64*2*2]; | 86 static UINT8 uni_mpeg4_intra_rl_len [64*64*2*2]; |
83 static UINT32 uni_mpeg4_inter_rl_bits[64*64*2*2]; | 87 static UINT32 uni_mpeg4_inter_rl_bits[64*64*2*2]; |
84 static UINT8 uni_mpeg4_inter_rl_len [64*64*2*2]; | 88 static UINT8 uni_mpeg4_inter_rl_len [64*64*2*2]; |
85 #define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128 + (run)*256 + (level)) | 89 #define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128 + (run)*256 + (level)) |
92 | 96 |
93 intra | 97 intra |
94 max level: 53/16 | 98 max level: 53/16 |
95 max run: 29/41 | 99 max run: 29/41 |
96 */ | 100 */ |
101 #endif | |
102 | |
97 | 103 |
98 int h263_get_picture_format(int width, int height) | 104 int h263_get_picture_format(int width, int height) |
99 { | 105 { |
100 int format; | 106 int format; |
101 | 107 |
362 } | 368 } |
363 } | 369 } |
364 } | 370 } |
365 } | 371 } |
366 | 372 |
373 #ifdef CONFIG_ENCODERS | |
367 void mpeg4_encode_mb(MpegEncContext * s, | 374 void mpeg4_encode_mb(MpegEncContext * s, |
368 DCTELEM block[6][64], | 375 DCTELEM block[6][64], |
369 int motion_x, int motion_y) | 376 int motion_x, int motion_y) |
370 { | 377 { |
371 int cbpc, cbpy, i, pred_x, pred_y; | 378 int cbpc, cbpy, i, pred_x, pred_y; |
868 block[i][0] = rec_intradc[i]; | 875 block[i][0] = rec_intradc[i]; |
869 | 876 |
870 } | 877 } |
871 } | 878 } |
872 } | 879 } |
880 #endif | |
873 | 881 |
874 static int h263_pred_dc(MpegEncContext * s, int n, UINT16 **dc_val_ptr) | 882 static int h263_pred_dc(MpegEncContext * s, int n, UINT16 **dc_val_ptr) |
875 { | 883 { |
876 int x, y, wrap, a, c, pred_dc, scale; | 884 int x, y, wrap, a, c, pred_dc, scale; |
877 INT16 *dc_val, *ac_val; | 885 INT16 *dc_val, *ac_val; |
1059 *py = mid_pred(A[1], B[1], C[1]); | 1067 *py = mid_pred(A[1], B[1], C[1]); |
1060 } | 1068 } |
1061 return mot_val; | 1069 return mot_val; |
1062 } | 1070 } |
1063 | 1071 |
1072 #ifdef CONFIG_ENCODERS | |
1064 static void h263_encode_motion(MpegEncContext * s, int val, int f_code) | 1073 static void h263_encode_motion(MpegEncContext * s, int val, int f_code) |
1065 { | 1074 { |
1066 int range, l, bit_size, sign, code, bits; | 1075 int range, l, bit_size, sign, code, bits; |
1067 | 1076 |
1068 if (val == 0) { | 1077 if (val == 0) { |
1150 | 1159 |
1151 static void init_mv_penalty_and_fcode(MpegEncContext *s) | 1160 static void init_mv_penalty_and_fcode(MpegEncContext *s) |
1152 { | 1161 { |
1153 int f_code; | 1162 int f_code; |
1154 int mv; | 1163 int mv; |
1164 | |
1165 if(mv_penalty==NULL) | |
1166 mv_penalty= av_mallocz( sizeof(UINT16)*(MAX_FCODE+1)*(2*MAX_MV+1) ); | |
1167 | |
1155 for(f_code=1; f_code<=MAX_FCODE; f_code++){ | 1168 for(f_code=1; f_code<=MAX_FCODE; f_code++){ |
1156 for(mv=-MAX_MV; mv<=MAX_MV; mv++){ | 1169 for(mv=-MAX_MV; mv<=MAX_MV; mv++){ |
1157 int len; | 1170 int len; |
1158 | 1171 |
1159 if(mv==0) len= mvtab[0][1]; | 1172 if(mv==0) len= mvtab[0][1]; |
1187 | 1200 |
1188 for(mv=0; mv<MAX_MV*2+1; mv++){ | 1201 for(mv=0; mv<MAX_MV*2+1; mv++){ |
1189 umv_fcode_tab[mv]= 1; | 1202 umv_fcode_tab[mv]= 1; |
1190 } | 1203 } |
1191 } | 1204 } |
1205 #endif | |
1192 | 1206 |
1193 static void init_uni_dc_tab(void) | 1207 static void init_uni_dc_tab(void) |
1194 { | 1208 { |
1195 int level, uni_code, uni_len; | 1209 int level, uni_code, uni_len; |
1196 | 1210 |
1240 uni_DCtab_chrom[level+256][1]= uni_len; | 1254 uni_DCtab_chrom[level+256][1]= uni_len; |
1241 | 1255 |
1242 } | 1256 } |
1243 } | 1257 } |
1244 | 1258 |
1259 #ifdef CONFIG_ENCODERS | |
1245 static void init_uni_mpeg4_rl_tab(RLTable *rl, UINT32 *bits_tab, UINT8 *len_tab){ | 1260 static void init_uni_mpeg4_rl_tab(RLTable *rl, UINT32 *bits_tab, UINT8 *len_tab){ |
1246 int slevel, run, last; | 1261 int slevel, run, last; |
1247 | 1262 |
1248 assert(MAX_LEVEL >= 64); | 1263 assert(MAX_LEVEL >= 64); |
1249 assert(MAX_RUN >= 63); | 1264 assert(MAX_RUN >= 63); |
1432 } | 1447 } |
1433 last_non_zero = i; | 1448 last_non_zero = i; |
1434 } | 1449 } |
1435 } | 1450 } |
1436 } | 1451 } |
1452 #endif | |
1437 | 1453 |
1438 /***************************************************/ | 1454 /***************************************************/ |
1439 /** | 1455 /** |
1440 * add mpeg4 stuffing bits (01...1) | 1456 * add mpeg4 stuffing bits (01...1) |
1441 */ | 1457 */ |
1830 if (size > 8) | 1846 if (size > 8) |
1831 put_bits(&s->pb, 1, 1); | 1847 put_bits(&s->pb, 1, 1); |
1832 } | 1848 } |
1833 #endif | 1849 #endif |
1834 } | 1850 } |
1835 | 1851 #ifdef CONFIG_ENCODERS |
1836 static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n, int intra_dc, | 1852 static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n, int intra_dc, |
1837 UINT8 *scan_table, PutBitContext *dc_pb, PutBitContext *ac_pb) | 1853 UINT8 *scan_table, PutBitContext *dc_pb, PutBitContext *ac_pb) |
1838 { | 1854 { |
1839 int i, last_non_zero; | 1855 int i, last_non_zero; |
1840 #if 0 //variables for the outcommented version | 1856 #if 0 //variables for the outcommented version |
1946 last_non_zero = i; | 1962 last_non_zero = i; |
1947 } | 1963 } |
1948 } | 1964 } |
1949 #endif | 1965 #endif |
1950 } | 1966 } |
1951 | 1967 #endif |
1952 | 1968 |
1953 | 1969 |
1954 /***********************************************/ | 1970 /***********************************************/ |
1955 /* decoding */ | 1971 /* decoding */ |
1956 | 1972 |