---
 libavcodec/h264.c |   51 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 18cc5ad..ba435fa 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -2510,7 +2510,12 @@ static void decode_postinit(H264Context *h){
 
     // Don't do anything if it's the first field or we've already been called.
     // FIXME the first field should call ff_report_frame_setup_done() even if it skips the rest
-    if (h->next_output_pic || cur->field_poc[0]==INT_MAX || cur->field_poc[1]==INT_MAX) return;
+    if (h->next_output_pic) return;
+
+    if (cur->field_poc[0]==INT_MAX || cur->field_poc[1]==INT_MAX) {
+        ff_report_frame_setup_done(s->avctx);
+        return;
+    }
 
     cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE;
     /* Derive top_field_first from field pocs. */
@@ -4075,7 +4080,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
             h->prev_frame_num++;
             h->prev_frame_num %= 1<<h->sps.log2_max_frame_num;
             s->current_picture_ptr->frame_num= h->prev_frame_num;
-            ff_report_frame_progress((AVFrame*)s->current_picture_ptr, INT_MAX);
+            ff_report_field_progress((AVFrame*)s->current_picture_ptr, INT_MAX, 0);
+            ff_report_field_progress((AVFrame*)s->current_picture_ptr, INT_MAX, 1);
             execute_ref_pic_marking(h, NULL, 0);
         }
 
@@ -6903,17 +6909,37 @@ static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8
 }
 
 /**
- * Report the last pixel row fully decoded.
- *
- * Lower rows than (last row of last MB - 3) might be changed in deblocking.
+ * Draw edges and report progress for the last MB row.
  */
-static void report_decode_progress(AVCodecContext *avctx, H264Context *h){
+static void decode_finish_row(H264Context *h){
     MpegEncContext * const s = &h->s;
-    int rows = FIELD_OR_MBAFF_PICTURE ? 2 : 1;
+    int top = 16*(s->mb_y >> FIELD_PICTURE);
+    int height = 16 << FRAME_MBAFF;
+    int deblock_border = (16 + 4) << FRAME_MBAFF;
+    int pic_height = 16*s->mb_height >> FIELD_PICTURE;
+
+    if (h->deblocking_filter) {
+        if((top + height) >= pic_height)
+            height += deblock_border;
+
+        top -= deblock_border;
+    }
+
+    if (top >= pic_height || (top + height) < h->emu_edge_height)
+        return;
+
+    height = FFMIN(height, pic_height - top);
+    if (top < h->emu_edge_height) {
+        height = top+height;
+        top = 0;
+    }
+
+    ff_draw_horiz_band(s, top, height);
 
     if (s->dropable) return;
 
-    ff_report_frame_progress((AVFrame*)s->current_picture_ptr, (s->mb_y - rows) * 16 - 3);
+    ff_report_field_progress((AVFrame*)s->current_picture_ptr, top + height - 1,
+                             s->picture_structure==PICT_BOTTOM_FIELD);
 }
 
 static int decode_slice(struct AVCodecContext *avctx, H264Context *h){
@@ -6973,8 +6999,7 @@ static int decode_slice(struct AVCodecContext *avctx, H264Context *h){
 
             if( ++s->mb_x >= s->mb_width ) {
                 s->mb_x = 0;
-                ff_draw_horiz_band(s, 16*s->mb_y >> FIELD_PICTURE, FRAME_MBAFF ? 32 : 16);
-                report_decode_progress(avctx, h);
+                decode_finish_row(h);
                 ++s->mb_y;
                 if(FIELD_OR_MBAFF_PICTURE) {
                     ++s->mb_y;
@@ -7011,8 +7036,7 @@ static int decode_slice(struct AVCodecContext *avctx, H264Context *h){
 
             if(++s->mb_x >= s->mb_width){
                 s->mb_x=0;
-                ff_draw_horiz_band(s, 16*s->mb_y >> FIELD_PICTURE, FRAME_MBAFF ? 32 : 16);
-                report_decode_progress(avctx, h);
+                decode_finish_row(h);
                 ++s->mb_y;
                 if(FIELD_OR_MBAFF_PICTURE) {
                     ++s->mb_y;
@@ -7901,7 +7925,8 @@ static int decode_frame(AVCodecContext *avctx,
         if(s->flags2 & CODEC_FLAG2_CHUNKS) decode_postinit(h);
 
         s->mb_y= 0;
-        ff_report_frame_progress((AVFrame*)s->current_picture_ptr, (16*s->mb_height >> s->first_field) - 1);
+        ff_report_field_progress((AVFrame*)s->current_picture_ptr, (16*s->mb_height >> FIELD_PICTURE) - 1,
+                                 s->picture_structure==PICT_BOTTOM_FIELD);
 
         if(!USE_FRAME_THREADING(avctx)){
             if(!s->dropable) {
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc

Reply via email to