From e481458bc308ee838deaeacac51929514762e7a7 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Mar 2016 16:14:31 +0100 Subject: h264: factor out pred weight table parsing into a separate file This will allow decoupling the parser from the decoder. --- libavcodec/h264_slice.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'libavcodec/h264_slice.c') diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 408cc48d73..49d7e6c215 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -726,8 +726,8 @@ static void implicit_weight_table(const H264Context *h, H264SliceContext *sl, in int ref0, ref1, i, cur_poc, ref_start, ref_count0, ref_count1; for (i = 0; i < 2; i++) { - sl->luma_weight_flag[i] = 0; - sl->chroma_weight_flag[i] = 0; + sl->pwt.luma_weight_flag[i] = 0; + sl->pwt.chroma_weight_flag[i] = 0; } if (field < 0) { @@ -738,8 +738,8 @@ static void implicit_weight_table(const H264Context *h, H264SliceContext *sl, in } if (sl->ref_count[0] == 1 && sl->ref_count[1] == 1 && !FRAME_MBAFF(h) && sl->ref_list[0][0].poc + sl->ref_list[1][0].poc == 2 * cur_poc) { - sl->use_weight = 0; - sl->use_weight_chroma = 0; + sl->pwt.use_weight = 0; + sl->pwt.use_weight_chroma = 0; return; } ref_start = 0; @@ -752,10 +752,10 @@ static void implicit_weight_table(const H264Context *h, H264SliceContext *sl, in ref_count1 = 16 + 2 * sl->ref_count[1]; } - sl->use_weight = 2; - sl->use_weight_chroma = 2; - sl->luma_log2_weight_denom = 5; - sl->chroma_log2_weight_denom = 5; + sl->pwt.use_weight = 2; + sl->pwt.use_weight_chroma = 2; + sl->pwt.luma_log2_weight_denom = 5; + sl->pwt.chroma_log2_weight_denom = 5; for (ref0 = ref_start; ref0 < ref_count0; ref0++) { int poc0 = sl->ref_list[0][ref0].poc; @@ -773,10 +773,10 @@ static void implicit_weight_table(const H264Context *h, H264SliceContext *sl, in } } if (field < 0) { - sl->implicit_weight[ref0][ref1][0] = - sl->implicit_weight[ref0][ref1][1] = w; + sl->pwt.implicit_weight[ref0][ref1][0] = + sl->pwt.implicit_weight[ref0][ref1][1] = w; } else { - sl->implicit_weight[ref0][ref1][field] = w; + sl->pwt.implicit_weight[ref0][ref1][field] = w; } } } @@ -1505,15 +1505,16 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl) if ((h->pps.weighted_pred && sl->slice_type_nos == AV_PICTURE_TYPE_P) || (h->pps.weighted_bipred_idc == 1 && sl->slice_type_nos == AV_PICTURE_TYPE_B)) - ff_pred_weight_table(h, sl); + ff_h264_pred_weight_table(&sl->gb, &h->sps, sl->ref_count, + sl->slice_type_nos, &sl->pwt); else if (h->pps.weighted_bipred_idc == 2 && sl->slice_type_nos == AV_PICTURE_TYPE_B) { implicit_weight_table(h, sl, -1); } else { - sl->use_weight = 0; + sl->pwt.use_weight = 0; for (i = 0; i < 2; i++) { - sl->luma_weight_flag[i] = 0; - sl->chroma_weight_flag[i] = 0; + sl->pwt.luma_weight_flag[i] = 0; + sl->pwt.chroma_weight_flag[i] = 0; } } @@ -1687,8 +1688,8 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl) sl->qscale, sl->deblocking_filter, sl->slice_alpha_c0_offset, sl->slice_beta_offset, - sl->use_weight, - sl->use_weight == 1 && sl->use_weight_chroma ? "c" : "", + sl->pwt.use_weight, + sl->pwt.use_weight == 1 && sl->pwt.use_weight_chroma ? "c" : "", sl->slice_type == AV_PICTURE_TYPE_B ? (sl->direct_spatial_mv_pred ? "SPAT" : "TEMP") : ""); } -- cgit v1.2.3