Mercurial > libavcodec.hg
comparison h263.c @ 1070:6da5ae9ee199 libavcodec
more #ifdef CONFIG_ENCODERS patch by (Wolfgang Hesseler <qv at multimediaware dot com>) with modifications by me (s/WOLFGANG/CONFIG_ENCODERS/ and some other fixes)
author | michaelni |
---|---|
date | Sun, 16 Feb 2003 23:05:38 +0000 |
parents | a5be963709d1 |
children | 7e79a58954b1 |
comparison
equal
deleted
inserted
replaced
1069:8528d0b9e508 | 1070:6da5ae9ee199 |
---|---|
71 int n, int coded); | 71 int n, int coded); |
72 static inline int mpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr); | 72 static inline int mpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr); |
73 static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block, | 73 static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block, |
74 int n, int coded, int intra); | 74 int n, int coded, int intra); |
75 static int h263_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr); | 75 static int h263_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr); |
76 #ifdef CONFIG_ENCODERS | |
76 static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n, | 77 static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n, |
77 int dir); | 78 int dir); |
79 #endif //CONFIG_ENCODERS | |
78 static void mpeg4_decode_sprite_trajectory(MpegEncContext * s); | 80 static void mpeg4_decode_sprite_trajectory(MpegEncContext * s); |
79 static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr, int *dir_ptr); | 81 static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr, int *dir_ptr); |
80 | 82 |
81 extern uint32_t inverse[256]; | 83 extern uint32_t inverse[256]; |
82 | 84 |
85 #ifdef CONFIG_ENCODERS | |
83 static uint8_t uni_DCtab_lum_len[512]; | 86 static uint8_t uni_DCtab_lum_len[512]; |
84 static uint8_t uni_DCtab_chrom_len[512]; | 87 static uint8_t uni_DCtab_chrom_len[512]; |
85 static uint16_t uni_DCtab_lum_bits[512]; | 88 static uint16_t uni_DCtab_lum_bits[512]; |
86 static uint16_t uni_DCtab_chrom_bits[512]; | 89 static uint16_t uni_DCtab_chrom_bits[512]; |
87 | 90 |
88 #ifdef CONFIG_ENCODERS | |
89 static uint16_t (*mv_penalty)[MAX_MV*2+1]= NULL; | 91 static uint16_t (*mv_penalty)[MAX_MV*2+1]= NULL; |
90 static uint8_t fcode_tab[MAX_MV*2+1]; | 92 static uint8_t fcode_tab[MAX_MV*2+1]; |
91 static uint8_t umv_fcode_tab[MAX_MV*2+1]; | 93 static uint8_t umv_fcode_tab[MAX_MV*2+1]; |
92 | 94 |
93 static uint32_t uni_mpeg4_intra_rl_bits[64*64*2*2]; | 95 static uint32_t uni_mpeg4_intra_rl_bits[64*64*2*2]; |
126 format = 5; | 128 format = 5; |
127 else | 129 else |
128 format = 7; | 130 format = 7; |
129 return format; | 131 return format; |
130 } | 132 } |
133 | |
134 #ifdef CONFIG_ENCODERS | |
131 | 135 |
132 static void float_aspect_to_info(MpegEncContext * s, float aspect){ | 136 static void float_aspect_to_info(MpegEncContext * s, float aspect){ |
133 int i; | 137 int i; |
134 | 138 |
135 aspect*= s->height/(double)s->width; | 139 aspect*= s->height/(double)s->width; |
395 } | 399 } |
396 } | 400 } |
397 } | 401 } |
398 } | 402 } |
399 | 403 |
404 #endif //CONFIG_ENCODERS | |
405 | |
400 void ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my){ | 406 void ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my){ |
401 const int mb_index= s->mb_x + s->mb_y*s->mb_width; | 407 const int mb_index= s->mb_x + s->mb_y*s->mb_width; |
402 int xy= s->block_index[0]; | 408 int xy= s->block_index[0]; |
403 uint16_t time_pp= s->pp_time; | 409 uint16_t time_pp= s->pp_time; |
404 uint16_t time_pb= s->pb_time; | 410 uint16_t time_pb= s->pb_time; |
1008 //pred_dc = (pred_dc + (scale >> 1)) / scale; | 1014 //pred_dc = (pred_dc + (scale >> 1)) / scale; |
1009 *dc_val_ptr = &dc_val[x + y * wrap]; | 1015 *dc_val_ptr = &dc_val[x + y * wrap]; |
1010 return pred_dc; | 1016 return pred_dc; |
1011 } | 1017 } |
1012 | 1018 |
1013 | |
1014 static void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n) | 1019 static void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n) |
1015 { | 1020 { |
1016 int x, y, wrap, a, c, pred_dc, scale, i; | 1021 int x, y, wrap, a, c, pred_dc, scale, i; |
1017 int16_t *dc_val, *ac_val, *ac_val1; | 1022 int16_t *dc_val, *ac_val, *ac_val1; |
1018 | 1023 |
1288 umv_fcode_tab[mv]= 1; | 1293 umv_fcode_tab[mv]= 1; |
1289 } | 1294 } |
1290 } | 1295 } |
1291 #endif | 1296 #endif |
1292 | 1297 |
1298 #ifdef CONFIG_ENCODERS | |
1299 | |
1293 static void init_uni_dc_tab(void) | 1300 static void init_uni_dc_tab(void) |
1294 { | 1301 { |
1295 int level, uni_code, uni_len; | 1302 int level, uni_code, uni_len; |
1296 | 1303 |
1297 for(level=-256; level<256; level++){ | 1304 for(level=-256; level<256; level++){ |
1339 uni_DCtab_chrom_bits[level+256]= uni_code; | 1346 uni_DCtab_chrom_bits[level+256]= uni_code; |
1340 uni_DCtab_chrom_len [level+256]= uni_len; | 1347 uni_DCtab_chrom_len [level+256]= uni_len; |
1341 | 1348 |
1342 } | 1349 } |
1343 } | 1350 } |
1351 | |
1352 #endif //CONFIG_ENCODERS | |
1344 | 1353 |
1345 #ifdef CONFIG_ENCODERS | 1354 #ifdef CONFIG_ENCODERS |
1346 static void init_uni_mpeg4_rl_tab(RLTable *rl, uint32_t *bits_tab, uint8_t *len_tab){ | 1355 static void init_uni_mpeg4_rl_tab(RLTable *rl, uint32_t *bits_tab, uint8_t *len_tab){ |
1347 int slevel, run, last; | 1356 int slevel, run, last; |
1348 | 1357 |
1547 } | 1556 } |
1548 } | 1557 } |
1549 } | 1558 } |
1550 #endif | 1559 #endif |
1551 | 1560 |
1561 #ifdef CONFIG_ENCODERS | |
1562 | |
1552 /***************************************************/ | 1563 /***************************************************/ |
1553 /** | 1564 /** |
1554 * add mpeg4 stuffing bits (01...1) | 1565 * add mpeg4 stuffing bits (01...1) |
1555 */ | 1566 */ |
1556 void ff_mpeg4_stuffing(PutBitContext * pbc) | 1567 void ff_mpeg4_stuffing(PutBitContext * pbc) |
1796 s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table; | 1807 s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table; |
1797 s->h_edge_pos= s->width; | 1808 s->h_edge_pos= s->width; |
1798 s->v_edge_pos= s->height; | 1809 s->v_edge_pos= s->height; |
1799 } | 1810 } |
1800 | 1811 |
1812 #endif //CONFIG_ENCODERS | |
1813 | |
1801 /** | 1814 /** |
1802 * change qscale by given dquant and update qscale dependant variables. | 1815 * change qscale by given dquant and update qscale dependant variables. |
1803 */ | 1816 */ |
1804 static void change_qscale(MpegEncContext * s, int dquant) | 1817 static void change_qscale(MpegEncContext * s, int dquant) |
1805 { | 1818 { |
1935 /* top copy */ | 1948 /* top copy */ |
1936 for(i=1;i<8;i++) | 1949 for(i=1;i<8;i++) |
1937 ac_val1[8 + i] = block[s->idct_permutation[i ]]; | 1950 ac_val1[8 + i] = block[s->idct_permutation[i ]]; |
1938 | 1951 |
1939 } | 1952 } |
1953 | |
1954 #ifdef CONFIG_ENCODERS | |
1940 | 1955 |
1941 static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n, | 1956 static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n, |
1942 int dir) | 1957 int dir) |
1943 { | 1958 { |
1944 int i; | 1959 int i; |
2023 if (size > 8) | 2038 if (size > 8) |
2024 put_bits(&s->pb, 1, 1); | 2039 put_bits(&s->pb, 1, 1); |
2025 } | 2040 } |
2026 #endif | 2041 #endif |
2027 } | 2042 } |
2028 #ifdef CONFIG_ENCODERS | 2043 |
2029 /** | 2044 /** |
2030 * encodes a 8x8 block | 2045 * encodes a 8x8 block |
2031 * @param n block index (0-3 are luma, 4-5 are chroma) | 2046 * @param n block index (0-3 are luma, 4-5 are chroma) |
2032 */ | 2047 */ |
2033 static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n, int intra_dc, | 2048 static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n, int intra_dc, |
2361 int i; | 2376 int i; |
2362 for(i=0;i<n;i++) | 2377 for(i=0;i<n;i++) |
2363 tab[i] = val; | 2378 tab[i] = val; |
2364 } | 2379 } |
2365 | 2380 |
2381 #ifdef CONFIG_ENCODERS | |
2382 | |
2366 void ff_mpeg4_init_partitions(MpegEncContext *s) | 2383 void ff_mpeg4_init_partitions(MpegEncContext *s) |
2367 { | 2384 { |
2368 init_put_bits(&s->tex_pb, s->tex_pb_buffer, PB_BUFFER_SIZE, NULL, NULL); | 2385 init_put_bits(&s->tex_pb, s->tex_pb_buffer, PB_BUFFER_SIZE, NULL, NULL); |
2369 init_put_bits(&s->pb2 , s->pb2_buffer , PB_BUFFER_SIZE, NULL, NULL); | 2386 init_put_bits(&s->pb2 , s->pb2_buffer , PB_BUFFER_SIZE, NULL, NULL); |
2370 } | 2387 } |
2391 | 2408 |
2392 ff_copy_bits(&s->pb, s->pb2_buffer , pb2_len); | 2409 ff_copy_bits(&s->pb, s->pb2_buffer , pb2_len); |
2393 ff_copy_bits(&s->pb, s->tex_pb_buffer, tex_pb_len); | 2410 ff_copy_bits(&s->pb, s->tex_pb_buffer, tex_pb_len); |
2394 s->last_bits= get_bit_count(&s->pb); | 2411 s->last_bits= get_bit_count(&s->pb); |
2395 } | 2412 } |
2413 | |
2414 #endif //CONFIG_ENCODERS | |
2396 | 2415 |
2397 int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s){ | 2416 int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s){ |
2398 switch(s->pict_type){ | 2417 switch(s->pict_type){ |
2399 case I_TYPE: | 2418 case I_TYPE: |
2400 return 16; | 2419 return 16; |
2406 default: | 2425 default: |
2407 return -1; | 2426 return -1; |
2408 } | 2427 } |
2409 } | 2428 } |
2410 | 2429 |
2430 #ifdef CONFIG_ENCODERS | |
2431 | |
2411 void ff_mpeg4_encode_video_packet_header(MpegEncContext *s) | 2432 void ff_mpeg4_encode_video_packet_header(MpegEncContext *s) |
2412 { | 2433 { |
2413 int mb_num_bits= av_log2(s->mb_num - 1) + 1; | 2434 int mb_num_bits= av_log2(s->mb_num - 1) + 1; |
2414 | 2435 |
2415 ff_mpeg4_stuffing(&s->pb); | 2436 ff_mpeg4_stuffing(&s->pb); |
2418 | 2439 |
2419 put_bits(&s->pb, mb_num_bits, s->mb_x + s->mb_y*s->mb_width); | 2440 put_bits(&s->pb, mb_num_bits, s->mb_x + s->mb_y*s->mb_width); |
2420 put_bits(&s->pb, s->quant_precision, s->qscale); | 2441 put_bits(&s->pb, s->quant_precision, s->qscale); |
2421 put_bits(&s->pb, 1, 0); /* no HEC */ | 2442 put_bits(&s->pb, 1, 0); /* no HEC */ |
2422 } | 2443 } |
2444 | |
2445 #endif //CONFIG_ENCODERS | |
2423 | 2446 |
2424 /** | 2447 /** |
2425 * check if the next stuff is a resync marker or the end. | 2448 * check if the next stuff is a resync marker or the end. |
2426 * @return 0 if not | 2449 * @return 0 if not |
2427 */ | 2450 */ |