h264: move direct_spatial_mv_pred into the per-slice context
authorAnton Khirnov <anton@khirnov.net>
Sat, 17 Jan 2015 21:28:46 +0000 (22:28 +0100)
committerAnton Khirnov <anton@khirnov.net>
Sat, 21 Mar 2015 10:27:13 +0000 (11:27 +0100)
libavcodec/dxva2_h264.c
libavcodec/h264.c
libavcodec/h264.h
libavcodec/h264_direct.c
libavcodec/h264_mvpred.h
libavcodec/h264_slice.c
libavcodec/vaapi_h264.c

index 9218316..ef2fc3d 100644 (file)
@@ -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;
index 7227368..8196fd4 100644 (file)
@@ -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) {
index 6cd30e8..a259a97 100644 (file)
@@ -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];
index f944695..cd30dd3 100644 (file)
@@ -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);
index ce7716a..73e136e 100644 (file)
@@ -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 ...
         }
index b80acc4..fb420fa 100644 (file)
@@ -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;
index 3787b67..6823f6d 100644 (file)
@@ -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;