[FFmpeg-devel] Fix decoding Xvid stream problem

Xwen.Kong konsunwin
Fri Dec 4 05:22:38 CET 2009


Hi,everyone
    I use libavcodec to decode Xvid encoded stream, but sometime error,
output as:

            [mpeg4 @ 0x8bae990]hmm, seems the headers are not complete,
trying to guess time_increment_bits
            [mpeg4 @ 0x8bae990]my guess is 1 bits ;)
            [mpeg4 @ 0x8bae990]looks like this file was encoded with
(divx4/(old)xvid/opendivx) -> forcing low_delay flag

    but when output "my guess is 5 bits", it can be rightly decoded, so I
modified the code as follows:

 --- h263dec_ref.c       2009-03-02 13:18:33.000000000 +0800
+++ h263dec.c   2009-12-04 12:10:39.000000000 +0800
@@ -62,7 +62,7 @@
         break;
     case CODEC_ID_MPEG4:
         s->decode_mb= ff_mpeg4_decode_mb;
-        s->time_increment_bits = 4; /* default value for broken headers */
+        s->time_increment_bits = 5; /* default value for broken headers */
         s->h263_pred = 1;
         s->low_delay = 0; //default, might be overriden in the vol header
during header parsing
         break;


--- h263_ref.c  2009-02-25 00:12:47.000000000 +0800
+++ h263.c      2009-12-04 12:19:23.000000000 +0800
@@ -5878,7 +5878,7 @@
         time_incr++;

     check_marker(gb, "before time_increment");
-
+/*
     if(s->time_increment_bits==0 || !(show_bits(gb,
s->time_increment_bits+1)&1)){
         av_log(s->avctx, AV_LOG_ERROR, "hmm, seems the headers are not
complete, trying to guess time_increment_bits\n");

@@ -5888,7 +5888,7 @@

         av_log(s->avctx, AV_LOG_ERROR, "my guess is %d bits
;)\n",s->time_increment_bits);
     }
-
+*/
     if(IS_3IV1) time_increment= get_bits1(gb); //FIXME investigate further
     else time_increment= get_bits(gb, s->time_increment_bits);

Are there any other better advices ?



More information about the ffmpeg-devel mailing list