Mercurial > libavcodec.hg
diff msmpeg4.c @ 208:2eb04d6be309 libavcodec
(commit by michael)
bye bye weird al rounding bug ;)
author | arpi_esp |
---|---|
date | Tue, 15 Jan 2002 22:22:41 +0000 |
parents | fceb435fae6b |
children | 73df666cacc7 |
line wrap: on
line diff
--- a/msmpeg4.c Tue Jan 15 05:02:26 2002 +0000 +++ b/msmpeg4.c Tue Jan 15 22:22:41 2002 +0000 @@ -185,7 +185,12 @@ put_bits(&s->pb, 1, s->dc_table_index); put_bits(&s->pb, 1, s->mv_table_index); - s->no_rounding ^= 1; + + if(s->flipflop_rounding){ + s->no_rounding ^= 1; + }else{ + s->no_rounding = 0; + } } if (!init_done) { @@ -203,6 +208,27 @@ #endif } +void msmpeg4_encode_ext_header(MpegEncContext * s) +{ + if(s->pict_type == P_TYPE) + { + return; // P-Frames dont seem to have them and not even a 0 bit + } + else + { + s->flipflop_rounding=1; + s->bitrate= 910; + + put_bits(&s->pb, 1, 1); // ext header indicator + + put_bits(&s->pb, 4, 7); // ? + + put_bits(&s->pb, 11, s->bitrate); + + put_bits(&s->pb, 1, s->flipflop_rounding); + } +} + /* predict coded block */ static inline int coded_block_pred(MpegEncContext * s, int n, UINT8 **coded_block_ptr) { @@ -654,7 +680,6 @@ int msmpeg4_decode_picture_header(MpegEncContext * s) { int code; -static int weirdAl=0; s->pict_type = get_bits(&s->gb, 2) + 1; if (s->pict_type != I_TYPE && @@ -696,17 +721,53 @@ s->rl_chroma_table_index, s->dc_table_index, s->mv_table_index);*/ - if(weirdAl) - s->no_rounding = 0; - else - s->no_rounding ^= 1; + if(s->flipflop_rounding){ + s->no_rounding ^= 1; + }else{ + s->no_rounding = 0; + } +// printf("%d", s->no_rounding); } + + #ifdef DEBUG printf("*****frame %d:\n", frame_count++); #endif return 0; } +int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size) +{ + int firstBit=0; + + /* the alt_bitstream reader could read over the end so we need to check it */ + if(get_bits_count(&s->gb) < buf_size*8) firstBit= get_bits1(&s->gb); + + if(s->pict_type == P_TYPE) + { + if(firstBit) return -1; // havnt seen ext headers in P-Frames yet ;) + } + else + { + int unk; + if(!firstBit) // no header found + { + s->flipflop_rounding= 0; + s->bitrate= 0; + return 0; + } + + unk= get_bits(&s->gb, 4); + s->bitrate= get_bits(&s->gb, 11); + +// printf("%2d %4d ;; %1X\n", unk,s->bitrate, unk); + + s->flipflop_rounding= get_bits1(&s->gb); + } + + return 0; +} + void memsetw(short *tab, int val, int n) { int i;