diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2015-07-12 22:06:21 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2015-07-12 22:28:54 +0200 |
commit | d5fcca83b915df9536d595a1a44c24294b606836 (patch) | |
tree | e414b8d967bf761a6be218d4f16b6796d928d590 /libavcodec/hevc.c | |
parent | 885afff01c720cc0a3c52802bd7f82bb81d9e576 (diff) | |
parent | b11acd57326db6c2cc1475dd0bea2a06fbc85aa2 (diff) | |
download | ffmpeg-d5fcca83b915df9536d595a1a44c24294b606836.tar.gz |
Merge commit 'b11acd57326db6c2cc1475dd0bea2a06fbc85aa2'
* commit 'b11acd57326db6c2cc1475dd0bea2a06fbc85aa2':
hevc: remove HEVCContext usage from hevc_ps
Conflicts:
libavcodec/hevc.c
libavcodec/hevc_cabac.c
libavcodec/hevc_filter.c
libavcodec/hevc_mvs.c
libavcodec/hevc_ps.c
libavcodec/hevc_refs.c
libavcodec/hevcpred_template.c
Merged-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/hevc.c')
-rw-r--r-- | libavcodec/hevc.c | 647 |
1 files changed, 324 insertions, 323 deletions
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c index 6ff52ec7fa..a4b0fdd167 100644 --- a/libavcodec/hevc.c +++ b/libavcodec/hevc.c @@ -149,7 +149,7 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb) if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) av_log(s->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom); s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3); - if (s->sps->chroma_format_idc != 0) { + if (s->ps.sps->chroma_format_idc != 0) { int delta = get_se_golomb(gb); s->sh.chroma_log2_weight_denom = av_clip_uintp2(s->sh.luma_log2_weight_denom + delta, 3); } @@ -161,7 +161,7 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb) s->sh.luma_offset_l0[i] = 0; } } - if (s->sps->chroma_format_idc != 0) { + if (s->ps.sps->chroma_format_idc != 0) { for (i = 0; i < s->sh.nb_refs[L0]; i++) chroma_weight_l0_flag[i] = get_bits1(gb); } else { @@ -197,7 +197,7 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb) s->sh.luma_offset_l1[i] = 0; } } - if (s->sps->chroma_format_idc != 0) { + if (s->ps.sps->chroma_format_idc != 0) { for (i = 0; i < s->sh.nb_refs[L1]; i++) chroma_weight_l1_flag[i] = get_bits1(gb); } else { @@ -230,7 +230,7 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb) static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb) { - const HEVCSPS *sps = s->sps; + const HEVCSPS *sps = s->ps.sps; int max_poc_lsb = 1 << sps->log2_max_poc_lsb; int prev_delta_msb = 0; unsigned int nb_sps = 0, nb_sh; @@ -283,7 +283,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb) static void export_stream_params(AVCodecContext *avctx, const HEVCContext *s, const HEVCSPS *sps) { - const HEVCVPS *vps = (const HEVCVPS*)s->vps_list[sps->vps_id]->data; + const HEVCVPS *vps = (const HEVCVPS*)s->ps.vps_list[sps->vps_id]->data; unsigned int num = 0, den = 0; avctx->pix_fmt = sps->pix_fmt; @@ -389,14 +389,14 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps, enum AVPixelFormat pix_fm } } - s->sps = sps; - s->vps = (HEVCVPS*) s->vps_list[s->sps->vps_id]->data; + s->ps.sps = sps; + s->ps.vps = (HEVCVPS*) s->ps.vps_list[s->ps.sps->vps_id]->data; return 0; fail: pic_arrays_free(s); - s->sps = NULL; + s->ps.sps = NULL; return ret; } @@ -419,30 +419,30 @@ static int hls_slice_header(HEVCContext *s) sh->no_output_of_prior_pics_flag = get_bits1(gb); sh->pps_id = get_ue_golomb_long(gb); - if (sh->pps_id >= MAX_PPS_COUNT || !s->pps_list[sh->pps_id]) { + if (sh->pps_id >= MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) { av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id); return AVERROR_INVALIDDATA; } if (!sh->first_slice_in_pic_flag && - s->pps != (HEVCPPS*)s->pps_list[sh->pps_id]->data) { + s->ps.pps != (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data) { av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n"); return AVERROR_INVALIDDATA; } - s->pps = (HEVCPPS*)s->pps_list[sh->pps_id]->data; + s->ps.pps = (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data; if (s->nal_unit_type == NAL_CRA_NUT && s->last_eos == 1) sh->no_output_of_prior_pics_flag = 1; - if (s->sps != (HEVCSPS*)s->sps_list[s->pps->sps_id]->data) { - const HEVCSPS* last_sps = s->sps; - s->sps = (HEVCSPS*)s->sps_list[s->pps->sps_id]->data; + if (s->ps.sps != (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data) { + const HEVCSPS* last_sps = s->ps.sps; + s->ps.sps = (HEVCSPS*)s->ps.sps_list[s->ps.pps->sps_id]->data; if (last_sps && IS_IRAP(s) && s->nal_unit_type != NAL_CRA_NUT) { - if (s->sps->width != last_sps->width || s->sps->height != last_sps->height || - s->sps->temporal_layer[s->sps->max_sub_layers - 1].max_dec_pic_buffering != + if (s->ps.sps->width != last_sps->width || s->ps.sps->height != last_sps->height || + s->ps.sps->temporal_layer[s->ps.sps->max_sub_layers - 1].max_dec_pic_buffering != last_sps->temporal_layer[last_sps->max_sub_layers - 1].max_dec_pic_buffering) sh->no_output_of_prior_pics_flag = 0; } ff_hevc_clear_refs(s); - ret = set_sps(s, s->sps, AV_PIX_FMT_NONE); + ret = set_sps(s, s->ps.sps, AV_PIX_FMT_NONE); if (ret < 0) return ret; @@ -454,13 +454,13 @@ static int hls_slice_header(HEVCContext *s) if (!sh->first_slice_in_pic_flag) { int slice_address_length; - if (s->pps->dependent_slice_segments_enabled_flag) + if (s->ps.pps->dependent_slice_segments_enabled_flag) sh->dependent_slice_segment_flag = get_bits1(gb); - slice_address_length = av_ceil_log2(s->sps->ctb_width * - s->sps->ctb_height); + slice_address_length = av_ceil_log2(s->ps.sps->ctb_width * + s->ps.sps->ctb_height); sh->slice_segment_addr = slice_address_length ? get_bits(gb, slice_address_length) : 0; - if (sh->slice_segment_addr >= s->sps->ctb_width * s->sps->ctb_height) { + if (sh->slice_segment_addr >= s->ps.sps->ctb_width * s->ps.sps->ctb_height) { av_log(s->avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n", sh->slice_segment_addr); @@ -480,7 +480,7 @@ static int hls_slice_header(HEVCContext *s) if (!sh->dependent_slice_segment_flag) { s->slice_initialized = 0; - for (i = 0; i < s->pps->num_extra_slice_header_bits; i++) + for (i = 0; i < s->ps.pps->num_extra_slice_header_bits; i++) skip_bits(gb, 1); // slice_reserved_undetermined_flag[] sh->slice_type = get_ue_golomb_long(gb); @@ -498,16 +498,16 @@ static int hls_slice_header(HEVCContext *s) // when flag is not present, picture is inferred to be output sh->pic_output_flag = 1; - if (s->pps->output_flag_present_flag) + if (s->ps.pps->output_flag_present_flag) sh->pic_output_flag = get_bits1(gb); - if (s->sps->separate_colour_plane_flag) + if (s->ps.sps->separate_colour_plane_flag) sh->colour_plane_id = get_bits(gb, 2); if (!IS_IDR(s)) { int poc, pos; - sh->pic_order_cnt_lsb = get_bits(gb, s->sps->log2_max_poc_lsb); + sh->pic_order_cnt_lsb = get_bits(gb, s->ps.sps->log2_max_poc_lsb); poc = ff_hevc_compute_poc(s, sh->pic_order_cnt_lsb); if (!sh->first_slice_in_pic_flag && poc != s->poc) { av_log(s->avctx, AV_LOG_WARNING, @@ -521,7 +521,7 @@ static int hls_slice_header(HEVCContext *s) sh->short_term_ref_pic_set_sps_flag = get_bits1(gb); pos = get_bits_left(gb); if (!sh->short_term_ref_pic_set_sps_flag) { - ret = ff_hevc_decode_short_term_rps(gb, s->avctx, &sh->slice_rps, s->sps, 1); + ret = ff_hevc_decode_short_term_rps(gb, s->avctx, &sh->slice_rps, s->ps.sps, 1); if (ret < 0) return ret; @@ -529,14 +529,14 @@ static int hls_slice_header(HEVCContext *s) } else { int numbits, rps_idx; - if (!s->sps->nb_st_rps) { + if (!s->ps.sps->nb_st_rps) { av_log(s->avctx, AV_LOG_ERROR, "No ref lists in the SPS.\n"); return AVERROR_INVALIDDATA; } - numbits = av_ceil_log2(s->sps->nb_st_rps); + numbits = av_ceil_log2(s->ps.sps->nb_st_rps); rps_idx = numbits > 0 ? get_bits(gb, numbits) : 0; - sh->short_term_rps = &s->sps->st_rps[rps_idx]; + sh->short_term_rps = &s->ps.sps->st_rps[rps_idx]; } sh->short_term_ref_pic_set_size = pos - get_bits_left(gb); @@ -549,7 +549,7 @@ static int hls_slice_header(HEVCContext *s) } sh->long_term_ref_pic_set_size = pos - get_bits_left(gb); - if (s->sps->sps_temporal_mvp_enabled_flag) + if (s->ps.sps->sps_temporal_mvp_enabled_flag) sh->slice_temporal_mvp_enabled_flag = get_bits1(gb); else sh->slice_temporal_mvp_enabled_flag = 0; @@ -569,9 +569,9 @@ static int hls_slice_header(HEVCContext *s) s->nal_unit_type != NAL_RASL_R) s->pocTid0 = s->poc; - if (s->sps->sao_enabled) { + if (s->ps.sps->sao_enabled) { sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb); - if (s->sps->chroma_format_idc) { + if (s->ps.sps->chroma_format_idc) { sh->slice_sample_adaptive_offset_flag[1] = sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb); } @@ -585,9 +585,9 @@ static int hls_slice_header(HEVCContext *s) if (sh->slice_type == P_SLICE || sh->slice_type == B_SLICE) { int nb_refs; - sh->nb_refs[L0] = s->pps->num_ref_idx_l0_default_active; + sh->nb_refs[L0] = s->ps.pps->num_ref_idx_l0_default_active; if (sh->slice_type == B_SLICE) - sh->nb_refs[L1] = s->pps->num_ref_idx_l1_default_active; + sh->nb_refs[L1] = s->ps.pps->num_ref_idx_l1_default_active; if (get_bits1(gb)) { // num_ref_idx_active_override_flag sh->nb_refs[L0] = get_ue_golomb_long(gb) + 1; @@ -608,7 +608,7 @@ static int hls_slice_header(HEVCContext *s) return AVERROR_INVALIDDATA; } - if (s->pps->lists_modification_present_flag && nb_refs > 1) { + if (s->ps.pps->lists_modification_present_flag && nb_refs > 1) { sh->rpl_modification_flag[0] = get_bits1(gb); if (sh->rpl_modification_flag[0]) { for (i = 0; i < sh->nb_refs[L0]; i++) @@ -626,7 +626,7 @@ static int hls_slice_header(HEVCContext *s) if (sh->slice_type == B_SLICE) sh->mvd_l1_zero_flag = get_bits1(gb); - if (s->pps->cabac_init_present_flag) + if (s->ps.pps->cabac_init_present_flag) sh->cabac_init_flag = get_bits1(gb); else sh->cabac_init_flag = 0; @@ -648,8 +648,8 @@ static int hls_slice_header(HEVCContext *s) } } - if ((s->pps->weighted_pred_flag && sh->slice_type == P_SLICE) || - (s->pps->weighted_bipred_flag && sh->slice_type == B_SLICE)) { + if ((s->ps.pps->weighted_pred_flag && sh->slice_type == P_SLICE) || + (s->ps.pps->weighted_bipred_flag && sh->slice_type == B_SLICE)) { pred_weight_table(s, gb); } @@ -664,7 +664,7 @@ static int hls_slice_header(HEVCContext *s) sh->slice_qp_delta = get_se_golomb(gb); - if (s->pps->pic_slice_level_chroma_qp_offsets_present_flag) { + if (s->ps.pps->pic_slice_level_chroma_qp_offsets_present_flag) { sh->slice_cb_qp_offset = get_se_golomb(gb); sh->slice_cr_qp_offset = get_se_golomb(gb); } else { @@ -672,15 +672,15 @@ static int hls_slice_header(HEVCContext *s) sh->slice_cr_qp_offset = 0; } - if (s->pps->chroma_qp_offset_list_enabled_flag) + if (s->ps.pps->chroma_qp_offset_list_enabled_flag) sh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb); else sh->cu_chroma_qp_offset_enabled_flag = 0; - if (s->pps->deblocking_filter_control_present_flag) { + if (s->ps.pps->deblocking_filter_control_present_flag) { int deblocking_filter_override_flag = 0; - if (s->pps->deblocking_filter_override_enabled_flag) + if (s->ps.pps->deblocking_filter_override_enabled_flag) deblocking_filter_override_flag = get_bits1(gb); if (deblocking_filter_override_flag) { @@ -690,9 +690,9 @@ static int hls_slice_header(HEVCContext *s) sh->tc_offset = get_se_golomb(gb) * 2; } } else { - sh->disable_deblocking_filter_flag = s->pps->disable_dbf; - sh->beta_offset = s->pps->beta_offset; - sh->tc_offset = s->pps->tc_offset; + sh->disable_deblocking_filter_flag = s->ps.pps->disable_dbf; + sh->beta_offset = s->ps.pps->beta_offset; + sh->tc_offset = s->ps.pps->tc_offset; } } else { sh->disable_deblocking_filter_flag = 0; @@ -700,13 +700,13 @@ static int hls_slice_header(HEVCContext *s) sh->tc_offset = 0; } - if (s->pps->seq_loop_filter_across_slices_enabled_flag && + if (s->ps.pps->seq_loop_filter_across_slices_enabled_flag && (sh->slice_sample_adaptive_offset_flag[0] || sh->slice_sample_adaptive_offset_flag[1] || !sh->disable_deblocking_filter_flag)) { sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb); } else { - sh->slice_loop_filter_across_slices_enabled_flag = s->pps->seq_loop_filter_across_slices_enabled_flag; + sh->slice_loop_filter_across_slices_enabled_flag = s->ps.pps->seq_loop_filter_across_slices_enabled_flag; } } else if (!s->slice_initialized) { av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n"); @@ -714,7 +714,7 @@ static int hls_slice_header(HEVCContext *s) } sh->num_entry_point_offsets = 0; - if (s->pps->tiles_enabled_flag || s->pps->entropy_coding_sync_enabled_flag) { + if (s->ps.pps->tiles_enabled_flag || s->ps.pps->entropy_coding_sync_enabled_flag) { unsigned num_entry_point_offsets = get_ue_golomb_long(gb); // It would be possible to bound this tighter but this here is simpler if (num_entry_point_offsets > get_bits_left(gb)) { @@ -747,7 +747,7 @@ static int hls_slice_header(HEVCContext *s) unsigned val = get_bits_long(gb, offset_len); sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the size } - if (s->threads_number > 1 && (s->pps->num_tile_rows > 1 || s->pps->num_tile_columns > 1)) { + if (s->threads_number > 1 && (s->ps.pps->num_tile_rows > 1 || s->ps.pps->num_tile_columns > 1)) { s->enable_parallel_tiles = 0; // TODO: you can enable tiles in parallel here s->threads_number = 1; } else @@ -756,7 +756,7 @@ static int hls_slice_header(HEVCContext *s) s->enable_parallel_tiles = 0; } - if (s->pps->slice_header_extension_present_flag) { + if (s->ps.pps->slice_header_extension_present_flag) { unsigned int length = get_ue_golomb_long(gb); if (length*8LL > get_bits_left(gb)) { av_log(s->avctx, AV_LOG_ERROR, "too many slice_header_extension_data_bytes\n"); @@ -767,14 +767,14 @@ static int hls_slice_header(HEVCContext *s) } // Inferred parameters - sh->slice_qp = 26U + s->pps->pic_init_qp_minus26 + sh->slice_qp_delta; + sh->slice_qp = 26U + s->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta; if (sh->slice_qp > 51 || - sh->slice_qp < -s->sps->qp_bd_offset) { + sh->slice_qp < -s->ps.sps->qp_bd_offset) { av_log(s->avctx, AV_LOG_ERROR, "The slice_qp %d is outside the valid range " "[%d, 51].\n", sh->slice_qp, - -s->sps->qp_bd_offset); + -s->ps.sps->qp_bd_offset); return AVERROR_INVALIDDATA; } @@ -793,7 +793,7 @@ static int hls_slice_header(HEVCContext *s) s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag; - if (!s->pps->cu_qp_delta_enabled_flag) + if (!s->ps.pps->cu_qp_delta_enabled_flag) s->HEVClc->qp_y = s->sh.slice_qp; s->slice_initialized = 1; @@ -803,7 +803,7 @@ static int hls_slice_header(HEVCContext *s) return 0; } -#define CTB(tab, x, y) ((tab)[(y) * s->sps->ctb_width + (x)]) +#define CTB(tab, x, y) ((tab)[(y) * s->ps.sps->ctb_width + (x)]) #define SET_SAO(elem, value) \ do { \ @@ -837,9 +837,9 @@ static void hls_sao_param(HEVCContext *s, int rx, int ry) } } - for (c_idx = 0; c_idx < (s->sps->chroma_format_idc ? 3 : 1); c_idx++) { - int log2_sao_offset_scale = c_idx == 0 ? s->pps->log2_sao_offset_scale_luma : - s->pps->log2_sao_offset_scale_chroma; + for (c_idx = 0; c_idx < (s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) { + int log2_sao_offset_scale = c_idx == 0 ? s->ps.pps->log2_sao_offset_scale_luma : + s->ps.pps->log2_sao_offset_scale_chroma; if (!s->sh.slice_sample_adaptive_offset_flag[c_idx]) { sao->type_idx[c_idx] = SAO_NOT_APPLIED; @@ -913,7 +913,7 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, int blk_idx, int cbf_luma, int *cbf_cb, int *cbf_cr) { HEVCLocalContext *lc = s->HEVClc; - const int log2_trafo_size_c = log2_trafo_size - s->sps->hshift[1]; + const int log2_trafo_size_c = log2_trafo_size - s->ps.sps->hshift[1]; int i; if (lc->cu.pred_mode == MODE_INTRA) { @@ -924,28 +924,28 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, } if (cbf_luma || cbf_cb[0] || cbf_cr[0] || - (s->sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) { + (s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) { int scan_idx = SCAN_DIAG; int scan_idx_c = SCAN_DIAG; int cbf_chroma = cbf_cb[0] || cbf_cr[0] || - (s->sps->chroma_format_idc == 2 && + (s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1])); - if (s->pps->cu_qp_delta_enabled_flag && !lc->tu.is_cu_qp_delta_coded) { + if (s->ps.pps->cu_qp_delta_enabled_flag && !lc->tu.is_cu_qp_delta_coded) { lc->tu.cu_qp_delta = ff_hevc_cu_qp_delta_abs(s); if (lc->tu.cu_qp_delta != 0) if (ff_hevc_cu_qp_delta_sign_flag(s) == 1) lc->tu.cu_qp_delta = -lc->tu.cu_qp_delta; lc->tu.is_cu_qp_delta_coded = 1; - if (lc->tu.cu_qp_delta < -(26 + s->sps->qp_bd_offset / 2) || - lc->tu.cu_qp_delta > (25 + s->sps->qp_bd_offset / 2)) { + if (lc->tu.cu_qp_delta < -(26 + s->ps.sps->qp_bd_offset / 2) || + lc->tu.cu_qp_delta > (25 + s->ps.sps->qp_bd_offset / 2)) { av_log(s->avctx, AV_LOG_ERROR, "The cu_qp_delta %d is outside the valid range " "[%d, %d].\n", lc->tu.cu_qp_delta, - -(26 + s->sps->qp_bd_offset / 2), - (25 + s->sps->qp_bd_offset / 2)); + -(26 + s->ps.sps->qp_bd_offset / 2), + (25 + s->ps.sps->qp_bd_offset / 2)); return AVERROR_INVALIDDATA; } @@ -957,13 +957,13 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, int cu_chroma_qp_offset_flag = ff_hevc_cu_chroma_qp_offset_flag(s); if (cu_chroma_qp_offset_flag) { int cu_chroma_qp_offset_idx = 0; - if (s->pps->chroma_qp_offset_list_len_minus1 > 0) { + if (s->ps.pps->chroma_qp_offset_list_len_minus1 > 0) { cu_chroma_qp_offset_idx = ff_hevc_cu_chroma_qp_offset_idx(s); av_log(s->avctx, AV_LOG_ERROR, "cu_chroma_qp_offset_idx not yet tested.\n"); } - lc->tu.cu_qp_offset_cb = s->pps->cb_qp_offset_list[cu_chroma_qp_offset_idx]; - lc->tu.cu_qp_offset_cr = s->pps->cr_qp_offset_list[cu_chroma_qp_offset_idx]; + lc->tu.cu_qp_offset_cb = s->ps.pps->cb_qp_offset_list[cu_chroma_qp_offset_idx]; + lc->tu.cu_qp_offset_cr = s->ps.pps->cr_qp_offset_list[cu_chroma_qp_offset_idx]; } else { lc->tu.cu_qp_offset_cb = 0; lc->tu.cu_qp_offset_cr = 0; @@ -993,17 +993,17 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, if (cbf_luma) ff_hevc_hls_residual_coding(s, x0, y0, log2_trafo_size, scan_idx, 0); - if (s->sps->chroma_format_idc && (log2_trafo_size > 2 || s->sps->chroma_format_idc == 3)) { - int trafo_size_h = 1 << (log2_trafo_size_c + s->sps->hshift[1]); - int trafo_size_v = 1 << (log2_trafo_size_c + s->sps->vshift[1]); - lc->tu.cross_pf = (s->pps->cross_component_prediction_enabled_flag && cbf_luma && + if (s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 || s->ps.sps->chroma_format_idc == 3)) { + int trafo_size_h = 1 << (log2_trafo_size_c + s->ps.sps->hshift[1]); + int trafo_size_v = 1 << (log2_trafo_size_c + s->ps.sps->vshift[1]); + lc->tu.cross_pf = (s->ps.pps->cross_component_prediction_enabled_flag && cbf_luma && (lc->cu.pred_mode == MODE_INTER || (lc->tu.chroma_mode_c == 4))); if (lc->tu.cross_pf) { hls_cross_component_pred(s, 0); } - for (i = 0; i < (s->sps->chroma_format_idc == 2 ? 2 : 1); i++) { + for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) { if (lc->cu.pred_mode == MODE_INTRA) { ff_hevc_set_neighbour_available(s, x0, y0 + (i << log2_trafo_size_c), trafo_size_h, trafo_size_v); s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0 + (i << log2_trafo_size_c), 1); @@ -1014,14 +1014,14 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, else if (lc->tu.cross_pf) { ptrdiff_t stride = s->frame->linesize[1]; - int hshift = s->sps->hshift[1]; - int vshift = s->sps->vshift[1]; + int hshift = s->ps.sps->hshift[1]; + int vshift = s->ps.sps->vshift[1]; int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer; int16_t *coeffs = (int16_t*)lc->edge_emu_buffer2; int size = 1 << log2_trafo_size_c; uint8_t *dst = &s->frame->data[1][(y0 >> vshift) * stride + - ((x0 >> hshift) << s->sps->pixel_shift)]; + ((x0 >> hshift) << s->ps.sps->pixel_shift)]; for (i = 0; i < (size * size); i++) { coeffs[i] = ((lc->tu.res_scale_val * coeffs_y[i]) >> 3); } @@ -1032,7 +1032,7 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, if (lc->tu.cross_pf) { hls_cross_component_pred(s, 1); } - for (i = 0; i < (s->sps->chroma_format_idc == 2 ? 2 : 1); i++) { + for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) { if (lc->cu.pred_mode == MODE_INTRA) { ff_hevc_set_neighbour_available(s, x0, y0 + (i << log2_trafo_size_c), trafo_size_h, trafo_size_v); s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0 + (i << log2_trafo_size_c), 2); @@ -1043,24 +1043,24 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, else if (lc->tu.cross_pf) { ptrdiff_t stride = s->frame->linesize[2]; - int hshift = s->sps->hshift[2]; - int vshift = s->sps->vshift[2]; + int hshift = s->ps.sps->hshift[2]; + int vshift = s->ps.sps->vshift[2]; int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer; int16_t *coeffs = (int16_t*)lc->edge_emu_buffer2; int size = 1 << log2_trafo_size_c; uint8_t *dst = &s->frame->data[2][(y0 >> vshift) * stride + - ((x0 >> hshift) << s->sps->pixel_shift)]; + ((x0 >> hshift) << s->ps.sps->pixel_shift)]; for (i = 0; i < (size * size); i++) { coeffs[i] = ((lc->tu.res_scale_val * coeffs_y[i]) >> 3); } s->hevcdsp.transform_add[log2_trafo_size_c-2](dst, coeffs, stride); } } - } else if (s->sps->chroma_format_idc && blk_idx == 3) { + } else if (s->ps.sps->chroma_format_idc && blk_idx == 3) { int trafo_size_h = 1 << (log2_trafo_size + 1); - int trafo_size_v = 1 << (log2_trafo_size + s->sps->vshift[1]); - for (i = 0; i < (s->sps->chroma_format_idc == 2 ? 2 : 1); i++) { + int trafo_size_v = 1 << (log2_trafo_size + s->ps.sps->vshift[1]); + for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) { if (lc->cu.pred_mode == MODE_INTRA) { ff_hevc_set_neighbour_available(s, xBase, yBase + (i << log2_trafo_size), trafo_size_h, trafo_size_v); @@ -1070,7 +1070,7 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, ff_hevc_hls_residual_coding(s, xBase, yBase + (i << log2_trafo_size), log2_trafo_size, scan_idx_c, 1); } - for (i = 0; i < (s->sps->chroma_format_idc == 2 ? 2 : 1); i++) { + for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) { if (lc->cu.pred_mode == MODE_INTRA) { ff_hevc_set_neighbour_available(s, xBase, yBase + (i << log2_trafo_size), trafo_size_h, trafo_size_v); @@ -1081,14 +1081,14 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, log2_trafo_size, scan_idx_c, 2); } } - } else if (s->sps->chroma_format_idc && lc->cu.pred_mode == MODE_INTRA) { - if (log2_trafo_size > 2 || s->sps->chroma_format_idc == 3) { - int trafo_size_h = 1 << (log2_trafo_size_c + s->sps->hshift[1]); - int trafo_size_v = 1 << (log2_trafo_size_c + s->sps->vshift[1]); + } else if (s->ps.sps->chroma_format_idc && lc->cu.pred_mode == MODE_INTRA) { + if (log2_trafo_size > 2 || s->ps.sps->chroma_format_idc == 3) { + int trafo_size_h = 1 << (log2_trafo_size_c + s->ps.sps->hshift[1]); + int trafo_size_v = 1 << (log2_trafo_size_c + s->ps.sps->vshift[1]); ff_hevc_set_neighbour_available(s, x0, y0, trafo_size_h, trafo_size_v); s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0, 1); s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0, 2); - if (s->sps->chroma_format_idc == 2) { + if (s->ps.sps->chroma_format_idc == 2) { ff_hevc_set_neighbour_available(s, x0, y0 + (1 << log2_trafo_size_c), trafo_size_h, trafo_size_v); s->hpc.intra_pred[log2_trafo_size_c - 2](s, x0, y0 + (1 << log2_trafo_size_c), 1); @@ -1096,12 +1096,12 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, } } else if (blk_idx == 3) { int trafo_size_h = 1 << (log2_trafo_size + 1); - int trafo_size_v = 1 << (log2_trafo_size + s->sps->vshift[1]); + int trafo_size_v = 1 << (log2_trafo_size + s->ps.sps->vshift[1]); ff_hevc_set_neighbour_available(s, xBase, yBase, trafo_size_h, trafo_size_v); s->hpc.intra_pred[log2_trafo_size - 2](s, xBase, yBase, 1); s->hpc.intra_pred[log2_trafo_size - 2](s, xBase, yBase, 2); - if (s->sps->chroma_format_idc == 2) { + if (s->ps.sps->chroma_format_idc == 2) { ff_hevc_set_neighbour_available(s, xBase, yBase + (1 << (log2_trafo_size)), trafo_size_h, trafo_size_v); s->hpc.intra_pred[log2_trafo_size - 2](s, xBase, yBase + (1 << (log2_trafo_size)), 1); @@ -1116,11 +1116,11 @@ static int hls_transform_unit(HEVCContext *s, int x0, int y0, static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_size) { int cb_size = 1 << log2_cb_size; - int log2_min_pu_size = s->sps->log2_min_pu_size; + int log2_min_pu_size = s->ps.sps->log2_min_pu_size; - int min_pu_width = s->sps->min_pu_width; - int x_end = FFMIN(x0 + cb_size, s->sps->width); - int y_end = FFMIN(y0 + cb_size, s->sps->height); + int min_pu_width = s->ps.sps->min_pu_width; + int x_end = FFMIN(x0 + cb_size, s->ps.sps->width); + int y_end = FFMIN(y0 + cb_size, s->ps.sps->height); int i, j; for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++) @@ -1148,7 +1148,7 @@ static int hls_transform_tree(HEVCContext *s, int x0, int y0, if (lc->cu.intra_split_flag) { if (trafo_depth == 1) { lc->tu.intra_pred_mode = lc->pu.intra_pred_mode[blk_idx]; - if (s->sps->chroma_format_idc == 3) { + if (s->ps.sps->chroma_format_idc == 3) { lc->tu.intra_pred_mode_c = lc->pu.intra_pred_mode_c[blk_idx]; lc->tu.chroma_mode_c = lc->pu.chroma_mode_c[blk_idx]; } else { @@ -1162,33 +1162,33 @@ static int hls_transform_tree(HEVCContext *s, int x0, int y0, lc->tu.chroma_mode_c = lc->pu.chroma_mode_c[0]; } - if (log2_trafo_size <= s->sps->log2_max_trafo_size && - log2_trafo_size > s->sps->log2_min_tb_size && + if (log2_trafo_size <= s->ps.sps->log2_max_trafo_size && + log2_trafo_size > s->ps.sps->log2_min_tb_size && trafo_depth < lc->cu.max_trafo_depth && !(lc->cu.intra_split_flag && trafo_depth == 0)) { split_transform_flag = ff_hevc_split_transform_flag_decode(s, log2_trafo_size); } else { - int inter_split = s->sps->max_transform_hierarchy_depth_inter == 0 && + int inter_split = s->ps.sps->max_transform_hierarchy_depth_inter == 0 && lc->cu.pred_mode == MODE_INTER && lc->cu.part_mode != PART_2Nx2N && trafo_depth == 0; - split_transform_flag = log2_trafo_size > s->sps->log2_max_trafo_size || + split_transform_flag = log2_trafo_size > s->ps.sps->log2_max_trafo_size || (lc->cu.intra_split_flag && trafo_depth == 0) || inter_split; } - if (s->sps->chroma_format_idc && (log2_trafo_size > 2 || s->sps->chroma_format_idc == 3)) { + if (s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 || s->ps.sps->chroma_format_idc == 3)) { if (trafo_depth == 0 || cbf_cb[0]) { cbf_cb[0] = ff_hevc_cbf_cb_cr_decode(s, trafo_depth); - if (s->sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) { + if (s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) { cbf_cb[1] = ff_hevc_cbf_cb_cr_decode(s, trafo_depth); } } if (trafo_depth == 0 || cbf_cr[0]) { cbf_cr[0] = ff_hevc_cbf_cb_cr_decode(s, trafo_depth); - if (s->sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) { + if (s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) { cbf_cr[1] = ff_hevc_cbf_cb_cr_decode(s, trafo_depth); } } @@ -1215,14 +1215,14 @@ do { #undef SUBDIVIDE } else { - int min_tu_size = 1 << s->sps->log2_min_tb_size; - int log2_min_tu_size = s->sps->log2_min_tb_size; - int min_tu_width = s->sps->min_tb_width; + int min_tu_size = 1 << s->ps.sps->log2_min_tb_size; + int log2_min_tu_size = s->ps.sps->log2_min_tb_size; + int min_tu_width = s->ps.sps->min_tb_width; int cbf_luma = 1; if (lc->cu.pred_mode == MODE_INTRA || trafo_depth != 0 || cbf_cb[0] || cbf_cr[0] || - (s->sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) { + (s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) { cbf_luma = ff_hevc_cbf_luma_decode(s, trafo_depth); } @@ -1243,7 +1243,7 @@ do { } if (!s->sh.disable_deblocking_filter_flag) { ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_trafo_size); - if (s->pps->transquant_bypass_enable_flag && + if (s->ps.pps->transquant_bypass_enable_flag && lc->cu.cu_transquant_bypass_flag) set_deblocking_bypass(s, x0, y0, log2_trafo_size); } @@ -1257,16 +1257,16 @@ static int hls_pcm_sample(HEVCContext *s, int x0, int y0, int log2_cb_size) GetBitContext gb; int cb_size = 1 << log2_cb_size; int stride0 = s->frame->linesize[0]; - uint8_t *dst0 = &s->frame->data[0][y0 * stride0 + (x0 << s->sps->pixel_shift)]; + uint8_t *dst0 = &s->frame->data[0][y0 * stride0 + (x0 << s->ps.sps->pixel_shift)]; int stride1 = s->frame->linesize[1]; - uint8_t *dst1 = &s->frame->data[1][(y0 >> s->sps->vshift[1]) * stride1 + ((x0 >> s->sps->hshift[1]) << s->sps->pixel_shift)]; + uint8_t *dst1 = &s->frame->data[1][(y0 >> s->ps.sps->vshift[1]) * stride1 + ((x0 >> s->ps.sps->hshift[1]) << s->ps.sps->pixel_shift)]; int stride2 = s->frame->linesize[2]; - uint8_t *dst2 = &s->frame->data[2][(y0 >> s->sps->vshift[2]) * stride2 + ((x0 >> s->sps->hshift[2]) << s->sps->pixel_shift)]; + uint8_t *dst2 = &s->frame->data[2][(y0 >> s->ps.sps->vshift[2]) * stride2 + ((x0 >> s->ps.sps->hshift[2]) << s->ps.sps->pixel_shift)]; - int length = cb_size * cb_size * s->sps->pcm.bit_depth + - (((cb_size >> s->sps->hshift[1]) * (cb_size >> s->sps->vshift[1])) + - ((cb_size >> s->sps->hshift[2]) * (cb_size >> s->sps->vshift[2]))) * - s->sps->pcm.bit_depth_chroma; + int length = cb_size * cb_size * s->ps.sps->pcm.bit_depth + + (((cb_size >> s->ps.sps->hshift[1]) * (cb_size >> s->ps.sps->vshift[1])) + + ((cb_size >> s->ps.sps->hshift[2]) * (cb_size >> s->ps.sps->vshift[2]))) * + s->ps.sps->pcm.bit_depth_chroma; const uint8_t *pcm = skip_bytes(&lc->cc, (length + 7) >> 3); int ret; @@ -1277,16 +1277,16 @@ static int hls_pcm_sample(HEVCContext *s, int x0, int y0, int log2_cb_size) if (ret < 0) return ret; - s->hevcdsp.put_pcm(dst0, stride0, cb_size, cb_size, &gb, s->sps->pcm.bit_depth); - if (s->sps->chroma_format_idc) { + s->hevcdsp.put_pcm(dst0, stride0, cb_size, cb_size, &gb, s->ps.sps->pcm.bit_depth); + if (s->ps.sps->chroma_format_idc) { s->hevcdsp.put_pcm(dst1, stride1, - cb_size >> s->sps->hshift[1], - cb_size >> s->sps->vshift[1], - &gb, s->sps->pcm.bit_depth_chroma); + cb_size >> s->ps.sps->hshift[1], + cb_size >> s->ps.sps->vshift[1], + &gb, s->ps.sps->pcm.bit_depth_chroma); s->hevcdsp.put_pcm(dst2, stride2, - cb_size >> s->sps->hshift[2], - cb_size >> s->sps->vshift[2], - &gb, s->sps->pcm.bit_depth_chroma); + cb_size >> s->ps.sps->hshift[2], + cb_size >> s->ps.sps->vshift[2], + &gb, s->ps.sps->pcm.bit_depth_chroma); } return 0; @@ -1315,24 +1315,24 @@ static void luma_mc_uni(HEVCContext *s, uint8_t *dst, ptrdiff_t dststride, HEVCLocalContext *lc = s->HEVClc; uint8_t *src = ref->data[0]; ptrdiff_t srcstride = ref->linesize[0]; - int pic_width = s->sps->width; - int pic_height = s->sps->height; + int pic_width = s->ps.sps->width; + int pic_height = s->ps.sps->height; int mx = mv->x & 3; int my = mv->y & 3; - int weight_flag = (s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || - (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag); + int weight_flag = (s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) || + (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag); int idx = ff_hevc_pel_weight[block_w]; x_off += mv->x >> 2; y_off += mv->y >> 2; - src += y_off * srcstride + x_off * (1 << s->sps->pixel_shift); + src += y_off * srcstride + x_off * (1 << s->ps.sps->pixel_shift); if (x_off < QPEL_EXTRA_BEFORE || y_off < QPEL_EXTRA_AFTER || x_off >= pic_width - block_w - QPEL_EXTRA_AFTER || y_off >= pic_height - block_h - QPEL_EXTRA_AFTER) { - const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift; - int offset = QPEL_EXTRA_BEFORE * srcstride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift); - int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift); + const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; + int offset = QPEL_EXTRA_BEFORE * srcstride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); + int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src - offset, edge_emu_stride, srcstride, @@ -1376,29 +1376,29 @@ static void luma_mc_uni(HEVCContext *s, uint8_t *dst, ptrdiff_t dststride, HEVCLocalContext *lc = s->HEVClc; ptrdiff_t src0stride = ref0->linesize[0]; ptrdiff_t src1stride = ref1->linesize[0]; - int pic_width = s->sps->width; - int pic_height = s->sps->height; + int pic_width = s->ps.sps->width; + int pic_height = s->ps.sps->height; int mx0 = mv0->x & 3; int my0 = mv0->y & 3; int mx1 = mv1->x & 3; int my1 = mv1->y & 3; - int weight_flag = (s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || - (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag); + int weight_flag = (s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) || + (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag); int x_off0 = x_off + (mv0->x >> 2); int y_off0 = y_off + (mv0->y >> 2); int x_off1 = x_off + (mv1->x >> 2); int y_off1 = y_off + (mv1->y >> 2); int idx = ff_hevc_pel_weight[block_w]; - uint8_t *src0 = ref0->data[0] + y_off0 * src0stride + (int)((unsigned)x_off0 << s->sps->pixel_shift); - uint8_t *src1 = ref1->data[0] + y_off1 * src1stride + (int)((unsigned)x_off1 << s->sps->pixel_shift); + uint8_t *src0 = ref0->data[0] + y_off0 * src0stride + (int)((unsigned)x_off0 << s->ps.sps->pixel_shift); + uint8_t *src1 = ref1->data[0] + y_off1 * src1stride + (int)((unsigned)x_off1 << s->ps.sps->pixel_shift); if (x_off0 < QPEL_EXTRA_BEFORE || y_off0 < QPEL_EXTRA_AFTER || x_off0 >= pic_width - block_w - QPEL_EXTRA_AFTER || y_off0 >= pic_height - block_h - QPEL_EXTRA_AFTER) { - const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift; - int offset = QPEL_EXTRA_BEFORE * src0stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift); - int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift); + const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; + int offset = QPEL_EXTRA_BEFORE * src0stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); + int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src0 - offset, edge_emu_stride, src0stride, @@ -1413,9 +1413,9 @@ static void luma_mc_uni(HEVCContext *s, uint8_t *dst, ptrdiff_t dststride, if (x_off1 < QPEL_EXTRA_BEFORE || y_off1 < QPEL_EXTRA_AFTER || x_off1 >= pic_width - block_w - QPEL_EXTRA_AFTER || y_off1 >= pic_height - block_h - QPEL_EXTRA_AFTER) { - const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift; - int offset = QPEL_EXTRA_BEFORE * src1stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift); - int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->sps->pixel_shift); + const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; + int offset = QPEL_EXTRA_BEFORE * src1stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); + int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); s->vdsp.emulated_edge_mc(lc->edge_emu_buffer2, src1 - offset, edge_emu_stride, src1stride, @@ -1465,14 +1465,14 @@ static void chroma_mc_uni(HEVCContext *s, uint8_t *dst0, int x_off, int y_off, int block_w, int block_h, struct MvField *current_mv, int chroma_weight, int chroma_offset) { HEVCLocalContext *lc = s->HEVClc; - int pic_width = s->sps->width >> s->sps->hshift[1]; - int pic_height = s->sps->height >> s->sps->vshift[1]; + int pic_width = s->ps.sps->width >> s->ps.sps->hshift[1]; + int pic_height = s->ps.sps->height >> s->ps.sps->vshift[1]; const Mv *mv = ¤t_mv->mv[reflist]; - int weight_flag = (s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || - (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag); + int weight_flag = (s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) || + (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag); int idx = ff_hevc_pel_weight[block_w]; - int hshift = s->sps->hshift[1]; - int vshift = s->sps->vshift[1]; + int hshift = s->ps.sps->hshift[1]; + int vshift = s->ps.sps->vshift[1]; intptr_t mx = av_mod_uintp2(mv->x, 2 + hshift); intptr_t my = av_mod_uintp2(mv->y, 2 + vshift); intptr_t _mx = mx << (1 - hshift); @@ -1480,15 +1480,15 @@ static void chroma_mc_uni(HEVCContext *s, uint8_t *dst0, x_off += mv->x >> (2 + hshift); y_off += mv->y >> (2 + vshift); - src0 += y_off * srcstride + x_off * (1 << s->sps->pixel_shift); + src0 += y_off * srcstride + x_off * (1 << s->ps.sps->pixel_shift); if (x_off < EPEL_EXTRA_BEFORE || y_off < EPEL_EXTRA_AFTER || x_off >= pic_width - block_w - EPEL_EXTRA_AFTER || y_off >= pic_height - block_h - EPEL_EXTRA_AFTER) { - const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift; - int offset0 = EPEL_EXTRA_BEFORE * (srcstride + (1 << s->sps->pixel_shift)); + const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; + int offset0 = EPEL_EXTRA_BEFORE * (srcstride + (1 << s->ps.sps->pixel_shift)); int buf_offset0 = EPEL_EXTRA_BEFORE * - (edge_emu_stride + (1 << s->sps->pixel_shift)); + (edge_emu_stride + (1 << s->ps.sps->pixel_shift)); s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src0 - offset0, edge_emu_stride, srcstride, block_w + EPEL_EXTRA, block_h + EPEL_EXTRA, @@ -1533,14 +1533,14 @@ static void chroma_mc_bi(HEVCContext *s, uint8_t *dst0, ptrdiff_t dststride, AVF uint8_t *src2 = ref1->data[cidx+1]; ptrdiff_t src1stride = ref0->linesize[cidx+1]; ptrdiff_t src2stride = ref1->linesize[cidx+1]; - int weight_flag = (s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || - (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag); - int pic_width = s->sps->width >> s->sps->hshift[1]; - int pic_height = s->sps->height >> s->sps->vshift[1]; + int weight_flag = (s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) || + (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag); + int pic_width = s->ps.sps->width >> s->ps.sps->hshift[1]; + int pic_height = s->ps.sps->height >> s->ps.sps->vshift[1]; Mv *mv0 = ¤t_mv->mv[0]; Mv *mv1 = ¤t_mv->mv[1]; - int hshift = s->sps->hshift[1]; - int vshift = s->sps->vshift[1]; + int hshift = s->ps.sps->hshift[1]; + int vshift = s->ps.sps->vshift[1]; intptr_t mx0 = av_mod_uintp2(mv0->x, 2 + hshift); intptr_t my0 = av_mod_uintp2(mv0->y, 2 + vshift); @@ -1556,16 +1556,16 @@ static void chroma_mc_bi(HEVCContext *s, uint8_t *dst0, ptrdiff_t dststride, AVF int x_off1 = x_off + (mv1->x >> (2 + hshift)); int y_off1 = y_off + (mv1->y >> (2 + vshift)); int idx = ff_hevc_pel_weight[block_w]; - src1 += y_off0 * src1stride + (int)((unsigned)x_off0 << s->sps->pixel_shift); - src2 += y_off1 * src2stride + (int)((unsigned)x_off1 << s->sps->pixel_shift); + src1 += y_off0 * src1stride + (int)((unsigned)x_off0 << s->ps.sps->pixel_shift); + src2 += y_off1 * src2stride + (int)((unsigned)x_off1 << s->ps.sps->pixel_shift); if (x_off0 < EPEL_EXTRA_BEFORE || y_off0 < EPEL_EXTRA_AFTER || x_off0 >= pic_width - block_w - EPEL_EXTRA_AFTER || y_off0 >= pic_height - block_h - EPEL_EXTRA_AFTER) { - const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift; - int offset1 = EPEL_EXTRA_BEFORE * (src1stride + (1 << s->sps->pixel_shift)); + const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; + int offset1 = EPEL_EXTRA_BEFORE * (src1stride + (1 << s->ps.sps->pixel_shift)); int buf_offset1 = EPEL_EXTRA_BEFORE * - (edge_emu_stride + (1 << s->sps->pixel_shift)); + (edge_emu_stride + (1 << s->ps.sps->pixel_shift)); s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src1 - offset1, edge_emu_stride, src1stride, @@ -1581,10 +1581,10 @@ static void chroma_mc_bi(HEVCContext *s, uint8_t *dst0, ptrdiff_t dststride, AVF if (x_off1 < EPEL_EXTRA_BEFORE || y_off1 < EPEL_EXTRA_AFTER || x_off1 >= pic_width - block_w - EPEL_EXTRA_AFTER || y_off1 >= pic_height - block_h - EPEL_EXTRA_AFTER) { - const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->sps->pixel_shift; - int offset1 = EPEL_EXTRA_BEFORE * (src2stride + (1 << s->sps->pixel_shift)); + const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; + int offset1 = EPEL_EXTRA_BEFORE * (src2stride + (1 << s->ps.sps->pixel_shift)); int buf_offset1 = EPEL_EXTRA_BEFORE * - (edge_emu_stride + (1 << s->sps->pixel_shift)); + (edge_emu_stride + (1 << s->ps.sps->pixel_shift)); s->vdsp.emulated_edge_mc(lc->edge_emu_buffer2, src2 - offset1, edge_emu_stride, src2stride, @@ -1674,13 +1674,13 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int log2_cb_size, int partIdx, int idx) { #define POS(c_idx, x, y) \ - &s->frame->data[c_idx][((y) >> s->sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \ - (((x) >> s->sps->hshift[c_idx]) << s->sps->pixel_shift)] + &s->frame->data[c_idx][((y) >> s->ps.sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \ + (((x) >> s->ps.sps->hshift[c_idx]) << s->ps.sps->pixel_shift)] HEVCLocalContext *lc = s->HEVClc; int merge_idx = 0; struct MvField current_mv = {{{ 0 }}}; - int min_pu_width = s->sps->min_pu_width; + int min_pu_width = s->ps.sps->min_pu_width; MvField *tab_mvf = s->ref->tab_mvf; RefPicList *refPicList = s->ref->refPicList; @@ -1688,8 +1688,8 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, uint8_t *dst0 = POS(0, x0, y0); uint8_t *dst1 = POS(1, x0, y0); uint8_t *dst2 = POS(2, x0, y0); - int log2_min_cb_size = s->sps->log2_min_cb_size; - int min_cb_width = s->sps->min_cb_width; + int log2_min_cb_size = s->ps.sps->log2_min_cb_size; + int min_cb_width = s->ps.sps->min_cb_width; int x_cb = x0 >> log2_min_cb_size; int y_cb = y0 >> log2_min_cb_size; int x_pu, y_pu; @@ -1713,11 +1713,11 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, partIdx, merge_idx, ¤t_mv); } - x_pu = x0 >> s->sps->log2_min_pu_size; - y_pu = y0 >> s->sps->log2_min_pu_size; + x_pu = x0 >> s->ps.sps->log2_min_pu_size; + y_pu = y0 >> s->ps.sps->log2_min_pu_size; - for (j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++) - for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++) + for (j = 0; j < nPbH >> s->ps.sps->log2_min_pu_size; j++) + for (i = 0; i < nPbW >> s->ps.sps->log2_min_pu_size; i++) tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv; if (current_mv.pred_flag & PF_L0) { @@ -1734,17 +1734,17 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, } if (current_mv.pred_flag == PF_L0) { - int x0_c = x0 >> s->sps->hshift[1]; - int y0_c = y0 >> s->sps->vshift[1]; - int nPbW_c = nPbW >> s->sps->hshift[1]; - int nPbH_c = nPbH >> s->sps->vshift[1]; + int x0_c = x0 >> s->ps.sps->hshift[1]; + int y0_c = y0 >> s->ps.sps->vshift[1]; + int nPbW_c = nPbW >> s->ps.sps->hshift[1]; + int nPbH_c = nPbH >> s->ps.sps->vshift[1]; luma_mc_uni(s, dst0, s->frame->linesize[0], ref0->frame, ¤t_mv.mv[0], x0, y0, nPbW, nPbH, s->sh.luma_weight_l0[current_mv.ref_idx[0]], s->sh.luma_offset_l0[current_mv.ref_idx[0]]); - if (s->sps->chroma_format_idc) { + if (s->ps.sps->chroma_format_idc) { chroma_mc_uni(s, dst1, s->frame->linesize[1], ref0->frame->data[1], ref0->frame->linesize[1], 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0]); @@ -1753,17 +1753,17 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1]); } } else if (current_mv.pred_flag == PF_L1) { - int x0_c = x0 >> s->sps->hshift[1]; - int y0_c = y0 >> s->sps->vshift[1]; - int nPbW_c = nPbW >> s->sps->hshift[1]; - int nPbH_c = nPbH >> s->sps->vshift[1]; + int x0_c = x0 >> s->ps.sps->hshift[1]; + int y0_c = y0 >> s->ps.sps->vshift[1]; + int nPbW_c = nPbW >> s->ps.sps->hshift[1]; + int nPbH_c = nPbH >> s->ps.sps->vshift[1]; luma_mc_uni(s, dst0, s->frame->linesize[0], ref1->frame, ¤t_mv.mv[1], x0, y0, nPbW, nPbH, s->sh.luma_weight_l1[current_mv.ref_idx[1]], s->sh.luma_offset_l1[current_mv.ref_idx[1]]); - if (s->sps->chroma_format_idc) { + if (s->ps.sps->chroma_format_idc) { chroma_mc_uni(s, dst1, s->frame->linesize[1], ref1->frame->data[1], ref1->frame->linesize[1], 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0]); @@ -1773,16 +1773,16 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1]); } } else if (current_mv.pred_flag == PF_BI) { - int x0_c = x0 >> s->sps->hshift[1]; - int y0_c = y0 >> s->sps->vshift[1]; - int nPbW_c = nPbW >> s->sps->hshift[1]; - int nPbH_c = nPbH >> s->sps->vshift[1]; + int x0_c = x0 >> s->ps.sps->hshift[1]; + int y0_c = y0 >> s->ps.sps->vshift[1]; + int nPbW_c = nPbW >> s->ps.sps->hshift[1]; + int nPbH_c = nPbH >> s->ps.sps->vshift[1]; luma_mc_bi(s, dst0, s->frame->linesize[0], ref0->frame, ¤t_mv.mv[0], x0, y0, nPbW, nPbH, ref1->frame, ¤t_mv.mv[1], ¤t_mv); - if (s->sps->chroma_format_idc) { + if (s->ps.sps->chroma_format_idc) { chroma_mc_bi(s, dst1, s->frame->linesize[1], ref0->frame, ref1->frame, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0); @@ -1799,19 +1799,19 @@ static int luma_intra_pred_mode(HEVCContext *s, int x0, int y0, int pu_size, int prev_intra_luma_pred_flag) { HEVCLocalContext *lc = s->HEVClc; - int x_pu = x0 >> s->sps->log2_min_pu_size; - int y_pu = y0 >> s->sps->log2_min_pu_size; - int min_pu_width = s->sps->min_pu_width; - int size_in_pus = pu_size >> s->sps->log2_min_pu_size; - int x0b = av_mod_uintp2(x0, s->sps->log2_ctb_size); - int y0b = av_mod_uintp2(y0, s->sps->log2_ctb_size); + int x_pu = x0 >> s->ps.sps->log2_min_pu_size; + int y_pu = y0 >> s->ps.sps->log2_min_pu_size; + int min_pu_width = s->ps.sps->min_pu_width; + int size_in_pus = pu_size >> s->ps.sps->log2_min_pu_size; + int x0b = av_mod_uintp2(x0, s->ps.sps->log2_ctb_size); + int y0b = av_mod_uintp2(y0, s->ps.sps->log2_ctb_size); int cand_up = (lc->ctb_up_flag || y0b) ? s->tab_ipm[(y_pu - 1) * min_pu_width + x_pu] : INTRA_DC; int cand_left = (lc->ctb_left_flag || x0b) ? s->tab_ipm[y_pu * min_pu_width + x_pu - 1] : INTRA_DC; - int y_ctb = (y0 >> (s->sps->log2_ctb_size)) << (s->sps->log2_ctb_size); + int y_ctb = (y0 >> (s->ps.sps->log2_ctb_size)) << (s->ps.sps->log2_ctb_size); MvField *tab_mvf = s->ref->tab_mvf; int intra_pred_mode; @@ -1878,13 +1878,13 @@ static int luma_intra_pred_mode(HEVCContext *s, int x0, int y0, int pu_size, static av_always_inline void set_ct_depth(HEVCContext *s, int x0, int y0, int log2_cb_size, int ct_depth) { - int length = (1 << log2_cb_size) >> s->sps->log2_min_cb_size; - int x_cb = x0 >> s->sps->log2_min_cb_size; - int y_cb = y0 >> s->sps->log2_min_cb_size; + int length = (1 << log2_cb_size) >> s->ps.sps->log2_min_cb_size; + int x_cb = x0 >> s->ps.sps->log2_min_cb_size; + int y_cb = y0 >> s->ps.sps->log2_min_cb_size; int y; for (y = 0; y < length; y++) - memset(&s->tab_ct_depth[(y_cb + y) * s->sps->min_cb_width + x_cb], + memset(&s->tab_ct_depth[(y_cb + y) * s->ps.sps->min_cb_width + x_cb], ct_depth, length); } @@ -1921,7 +1921,7 @@ static void intra_prediction_unit(HEVCContext *s, int x0, int y0, } } - if (s->sps->chroma_format_idc == 3) { + if (s->ps.sps->chroma_format_idc == 3) { for (i = 0; i < side; i++) { for (j = 0; j < side; j++) { lc->pu.chroma_mode_c[2 * i + j] = chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(s); @@ -1935,7 +1935,7 @@ static void intra_prediction_unit(HEVCContext *s, int x0, int y0, } } } - } else if (s->sps->chroma_format_idc == 2) { + } else if (s->ps.sps->chroma_format_idc == 2) { int mode_idx; lc->pu.chroma_mode_c[0] = chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(s); if (chroma_mode != 4) { @@ -1947,7 +1947,7 @@ static void intra_prediction_unit(HEVCContext *s, int x0, int y0, mode_idx = lc->pu.intra_pred_mode[0]; } lc->pu.intra_pred_mode_c[0] = tab_mode_idx[mode_idx]; - } else if (s->sps->chroma_format_idc != 0) { + } else if (s->ps.sps->chroma_format_idc != 0) { chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(s); if (chroma_mode != 4) { if (lc->pu.intra_pred_mode[0] == intra_chroma_table[chroma_mode]) @@ -1966,11 +1966,11 @@ static void intra_prediction_unit_default_value(HEVCContext *s, { HEVCLocalContext *lc = s->HEVClc; int pb_size = 1 << log2_cb_size; - int size_in_pus = pb_size >> s->sps->log2_min_pu_size; - int min_pu_width = s->sps->min_pu_width; + int size_in_pus = pb_size >> s->ps.sps->log2_min_pu_size; + int min_pu_width = s->ps.sps->min_pu_width; MvField *tab_mvf = s->ref->tab_mvf; - int x_pu = x0 >> s->sps->log2_min_pu_size; - int y_pu = y0 >> s->sps->log2_min_pu_size; + int x_pu = x0 >> s->ps.sps->log2_min_pu_size; + int y_pu = y0 >> s->ps.sps->log2_min_pu_size; int j, k; if (size_in_pus == 0) @@ -1987,13 +1987,13 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size) { int cb_size = 1 << log2_cb_size; HEVCLocalContext *lc = s->HEVClc; - int log2_min_cb_size = s->sps->log2_min_cb_size; + int log2_min_cb_size = s->ps.sps->log2_min_cb_size; int length = cb_size >> log2_min_cb_size; - int min_cb_width = s->sps->min_cb_width; + int min_cb_width = s->ps.sps->min_cb_width; int x_cb = x0 >> log2_min_cb_size; int y_cb = y0 >> log2_min_cb_size; int idx = log2_cb_size - 2; - int qp_block_mask = (1<<(s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth)) - 1; + int qp_block_mask = (1<<(s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_qp_delta_depth)) - 1; int x, y, ret; lc->cu.x = x0; @@ -2005,7 +2005,7 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size) SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0; for (x = 0; x < 4; x++) lc->pu.intra_pred_mode[x] = 1; - if (s->pps->transquant_bypass_enable_flag) { + if (s->ps.pps->transquant_bypass_enable_flag) { lc->cu.cu_transquant_bypass_flag = ff_hevc_cu_transquant_bypass_flag_decode(s); if (lc->cu.cu_transquant_bypass_flag) set_deblocking_bypass(s, x0, y0, log2_cb_size); @@ -2041,22 +2041,22 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size) if (s->sh.slice_type != I_SLICE) lc->cu.pred_mode = ff_hevc_pred_mode_decode(s); if (lc->cu.pred_mode != MODE_INTRA || - log2_cb_size == s->sps->log2_min_cb_size) { + log2_cb_size == s->ps.sps->log2_min_cb_size) { lc->cu.part_mode = ff_hevc_part_mode_decode(s, log2_cb_size); lc->cu.intra_split_flag = lc->cu.part_mode == PART_NxN && lc->cu.pred_mode == MODE_INTRA; } if (lc->cu.pred_mode == MODE_INTRA) { - if (lc->cu.part_mode == PART_2Nx2N && s->sps->pcm_enabled_flag && - log2_cb_size >= s->sps->pcm.log2_min_pcm_cb_size && - log2_cb_size <= s->sps->pcm.log2_max_pcm_cb_size) { + if (lc->cu.part_mode == PART_2Nx2N && s->ps.sps->pcm_enabled_flag && + log2_cb_size >= s->ps.sps->pcm.log2_min_pcm_cb_size && + log2_cb_size <= s->ps.sps->pcm.log2_max_pcm_cb_size) { pcm_flag = ff_hevc_pcm_flag_decode(s); } if (pcm_flag) { intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); ret = hls_pcm_sample(s, x0, y0, log2_cb_size); - if (s->sps->pcm.loop_filter_disable_flag) + if (s->ps.sps->pcm.loop_filter_disable_flag) set_deblocking_bypass(s, x0, y0, log2_cb_size); if (ret < 0) @@ -2113,8 +2113,8 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size) if (rqt_root_cbf) { const static int cbf[2] = { 0 }; lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ? - s->sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag : - s->sps->max_transform_hierarchy_depth_inter; + s->ps.sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag : + s->ps.sps->max_transform_hierarchy_depth_inter; ret = hls_transform_tree(s, x0, y0, x0, y0, x0, y0, log2_cb_size, log2_cb_size, 0, 0, cbf, cbf); @@ -2127,7 +2127,7 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size) } } - if (s->pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0) + if (s->ps.pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0) ff_hevc_set_qPy(s, x0, y0, log2_cb_size); x = y_cb * min_cb_width + x_cb; @@ -2155,26 +2155,26 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, int split_cu; lc->ct_depth = cb_depth; - if (x0 + cb_size <= s->sps->width && - y0 + cb_size <= s->sps->height && - log2_cb_size > s->sps->log2_min_cb_size) { + if (x0 + cb_size <= s->ps.sps->width && + y0 + cb_size <= s->ps.sps->height && + log2_cb_size > s->ps.sps->log2_min_cb_size) { split_cu = ff_hevc_split_coding_unit_flag_decode(s, cb_depth, x0, y0); } else { - split_cu = (log2_cb_size > s->sps->log2_min_cb_size); + split_cu = (log2_cb_size > s->ps.sps->log2_min_cb_size); } - if (s->pps->cu_qp_delta_enabled_flag && - log2_cb_size >= s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth) { + if (s->ps.pps->cu_qp_delta_enabled_flag && + log2_cb_size >= s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_qp_delta_depth) { lc->tu.is_cu_qp_delta_coded = 0; lc->tu.cu_qp_delta = 0; } if (s->sh.cu_chroma_qp_offset_enabled_flag && - log2_cb_size >= s->sps->log2_ctb_size - s->pps->diff_cu_chroma_qp_offset_depth) { + log2_cb_size >= s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_chroma_qp_offset_depth) { lc->tu.is_cu_chroma_qp_offset_coded = 0; } if (split_cu) { - int qp_block_mask = (1<<(s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth)) - 1; + int qp_block_mask = (1<<(s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_qp_delta_depth)) - 1; const int cb_size_split = cb_size >> 1; const int x1 = x0 + cb_size_split; const int y1 = y0 + cb_size_split; @@ -2185,18 +2185,18 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, if (more_data < 0) return more_data; - if (more_data && x1 < s->sps->width) { + if (more_data && x1 < s->ps.sps->width) { more_data = hls_coding_quadtree(s, x1, y0, log2_cb_size - 1, cb_depth + 1); if (more_data < 0) return more_data; } - if (more_data && y1 < s->sps->height) { + if (more_data && y1 < s->ps.sps->height) { more_data = hls_coding_quadtree(s, x0, y1, log2_cb_size - 1, cb_depth + 1); if (more_data < 0) return more_data; } - if (more_data && x1 < s->sps->width && - y1 < s->sps->height) { + if (more_data && x1 < s->ps.sps->width && + y1 < s->ps.sps->height) { more_data = hls_coding_quadtree(s, x1, y1, log2_cb_size - 1, cb_depth + 1); if (more_data < 0) return more_data; @@ -2207,8 +2207,8 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, lc->qPy_pred = lc->qp_y; if (more_data) - return ((x1 + cb_size_split) < s->sps->width || - (y1 + cb_size_split) < s->sps->height); + return ((x1 + cb_size_split) < s->ps.sps->width || + (y1 + cb_size_split) < s->ps.sps->height); else return 0; } else { @@ -2216,11 +2216,11 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, if (ret < 0) return ret; if ((!((x0 + cb_size) % - (1 << (s->sps->log2_ctb_size))) || - (x0 + cb_size >= s->sps->width)) && + (1 << (s->ps.sps->log2_ctb_size))) || + (x0 + cb_size >= s->ps.sps->width)) && (!((y0 + cb_size) % - (1 << (s->sps->log2_ctb_size))) || - (y0 + cb_size >= s->sps->height))) { + (1 << (s->ps.sps->log2_ctb_size))) || + (y0 + cb_size >= s->ps.sps->height))) { int end_of_slice_flag = ff_hevc_end_of_slice_flag_decode(s); return !end_of_slice_flag; } else { @@ -2235,59 +2235,59 @@ static void hls_decode_neighbour(HEVCContext *s, int x_ctb, int y_ctb, int ctb_addr_ts) { HEVCLocalContext *lc = s->HEVClc; - int ctb_size = 1 << s->sps->log2_ctb_size; - int ctb_addr_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts]; + int ctb_size = 1 << s->ps.sps->log2_ctb_size; + int ctb_addr_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts]; int ctb_addr_in_slice = ctb_addr_rs - s->sh.slice_addr; s->tab_slice_address[ctb_addr_rs] = s->sh.slice_addr; - if (s->pps->entropy_coding_sync_enabled_flag) { + if (s->ps.pps->entropy_coding_sync_enabled_flag) { if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0) lc->first_qp_group = 1; - lc->end_of_tiles_x = s->sps->width; - } else if (s->pps->tiles_enabled_flag) { - if (ctb_addr_ts && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[ctb_addr_ts - 1]) { - int idxX = s->pps->col_idxX[x_ctb >> s->sps->log2_ctb_size]; - lc->end_of_tiles_x = x_ctb + (s->pps->column_width[idxX] << s->sps->log2_ctb_size); + lc->end_of_tiles_x = s->ps.sps->width; + } else if (s->ps.pps->tiles_enabled_flag) { + if (ctb_addr_ts && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]) { + int idxX = s->ps.pps->col_idxX[x_ctb >> s->ps.sps->log2_ctb_size]; + lc->end_of_tiles_x = x_ctb + (s->ps.pps->column_width[idxX] << s->ps.sps->log2_ctb_size); lc->first_qp_group = 1; } } else { - lc->end_of_tiles_x = s->sps->width; + lc->end_of_tiles_x = s->ps.sps->width; } - lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, s->sps->height); + lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, s->ps.sps->height); lc->boundary_flags = 0; - if (s->pps->tiles_enabled_flag) { - if (x_ctb > 0 && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs - 1]]) + if (s->ps.pps->tiles_enabled_flag) { + if (x_ctb > 0 && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs - 1]]) lc->boundary_flags |= BOUNDARY_LEFT_TILE; if (x_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - 1]) lc->boundary_flags |= BOUNDARY_LEFT_SLICE; - if (y_ctb > 0 && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs - s->sps->ctb_width]]) + if (y_ctb > 0 && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs - s->ps.sps->ctb_width]]) lc->boundary_flags |= BOUNDARY_UPPER_TILE; - if (y_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - s->sps->ctb_width]) + if (y_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - s->ps.sps->ctb_width]) lc->boundary_flags |= BOUNDARY_UPPER_SLICE; } else { if (ctb_addr_in_slice <= 0) lc->boundary_flags |= BOUNDARY_LEFT_SLICE; - if (ctb_addr_in_slice < s->sps->ctb_width) + if (ctb_addr_in_slice < s->ps.sps->ctb_width) lc->boundary_flags |= BOUNDARY_UPPER_SLICE; } lc->ctb_left_flag = ((x_ctb > 0) && (ctb_addr_in_slice > 0) && !(lc->boundary_flags & BOUNDARY_LEFT_TILE)); - lc->ctb_up_flag = ((y_ctb > 0) && (ctb_addr_in_slice >= s->sps->ctb_width) && !(lc->boundary_flags & BOUNDARY_UPPER_TILE)); - lc->ctb_up_right_flag = ((y_ctb > 0) && (ctb_addr_in_slice+1 >= s->sps->ctb_width) && (s->pps->tile_id[ctb_addr_ts] == s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs+1 - s->sps->ctb_width]])); - lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0) && (ctb_addr_in_slice-1 >= s->sps->ctb_width) && (s->pps->tile_id[ctb_addr_ts] == s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - s->sps->ctb_width]])); + lc->ctb_up_flag = ((y_ctb > 0) && (ctb_addr_in_slice >= s->ps.sps->ctb_width) && !(lc->boundary_flags & BOUNDARY_UPPER_TILE)); + lc->ctb_up_right_flag = ((y_ctb > 0) && (ctb_addr_in_slice+1 >= s->ps.sps->ctb_width) && (s->ps.pps->tile_id[ctb_addr_ts] == s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs+1 - s->ps.sps->ctb_width]])); + lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0) && (ctb_addr_in_slice-1 >= s->ps.sps->ctb_width) && (s->ps.pps->tile_id[ctb_addr_ts] == s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - s->ps.sps->ctb_width]])); } static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread) { HEVCContext *s = avctxt->priv_data; - int ctb_size = 1 << s->sps->log2_ctb_size; + int ctb_size = 1 << s->ps.sps->log2_ctb_size; int more_data = 1; int x_ctb = 0; int y_ctb = 0; - int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]; + int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]; if (!ctb_addr_ts && s->sh.dependent_slice_segment_flag) { av_log(s->avctx, AV_LOG_ERROR, "Impossible initial tile.\n"); @@ -2295,29 +2295,29 @@ static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread) } if (s->sh.dependent_slice_segment_flag) { - int prev_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1]; + int prev_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1]; if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) { av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n"); return AVERROR_INVALIDDATA; } } - while (more_data && ctb_addr_ts < s->sps->ctb_size) { - int ctb_addr_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts]; + while (more_data && ctb_addr_ts < s->ps.sps->ctb_size) { + int ctb_addr_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts]; - x_ctb = (ctb_addr_rs % ((s->sps->width + ctb_size - 1) >> s->sps->log2_ctb_size)) << s->sps->log2_ctb_size; - y_ctb = (ctb_addr_rs / ((s->sps->width + ctb_size - 1) >> s->sps->log2_ctb_size)) << s->sps->log2_ctb_size; + x_ctb = (ctb_addr_rs % ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size; + y_ctb = (ctb_addr_rs / ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size; hls_decode_neighbour(s, x_ctb, y_ctb, ctb_addr_ts); ff_hevc_cabac_init(s, ctb_addr_ts); - hls_sao_param(s, x_ctb >> s->sps->log2_ctb_size, y_ctb >> s->sps->log2_ctb_size); + hls_sao_param(s, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size); s->deblock[ctb_addr_rs].beta_offset = s->sh.beta_offset; s->deblock[ctb_addr_rs].tc_offset = s->sh.tc_offset; s->filter_slice_edges[ctb_addr_rs] = s->sh.slice_loop_filter_across_slices_enabled_flag; - more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->sps->log2_ctb_size, 0); + more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->ps.sps->log2_ctb_size, 0); if (more_data < 0) { s->tab_slice_address[ctb_addr_rs] = -1; return more_data; @@ -2329,8 +2329,8 @@ static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread) ff_hevc_hls_filters(s, x_ctb, y_ctb, ctb_size); } - if (x_ctb + ctb_size >= s->sps->width && - y_ctb + ctb_size >= s->sps->height) + if (x_ctb + ctb_size >= s->ps.sps->width && + y_ctb + ctb_size >= s->ps.sps->height) ff_hevc_hls_filter(s, x_ctb, y_ctb, ctb_size); return ctb_addr_ts; @@ -2351,12 +2351,12 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int { HEVCContext *s1 = avctxt->priv_data, *s; HEVCLocalContext *lc; - int ctb_size = 1<< s1->sps->log2_ctb_size; + int ctb_size = 1<< s1->ps.sps->log2_ctb_size; int more_data = 1; int *ctb_row_p = input_ctb_row; int ctb_row = ctb_row_p[job]; - int ctb_addr_rs = s1->sh.slice_ctb_addr_rs + ctb_row * ((s1->sps->width + ctb_size - 1) >> s1->sps->log2_ctb_size); - int ctb_addr_ts = s1->pps->ctb_addr_rs_to_ts[ctb_addr_rs]; + int ctb_addr_rs = s1->sh.slice_ctb_addr_rs + ctb_row * ((s1->ps.sps->width + ctb_size - 1) >> s1->ps.sps->log2_ctb_size); + int ctb_addr_ts = s1->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs]; int thread = ctb_row % s1->threads_number; int ret; @@ -2371,9 +2371,9 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int ff_init_cabac_decoder(&lc->cc, s->data + s->sh.offset[(ctb_row)-1], s->sh.size[ctb_row - 1]); } - while(more_data && ctb_addr_ts < s->sps->ctb_size) { - int x_ctb = (ctb_addr_rs % s->sps->ctb_width) << s->sps->log2_ctb_size; - int y_ctb = (ctb_addr_rs / s->sps->ctb_width) << s->sps->log2_ctb_size; + while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) { + int x_ctb = (ctb_addr_rs % s->ps.sps->ctb_width) << s->ps.sps->log2_ctb_size; + int y_ctb = (ctb_addr_rs / s->ps.sps->ctb_width) << s->ps.sps->log2_ctb_size; hls_decode_neighbour(s, x_ctb, y_ctb, ctb_addr_ts); @@ -2385,8 +2385,8 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int } ff_hevc_cabac_init(s, ctb_addr_ts); - hls_sao_param(s, x_ctb >> s->sps->log2_ctb_size, y_ctb >> s->sps->log2_ctb_size); - more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->sps->log2_ctb_size, 0); + hls_sao_param(s, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size); + more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->ps.sps->log2_ctb_size, 0); if (more_data < 0) { s->tab_slice_address[ctb_addr_rs] = -1; @@ -2399,21 +2399,21 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int ff_thread_report_progress2(s->avctx, ctb_row, thread, 1); ff_hevc_hls_filters(s, x_ctb, y_ctb, ctb_size); - if (!more_data && (x_ctb+ctb_size) < s->sps->width && ctb_row != s->sh.num_entry_point_offsets) { + if (!more_data && (x_ctb+ctb_size) < s->ps.sps->width && ctb_row != s->sh.num_entry_point_offsets) { avpriv_atomic_int_set(&s1->wpp_err, 1); ff_thread_report_progress2(s->avctx, ctb_row ,thread, SHIFT_CTB_WPP); return 0; } - if ((x_ctb+ctb_size) >= s->sps->width && (y_ctb+ctb_size) >= s->sps->height ) { + if ((x_ctb+ctb_size) >= s->ps.sps->width && (y_ctb+ctb_size) >= s->ps.sps->height ) { ff_hevc_hls_filter(s, x_ctb, y_ctb, ctb_size); ff_thread_report_progress2(s->avctx, ctb_row , thread, SHIFT_CTB_WPP); return ctb_addr_ts; } - ctb_addr_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts]; + ctb_addr_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts]; x_ctb+=ctb_size; - if(x_ctb >= s->sps->width) { + if(x_ctb >= s->ps.sps->width) { break; } } @@ -2495,7 +2495,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length) ret[i] = 0; } - if (s->pps->entropy_coding_sync_enabled_flag) + if (s->ps.pps->entropy_coding_sync_enabled_flag) s->avctx->execute2(s->avctx, (void *) hls_decode_entry_wpp, arg, ret, s->sh.num_entry_point_offsets + 1); for (i = 0; i <= s->sh.num_entry_point_offsets; i++) @@ -2583,21 +2583,21 @@ static int set_side_data(HEVCContext *s) static int hevc_frame_start(HEVCContext *s) { HEVCLocalContext *lc = s->HEVClc; - int pic_size_in_ctb = ((s->sps->width >> s->sps->log2_min_cb_size) + 1) * - ((s->sps->height >> s->sps->log2_min_cb_size) + 1); + int pic_size_in_ctb = ((s->ps.sps->width >> s->ps.sps->log2_min_cb_size) + 1) * + ((s->ps.sps->height >> s->ps.sps->log2_min_cb_size) + 1); int ret; memset(s->horizontal_bs, 0, s->bs_width * s->bs_height); memset(s->vertical_bs, 0, s->bs_width * s->bs_height); - memset(s->cbf_luma, 0, s->sps->min_tb_width * s->sps->min_tb_height); - memset(s->is_pcm, 0, (s->sps->min_pu_width + 1) * (s->sps->min_pu_height + 1)); + memset(s->cbf_luma, 0, s->ps.sps->min_tb_width * s->ps.sps->min_tb_height); + memset(s->is_pcm, 0, (s->ps.sps->min_pu_width + 1) * (s->ps.sps->min_pu_height + 1)); memset(s->tab_slice_address, -1, pic_size_in_ctb * sizeof(*s->tab_slice_address)); s->is_decoded = 0; s->first_nal_type = s->nal_unit_type; - if (s->pps->tiles_enabled_flag) - lc->end_of_tiles_x = s->pps->column_width[0] << s->sps->log2_ctb_size; + if (s->ps.pps->tiles_enabled_flag) + lc->end_of_tiles_x = s->ps.pps->column_width[0] << s->ps.sps->log2_ctb_size; ret = ff_hevc_set_new_ref(s, &s->frame, s->poc); if (ret < 0) @@ -2657,17 +2657,18 @@ static int decode_nal_unit(HEVCContext *s, const HEVCNAL *nal) switch (s->nal_unit_type) { case NAL_VPS: - ret = ff_hevc_decode_nal_vps(s); + ret = ff_hevc_decode_nal_vps(gb, s->avctx, &s->ps); if (ret < 0) goto fail; break; case NAL_SPS: - ret = ff_hevc_decode_nal_sps(s); + ret = ff_hevc_decode_nal_sps(gb, s->avctx, &s->ps, + s->apply_defdispwin); if (ret < 0) goto fail; break; case NAL_PPS: - ret = ff_hevc_decode_nal_pps(s); + ret = ff_hevc_decode_nal_pps(gb, s->avctx, &s->ps); if (ret < 0) goto fail; break; @@ -2756,7 +2757,7 @@ static int decode_nal_unit(HEVCContext *s, const HEVCNAL *nal) ctb_addr_ts = hls_slice_data_wpp(s, nal->data, nal->size); else ctb_addr_ts = hls_slice_data(s); - if (ctb_addr_ts >= (s->sps->ctb_width * s->sps->ctb_height)) { + if (ctb_addr_ts >= (s->ps.sps->ctb_width * s->ps.sps->ctb_height)) { s->is_decoded = 1; } @@ -3104,15 +3105,15 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx) av_frame_free(&s->DPB[i].frame); } - for (i = 0; i < FF_ARRAY_ELEMS(s->vps_list); i++) - av_buffer_unref(&s->vps_list[i]); - for (i = 0; i < FF_ARRAY_ELEMS(s->sps_list); i++) - av_buffer_unref(&s->sps_list[i]); - for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++) - av_buffer_unref(&s->pps_list[i]); - s->sps = NULL; - s->pps = NULL; - s->vps = NULL; + for (i = 0; i < FF_ARRAY_ELEMS(s->ps.vps_list); i++) + av_buffer_unref(&s->ps.vps_list[i]); + for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) + av_buffer_unref(&s->ps.sps_list[i]); + for (i = 0; i < FF_ARRAY_ELEMS(s->ps.pps_list); i++) + av_buffer_unref(&s->ps.pps_list[i]); + s->ps.sps = NULL; + s->ps.pps = NULL; + s->ps.vps = NULL; av_freep(&s->sh.entry_point_offset); av_freep(&s->sh.offset); @@ -3205,37 +3206,37 @@ static int hevc_update_thread_context(AVCodecContext *dst, } } - if (s->sps != s0->sps) - s->sps = NULL; - for (i = 0; i < FF_ARRAY_ELEMS(s->vps_list); i++) { - av_buffer_unref(&s->vps_list[i]); - if (s0->vps_list[i]) { - s->vps_list[i] = av_buffer_ref(s0->vps_list[i]); - if (!s->vps_list[i]) + if (s->ps.sps != s0->ps.sps) + s->ps.sps = NULL; + for (i = 0; i < FF_ARRAY_ELEMS(s->ps.vps_list); i++) { + av_buffer_unref(&s->ps.vps_list[i]); + if (s0->ps.vps_list[i]) { + s->ps.vps_list[i] = av_buffer_ref(s0->ps.vps_list[i]); + if (!s->ps.vps_list[i]) return AVERROR(ENOMEM); } } - for (i = 0; i < FF_ARRAY_ELEMS(s->sps_list); i++) { - av_buffer_unref(&s->sps_list[i]); - if (s0->sps_list[i]) { - s->sps_list[i] = av_buffer_ref(s0->sps_list[i]); - if (!s->sps_list[i]) + for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) { + av_buffer_unref(&s->ps.sps_list[i]); + if (s0->ps.sps_list[i]) { + s->ps.sps_list[i] = av_buffer_ref(s0->ps.sps_list[i]); + if (!s->ps.sps_list[i]) return AVERROR(ENOMEM); } } - for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++) { - av_buffer_unref(&s->pps_list[i]); - if (s0->pps_list[i]) { - s->pps_list[i] = av_buffer_ref(s0->pps_list[i]); - if (!s->pps_list[i]) + for (i = 0; i < FF_ARRAY_ELEMS(s->ps.pps_list); i++) { + av_buffer_unref(&s->ps.pps_list[i]); + if (s0->ps.pps_list[i]) { + s->ps.pps_list[i] = av_buffer_ref(s0->ps.pps_list[i]); + if (!s->ps.pps_list[i]) return AVERROR(ENOMEM); } } - if (s->sps != s0->sps) - if ((ret = set_sps(s, s0->sps, src->pix_fmt)) < 0) + if (s->ps.sps != s0->ps.sps) + if ((ret = set_sps(s, s0->ps.sps, src->pix_fmt)) < 0) return ret; s->seq_decode = s0->seq_decode; @@ -3321,9 +3322,9 @@ static int hevc_decode_extradata(HEVCContext *s) } /* export stream parameters from the first SPS */ - for (i = 0; i < FF_ARRAY_ELEMS(s->sps_list); i++) { - if (s->sps_list[i]) { - const HEVCSPS *sps = (const HEVCSPS*)s->sps_list[i]->data; + for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) { + if (s->ps.sps_list[i]) { + const HEVCSPS *sps = (const HEVCSPS*)s->ps.sps_list[i]->data; export_stream_params(s->avctx, s, sps); break; } |