diff options
author | Anton Khirnov <anton@khirnov.net> | 2015-01-27 14:39:06 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2015-03-21 11:27:14 +0100 |
commit | f42485dbce614b3f63182845da43db690b427b7c (patch) | |
tree | 7e776eca6a3c8fe0239074481a0310d9eb591919 /libavcodec/h264_slice.c | |
parent | 2ea00e35e4e0b58f7a306dd55d8f72a21c32c946 (diff) | |
download | ffmpeg-streaming-f42485dbce614b3f63182845da43db690b427b7c.zip ffmpeg-streaming-f42485dbce614b3f63182845da43db690b427b7c.tar.gz |
h264: use a separate GetBitContext for slice data
Diffstat (limited to 'libavcodec/h264_slice.c')
-rw-r--r-- | libavcodec/h264_slice.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index e409847..7ad25b9 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1186,7 +1186,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex h->qpel_put = h->h264qpel.put_h264_qpel_pixels_tab; h->qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab; - first_mb_in_slice = get_ue_golomb(&h->gb); + first_mb_in_slice = get_ue_golomb(&sl->gb); if (first_mb_in_slice == 0) { // FIXME better field boundary detection if (h0->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) { @@ -1203,7 +1203,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex } } - slice_type = get_ue_golomb_31(&h->gb); + slice_type = get_ue_golomb_31(&sl->gb); if (slice_type > 9) { av_log(h->avctx, AV_LOG_ERROR, "slice type %d too large at %d\n", @@ -1233,7 +1233,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex // to make a few old functions happy, it's wrong though h->pict_type = sl->slice_type; - pps_id = get_ue_golomb(&h->gb); + pps_id = get_ue_golomb(&sl->gb); if (pps_id >= MAX_PPS_COUNT) { av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id); return AVERROR_INVALIDDATA; @@ -1354,7 +1354,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex h264_init_dequant_tables(h); } - h->frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num); + h->frame_num = get_bits(&sl->gb, h->sps.log2_max_frame_num); h->mb_mbaff = 0; h->mb_aff_frame = 0; @@ -1364,9 +1364,9 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex if (h->sps.frame_mbs_only_flag) { h->picture_structure = PICT_FRAME; } else { - field_pic_flag = get_bits1(&h->gb); + field_pic_flag = get_bits1(&sl->gb); if (field_pic_flag) { - bottom_field_flag = get_bits1(&h->gb); + bottom_field_flag = get_bits1(&sl->gb); h->picture_structure = PICT_TOP_FIELD + bottom_field_flag; } else { h->picture_structure = PICT_FRAME; @@ -1571,26 +1571,26 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex } if (h->nal_unit_type == NAL_IDR_SLICE) - get_ue_golomb(&h->gb); /* idr_pic_id */ + get_ue_golomb(&sl->gb); /* idr_pic_id */ if (h->sps.poc_type == 0) { - h->poc_lsb = get_bits(&h->gb, h->sps.log2_max_poc_lsb); + h->poc_lsb = get_bits(&sl->gb, h->sps.log2_max_poc_lsb); if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME) - h->delta_poc_bottom = get_se_golomb(&h->gb); + h->delta_poc_bottom = get_se_golomb(&sl->gb); } if (h->sps.poc_type == 1 && !h->sps.delta_pic_order_always_zero_flag) { - h->delta_poc[0] = get_se_golomb(&h->gb); + h->delta_poc[0] = get_se_golomb(&sl->gb); if (h->pps.pic_order_present == 1 && h->picture_structure == PICT_FRAME) - h->delta_poc[1] = get_se_golomb(&h->gb); + h->delta_poc[1] = get_se_golomb(&sl->gb); } ff_init_poc(h, h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc); if (h->pps.redundant_pic_cnt_present) - sl->redundant_pic_count = get_ue_golomb(&h->gb); + sl->redundant_pic_count = get_ue_golomb(&sl->gb); ret = ff_set_ref_count(h, sl); if (ret < 0) @@ -1630,7 +1630,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex // further down the line. This may break decoding if the first slice is // corrupt, thus we only do this if frame-mt is enabled. if (h->nal_ref_idc) { - ret = ff_h264_decode_ref_pic_marking(h0, &h->gb, + ret = ff_h264_decode_ref_pic_marking(h0, &sl->gb, !(h->avctx->active_thread_type & FF_THREAD_FRAME) || h0->current_slice == 0); if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE)) @@ -1651,7 +1651,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ff_h264_direct_ref_list_init(h, sl); if (sl->slice_type_nos != AV_PICTURE_TYPE_I && h->pps.cabac) { - tmp = get_ue_golomb_31(&h->gb); + tmp = get_ue_golomb_31(&sl->gb); if (tmp > 2) { av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc %u overflow\n", tmp); return AVERROR_INVALIDDATA; @@ -1660,7 +1660,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex } sl->last_qscale_diff = 0; - tmp = h->pps.init_qp + get_se_golomb(&h->gb); + tmp = h->pps.init_qp + get_se_golomb(&sl->gb); if (tmp > 51 + 6 * (h->sps.bit_depth_luma - 8)) { av_log(h->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp); return AVERROR_INVALIDDATA; @@ -1670,16 +1670,16 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex sl->chroma_qp[1] = get_chroma_qp(h, 1, sl->qscale); // FIXME qscale / qp ... stuff if (sl->slice_type == AV_PICTURE_TYPE_SP) - get_bits1(&h->gb); /* sp_for_switch_flag */ + get_bits1(&sl->gb); /* sp_for_switch_flag */ if (sl->slice_type == AV_PICTURE_TYPE_SP || sl->slice_type == AV_PICTURE_TYPE_SI) - get_se_golomb(&h->gb); /* slice_qs_delta */ + get_se_golomb(&sl->gb); /* slice_qs_delta */ sl->deblocking_filter = 1; sl->slice_alpha_c0_offset = 0; sl->slice_beta_offset = 0; if (h->pps.deblocking_filter_parameters_present) { - tmp = get_ue_golomb_31(&h->gb); + tmp = get_ue_golomb_31(&sl->gb); if (tmp > 2) { av_log(h->avctx, AV_LOG_ERROR, "deblocking_filter_idc %u out of range\n", tmp); @@ -1690,8 +1690,8 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex sl->deblocking_filter ^= 1; // 1<->0 if (sl->deblocking_filter) { - sl->slice_alpha_c0_offset = get_se_golomb(&h->gb) * 2; - sl->slice_beta_offset = get_se_golomb(&h->gb) * 2; + sl->slice_alpha_c0_offset = get_se_golomb(&sl->gb) * 2; + sl->slice_beta_offset = get_se_golomb(&sl->gb) * 2; if (sl->slice_alpha_c0_offset > 12 || sl->slice_alpha_c0_offset < -12 || sl->slice_beta_offset > 12 || @@ -2190,12 +2190,12 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) if (h->pps.cabac) { /* realign */ - align_get_bits(&h->gb); + align_get_bits(&sl->gb); /* init cabac */ ff_init_cabac_decoder(&sl->cabac, - h->gb.buffer + get_bits_count(&h->gb) / 8, - (get_bits_left(&h->gb) + 7) / 8); + sl->gb.buffer + get_bits_count(&sl->gb) / 8, + (get_bits_left(&sl->gb) + 7) / 8); ff_h264_init_cabac_states(h, sl); @@ -2252,7 +2252,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) if (eos || sl->mb_y >= h->mb_height) { tprintf(h->avctx, "slice end %d %d\n", - get_bits_count(&h->gb), h->gb.size_in_bits); + get_bits_count(&sl->gb), sl->gb.size_in_bits); er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x - 1, sl->mb_y, ER_MB_END); if (sl->mb_x > lf_x_start) @@ -2297,9 +2297,9 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) } if (sl->mb_y >= h->mb_height) { tprintf(h->avctx, "slice end %d %d\n", - get_bits_count(&h->gb), h->gb.size_in_bits); + get_bits_count(&sl->gb), sl->gb.size_in_bits); - if (get_bits_left(&h->gb) == 0) { + if (get_bits_left(&sl->gb) == 0) { er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x - 1, sl->mb_y, ER_MB_END); @@ -2313,11 +2313,11 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) } } - if (get_bits_left(&h->gb) <= 0 && sl->mb_skip_run <= 0) { + if (get_bits_left(&sl->gb) <= 0 && sl->mb_skip_run <= 0) { tprintf(h->avctx, "slice end %d %d\n", - get_bits_count(&h->gb), h->gb.size_in_bits); + get_bits_count(&sl->gb), sl->gb.size_in_bits); - if (get_bits_left(&h->gb) == 0) { + if (get_bits_left(&sl->gb) == 0) { er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x - 1, sl->mb_y, ER_MB_END); if (sl->mb_x > lf_x_start) |