[FFmpeg-cvslog] h264: move direct_spatial_mv_pred into the per-slice context

Anton Khirnov git at videolan.org
Sat Mar 21 14:46:53 CET 2015


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Jan 17 22:28:46 2015 +0100| [066aafced4dc6c7c9e7b37082635472249f1e93e] | committer: Anton Khirnov

h264: move direct_spatial_mv_pred into the per-slice context

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

 libavcodec/dxva2_h264.c  |    2 +-
 libavcodec/h264.c        |    2 +-
 libavcodec/h264.h        |    3 ++-
 libavcodec/h264_direct.c |    4 ++--
 libavcodec/h264_mvpred.h |    6 +++---
 libavcodec/h264_slice.c  |    4 ++--
 libavcodec/vaapi_h264.c  |    2 +-
 7 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index 9218316..ef2fc3d 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -279,7 +279,7 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
     slice->slice_qp_delta    = sl->qscale - h->pps.init_qp;
     slice->redundant_pic_cnt = h->redundant_pic_count;
     if (sl->slice_type == AV_PICTURE_TYPE_B)
-        slice->direct_spatial_mv_pred_flag = h->direct_spatial_mv_pred;
+        slice->direct_spatial_mv_pred_flag = sl->direct_spatial_mv_pred;
     slice->cabac_init_idc = h->pps.cabac ? h->cabac_init_idc : 0;
     if (h->deblocking_filter < 2)
         slice->disable_deblocking_filter_idc = 1 - h->deblocking_filter;
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 7227368..8196fd4 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1270,7 +1270,7 @@ int ff_set_ref_count(H264Context *h, H264SliceContext *sl)
 
     if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {
         if (sl->slice_type_nos == AV_PICTURE_TYPE_B)
-            h->direct_spatial_mv_pred = get_bits1(&h->gb);
+            sl->direct_spatial_mv_pred = get_bits1(&h->gb);
         num_ref_idx_active_override_flag = get_bits1(&h->gb);
 
         if (num_ref_idx_active_override_flag) {
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 6cd30e8..a259a97 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -355,6 +355,8 @@ typedef struct H264SliceContext {
      */
     int neighbor_transform_size;
 
+    int direct_spatial_mv_pred;
+
     /**
      * non zero coeff count cache.
      * is 64 if not available.
@@ -440,7 +442,6 @@ typedef struct H264Context {
     int picture_structure;
     int first_field;
 
-    int direct_spatial_mv_pred;
     int col_parity;
     int col_fieldoff;
     int dist_scale_factor[32];
diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c
index f944695..cd30dd3 100644
--- a/libavcodec/h264_direct.c
+++ b/libavcodec/h264_direct.c
@@ -140,7 +140,7 @@ void ff_h264_direct_ref_list_init(H264Context *const h, H264SliceContext *sl)
         h->col_fieldoff = 2 * h->ref_list[1][0].reference - 3;
     }
 
-    if (sl->slice_type_nos != AV_PICTURE_TYPE_B || h->direct_spatial_mv_pred)
+    if (sl->slice_type_nos != AV_PICTURE_TYPE_B || sl->direct_spatial_mv_pred)
         return;
 
     for (list = 0; list < 2; list++) {
@@ -694,7 +694,7 @@ single_col:
 void ff_h264_pred_direct_motion(H264Context *const h, H264SliceContext *sl,
                                 int *mb_type)
 {
-    if (h->direct_spatial_mv_pred)
+    if (sl->direct_spatial_mv_pred)
         pred_spatial_direct_motion(h, sl, mb_type);
     else
         pred_temp_direct_motion(h, sl, mb_type);
diff --git a/libavcodec/h264_mvpred.h b/libavcodec/h264_mvpred.h
index ce7716a..73e136e 100644
--- a/libavcodec/h264_mvpred.h
+++ b/libavcodec/h264_mvpred.h
@@ -603,7 +603,7 @@ static void fill_decode_caches(H264Context *h, H264SliceContext *sl, int mb_type
         }
     }
 
-    if (IS_INTER(mb_type) || (IS_DIRECT(mb_type) && h->direct_spatial_mv_pred)) {
+    if (IS_INTER(mb_type) || (IS_DIRECT(mb_type) && sl->direct_spatial_mv_pred)) {
         int list;
         int b_stride = h->b_stride;
         for (list = 0; list < h->list_count; list++) {
@@ -613,7 +613,7 @@ static void fill_decode_caches(H264Context *h, H264SliceContext *sl, int mb_type
             int16_t(*mv)[2]       = h->cur_pic.motion_val[list];
             if (!USES_LIST(mb_type, list))
                 continue;
-            assert(!(IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred));
+            assert(!(IS_DIRECT(mb_type) && !sl->direct_spatial_mv_pred));
 
             if (USES_LIST(top_type, list)) {
                 const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride;
@@ -813,7 +813,7 @@ static void av_unused decode_mb_skip(H264Context *h, H264SliceContext *sl)
     if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
         // just for fill_caches. pred_direct_motion will set the real mb_type
         mb_type |= MB_TYPE_L0L1 | MB_TYPE_DIRECT2 | MB_TYPE_SKIP;
-        if (h->direct_spatial_mv_pred) {
+        if (sl->direct_spatial_mv_pred) {
             fill_decode_neighbors(h, sl, mb_type);
             fill_decode_caches(h, sl, mb_type); //FIXME check what is needed and what not ...
         }
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index b80acc4..fb420fa 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1646,7 +1646,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
         }
     }
 
-    if (sl->slice_type_nos == AV_PICTURE_TYPE_B && !h->direct_spatial_mv_pred)
+    if (sl->slice_type_nos == AV_PICTURE_TYPE_B && !sl->direct_spatial_mv_pred)
         ff_h264_direct_dist_scale_factor(h);
     ff_h264_direct_ref_list_init(h, sl);
 
@@ -1797,7 +1797,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
                h->slice_alpha_c0_offset, h->slice_beta_offset,
                sl->use_weight,
                sl->use_weight == 1 && sl->use_weight_chroma ? "c" : "",
-               sl->slice_type == AV_PICTURE_TYPE_B ? (h->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
+               sl->slice_type == AV_PICTURE_TYPE_B ? (sl->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
     }
 
     return 0;
diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
index 3787b67..6823f6d 100644
--- a/libavcodec/vaapi_h264.c
+++ b/libavcodec/vaapi_h264.c
@@ -330,7 +330,7 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
     slice_param->slice_data_bit_offset          = get_bits_count(&h->gb) + 8; /* bit buffer started beyond nal_unit_type */
     slice_param->first_mb_in_slice              = (h->mb_y >> FIELD_OR_MBAFF_PICTURE(h)) * h->mb_width + h->mb_x;
     slice_param->slice_type                     = ff_h264_get_slice_type(sl);
-    slice_param->direct_spatial_mv_pred_flag    = sl->slice_type == AV_PICTURE_TYPE_B ? h->direct_spatial_mv_pred : 0;
+    slice_param->direct_spatial_mv_pred_flag    = sl->slice_type == AV_PICTURE_TYPE_B ? sl->direct_spatial_mv_pred : 0;
     slice_param->num_ref_idx_l0_active_minus1   = h->list_count > 0 ? h->ref_count[0] - 1 : 0;
     slice_param->num_ref_idx_l1_active_minus1   = h->list_count > 1 ? h->ref_count[1] - 1 : 0;
     slice_param->cabac_init_idc                 = h->cabac_init_idc;



More information about the ffmpeg-cvslog mailing list