[FFmpeg-devel] [RFC] Error concealment for B-frames/fixing issue 824

Reimar Döffinger Reimar.Doeffinger
Thu Apr 9 11:37:32 CEST 2009


Hello,
please be kind, I do not know much about the code...
My idea was that we already have error concealment code and it could be
used instead of just dropping B-frame, which attached patch should do.
I do admit though that I am not sure about the full consequence of this
change, in particular if it might make error concealment worse in some
cases.
-------------- next part --------------
Index: libavcodec/mpegvideo.c
===================================================================
--- libavcodec/mpegvideo.c	(revision 18382)
+++ libavcodec/mpegvideo.c	(working copy)
@@ -948,7 +948,10 @@
 
     if(s->pict_type != FF_I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) && !s->dropable && s->codec_id != CODEC_ID_H264){
         av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n");
-        assert(s->pict_type != FF_B_TYPE); //these should have been dropped if we don't have a reference
+        if (s->pict_type == FF_B_TYPE) {
+            s->last_picture_ptr = s->next_picture_ptr;
+            if(s->last_picture_ptr) ff_copy_picture(&s->last_picture, s->last_picture_ptr);
+        }
         goto alloc;
     }
 
Index: libavcodec/mpeg12.c
===================================================================
--- libavcodec/mpeg12.c	(revision 18382)
+++ libavcodec/mpeg12.c	(working copy)
@@ -2385,10 +2385,7 @@
                 start_code <= SLICE_MAX_START_CODE) {
                 int mb_y= start_code - SLICE_MIN_START_CODE;
 
-                if(s2->last_picture_ptr==NULL){
-                /* Skip B-frames if we do not have reference frames. */
-                    if(s2->pict_type==FF_B_TYPE) break;
-                }
+                /* B-frames with missing reference frames are handled by error concealment code. */
                 if(s2->next_picture_ptr==NULL){
                 /* Skip P-frames if we do not have a reference frame or we have an invalid header. */
                     if(s2->pict_type==FF_P_TYPE && (s2->first_field || s2->picture_structure==PICT_FRAME)) break;



More information about the ffmpeg-devel mailing list