h264: move cabac_init_idc 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:14 +0000 (11:27 +0100)
libavcodec/dxva2_h264.c
libavcodec/h264.h
libavcodec/h264_cabac.c
libavcodec/h264_slice.c
libavcodec/vaapi_h264.c

index 5e84275..f7b1671 100644 (file)
@@ -280,7 +280,7 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
     slice->redundant_pic_cnt = h->redundant_pic_count;
     if (sl->slice_type == AV_PICTURE_TYPE_B)
         slice->direct_spatial_mv_pred_flag = sl->direct_spatial_mv_pred;
-    slice->cabac_init_idc = h->pps.cabac ? h->cabac_init_idc : 0;
+    slice->cabac_init_idc = h->pps.cabac ? sl->cabac_init_idc : 0;
     if (sl->deblocking_filter < 2)
         slice->disable_deblocking_filter_idc = 1 - sl->deblocking_filter;
     else
index d28d185..18aa8cb 100644 (file)
@@ -416,6 +416,7 @@ typedef struct H264SliceContext {
      */
     CABACContext cabac;
     uint8_t cabac_state[1024];
+    int cabac_init_idc;
 } H264SliceContext;
 
 /**
@@ -597,8 +598,6 @@ typedef struct H264Context {
     int long_ref_count;     ///< number of actual long term references
     int short_ref_count;    ///< number of actual short term references
 
-    int cabac_init_idc;
-
     /**
      * @name Members for slice based multithreading
      * @{
index 2dbd7ce..c029fd5 100644 (file)
@@ -1268,7 +1268,7 @@ void ff_h264_init_cabac_states(H264Context *h, H264SliceContext *sl)
     const int slice_qp = av_clip(sl->qscale - 6*(h->sps.bit_depth_luma-8), 0, 51);
 
     if (sl->slice_type_nos == AV_PICTURE_TYPE_I) tab = cabac_context_init_I;
-    else                                 tab = cabac_context_init_PB[h->cabac_init_idc];
+    else                                 tab = cabac_context_init_PB[sl->cabac_init_idc];
 
     /* calculate pre-state */
     for( i= 0; i < 1024; i++ ) {
index a45bf9f..59016c1 100644 (file)
@@ -608,7 +608,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
     copy_fields(h, h1, poc_lsb, redundant_pic_count);
 
     // reference lists
-    copy_fields(h, h1, short_ref, cabac_init_idc);
+    copy_fields(h, h1, short_ref, thread_context);
 
     copy_picture_range(h->short_ref, h1->short_ref, 32, h, h1);
     copy_picture_range(h->long_ref, h1->long_ref, 32, h, h1);
@@ -1657,7 +1657,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
             av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc %u overflow\n", tmp);
             return AVERROR_INVALIDDATA;
         }
-        h->cabac_init_idc = tmp;
+        sl->cabac_init_idc = tmp;
     }
 
     sl->last_qscale_diff = 0;
index 2196771..ce7643e 100644 (file)
@@ -334,7 +334,7 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
     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   = sl->list_count > 0 ? sl->ref_count[0] - 1 : 0;
     slice_param->num_ref_idx_l1_active_minus1   = sl->list_count > 1 ? sl->ref_count[1] - 1 : 0;
-    slice_param->cabac_init_idc                 = h->cabac_init_idc;
+    slice_param->cabac_init_idc                 = sl->cabac_init_idc;
     slice_param->slice_qp_delta                 = sl->qscale - h->pps.init_qp;
     slice_param->disable_deblocking_filter_idc  = sl->deblocking_filter < 2 ? !sl->deblocking_filter : sl->deblocking_filter;
     slice_param->slice_alpha_c0_offset_div2     = sl->slice_alpha_c0_offset / 2;