[FFmpeg-cvslog] h264_direct: use the reference mask from the actual reference

Anton Khirnov git at videolan.org
Sat Mar 18 20:32:50 EET 2017


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Tue Aug  2 10:43:39 2016 +0200| [04763c6f87690b31cfcd0d324cf36a451531dcd0] | committer: Anton Khirnov

h264_direct: use the reference mask from the actual reference

Not from the underlying frame. Fixes races with frame threading in
field-coded files, where decoding would wait for the wrong field (e.g.
random failures in mixed-nal-coding).

Bug-Id: 954

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=04763c6f87690b31cfcd0d324cf36a451531dcd0
---

 libavcodec/h264_direct.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c
index 85a4760..7ec49b6 100644
--- a/libavcodec/h264_direct.c
+++ b/libavcodec/h264_direct.c
@@ -160,11 +160,11 @@ void ff_h264_direct_ref_list_init(const H264Context *const h, H264SliceContext *
     }
 }
 
-static void await_reference_mb_row(const H264Context *const h, H264Picture *ref,
+static void await_reference_mb_row(const H264Context *const h, H264Ref *ref,
                                    int mb_y)
 {
     int ref_field         = ref->reference - 1;
-    int ref_field_picture = ref->field_picture;
+    int ref_field_picture = ref->parent->field_picture;
     int ref_height        = 16 * h->mb_height >> ref_field_picture;
 
     if (!HAVE_THREADS || !(h->avctx->active_thread_type & FF_THREAD_FRAME))
@@ -173,7 +173,7 @@ static void await_reference_mb_row(const H264Context *const h, H264Picture *ref,
     /* FIXME: It can be safe to access mb stuff
      * even if pixels aren't deblocked yet. */
 
-    ff_thread_await_progress(&ref->tf,
+    ff_thread_await_progress(&ref->parent->tf,
                              FFMIN(16 * mb_y >> ref_field_picture,
                                    ref_height - 1),
                              ref_field_picture && ref_field);
@@ -197,7 +197,7 @@ static void pred_spatial_direct_motion(const H264Context *const h, H264SliceCont
 
     assert(sl->ref_list[1][0].reference & 3);
 
-    await_reference_mb_row(h, sl->ref_list[1][0].parent,
+    await_reference_mb_row(h, &sl->ref_list[1][0],
                            sl->mb_y + !!IS_INTERLACED(*mb_type));
 
 #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \
@@ -321,7 +321,7 @@ single_col:
         }
     }
 
-    await_reference_mb_row(h, sl->ref_list[1][0].parent, mb_y);
+    await_reference_mb_row(h, &sl->ref_list[1][0], mb_y);
 
     l1mv0  = &sl->ref_list[1][0].parent->motion_val[0][h->mb2b_xy[mb_xy]];
     l1mv1  = &sl->ref_list[1][0].parent->motion_val[1][h->mb2b_xy[mb_xy]];
@@ -480,7 +480,7 @@ static void pred_temp_direct_motion(const H264Context *const h, H264SliceContext
 
     assert(sl->ref_list[1][0].reference & 3);
 
-    await_reference_mb_row(h, sl->ref_list[1][0].parent,
+    await_reference_mb_row(h, &sl->ref_list[1][0],
                            sl->mb_y + !!IS_INTERLACED(*mb_type));
 
     if (IS_INTERLACED(sl->ref_list[1][0].parent->mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
@@ -545,7 +545,7 @@ single_col:
         }
     }
 
-    await_reference_mb_row(h, sl->ref_list[1][0].parent, mb_y);
+    await_reference_mb_row(h, &sl->ref_list[1][0], mb_y);
 
     l1mv0  = &sl->ref_list[1][0].parent->motion_val[0][h->mb2b_xy[mb_xy]];
     l1mv1  = &sl->ref_list[1][0].parent->motion_val[1][h->mb2b_xy[mb_xy]];



More information about the ffmpeg-cvslog mailing list