changeset 365:fdeec2834c79 libavcodec

there are divx5? encoded files without a userdata section but with b-frames :(
author michaelni
date Mon, 06 May 2002 13:15:05 +0000
parents 6b6332e7008a
children 94268ece131e
files h263.c mpegvideo.c mpegvideo.h
diffstat 3 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/h263.c	Sun May 05 19:03:24 2002 +0000
+++ b/h263.c	Mon May 06 13:15:05 2002 +0000
@@ -2747,7 +2747,6 @@
 {
     int time_incr, startcode, state, v;
     int time_increment;
-    int vol_control=-1;
 
  redo:
     /* search next start code */
@@ -2791,7 +2790,7 @@
             skip_bits(&s->gb, 8); // par_height
         }
 
-        if ((vol_control=get_bits1(&s->gb))) { /* vol control parameter */
+        if ((s->vol_control_parameters=get_bits1(&s->gb))) { /* vol control parameter */
             int chroma_format= get_bits(&s->gb, 2);
             if(chroma_format!=1){
                 printf("illegal chroma format\n");
@@ -3000,6 +2999,10 @@
     }
 
     s->pict_type = get_bits(&s->gb, 2) + I_TYPE;	/* pict type: I = 0 , P = 1 */
+    if(s->pict_type==B_TYPE && s->low_delay && s->vol_control_parameters==0){
+        printf("low_delay flag set, but shouldnt, clearing it\n");
+        s->low_delay=0;
+    }
 // printf("pic: %d, qpel:%d\n", s->pict_type, s->quarter_sample); 
     time_incr=0;
     while (get_bits1(&s->gb) != 0) 
@@ -3109,9 +3112,8 @@
      }
      /* detect buggy encoders which dont set the low_delay flag (divx4/xvid/opendivx)*/
      // note we cannot detect divx5 without b-frames easyly (allthough its buggy too)
-     if(s->vo_type==0 && vol_control==0 && s->divx_version==0){
-         if(s->picture_number==0)
-             printf("looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
+     if(s->vo_type==0 && s->vol_control_parameters==0 && s->divx_version==0 && s->picture_number==0){
+         printf("looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
          s->low_delay=1;
      }
 
--- a/mpegvideo.c	Sun May 05 19:03:24 2002 +0000
+++ b/mpegvideo.c	Mon May 06 13:15:05 2002 +0000
@@ -159,7 +159,9 @@
         s->next_picture_base[i] = pict;
         s->next_picture[i] = pict + pict_start;
         
-        if (s->has_b_frames) {
+        if (s->has_b_frames || s->codec_id==CODEC_ID_MPEG4) {
+        /* Note the MPEG4 stuff is here cuz of buggy encoders which dont set the low_delay flag but 
+           do low-delay encoding, so we cant allways distinguish b-frame containing streams from low_delay streams */
             pict = av_mallocz(c_size);
             if (pict == NULL) 
                 goto fail;
--- a/mpegvideo.h	Sun May 05 19:03:24 2002 +0000
+++ b/mpegvideo.h	Mon May 06 13:15:05 2002 +0000
@@ -313,6 +313,7 @@
     int resync_x_pos;
     int low_delay;                   /* no reordering needed / has no b-frames */
     int vo_type;
+    int vol_control_parameters;      /* does the stream contain the low_delay flag, used to workaround buggy encoders */
 
     /* divx specific, used to workaround (many) bugs in divx5 */
     int divx_version;