diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-03-21 17:13:24 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-03-21 17:13:24 +0100 |
commit | 55215383dc04365935c86f8a4db7b5396f1e3541 (patch) | |
tree | 416380f73859591236b30e05a5213f66525c6822 | |
parent | 727b202330712eb981eb008b1e7a936d71092f71 (diff) | |
parent | f42485dbce614b3f63182845da43db690b427b7c (diff) | |
download | ffmpeg-55215383dc04365935c86f8a4db7b5396f1e3541.tar.gz |
Merge commit 'f42485dbce614b3f63182845da43db690b427b7c'
* commit 'f42485dbce614b3f63182845da43db690b427b7c':
h264: use a separate GetBitContext for slice data
Conflicts:
libavcodec/h264.c
libavcodec/h264_cavlc.c
libavcodec/h264_parser.c
libavcodec/h264_slice.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/h264.c | 26 | ||||
-rw-r--r-- | libavcodec/h264.h | 1 | ||||
-rw-r--r-- | libavcodec/h264_cavlc.c | 66 | ||||
-rw-r--r-- | libavcodec/h264_parser.c | 40 | ||||
-rw-r--r-- | libavcodec/h264_refs.c | 8 | ||||
-rw-r--r-- | libavcodec/h264_slice.c | 60 |
6 files changed, 102 insertions, 99 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 1c71e3fb8a..a68a911cd4 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1010,9 +1010,9 @@ int ff_pred_weight_table(H264Context *h, H264SliceContext *sl) sl->use_weight = 0; sl->use_weight_chroma = 0; - sl->luma_log2_weight_denom = get_ue_golomb(&h->gb); + sl->luma_log2_weight_denom = get_ue_golomb(&sl->gb); if (h->sps.chroma_format_idc) - sl->chroma_log2_weight_denom = get_ue_golomb(&h->gb); + sl->chroma_log2_weight_denom = get_ue_golomb(&sl->gb); if (sl->luma_log2_weight_denom > 7U) { av_log(h->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is out of range\n", sl->luma_log2_weight_denom); @@ -1032,10 +1032,10 @@ int ff_pred_weight_table(H264Context *h, H264SliceContext *sl) for (i = 0; i < sl->ref_count[list]; i++) { int luma_weight_flag, chroma_weight_flag; - luma_weight_flag = get_bits1(&h->gb); + luma_weight_flag = get_bits1(&sl->gb); if (luma_weight_flag) { - sl->luma_weight[i][list][0] = get_se_golomb(&h->gb); - sl->luma_weight[i][list][1] = get_se_golomb(&h->gb); + sl->luma_weight[i][list][0] = get_se_golomb(&sl->gb); + sl->luma_weight[i][list][1] = get_se_golomb(&sl->gb); if (sl->luma_weight[i][list][0] != luma_def || sl->luma_weight[i][list][1] != 0) { sl->use_weight = 1; @@ -1047,12 +1047,12 @@ int ff_pred_weight_table(H264Context *h, H264SliceContext *sl) } if (h->sps.chroma_format_idc) { - chroma_weight_flag = get_bits1(&h->gb); + chroma_weight_flag = get_bits1(&sl->gb); if (chroma_weight_flag) { int j; for (j = 0; j < 2; j++) { - sl->chroma_weight[i][list][j][0] = get_se_golomb(&h->gb); - sl->chroma_weight[i][list][j][1] = get_se_golomb(&h->gb); + sl->chroma_weight[i][list][j][0] = get_se_golomb(&sl->gb); + sl->chroma_weight[i][list][j][1] = get_se_golomb(&sl->gb); if (sl->chroma_weight[i][list][j][0] != chroma_def || sl->chroma_weight[i][list][j][1] != 0) { sl->use_weight_chroma = 1; @@ -1307,13 +1307,13 @@ int ff_set_ref_count(H264Context *h, H264SliceContext *sl) max[0] = max[1] = h->picture_structure == PICT_FRAME ? 15 : 31; if (sl->slice_type_nos == AV_PICTURE_TYPE_B) - sl->direct_spatial_mv_pred = get_bits1(&h->gb); - num_ref_idx_active_override_flag = get_bits1(&h->gb); + sl->direct_spatial_mv_pred = get_bits1(&sl->gb); + num_ref_idx_active_override_flag = get_bits1(&sl->gb); if (num_ref_idx_active_override_flag) { - ref_count[0] = get_ue_golomb(&h->gb) + 1; + ref_count[0] = get_ue_golomb(&sl->gb) + 1; if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { - ref_count[1] = get_ue_golomb(&h->gb) + 1; + ref_count[1] = get_ue_golomb(&sl->gb) + 1; } else // full range is spec-ok in this case, even for frames ref_count[1] = 1; @@ -1569,7 +1569,7 @@ again: idr_cleared = 1; h->has_recovery_point = 1; case NAL_SLICE: - init_get_bits(&hx->gb, ptr, bit_length); + init_get_bits(&sl->gb, ptr, bit_length); if ((err = ff_h264_decode_slice_header(hx, sl, h))) break; diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 2d39a02c01..51721f1190 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -335,6 +335,7 @@ typedef struct H264Picture { typedef struct H264SliceContext { struct H264Context *h264; + GetBitContext gb; int slice_num; int slice_type; diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c index 24db71ff5d..4ccfb4ce1d 100644 --- a/libavcodec/h264_cavlc.c +++ b/libavcodec/h264_cavlc.c @@ -718,12 +718,12 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl) down the code */ if (sl->slice_type_nos != AV_PICTURE_TYPE_I) { if (sl->mb_skip_run == -1) - sl->mb_skip_run = get_ue_golomb_long(&h->gb); + sl->mb_skip_run = get_ue_golomb_long(&sl->gb); if (sl->mb_skip_run--) { if (FRAME_MBAFF(h) && (sl->mb_y & 1) == 0) { if (sl->mb_skip_run == 0) - h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&h->gb); + h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&sl->gb); } decode_mb_skip(h, sl); return 0; @@ -731,12 +731,12 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl) } if (FRAME_MBAFF(h)) { if ((sl->mb_y & 1) == 0) - h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&h->gb); + h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&sl->gb); } sl->prev_mb_skipped = 0; - mb_type= get_ue_golomb(&h->gb); + mb_type= get_ue_golomb(&sl->gb); if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { if(mb_type < 23){ partition_count= b_mb_type_info[mb_type].partition_count; @@ -778,12 +778,12 @@ decode_intra_mb: h->sps.bit_depth_luma; // We assume these blocks are very rare so we do not optimize it. - sl->intra_pcm_ptr = align_get_bits(&h->gb); - if (get_bits_left(&h->gb) < mb_size) { + sl->intra_pcm_ptr = align_get_bits(&sl->gb); + if (get_bits_left(&sl->gb) < mb_size) { av_log(h->avctx, AV_LOG_ERROR, "Not enough data for an intra PCM block.\n"); return AVERROR_INVALIDDATA; } - skip_bits_long(&h->gb, mb_size); + skip_bits_long(&sl->gb, mb_size); // In deblocking, the quantizer is 0 h->cur_pic.qscale_table[mb_xy] = 0; @@ -807,7 +807,7 @@ decode_intra_mb: if(IS_INTRA4x4(mb_type)){ int i; int di = 1; - if(dct8x8_allowed && get_bits1(&h->gb)){ + if(dct8x8_allowed && get_bits1(&sl->gb)){ mb_type |= MB_TYPE_8x8DCT; di = 4; } @@ -816,8 +816,8 @@ decode_intra_mb: for(i=0; i<16; i+=di){ int mode = pred_intra_mode(h, sl, i); - if(!get_bits1(&h->gb)){ - const int rem_mode= get_bits(&h->gb, 3); + if(!get_bits1(&sl->gb)){ + const int rem_mode= get_bits(&sl->gb, 3); mode = rem_mode + (rem_mode >= mode); } @@ -835,7 +835,7 @@ decode_intra_mb: return -1; } if(decode_chroma){ - pred_mode= ff_h264_check_intra_pred_mode(h, sl, get_ue_golomb_31(&h->gb), 1); + pred_mode= ff_h264_check_intra_pred_mode(h, sl, get_ue_golomb_31(&sl->gb), 1); if(pred_mode < 0) return -1; sl->chroma_pred_mode = pred_mode; @@ -847,7 +847,7 @@ decode_intra_mb: if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { for(i=0; i<4; i++){ - sl->sub_mb_type[i]= get_ue_golomb_31(&h->gb); + sl->sub_mb_type[i]= get_ue_golomb_31(&sl->gb); if(sl->sub_mb_type[i] >=13){ av_log(h->avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], sl->mb_x, sl->mb_y); return -1; @@ -865,7 +865,7 @@ decode_intra_mb: }else{ av_assert2(sl->slice_type_nos == AV_PICTURE_TYPE_P); //FIXME SP correct ? for(i=0; i<4; i++){ - sl->sub_mb_type[i]= get_ue_golomb_31(&h->gb); + sl->sub_mb_type[i]= get_ue_golomb_31(&sl->gb); if(sl->sub_mb_type[i] >=4){ av_log(h->avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", sl->sub_mb_type[i], sl->mb_x, sl->mb_y); return -1; @@ -884,9 +884,9 @@ decode_intra_mb: if(ref_count == 1){ tmp= 0; }else if(ref_count == 2){ - tmp= get_bits1(&h->gb)^1; + tmp= get_bits1(&sl->gb)^1; }else{ - tmp= get_ue_golomb_31(&h->gb); + tmp= get_ue_golomb_31(&sl->gb); if(tmp>=ref_count){ av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", tmp); return -1; @@ -920,8 +920,8 @@ decode_intra_mb: const int index= 4*i + block_width*j; int16_t (* mv_cache)[2]= &sl->mv_cache[list][ scan8[index] ]; pred_motion(h, sl, index, block_width, list, sl->ref_cache[list][ scan8[index] ], &mx, &my); - mx += get_se_golomb(&h->gb); - my += get_se_golomb(&h->gb); + mx += get_se_golomb(&sl->gb); + my += get_se_golomb(&sl->gb); tprintf(h->avctx, "final mv:%d %d\n", mx, my); if(IS_SUB_8X8(sub_mb_type)){ @@ -959,9 +959,9 @@ decode_intra_mb: if(local_ref_count[list]==1){ val= 0; } else if(local_ref_count[list]==2){ - val= get_bits1(&h->gb)^1; + val= get_bits1(&sl->gb)^1; }else{ - val= get_ue_golomb_31(&h->gb); + val= get_ue_golomb_31(&sl->gb); if (val >= local_ref_count[list]){ av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; @@ -973,8 +973,8 @@ decode_intra_mb: for (list = 0; list < sl->list_count; list++) { if(IS_DIR(mb_type, 0, list)){ pred_motion(h, sl, 0, 4, list, sl->ref_cache[list][ scan8[0] ], &mx, &my); - mx += get_se_golomb(&h->gb); - my += get_se_golomb(&h->gb); + mx += get_se_golomb(&sl->gb); + my += get_se_golomb(&sl->gb); tprintf(h->avctx, "final mv:%d %d\n", mx, my); fill_rectangle(sl->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4); @@ -989,9 +989,9 @@ decode_intra_mb: if(local_ref_count[list] == 1) { val= 0; } else if(local_ref_count[list] == 2) { - val= get_bits1(&h->gb)^1; + val= get_bits1(&sl->gb)^1; }else{ - val= get_ue_golomb_31(&h->gb); + val= get_ue_golomb_31(&sl->gb); if (val >= local_ref_count[list]){ av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; @@ -1007,8 +1007,8 @@ decode_intra_mb: unsigned int val; if(IS_DIR(mb_type, i, list)){ pred_16x8_motion(h, sl, 8*i, list, sl->ref_cache[list][scan8[0] + 16*i], &mx, &my); - mx += get_se_golomb(&h->gb); - my += get_se_golomb(&h->gb); + mx += get_se_golomb(&sl->gb); + my += get_se_golomb(&sl->gb); tprintf(h->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); @@ -1026,9 +1026,9 @@ decode_intra_mb: if(local_ref_count[list]==1){ val= 0; } else if(local_ref_count[list]==2){ - val= get_bits1(&h->gb)^1; + val= get_bits1(&sl->gb)^1; }else{ - val= get_ue_golomb_31(&h->gb); + val= get_ue_golomb_31(&sl->gb); if (val >= local_ref_count[list]){ av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; @@ -1044,8 +1044,8 @@ decode_intra_mb: unsigned int val; if(IS_DIR(mb_type, i, list)){ pred_8x16_motion(h, sl, i*4, list, sl->ref_cache[list][ scan8[0] + 2*i ], &mx, &my); - mx += get_se_golomb(&h->gb); - my += get_se_golomb(&h->gb); + mx += get_se_golomb(&sl->gb); + my += get_se_golomb(&sl->gb); tprintf(h->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); @@ -1061,7 +1061,7 @@ decode_intra_mb: write_back_motion(h, sl, mb_type); if(!IS_INTRA16x16(mb_type)){ - cbp= get_ue_golomb(&h->gb); + cbp= get_ue_golomb(&sl->gb); if(decode_chroma){ if(cbp > 47){ @@ -1086,7 +1086,7 @@ decode_intra_mb: } if(dct8x8_allowed && (cbp&15) && !IS_INTRA(mb_type)){ - mb_type |= MB_TYPE_8x8DCT*get_bits1(&h->gb); + mb_type |= MB_TYPE_8x8DCT*get_bits1(&sl->gb); } sl->cbp= h->cbp_table[mb_xy]= cbp; @@ -1096,7 +1096,7 @@ decode_intra_mb: int i4x4, i8x8, chroma_idx; int dquant; int ret; - GetBitContext *gb = &h->gb; + GetBitContext *gb = &sl->gb; const uint8_t *scan, *scan8x8; const int max_qp = 51 + 6*(h->sps.bit_depth_luma-8); @@ -1108,7 +1108,7 @@ decode_intra_mb: scan = sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0; } - dquant= get_se_golomb(&h->gb); + dquant= get_se_golomb(&sl->gb); sl->qscale += dquant; diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c index fe14c249e0..6aec473a9f 100644 --- a/libavcodec/h264_parser.c +++ b/libavcodec/h264_parser.c @@ -138,7 +138,7 @@ static int scan_mmco_reset(AVCodecParserContext *s) sl->slice_type_nos = s->pict_type & 3; if (h->pps.redundant_pic_cnt_present) - get_ue_golomb(&h->gb); // redundant_pic_count + get_ue_golomb(&sl->gb); // redundant_pic_count if (ff_set_ref_count(h, sl) < 0) return AVERROR_INVALIDDATA; @@ -146,13 +146,13 @@ static int scan_mmco_reset(AVCodecParserContext *s) if (sl->slice_type_nos != AV_PICTURE_TYPE_I) { int list; for (list = 0; list < sl->list_count; list++) { - if (get_bits1(&h->gb)) { + if (get_bits1(&sl->gb)) { int index; for (index = 0; ; index++) { - unsigned int reordering_of_pic_nums_idc = get_ue_golomb_31(&h->gb); + unsigned int reordering_of_pic_nums_idc = get_ue_golomb_31(&sl->gb); if (reordering_of_pic_nums_idc < 3) - get_ue_golomb(&h->gb); + get_ue_golomb(&sl->gb); else if (reordering_of_pic_nums_idc > 3) { av_log(h->avctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc %d\n", @@ -175,10 +175,10 @@ static int scan_mmco_reset(AVCodecParserContext *s) (h->pps.weighted_bipred_idc == 1 && sl->slice_type_nos == AV_PICTURE_TYPE_B)) ff_pred_weight_table(h, sl); - if (get_bits1(&h->gb)) { // adaptive_ref_pic_marking_mode_flag + if (get_bits1(&sl->gb)) { // adaptive_ref_pic_marking_mode_flag int i; for (i = 0; i < MAX_MMCO_COUNT; i++) { - MMCOOpcode opcode = get_ue_golomb_31(&h->gb); + MMCOOpcode opcode = get_ue_golomb_31(&sl->gb); if (opcode > (unsigned) MMCO_LONG) { av_log(h->avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", @@ -191,10 +191,10 @@ static int scan_mmco_reset(AVCodecParserContext *s) return 1; if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG) - get_ue_golomb(&h->gb); + get_ue_golomb(&sl->gb); if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED || opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG) - get_ue_golomb_31(&h->gb); + get_ue_golomb_31(&sl->gb); } } @@ -215,6 +215,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, { H264ParseContext *p = s->priv_data; H264Context *h = &p->h; + H264SliceContext *sl = &h->slice_ctx[0]; int buf_index, next_avc; unsigned int pps_id; unsigned int slice_type; @@ -298,14 +299,15 @@ static inline int parse_nal_units(AVCodecParserContext *s, h->prev_poc_lsb = 0; /* fall through */ case NAL_SLICE: - get_ue_golomb_long(&h->gb); // skip first_mb_in_slice - slice_type = get_ue_golomb_31(&h->gb); + init_get_bits(&sl->gb, ptr, 8 * dst_length); + get_ue_golomb_long(&sl->gb); // skip first_mb_in_slice + slice_type = get_ue_golomb_31(&sl->gb); s->pict_type = golomb_to_pict_type[slice_type % 5]; if (h->sei_recovery_frame_cnt >= 0) { /* key frame, since recovery_frame_cnt is set */ s->key_frame = 1; } - 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); @@ -323,7 +325,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, return -1; } h->sps = *h->sps_buffers[h->pps.sps_id]; - 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); if(h->sps.ref_frame_count <= 1 && h->pps.ref_count[0] <= 1 && s->pict_type == AV_PICTURE_TYPE_I) s->key_frame = 1; @@ -363,30 +365,30 @@ static inline int parse_nal_units(AVCodecParserContext *s, if (h->sps.frame_mbs_only_flag) { h->picture_structure = PICT_FRAME; } else { - if (get_bits1(&h->gb)) { // field_pic_flag - h->picture_structure = PICT_TOP_FIELD + get_bits1(&h->gb); // bottom_field_flag + if (get_bits1(&sl->gb)) { // field_pic_flag + h->picture_structure = PICT_TOP_FIELD + get_bits1(&sl->gb); // bottom_field_flag } else { h->picture_structure = PICT_FRAME; } } 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); } /* Decode POC of this picture. diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index f113e5535a..6c7ec60e68 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -221,11 +221,11 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl) for (i = 0; i < sl->ref_count[list]; i++) COPY_PICTURE(&sl->ref_list[list][i], &h->default_ref_list[list][i]); - if (get_bits1(&h->gb)) { // ref_pic_list_modification_flag_l[01] + if (get_bits1(&sl->gb)) { // ref_pic_list_modification_flag_l[01] int pred = h->curr_pic_num; for (index = 0; ; index++) { - unsigned int modification_of_pic_nums_idc = get_ue_golomb_31(&h->gb); + unsigned int modification_of_pic_nums_idc = get_ue_golomb_31(&sl->gb); unsigned int pic_id; int i; H264Picture *ref = NULL; @@ -241,7 +241,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl) switch (modification_of_pic_nums_idc) { case 0: case 1: { - const unsigned int abs_diff_pic_num = get_ue_golomb(&h->gb) + 1; + const unsigned int abs_diff_pic_num = get_ue_golomb(&sl->gb) + 1; int frame_num; if (abs_diff_pic_num > h->max_pic_num) { @@ -272,7 +272,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h, H264SliceContext *sl) } case 2: { int long_idx; - pic_id = get_ue_golomb(&h->gb); // long_term_pic_idx + pic_id = get_ue_golomb(&sl->gb); // long_term_pic_idx long_idx = pic_num_extract(h, pic_id, &pic_structure); diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 639bbaf66c..559c6a04e4 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1296,7 +1296,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_long(&h->gb); + first_mb_in_slice = get_ue_golomb_long(&sl->gb); if (first_mb_in_slice == 0) { // FIXME better field boundary detection if (h0->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) { @@ -1313,7 +1313,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", @@ -1348,7 +1348,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; @@ -1504,7 +1504,7 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ff_h264_init_dequant_tables(h); } - frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num); + frame_num = get_bits(&sl->gb, h->sps.log2_max_frame_num); if (!first_slice) { if (h0->frame_num != frame_num) { av_log(h->avctx, AV_LOG_ERROR, "Frame num change from %d to %d\n", @@ -1525,10 +1525,10 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex av_log(h->avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n"); return -1; } - 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); picture_structure = PICT_TOP_FIELD + bottom_field_flag; } else { picture_structure = PICT_FRAME; @@ -1769,26 +1769,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) @@ -1831,7 +1831,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)) @@ -1852,7 +1852,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; @@ -1861,7 +1861,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; @@ -1871,16 +1871,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); @@ -1891,8 +1891,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 || @@ -2418,12 +2418,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); @@ -2482,7 +2482,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) @@ -2527,10 +2527,10 @@ 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 - || get_bits_left(&h->gb) > 0 && !(h->avctx->err_recognition & AV_EF_AGGRESSIVE)) { + if ( get_bits_left(&sl->gb) == 0 + || get_bits_left(&sl->gb) > 0 && !(h->avctx->err_recognition & AV_EF_AGGRESSIVE)) { er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x - 1, sl->mb_y, ER_MB_END); @@ -2544,11 +2544,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) |