diff h263dec.c @ 341:bf26081c373c libavcodec

avcodec_flush_buffers()
author michaelni
date Wed, 24 Apr 2002 01:24:06 +0000
parents c56b45669214
children 9f6071a87e17
line wrap: on
line diff
--- a/h263dec.c	Tue Apr 23 08:52:53 2002 +0000
+++ b/h263dec.c	Wed Apr 24 01:24:06 2002 +0000
@@ -135,7 +135,6 @@
     } else {
         ret = h263_decode_picture_header(s);
     }
-    if(ret==FRAME_SKIPED) return 0;
 
         /* After H263 & mpeg4 header decode we have the height, width,*/
         /* and other parameters. So then we could init the picture   */
@@ -154,9 +153,12 @@
             return -1;
     }
 
+    if(ret==FRAME_SKIPED) return 0;
     if (ret < 0)
         return -1;
-
+    /* skip b frames if we dont have reference frames */
+    if(s->num_available_buffers<2 && s->pict_type==B_TYPE) return 0;
+        
     MPV_frame_start(s);
 
 #ifdef DEBUG
@@ -222,7 +224,8 @@
             }
             MPV_decode_mb(s, s->block);
         }
-        if (avctx->draw_horiz_band) {
+        if (    avctx->draw_horiz_band 
+            && (s->num_available_buffers>=1 || (!s->has_b_frames)) ) {
             UINT8 *src_ptr[3];
             int y, h, offset;
             y = s->mb_y * 16;
@@ -279,7 +282,11 @@
     /* we substract 1 because it is added on utils.c    */
     avctx->frame_number = s->picture_number - 1;
 
-    *data_size = sizeof(AVPicture);
+    /* dont output the last pic after seeking 
+       note we allready added +1 for the current pix in MPV_frame_end(s) */
+    if(s->num_available_buffers>=2 || (!s->has_b_frames))
+        *data_size = sizeof(AVPicture);
+
     return buf_size;
 }