aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-07-12 22:06:21 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-07-12 22:28:54 +0200
commitd5fcca83b915df9536d595a1a44c24294b606836 (patch)
treee414b8d967bf761a6be218d4f16b6796d928d590
parent885afff01c720cc0a3c52802bd7f82bb81d9e576 (diff)
parentb11acd57326db6c2cc1475dd0bea2a06fbc85aa2 (diff)
downloadffmpeg-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>
-rw-r--r--libavcodec/hevc.c647
-rw-r--r--libavcodec/hevc.h27
-rw-r--r--libavcodec/hevc_cabac.c118
-rw-r--r--libavcodec/hevc_filter.c186
-rw-r--r--libavcodec/hevc_mvs.c72
-rw-r--r--libavcodec/hevc_parser.c52
-rw-r--r--libavcodec/hevc_ps.c123
-rw-r--r--libavcodec/hevc_refs.c34
-rw-r--r--libavcodec/hevc_sei.c4
-rw-r--r--libavcodec/hevcpred_template.c62
10 files changed, 669 insertions, 656 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 = &current_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 = &current_mv->mv[0];
Mv *mv1 = &current_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, &current_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,
&current_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, &current_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,
&current_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, &current_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,
&current_mv.mv[0], x0, y0, nPbW, nPbH,
ref1->frame, &current_mv.mv[1], &current_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, &current_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;
}
diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index aa91bdd607..73824514c9 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -557,6 +557,17 @@ typedef struct HEVCPPS {
int *min_tb_addr_zs_tab;///< MinTbAddrZS
} HEVCPPS;
+typedef struct HEVCParamSets {
+ AVBufferRef *vps_list[MAX_VPS_COUNT];
+ AVBufferRef *sps_list[MAX_SPS_COUNT];
+ AVBufferRef *pps_list[MAX_PPS_COUNT];
+
+ /* currently active parameter sets */
+ const HEVCVPS *vps;
+ const HEVCSPS *sps;
+ const HEVCPPS *pps;
+} HEVCParamSets;
+
typedef struct SliceHeader {
unsigned int pps_id;
@@ -813,12 +824,7 @@ typedef struct HEVCContext {
uint8_t *sao_pixel_buffer_h[3];
uint8_t *sao_pixel_buffer_v[3];
- const HEVCVPS *vps;
- const HEVCSPS *sps;
- const HEVCPPS *pps;
- AVBufferRef *vps_list[MAX_VPS_COUNT];
- AVBufferRef *sps_list[MAX_SPS_COUNT];
- AVBufferRef *pps_list[MAX_PPS_COUNT];
+ HEVCParamSets ps;
AVBufferPool *tab_mvf_pool;
AVBufferPool *rpl_tab_pool;
@@ -939,9 +945,12 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
int apply_defdispwin, AVBufferRef **vps_list, AVCodecContext *avctx);
-int ff_hevc_decode_nal_vps(HEVCContext *s);
-int ff_hevc_decode_nal_sps(HEVCContext *s);
-int ff_hevc_decode_nal_pps(HEVCContext *s);
+int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
+ HEVCParamSets *ps);
+int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx,
+ HEVCParamSets *ps, int apply_defdispwin);
+int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
+ HEVCParamSets *ps);
int ff_hevc_decode_nal_sei(HEVCContext *s);
/**
diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index 3d16896b3c..8c191d34c2 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -499,10 +499,10 @@ static const uint8_t diag_scan8x8_inv[8][8] = {
void ff_hevc_save_states(HEVCContext *s, int ctb_addr_ts)
{
- if (s->pps->entropy_coding_sync_enabled_flag &&
- (ctb_addr_ts % s->sps->ctb_width == 2 ||
- (s->sps->ctb_width == 2 &&
- ctb_addr_ts % s->sps->ctb_width == 0))) {
+ if (s->ps.pps->entropy_coding_sync_enabled_flag &&
+ (ctb_addr_ts % s->ps.sps->ctb_width == 2 ||
+ (s->ps.sps->ctb_width == 2 &&
+ ctb_addr_ts % s->ps.sps->ctb_width == 0))) {
memcpy(s->cabac_state, s->HEVClc->cabac_state, HEVC_CONTEXTS);
}
}
@@ -553,40 +553,40 @@ static void cabac_init_state(HEVCContext *s)
void ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts)
{
- if (ctb_addr_ts == s->pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) {
+ if (ctb_addr_ts == s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) {
cabac_init_decoder(s);
if (s->sh.dependent_slice_segment_flag == 0 ||
- (s->pps->tiles_enabled_flag &&
- s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[ctb_addr_ts - 1]))
+ (s->ps.pps->tiles_enabled_flag &&
+ s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]))
cabac_init_state(s);
if (!s->sh.first_slice_in_pic_flag &&
- s->pps->entropy_coding_sync_enabled_flag) {
- if (ctb_addr_ts % s->sps->ctb_width == 0) {
- if (s->sps->ctb_width == 1)
+ s->ps.pps->entropy_coding_sync_enabled_flag) {
+ if (ctb_addr_ts % s->ps.sps->ctb_width == 0) {
+ if (s->ps.sps->ctb_width == 1)
cabac_init_state(s);
else if (s->sh.dependent_slice_segment_flag == 1)
load_states(s);
}
}
} else {
- if (s->pps->tiles_enabled_flag &&
- s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[ctb_addr_ts - 1]) {
+ if (s->ps.pps->tiles_enabled_flag &&
+ s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]) {
if (s->threads_number == 1)
cabac_reinit(s->HEVClc);
else
cabac_init_decoder(s);
cabac_init_state(s);
}
- if (s->pps->entropy_coding_sync_enabled_flag) {
- if (ctb_addr_ts % s->sps->ctb_width == 0) {
+ if (s->ps.pps->entropy_coding_sync_enabled_flag) {
+ if (ctb_addr_ts % s->ps.sps->ctb_width == 0) {
get_cabac_terminate(&s->HEVClc->cc);
if (s->threads_number == 1)
cabac_reinit(s->HEVClc);
else
cabac_init_decoder(s);
- if (s->sps->ctb_width == 1)
+ if (s->ps.sps->ctb_width == 1)
cabac_init_state(s);
else
load_states(s);
@@ -625,7 +625,7 @@ int ff_hevc_sao_band_position_decode(HEVCContext *s)
int ff_hevc_sao_offset_abs_decode(HEVCContext *s)
{
int i = 0;
- int length = (1 << (FFMIN(s->sps->bit_depth, 10) - 5)) - 1;
+ int length = (1 << (FFMIN(s->ps.sps->bit_depth, 10) - 5)) - 1;
while (i < length && get_cabac_bypass(&s->HEVClc->cc))
i++;
@@ -656,10 +656,10 @@ int ff_hevc_cu_transquant_bypass_flag_decode(HEVCContext *s)
int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0, int x_cb, int y_cb)
{
- int min_cb_width = s->sps->min_cb_width;
+ int min_cb_width = s->ps.sps->min_cb_width;
int inc = 0;
- int x0b = av_mod_uintp2(x0, s->sps->log2_ctb_size);
- int y0b = av_mod_uintp2(y0, s->sps->log2_ctb_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);
if (s->HEVClc->ctb_left_flag || x0b)
inc = !!SAMPLE_CTB(s->skip_flag, x_cb - 1, y_cb);
@@ -706,7 +706,7 @@ int ff_hevc_cu_chroma_qp_offset_flag(HEVCContext *s)
int ff_hevc_cu_chroma_qp_offset_idx(HEVCContext *s)
{
- int c_max= FFMAX(5, s->pps->chroma_qp_offset_list_len_minus1);
+ int c_max= FFMAX(5, s->ps.pps->chroma_qp_offset_list_len_minus1);
int i = 0;
while (i < c_max && GET_CABAC(elem_offset[CU_CHROMA_QP_OFFSET_IDX]))
@@ -723,15 +723,15 @@ int ff_hevc_pred_mode_decode(HEVCContext *s)
int ff_hevc_split_coding_unit_flag_decode(HEVCContext *s, int ct_depth, int x0, int y0)
{
int inc = 0, depth_left = 0, depth_top = 0;
- int x0b = av_mod_uintp2(x0, s->sps->log2_ctb_size);
- int y0b = av_mod_uintp2(y0, s->sps->log2_ctb_size);
- int x_cb = x0 >> s->sps->log2_min_cb_size;
- int y_cb = y0 >> s->sps->log2_min_cb_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 x_cb = x0 >> s->ps.sps->log2_min_cb_size;
+ int y_cb = y0 >> s->ps.sps->log2_min_cb_size;
if (s->HEVClc->ctb_left_flag || x0b)
- depth_left = s->tab_ct_depth[(y_cb) * s->sps->min_cb_width + x_cb - 1];
+ depth_left = s->tab_ct_depth[(y_cb) * s->ps.sps->min_cb_width + x_cb - 1];
if (s->HEVClc->ctb_up_flag || y0b)
- depth_top = s->tab_ct_depth[(y_cb - 1) * s->sps->min_cb_width + x_cb];
+ depth_top = s->tab_ct_depth[(y_cb - 1) * s->ps.sps->min_cb_width + x_cb];
inc += (depth_left > ct_depth);
inc += (depth_top > ct_depth);
@@ -743,7 +743,7 @@ int ff_hevc_part_mode_decode(HEVCContext *s, int log2_cb_size)
{
if (GET_CABAC(elem_offset[PART_MODE])) // 1
return PART_2Nx2N;
- if (log2_cb_size == s->sps->log2_min_cb_size) {
+ if (log2_cb_size == s->ps.sps->log2_min_cb_size) {
if (s->HEVClc->cu.pred_mode == MODE_INTRA) // 0
return PART_NxN;
if (GET_CABAC(elem_offset[PART_MODE] + 1)) // 01
@@ -755,7 +755,7 @@ int ff_hevc_part_mode_decode(HEVCContext *s, int log2_cb_size)
return PART_NxN; // 000
}
- if (!s->sps->amp_enabled_flag) {
+ if (!s->ps.sps->amp_enabled_flag) {
if (GET_CABAC(elem_offset[PART_MODE] + 1)) // 01
return PART_2NxN;
return PART_Nx2N;
@@ -1075,10 +1075,10 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
const uint8_t *scan_x_cg, *scan_y_cg, *scan_x_off, *scan_y_off;
ptrdiff_t stride = s->frame->linesize[c_idx];
- int hshift = s->sps->hshift[c_idx];
- int vshift = s->sps->vshift[c_idx];
+ int hshift = s->ps.sps->hshift[c_idx];
+ int vshift = s->ps.sps->vshift[c_idx];
uint8_t *dst = &s->frame->data[c_idx][(y0 >> vshift) * stride +
- ((x0 >> hshift) << s->sps->pixel_shift)];
+ ((x0 >> hshift) << s->ps.sps->pixel_shift)];
int16_t *coeffs = (int16_t*)(c_idx ? lc->edge_emu_buffer2 : lc->edge_emu_buffer);
uint8_t significant_coeff_group_flag[8][8] = {{0}};
int explicit_rdpcm_flag = 0;
@@ -1113,25 +1113,25 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
};
int qp_y = lc->qp_y;
- if (s->pps->transform_skip_enabled_flag &&
- log2_trafo_size <= s->pps->log2_max_transform_skip_block_size) {
+ if (s->ps.pps->transform_skip_enabled_flag &&
+ log2_trafo_size <= s->ps.pps->log2_max_transform_skip_block_size) {
transform_skip_flag = hevc_transform_skip_flag_decode(s, c_idx);
}
if (c_idx == 0) {
- qp = qp_y + s->sps->qp_bd_offset;
+ qp = qp_y + s->ps.sps->qp_bd_offset;
} else {
int qp_i, offset;
if (c_idx == 1)
- offset = s->pps->cb_qp_offset + s->sh.slice_cb_qp_offset +
+ offset = s->ps.pps->cb_qp_offset + s->sh.slice_cb_qp_offset +
lc->tu.cu_qp_offset_cb;
else
- offset = s->pps->cr_qp_offset + s->sh.slice_cr_qp_offset +
+ offset = s->ps.pps->cr_qp_offset + s->sh.slice_cr_qp_offset +
lc->tu.cu_qp_offset_cr;
- qp_i = av_clip(qp_y + offset, - s->sps->qp_bd_offset, 57);
- if (s->sps->chroma_format_idc == 1) {
+ qp_i = av_clip(qp_y + offset, - s->ps.sps->qp_bd_offset, 57);
+ if (s->ps.sps->chroma_format_idc == 1) {
if (qp_i < 30)
qp = qp_i;
else if (qp_i > 43)
@@ -1145,18 +1145,18 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
qp = qp_i;
}
- qp += s->sps->qp_bd_offset;
+ qp += s->ps.sps->qp_bd_offset;
}
- shift = s->sps->bit_depth + log2_trafo_size - 5;
+ shift = s->ps.sps->bit_depth + log2_trafo_size - 5;
add = 1 << (shift-1);
scale = level_scale[rem6[qp]] << (div6[qp]);
scale_m = 16; // default when no custom scaling lists.
dc_scale = 16;
- if (s->sps->scaling_list_enable_flag && !(transform_skip_flag && log2_trafo_size > 2)) {
- const ScalingList *sl = s->pps->scaling_list_data_present_flag ?
- &s->pps->scaling_list : &s->sps->scaling_list;
+ if (s->ps.sps->scaling_list_enable_flag && !(transform_skip_flag && log2_trafo_size > 2)) {
+ const ScalingList *sl = s->ps.pps->scaling_list_data_present_flag ?
+ &s->ps.pps->scaling_list : &s->ps.sps->scaling_list;
int matrix_id = lc->cu.pred_mode != MODE_INTRA;
matrix_id = 3 * matrix_id + c_idx;
@@ -1172,7 +1172,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
dc_scale = 0;
}
- if (lc->cu.pred_mode == MODE_INTER && s->sps->explicit_rdpcm_enabled_flag &&
+ if (lc->cu.pred_mode == MODE_INTER && s->ps.sps->explicit_rdpcm_enabled_flag &&
(transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) {
explicit_rdpcm_flag = explicit_rdpcm_flag_decode(s, c_idx);
if (explicit_rdpcm_flag) {
@@ -1303,7 +1303,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
};
const uint8_t *ctx_idx_map_p;
int scf_offset = 0;
- if (s->sps->transform_skip_context_enabled_flag &&
+ if (s->ps.sps->transform_skip_context_enabled_flag &&
(transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) {
ctx_idx_map_p = (uint8_t*) &ctx_idx_map[4 * 16];
if (c_idx == 0) {
@@ -1344,7 +1344,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
}
}
if (implicit_non_zero_coeff == 0) {
- if (s->sps->transform_skip_context_enabled_flag &&
+ if (s->ps.sps->transform_skip_context_enabled_flag &&
(transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) {
if (c_idx == 0) {
scf_offset = 42;
@@ -1389,7 +1389,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
// initialize first elem of coeff_bas_level_greater1_flag
int ctx_set = (i > 0 && c_idx == 0) ? 2 : 0;
- if (s->sps->persistent_rice_adaptation_enabled_flag) {
+ if (s->ps.sps->persistent_rice_adaptation_enabled_flag) {
if (!transform_skip_flag && !lc->cu.cu_transquant_bypass_flag)
sb_type = 2 * (c_idx == 0 ? 1 : 0);
else
@@ -1418,7 +1418,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
if (lc->cu.cu_transquant_bypass_flag ||
(lc->cu.pred_mode == MODE_INTRA &&
- s->sps->implicit_rdpcm_enabled_flag && transform_skip_flag &&
+ s->ps.sps->implicit_rdpcm_enabled_flag && transform_skip_flag &&
(pred_mode_intra == 10 || pred_mode_intra == 26 )) ||
explicit_rdpcm_flag)
sign_hidden = 0;
@@ -1428,7 +1428,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
if (first_greater1_coeff_idx != -1) {
coeff_abs_level_greater1_flag[first_greater1_coeff_idx] += coeff_abs_level_greater2_flag_decode(s, c_idx, ctx_set);
}
- if (!s->pps->sign_data_hiding_flag || !sign_hidden ) {
+ if (!s->ps.pps->sign_data_hiding_flag || !sign_hidden ) {
coeff_sign_flag = coeff_sign_flag_decode(s, nb_significant_coeff_flag) << (16 - nb_significant_coeff_flag);
} else {
coeff_sign_flag = coeff_sign_flag_decode(s, nb_significant_coeff_flag - 1) << (16 - (nb_significant_coeff_flag - 1));
@@ -1444,8 +1444,8 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
trans_coeff_level += last_coeff_abs_level_remaining;
if (trans_coeff_level > (3 << c_rice_param))
- c_rice_param = s->sps->persistent_rice_adaptation_enabled_flag ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4);
- if (s->sps->persistent_rice_adaptation_enabled_flag && !rice_init) {
+ c_rice_param = s->ps.sps->persistent_rice_adaptation_enabled_flag ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4);
+ if (s->ps.sps->persistent_rice_adaptation_enabled_flag && !rice_init) {
int c_rice_p_init = lc->stat_coeff[sb_type] / 4;
if (last_coeff_abs_level_remaining >= (3 << c_rice_p_init))
lc->stat_coeff[sb_type]++;
@@ -1460,8 +1460,8 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
trans_coeff_level = 1 + last_coeff_abs_level_remaining;
if (trans_coeff_level > (3 << c_rice_param))
- c_rice_param = s->sps->persistent_rice_adaptation_enabled_flag ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4);
- if (s->sps->persistent_rice_adaptation_enabled_flag && !rice_init) {
+ c_rice_param = s->ps.sps->persistent_rice_adaptation_enabled_flag ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4);
+ if (s->ps.sps->persistent_rice_adaptation_enabled_flag && !rice_init) {
int c_rice_p_init = lc->stat_coeff[sb_type] / 4;
if (last_coeff_abs_level_remaining >= (3 << c_rice_p_init))
lc->stat_coeff[sb_type]++;
@@ -1471,7 +1471,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
rice_init = 1;
}
}
- if (s->pps->sign_data_hiding_flag && sign_hidden) {
+ if (s->ps.pps->sign_data_hiding_flag && sign_hidden) {
sum_abs += trans_coeff_level;
if (n == first_nz_pos_in_cg && (sum_abs&1))
trans_coeff_level = -trans_coeff_level;
@@ -1480,7 +1480,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
trans_coeff_level = -trans_coeff_level;
coeff_sign_flag <<= 1;
if(!lc->cu.cu_transquant_bypass_flag) {
- if (s->sps->scaling_list_enable_flag && !(transform_skip_flag && log2_trafo_size > 2)) {
+ if (s->ps.sps->scaling_list_enable_flag && !(transform_skip_flag && log2_trafo_size > 2)) {
if(y_c || x_c || log2_trafo_size < 4) {
switch(log2_trafo_size) {
case 3: pos = (y_c << 3) + x_c; break;
@@ -1508,15 +1508,15 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
}
if (lc->cu.cu_transquant_bypass_flag) {
- if (explicit_rdpcm_flag || (s->sps->implicit_rdpcm_enabled_flag &&
+ if (explicit_rdpcm_flag || (s->ps.sps->implicit_rdpcm_enabled_flag &&
(pred_mode_intra == 10 || pred_mode_intra == 26))) {
- int mode = s->sps->implicit_rdpcm_enabled_flag ? (pred_mode_intra == 26) : explicit_rdpcm_dir_flag;
+ int mode = s->ps.sps->implicit_rdpcm_enabled_flag ? (pred_mode_intra == 26) : explicit_rdpcm_dir_flag;
s->hevcdsp.transform_rdpcm(coeffs, log2_trafo_size, mode);
}
} else {
if (transform_skip_flag) {
- int rot = s->sps->transform_skip_rotation_enabled_flag &&
+ int rot = s->ps.sps->transform_skip_rotation_enabled_flag &&
log2_trafo_size == 2 &&
lc->cu.pred_mode == MODE_INTRA;
if (rot) {
@@ -1526,7 +1526,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
s->hevcdsp.transform_skip(coeffs, log2_trafo_size);
- if (explicit_rdpcm_flag || (s->sps->implicit_rdpcm_enabled_flag &&
+ if (explicit_rdpcm_flag || (s->ps.sps->implicit_rdpcm_enabled_flag &&
lc->cu.pred_mode == MODE_INTRA &&
(pred_mode_intra == 10 || pred_mode_intra == 26))) {
int mode = explicit_rdpcm_flag ? explicit_rdpcm_dir_flag : (pred_mode_intra == 26);
diff --git a/libavcodec/hevc_filter.c b/libavcodec/hevc_filter.c
index f50a640eab..45cb823d6e 100644
--- a/libavcodec/hevc_filter.c
+++ b/libavcodec/hevc_filter.c
@@ -56,12 +56,12 @@ static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset)
// slice qp offset is not used for deblocking
if (c_idx == 1)
- offset = s->pps->cb_qp_offset;
+ offset = s->ps.pps->cb_qp_offset;
else
- offset = s->pps->cr_qp_offset;
+ offset = s->ps.pps->cr_qp_offset;
qp_i = av_clip(qp_y + offset, 0, 57);
- if (s->sps->chroma_format_idc == 1) {
+ if (s->ps.sps->chroma_format_idc == 1) {
if (qp_i < 30)
qp = qp_i;
else if (qp_i > 43)
@@ -79,14 +79,14 @@ static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset)
static int get_qPy_pred(HEVCContext *s, int xBase, int yBase, int log2_cb_size)
{
HEVCLocalContext *lc = s->HEVClc;
- int ctb_size_mask = (1 << s->sps->log2_ctb_size) - 1;
- int MinCuQpDeltaSizeMask = (1 << (s->sps->log2_ctb_size -
- s->pps->diff_cu_qp_delta_depth)) - 1;
+ int ctb_size_mask = (1 << s->ps.sps->log2_ctb_size) - 1;
+ int MinCuQpDeltaSizeMask = (1 << (s->ps.sps->log2_ctb_size -
+ s->ps.pps->diff_cu_qp_delta_depth)) - 1;
int xQgBase = xBase - (xBase & MinCuQpDeltaSizeMask);
int yQgBase = yBase - (yBase & MinCuQpDeltaSizeMask);
- int min_cb_width = s->sps->min_cb_width;
- int x_cb = xQgBase >> s->sps->log2_min_cb_size;
- int y_cb = yQgBase >> s->sps->log2_min_cb_size;
+ int min_cb_width = s->ps.sps->min_cb_width;
+ int x_cb = xQgBase >> s->ps.sps->log2_min_cb_size;
+ int y_cb = yQgBase >> s->ps.sps->log2_min_cb_size;
int availableA = (xBase & ctb_size_mask) &&
(xQgBase & ctb_size_mask);
int availableB = (yBase & ctb_size_mask) &&
@@ -113,8 +113,8 @@ static int get_qPy_pred(HEVCContext *s, int xBase, int yBase, int log2_cb_size)
else
qPy_b = s->qp_y_tab[x_cb + (y_cb - 1) * min_cb_width];
- av_assert2(qPy_a >= -s->sps->qp_bd_offset && qPy_a < 52);
- av_assert2(qPy_b >= -s->sps->qp_bd_offset && qPy_b < 52);
+ av_assert2(qPy_a >= -s->ps.sps->qp_bd_offset && qPy_a < 52);
+ av_assert2(qPy_b >= -s->ps.sps->qp_bd_offset && qPy_b < 52);
return (qPy_a + qPy_b + 1) >> 1;
}
@@ -124,7 +124,7 @@ void ff_hevc_set_qPy(HEVCContext *s, int xBase, int yBase, int log2_cb_size)
int qp_y = get_qPy_pred(s, xBase, yBase, log2_cb_size);
if (s->HEVClc->tu.cu_qp_delta != 0) {
- int off = s->sps->qp_bd_offset;
+ int off = s->ps.sps->qp_bd_offset;
s->HEVClc->qp_y = FFUMOD(qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off,
52 + off) - off;
} else
@@ -133,10 +133,10 @@ void ff_hevc_set_qPy(HEVCContext *s, int xBase, int yBase, int log2_cb_size)
static int get_qPy(HEVCContext *s, int xC, int yC)
{
- int log2_min_cb_size = s->sps->log2_min_cb_size;
+ int log2_min_cb_size = s->ps.sps->log2_min_cb_size;
int x = xC >> log2_min_cb_size;
int y = yC >> log2_min_cb_size;
- return s->qp_y_tab[x + y * s->sps->min_cb_width];
+ return s->qp_y_tab[x + y * s->ps.sps->min_cb_width];
}
static void copy_CTB(uint8_t *dst, const uint8_t *src, int width, int height,
@@ -193,9 +193,9 @@ static void copy_CTB_to_hv(HEVCContext *s, const uint8_t *src,
int stride_src, int x, int y, int width, int height,
int c_idx, int x_ctb, int y_ctb)
{
- int sh = s->sps->pixel_shift;
- int w = s->sps->width >> s->sps->hshift[c_idx];
- int h = s->sps->height >> s->sps->vshift[c_idx];
+ int sh = s->ps.sps->pixel_shift;
+ int w = s->ps.sps->width >> s->ps.sps->hshift[c_idx];
+ int h = s->ps.sps->height >> s->ps.sps->vshift[c_idx];
/* copy horizontal edges */
memcpy(s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb) * w + x) << sh),
@@ -214,23 +214,23 @@ static void restore_tqb_pixels(HEVCContext *s,
ptrdiff_t stride_src, ptrdiff_t stride_dst,
int x0, int y0, int width, int height, int c_idx)
{
- if ( s->pps->transquant_bypass_enable_flag ||
- (s->sps->pcm.loop_filter_disable_flag && s->sps->pcm_enabled_flag)) {
+ if ( s->ps.pps->transquant_bypass_enable_flag ||
+ (s->ps.sps->pcm.loop_filter_disable_flag && s->ps.sps->pcm_enabled_flag)) {
int x, y;
- int min_pu_size = 1 << s->sps->log2_min_pu_size;
- int hshift = s->sps->hshift[c_idx];
- int vshift = s->sps->vshift[c_idx];
- int x_min = ((x0 ) >> s->sps->log2_min_pu_size);
- int y_min = ((y0 ) >> s->sps->log2_min_pu_size);
- int x_max = ((x0 + width ) >> s->sps->log2_min_pu_size);
- int y_max = ((y0 + height) >> s->sps->log2_min_pu_size);
- int len = (min_pu_size >> hshift) << s->sps->pixel_shift;
+ int min_pu_size = 1 << s->ps.sps->log2_min_pu_size;
+ int hshift = s->ps.sps->hshift[c_idx];
+ int vshift = s->ps.sps->vshift[c_idx];
+ int x_min = ((x0 ) >> s->ps.sps->log2_min_pu_size);
+ int y_min = ((y0 ) >> s->ps.sps->log2_min_pu_size);
+ int x_max = ((x0 + width ) >> s->ps.sps->log2_min_pu_size);
+ int y_max = ((y0 + height) >> s->ps.sps->log2_min_pu_size);
+ int len = (min_pu_size >> hshift) << s->ps.sps->pixel_shift;
for (y = y_min; y < y_max; y++) {
for (x = x_min; x < x_max; x++) {
- if (s->is_pcm[y * s->sps->min_pu_width + x]) {
+ if (s->is_pcm[y * s->ps.sps->min_pu_width + x]) {
int n;
- uint8_t *src = src1 + (((y << s->sps->log2_min_pu_size) - y0) >> vshift) * stride_src + ((((x << s->sps->log2_min_pu_size) - x0) >> hshift) << s->sps->pixel_shift);
- const uint8_t *dst = dst1 + (((y << s->sps->log2_min_pu_size) - y0) >> vshift) * stride_dst + ((((x << s->sps->log2_min_pu_size) - x0) >> hshift) << s->sps->pixel_shift);
+ uint8_t *src = src1 + (((y << s->ps.sps->log2_min_pu_size) - y0) >> vshift) * stride_src + ((((x << s->ps.sps->log2_min_pu_size) - x0) >> hshift) << s->ps.sps->pixel_shift);
+ const uint8_t *dst = dst1 + (((y << s->ps.sps->log2_min_pu_size) - y0) >> vshift) * stride_dst + ((((x << s->ps.sps->log2_min_pu_size) - x0) >> hshift) << s->ps.sps->pixel_shift);
for (n = 0; n < (min_pu_size >> vshift); n++) {
memcpy(src, dst, len);
src += stride_src;
@@ -242,7 +242,7 @@ static void restore_tqb_pixels(HEVCContext *s,
}
}
-#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)])
static void sao_filter_CTB(HEVCContext *s, int x, int y)
{
@@ -250,18 +250,18 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y)
HEVCLocalContext *lc = s->HEVClc;
int c_idx;
int edges[4]; // 0 left 1 top 2 right 3 bottom
- int x_ctb = x >> s->sps->log2_ctb_size;
- int y_ctb = y >> s->sps->log2_ctb_size;
- int ctb_addr_rs = y_ctb * s->sps->ctb_width + x_ctb;
- int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[ctb_addr_rs];
+ int x_ctb = x >> s->ps.sps->log2_ctb_size;
+ int y_ctb = y >> s->ps.sps->log2_ctb_size;
+ int ctb_addr_rs = y_ctb * s->ps.sps->ctb_width + x_ctb;
+ int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs];
SAOParams *sao = &CTB(s->sao, x_ctb, y_ctb);
// flags indicating unfilterable edges
uint8_t vert_edge[] = { 0, 0 };
uint8_t horiz_edge[] = { 0, 0 };
uint8_t diag_edge[] = { 0, 0, 0, 0 };
uint8_t lfase = CTB(s->filter_slice_edges, x_ctb, y_ctb);
- uint8_t no_tile_filter = s->pps->tiles_enabled_flag &&
- !s->pps->loop_filter_across_tiles_enabled_flag;
+ uint8_t no_tile_filter = s->ps.pps->tiles_enabled_flag &&
+ !s->ps.pps->loop_filter_across_tiles_enabled_flag;
uint8_t restore = no_tile_filter || !lfase;
uint8_t left_tile_edge = 0;
uint8_t right_tile_edge = 0;
@@ -270,24 +270,24 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y)
edges[0] = x_ctb == 0;
edges[1] = y_ctb == 0;
- edges[2] = x_ctb == s->sps->ctb_width - 1;
- edges[3] = y_ctb == s->sps->ctb_height - 1;
+ edges[2] = x_ctb == s->ps.sps->ctb_width - 1;
+ edges[3] = y_ctb == s->ps.sps->ctb_height - 1;
if (restore) {
if (!edges[0]) {
- left_tile_edge = no_tile_filter && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs-1]];
+ left_tile_edge = no_tile_filter && 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]];
vert_edge[0] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb - 1, y_ctb)) || left_tile_edge;
}
if (!edges[2]) {
- right_tile_edge = no_tile_filter && s->pps->tile_id[ctb_addr_ts] != s->pps->tile_id[s->pps->ctb_addr_rs_to_ts[ctb_addr_rs+1]];
+ right_tile_edge = no_tile_filter && 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]];
vert_edge[1] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb + 1, y_ctb)) || right_tile_edge;
}
if (!edges[1]) {
- up_tile_edge = no_tile_filter && 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]];
+ up_tile_edge = no_tile_filter && 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]];
horiz_edge[0] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb, y_ctb - 1)) || up_tile_edge;
}
if (!edges[3]) {
- bottom_tile_edge = no_tile_filter && 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]];
+ bottom_tile_edge = no_tile_filter && 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]];
horiz_edge[1] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb, y_ctb + 1)) || bottom_tile_edge;
}
if (!edges[0] && !edges[1]) {
@@ -304,16 +304,16 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y)
}
}
- for (c_idx = 0; c_idx < (s->sps->chroma_format_idc ? 3 : 1); c_idx++) {
- int x0 = x >> s->sps->hshift[c_idx];
- int y0 = y >> s->sps->vshift[c_idx];
+ for (c_idx = 0; c_idx < (s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) {
+ int x0 = x >> s->ps.sps->hshift[c_idx];
+ int y0 = y >> s->ps.sps->vshift[c_idx];
int stride_src = s->frame->linesize[c_idx];
- int ctb_size_h = (1 << (s->sps->log2_ctb_size)) >> s->sps->hshift[c_idx];
- int ctb_size_v = (1 << (s->sps->log2_ctb_size)) >> s->sps->vshift[c_idx];
- int width = FFMIN(ctb_size_h, (s->sps->width >> s->sps->hshift[c_idx]) - x0);
- int height = FFMIN(ctb_size_v, (s->sps->height >> s->sps->vshift[c_idx]) - y0);
+ int ctb_size_h = (1 << (s->ps.sps->log2_ctb_size)) >> s->ps.sps->hshift[c_idx];
+ int ctb_size_v = (1 << (s->ps.sps->log2_ctb_size)) >> s->ps.sps->vshift[c_idx];
+ int width = FFMIN(ctb_size_h, (s->ps.sps->width >> s->ps.sps->hshift[c_idx]) - x0);
+ int height = FFMIN(ctb_size_v, (s->ps.sps->height >> s->ps.sps->vshift[c_idx]) - y0);
int tab = sao_tab[(FFALIGN(width, 8) >> 3) - 1];
- uint8_t *src = &s->frame->data[c_idx][y0 * stride_src + (x0 << s->sps->pixel_shift)];
+ uint8_t *src = &s->frame->data[c_idx][y0 * stride_src + (x0 << s->ps.sps->pixel_shift)];
int stride_dst;
uint8_t *dst;
@@ -321,11 +321,11 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y)
case SAO_BAND:
copy_CTB_to_hv(s, src, stride_src, x0, y0, width, height, c_idx,
x_ctb, y_ctb);
- if (s->pps->transquant_bypass_enable_flag ||
- (s->sps->pcm.loop_filter_disable_flag && s->sps->pcm_enabled_flag)) {
+ if (s->ps.pps->transquant_bypass_enable_flag ||
+ (s->ps.sps->pcm.loop_filter_disable_flag && s->ps.sps->pcm_enabled_flag)) {
dst = lc->edge_emu_buffer;
stride_dst = 2*MAX_PB_SIZE;
- copy_CTB(dst, src, width << s->sps->pixel_shift, height, stride_dst, stride_src);
+ copy_CTB(dst, src, width << s->ps.sps->pixel_shift, height, stride_dst, stride_src);
s->hevcdsp.sao_band_filter[tab](src, dst, stride_src, stride_dst,
sao->offset_val[c_idx], sao->band_position[c_idx],
width, height);
@@ -340,13 +340,13 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y)
break;
case SAO_EDGE:
{
- int w = s->sps->width >> s->sps->hshift[c_idx];
- int h = s->sps->height >> s->sps->vshift[c_idx];
+ int w = s->ps.sps->width >> s->ps.sps->hshift[c_idx];
+ int h = s->ps.sps->height >> s->ps.sps->vshift[c_idx];
int left_edge = edges[0];
int top_edge = edges[1];
int right_edge = edges[2];
int bottom_edge = edges[3];
- int sh = s->sps->pixel_shift;
+ int sh = s->ps.sps->pixel_shift;
int left_pixels, right_pixels;
stride_dst = 2*MAX_PB_SIZE + FF_INPUT_BUFFER_PADDING_SIZE;
@@ -455,7 +455,7 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y)
static int get_pcm(HEVCContext *s, int x, int y)
{
- int log2_min_pu_size = s->sps->log2_min_pu_size;
+ int log2_min_pu_size = s->ps.sps->log2_min_pu_size;
int x_pu, y_pu;
if (x < 0 || y < 0)
@@ -464,9 +464,9 @@ static int get_pcm(HEVCContext *s, int x, int y)
x_pu = x >> log2_min_pu_size;
y_pu = y >> log2_min_pu_size;
- if (x_pu >= s->sps->min_pu_width || y_pu >= s->sps->min_pu_height)
+ if (x_pu >= s->ps.sps->min_pu_width || y_pu >= s->ps.sps->min_pu_height)
return 2;
- return s->is_pcm[y_pu * s->sps->min_pu_width + x_pu];
+ return s->is_pcm[y_pu * s->ps.sps->min_pu_width + x_pu];
}
#define TC_CALC(qp, bs) \
@@ -483,18 +483,18 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
uint8_t no_p[2] = { 0 };
uint8_t no_q[2] = { 0 };
- int log2_ctb_size = s->sps->log2_ctb_size;
+ int log2_ctb_size = s->ps.sps->log2_ctb_size;
int x_end, x_end2, y_end;
int ctb_size = 1 << log2_ctb_size;
int ctb = (x0 >> log2_ctb_size) +
- (y0 >> log2_ctb_size) * s->sps->ctb_width;
+ (y0 >> log2_ctb_size) * s->ps.sps->ctb_width;
int cur_tc_offset = s->deblock[ctb].tc_offset;
int cur_beta_offset = s->deblock[ctb].beta_offset;
int left_tc_offset, left_beta_offset;
int tc_offset, beta_offset;
- int pcmf = (s->sps->pcm_enabled_flag &&
- s->sps->pcm.loop_filter_disable_flag) ||
- s->pps->transquant_bypass_enable_flag;
+ int pcmf = (s->ps.sps->pcm_enabled_flag &&
+ s->ps.sps->pcm.loop_filter_disable_flag) ||
+ s->ps.pps->transquant_bypass_enable_flag;
if (x0) {
left_tc_offset = s->deblock[ctb - 1].tc_offset;
@@ -505,17 +505,17 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
}
x_end = x0 + ctb_size;
- if (x_end > s->sps->width)
- x_end = s->sps->width;
+ if (x_end > s->ps.sps->width)
+ x_end = s->ps.sps->width;
y_end = y0 + ctb_size;
- if (y_end > s->sps->height)
- y_end = s->sps->height;
+ if (y_end > s->ps.sps->height)
+ y_end = s->ps.sps->height;
tc_offset = cur_tc_offset;
beta_offset = cur_beta_offset;
x_end2 = x_end;
- if (x_end2 != s->sps->width)
+ if (x_end2 != s->ps.sps->width)
x_end2 -= 8;
for (y = y0; y < y_end; y += 8) {
// vertical filtering luma
@@ -529,7 +529,7 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
tc[0] = bs0 ? TC_CALC(qp, bs0) : 0;
tc[1] = bs1 ? TC_CALC(qp, bs1) : 0;
- src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)];
+ src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->ps.sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(s, x - 1, y);
no_p[1] = get_pcm(s, x - 1, y + 4);
@@ -561,7 +561,7 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)];
tc[0] = bs0 ? TC_CALC(qp, bs0) : 0;
tc[1] = bs1 ? TC_CALC(qp, bs1) : 0;
- src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)];
+ src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->ps.sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(s, x, y - 1);
no_p[1] = get_pcm(s, x + 4, y - 1);
@@ -578,10 +578,10 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
}
}
- if (s->sps->chroma_format_idc) {
+ if (s->ps.sps->chroma_format_idc) {
for (chroma = 1; chroma <= 2; chroma++) {
- int h = 1 << s->sps->hshift[chroma];
- int v = 1 << s->sps->vshift[chroma];
+ int h = 1 << s->ps.sps->hshift[chroma];
+ int v = 1 << s->ps.sps->vshift[chroma];
// vertical filtering chroma
for (y = y0; y < y_end; y += (8 * v)) {
@@ -595,7 +595,7 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
c_tc[0] = (bs0 == 2) ? chroma_tc(s, qp0, chroma, tc_offset) : 0;
c_tc[1] = (bs1 == 2) ? chroma_tc(s, qp1, chroma, tc_offset) : 0;
- src = &s->frame->data[chroma][(y >> s->sps->vshift[chroma]) * s->frame->linesize[chroma] + ((x >> s->sps->hshift[chroma]) << s->sps->pixel_shift)];
+ src = &s->frame->data[chroma][(y >> s->ps.sps->vshift[chroma]) * s->frame->linesize[chroma] + ((x >> s->ps.sps->hshift[chroma]) << s->ps.sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(s, x - 1, y);
no_p[1] = get_pcm(s, x - 1, y + (4 * v));
@@ -617,7 +617,7 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
// horizontal filtering chroma
tc_offset = x0 ? left_tc_offset : cur_tc_offset;
x_end2 = x_end;
- if (x_end != s->sps->width)
+ if (x_end != s->ps.sps->width)
x_end2 = x_end - 8 * h;
for (x = x0 ? x0 - 8 * h : 0; x < x_end2; x += (8 * h)) {
const int bs0 = s->horizontal_bs[( x + y * s->bs_width) >> 2];
@@ -628,7 +628,7 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
c_tc[0] = bs0 == 2 ? chroma_tc(s, qp0, chroma, tc_offset) : 0;
c_tc[1] = bs1 == 2 ? chroma_tc(s, qp1, chroma, cur_tc_offset) : 0;
- src = &s->frame->data[chroma][(y >> s->sps->vshift[1]) * s->frame->linesize[chroma] + ((x >> s->sps->hshift[1]) << s->sps->pixel_shift)];
+ src = &s->frame->data[chroma][(y >> s->ps.sps->vshift[1]) * s->frame->linesize[chroma] + ((x >> s->ps.sps->hshift[1]) << s->ps.sps->pixel_shift)];
if (pcmf) {
no_p[0] = get_pcm(s, x, y - 1);
no_p[1] = get_pcm(s, x + (4 * h), y - 1);
@@ -717,10 +717,10 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
{
HEVCLocalContext *lc = s->HEVClc;
MvField *tab_mvf = s->ref->tab_mvf;
- int log2_min_pu_size = s->sps->log2_min_pu_size;
- int log2_min_tu_size = s->sps->log2_min_tb_size;
- int min_pu_width = s->sps->min_pu_width;
- int min_tu_width = s->sps->min_tb_width;
+ int log2_min_pu_size = s->ps.sps->log2_min_pu_size;
+ int log2_min_tu_size = s->ps.sps->log2_min_tb_size;
+ int min_pu_width = s->ps.sps->min_pu_width;
+ int min_tu_width = s->ps.sps->min_tb_width;
int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width +
(x0 >> log2_min_pu_size)].pred_flag == PF_INTRA;
int boundary_upper, boundary_left;
@@ -730,10 +730,10 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
if (boundary_upper &&
((!s->sh.slice_loop_filter_across_slices_enabled_flag &&
lc->boundary_flags & BOUNDARY_UPPER_SLICE &&
- (y0 % (1 << s->sps->log2_ctb_size)) == 0) ||
- (!s->pps->loop_filter_across_tiles_enabled_flag &&
+ (y0 % (1 << s->ps.sps->log2_ctb_size)) == 0) ||
+ (!s->ps.pps->loop_filter_across_tiles_enabled_flag &&
lc->boundary_flags & BOUNDARY_UPPER_TILE &&
- (y0 % (1 << s->sps->log2_ctb_size)) == 0)))
+ (y0 % (1 << s->ps.sps->log2_ctb_size)) == 0)))
boundary_upper = 0;
if (boundary_upper) {
@@ -768,10 +768,10 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
if (boundary_left &&
((!s->sh.slice_loop_filter_across_slices_enabled_flag &&
lc->boundary_flags & BOUNDARY_LEFT_SLICE &&
- (x0 % (1 << s->sps->log2_ctb_size)) == 0) ||
- (!s->pps->loop_filter_across_tiles_enabled_flag &&
+ (x0 % (1 << s->ps.sps->log2_ctb_size)) == 0) ||
+ (!s->ps.pps->loop_filter_across_tiles_enabled_flag &&
lc->boundary_flags & BOUNDARY_LEFT_TILE &&
- (x0 % (1 << s->sps->log2_ctb_size)) == 0)))
+ (x0 % (1 << s->ps.sps->log2_ctb_size)) == 0)))
boundary_left = 0;
if (boundary_left) {
@@ -842,10 +842,10 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size)
{
- int x_end = x >= s->sps->width - ctb_size;
+ int x_end = x >= s->ps.sps->width - ctb_size;
deblocking_filter_CTB(s, x, y);
- if (s->sps->sao_enabled) {
- int y_end = y >= s->sps->height - ctb_size;
+ if (s->ps.sps->sao_enabled) {
+ int y_end = y >= s->ps.sps->height - ctb_size;
if (y && x)
sao_filter_CTB(s, x - ctb_size, y - ctb_size);
if (x && y_end)
@@ -866,8 +866,8 @@ void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size)
void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size)
{
- int x_end = x_ctb >= s->sps->width - ctb_size;
- int y_end = y_ctb >= s->sps->height - ctb_size;
+ int x_end = x_ctb >= s->ps.sps->width - ctb_size;
+ int y_end = y_ctb >= s->ps.sps->height - ctb_size;
if (y_ctb && x_ctb)
ff_hevc_hls_filter(s, x_ctb - ctb_size, y_ctb - ctb_size, ctb_size);
if (y_ctb && x_end)
diff --git a/libavcodec/hevc_mvs.c b/libavcodec/hevc_mvs.c
index e504257c47..00da575aad 100644
--- a/libavcodec/hevc_mvs.c
+++ b/libavcodec/hevc_mvs.c
@@ -42,14 +42,14 @@ void ff_hevc_set_neighbour_available(HEVCContext *s, int x0, int y0,
int nPbW, int nPbH)
{
HEVCLocalContext *lc = s->HEVClc;
- int x0b = av_mod_uintp2(x0, s->sps->log2_ctb_size);
- int y0b = av_mod_uintp2(y0, s->sps->log2_ctb_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);
lc->na.cand_up = (lc->ctb_up_flag || y0b);
lc->na.cand_left = (lc->ctb_left_flag || x0b);
lc->na.cand_up_left = (!x0b && !y0b) ? lc->ctb_up_left_flag : lc->na.cand_left && lc->na.cand_up;
lc->na.cand_up_right_sap =
- ((x0b + nPbW) == (1 << s->sps->log2_ctb_size)) ?
+ ((x0b + nPbW) == (1 << s->ps.sps->log2_ctb_size)) ?
lc->ctb_up_right_flag && !y0b : lc->na.cand_up;
lc->na.cand_up_right =
lc->na.cand_up_right_sap
@@ -64,19 +64,19 @@ static av_always_inline int z_scan_block_avail(HEVCContext *s, int xCurr, int yC
int xN, int yN)
{
#define MIN_TB_ADDR_ZS(x, y) \
- s->pps->min_tb_addr_zs[(y) * (s->sps->tb_mask+2) + (x)]
+ s->ps.pps->min_tb_addr_zs[(y) * (s->ps.sps->tb_mask+2) + (x)]
- int xCurr_ctb = xCurr >> s->sps->log2_ctb_size;
- int yCurr_ctb = yCurr >> s->sps->log2_ctb_size;
- int xN_ctb = xN >> s->sps->log2_ctb_size;
- int yN_ctb = yN >> s->sps->log2_ctb_size;
+ int xCurr_ctb = xCurr >> s->ps.sps->log2_ctb_size;
+ int yCurr_ctb = yCurr >> s->ps.sps->log2_ctb_size;
+ int xN_ctb = xN >> s->ps.sps->log2_ctb_size;
+ int yN_ctb = yN >> s->ps.sps->log2_ctb_size;
if( yN_ctb < yCurr_ctb || xN_ctb < xCurr_ctb )
return 1;
else {
- int Curr = MIN_TB_ADDR_ZS((xCurr >> s->sps->log2_min_tb_size) & s->sps->tb_mask,
- (yCurr >> s->sps->log2_min_tb_size) & s->sps->tb_mask);
- int N = MIN_TB_ADDR_ZS((xN >> s->sps->log2_min_tb_size) & s->sps->tb_mask,
- (yN >> s->sps->log2_min_tb_size) & s->sps->tb_mask);
+ int Curr = MIN_TB_ADDR_ZS((xCurr >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask,
+ (yCurr >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask);
+ int N = MIN_TB_ADDR_ZS((xN >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask,
+ (yN >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask);
return N <= Curr;
}
}
@@ -84,7 +84,7 @@ static av_always_inline int z_scan_block_avail(HEVCContext *s, int xCurr, int yC
//check if the two luma locations belong to the same mostion estimation region
static av_always_inline int is_diff_mer(HEVCContext *s, int xN, int yN, int xP, int yP)
{
- uint8_t plevel = s->pps->log2_parallel_merge_level;
+ uint8_t plevel = s->ps.pps->log2_parallel_merge_level;
return xN >> plevel == xP >> plevel &&
yN >> plevel == yP >> plevel;
@@ -203,8 +203,8 @@ static int derive_temporal_colocated_mvs(HEVCContext *s, MvField temp_col,
tab_mvf[(y) * min_pu_width + x]
#define TAB_MVF_PU(v) \
- TAB_MVF(((x ## v) >> s->sps->log2_min_pu_size), \
- ((y ## v) >> s->sps->log2_min_pu_size))
+ TAB_MVF(((x ## v) >> s->ps.sps->log2_min_pu_size), \
+ ((y ## v) >> s->ps.sps->log2_min_pu_size))
#define DERIVE_TEMPORAL_COLOCATED_MVS \
derive_temporal_colocated_mvs(s, temp_col, \
@@ -221,7 +221,7 @@ static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0,
MvField *tab_mvf;
MvField temp_col;
int x, y, x_pu, y_pu;
- int min_pu_width = s->sps->min_pu_width;
+ int min_pu_width = s->ps.sps->min_pu_width;
int availableFlagLXCol = 0;
int colPic;
@@ -240,15 +240,15 @@ static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0,
y = y0 + nPbH;
if (tab_mvf &&
- (y0 >> s->sps->log2_ctb_size) == (y >> s->sps->log2_ctb_size) &&
- y < s->sps->height &&
- x < s->sps->width) {
+ (y0 >> s->ps.sps->log2_ctb_size) == (y >> s->ps.sps->log2_ctb_size) &&
+ y < s->ps.sps->height &&
+ x < s->ps.sps->width) {
x &= ~15;
y &= ~15;
if (s->threads_type == FF_THREAD_FRAME)
ff_thread_await_progress(&ref->tf, y, 0);
- x_pu = x >> s->sps->log2_min_pu_size;
- y_pu = y >> s->sps->log2_min_pu_size;
+ x_pu = x >> s->ps.sps->log2_min_pu_size;
+ y_pu = y >> s->ps.sps->log2_min_pu_size;
temp_col = TAB_MVF(x_pu, y_pu);
availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS;
}
@@ -261,8 +261,8 @@ static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0,
y &= ~15;
if (s->threads_type == FF_THREAD_FRAME)
ff_thread_await_progress(&ref->tf, y, 0);
- x_pu = x >> s->sps->log2_min_pu_size;
- y_pu = y >> s->sps->log2_min_pu_size;
+ x_pu = x >> s->ps.sps->log2_min_pu_size;
+ y_pu = y >> s->ps.sps->log2_min_pu_size;
temp_col = TAB_MVF(x_pu, y_pu);
availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS;
}
@@ -292,7 +292,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
RefPicList *refPicList = s->ref->refPicList;
MvField *tab_mvf = s->ref->tab_mvf;
- const int min_pu_width = s->sps->min_pu_width;
+ const int min_pu_width = s->ps.sps->min_pu_width;
const int cand_bottom_left = lc->na.cand_bottom_left;
const int cand_left = lc->na.cand_left;
@@ -365,7 +365,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
// above right spatial merge candidate
is_available_b0 = AVAILABLE(cand_up_right, B0) &&
- xB0 < s->sps->width &&
+ xB0 < s->ps.sps->width &&
PRED_BLOCK_AVAILABLE(B0) &&
!is_diff_mer(s, xB0, yB0, x0, y0);
@@ -379,7 +379,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
// left bottom spatial merge candidate
is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
- yA0 < s->sps->height &&
+ yA0 < s->ps.sps->height &&
PRED_BLOCK_AVAILABLE(A0) &&
!is_diff_mer(s, xA0, yA0, x0, y0);
@@ -486,7 +486,7 @@ void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0, int nPbW,
int nPbH2 = nPbH;
HEVCLocalContext *lc = s->HEVClc;
- if (s->pps->log2_parallel_merge_level > 2 && nCS == 8) {
+ if (s->ps.pps->log2_parallel_merge_level > 2 && nCS == 8) {
singleMCLFlag = 1;
x0 = lc->cu.x;
y0 = lc->cu.y;
@@ -529,7 +529,7 @@ static int mv_mp_mode_mx(HEVCContext *s, int x, int y, int pred_flag_index,
Mv *mv, int ref_idx_curr, int ref_idx)
{
MvField *tab_mvf = s->ref->tab_mvf;
- int min_pu_width = s->sps->min_pu_width;
+ int min_pu_width = s->ps.sps->min_pu_width;
RefPicList *refPicList = s->ref->refPicList;
@@ -545,7 +545,7 @@ static int mv_mp_mode_mx_lt(HEVCContext *s, int x, int y, int pred_flag_index,
Mv *mv, int ref_idx_curr, int ref_idx)
{
MvField *tab_mvf = s->ref->tab_mvf;
- int min_pu_width = s->sps->min_pu_width;
+ int min_pu_width = s->ps.sps->min_pu_width;
RefPicList *refPicList = s->ref->refPicList;
@@ -568,14 +568,14 @@ static int mv_mp_mode_mx_lt(HEVCContext *s, int x, int y, int pred_flag_index,
#define MP_MX(v, pred, mx) \
mv_mp_mode_mx(s, \
- (x ## v) >> s->sps->log2_min_pu_size, \
- (y ## v) >> s->sps->log2_min_pu_size, \
+ (x ## v) >> s->ps.sps->log2_min_pu_size, \
+ (y ## v) >> s->ps.sps->log2_min_pu_size, \
pred, &mx, ref_idx_curr, ref_idx)
#define MP_MX_LT(v, pred, mx) \
mv_mp_mode_mx_lt(s, \
- (x ## v) >> s->sps->log2_min_pu_size, \
- (y ## v) >> s->sps->log2_min_pu_size, \
+ (x ## v) >> s->ps.sps->log2_min_pu_size, \
+ (y ## v) >> s->ps.sps->log2_min_pu_size, \
pred, &mx, ref_idx_curr, ref_idx)
void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
@@ -589,7 +589,7 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
int availableFlagLXA0 = 1;
int availableFlagLXB0 = 1;
int numMVPCandLX = 0;
- int min_pu_width = s->sps->min_pu_width;
+ int min_pu_width = s->ps.sps->min_pu_width;
int xA0, yA0;
int is_available_a0;
@@ -625,7 +625,7 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
yA0 = y0 + nPbH;
is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
- yA0 < s->sps->height &&
+ yA0 < s->ps.sps->height &&
PRED_BLOCK_AVAILABLE(A0);
//left spatial merge candidate
@@ -680,7 +680,7 @@ b_candidates:
yB0 = y0 - 1;
is_available_b0 = AVAILABLE(cand_up_right, B0) &&
- xB0 < s->sps->width &&
+ xB0 < s->ps.sps->width &&
PRED_BLOCK_AVAILABLE(B0);
// above spatial merge candidate
diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 31452f2055..d27af31cac 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -90,6 +90,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx
HEVCContext *h = &((HEVCParseContext *)s->priv_data)->h;
GetBitContext *gb = &h->HEVClc->gb;
SliceHeader *sh = &h->sh;
+ HEVCParamSets *ps = &h->ps;
const uint8_t *buf_end = buf + buf_size;
int state = -1, i;
HEVCNAL *nal;
@@ -137,13 +138,13 @@ static inline int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx
init_get_bits8(gb, nal->data + 2, nal->size);
switch (h->nal_unit_type) {
case NAL_VPS:
- ff_hevc_decode_nal_vps(h);
+ ff_hevc_decode_nal_vps(gb, avctx, ps);
break;
case NAL_SPS:
- ff_hevc_decode_nal_sps(h);
+ ff_hevc_decode_nal_sps(gb, avctx, ps, h->apply_defdispwin);
break;
case NAL_PPS:
- ff_hevc_decode_nal_pps(h);
+ ff_hevc_decode_nal_pps(gb, avctx, ps);
break;
case NAL_SEI_PREFIX:
case NAL_SEI_SUFFIX:
@@ -175,33 +176,33 @@ static inline int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx
}
sh->pps_id = get_ue_golomb(gb);
- if (sh->pps_id >= MAX_PPS_COUNT || !h->pps_list[sh->pps_id]) {
+ if (sh->pps_id >= MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) {
av_log(h->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
return AVERROR_INVALIDDATA;
}
- h->pps = (HEVCPPS*)h->pps_list[sh->pps_id]->data;
+ ps->pps = (HEVCPPS*)ps->pps_list[sh->pps_id]->data;
- if (h->pps->sps_id >= MAX_SPS_COUNT || !h->sps_list[h->pps->sps_id]) {
- av_log(h->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", h->pps->sps_id);
+ if (ps->pps->sps_id >= MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) {
+ av_log(h->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id);
return AVERROR_INVALIDDATA;
}
- if (h->sps != (HEVCSPS*)h->sps_list[h->pps->sps_id]->data) {
- h->sps = (HEVCSPS*)h->sps_list[h->pps->sps_id]->data;
- h->vps = (HEVCVPS*)h->vps_list[h->sps->vps_id]->data;
+ if (ps->sps != (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data) {
+ ps->sps = (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data;
+ ps->vps = (HEVCVPS*)ps->vps_list[ps->sps->vps_id]->data;
}
if (!sh->first_slice_in_pic_flag) {
int slice_address_length;
- if (h->pps->dependent_slice_segments_enabled_flag)
+ if (ps->pps->dependent_slice_segments_enabled_flag)
sh->dependent_slice_segment_flag = get_bits1(gb);
else
sh->dependent_slice_segment_flag = 0;
- slice_address_length = av_ceil_log2_c(h->sps->ctb_width *
- h->sps->ctb_height);
+ slice_address_length = av_ceil_log2_c(ps->sps->ctb_width *
+ ps->sps->ctb_height);
sh->slice_segment_addr = slice_address_length ? get_bits(gb, slice_address_length) : 0;
- if (sh->slice_segment_addr >= h->sps->ctb_width * h->sps->ctb_height) {
+ if (sh->slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) {
av_log(h->avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n",
sh->slice_segment_addr);
return AVERROR_INVALIDDATA;
@@ -212,7 +213,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx
if (sh->dependent_slice_segment_flag)
break;
- for (i = 0; i < h->pps->num_extra_slice_header_bits; i++)
+ for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++)
skip_bits(gb, 1); // slice_reserved_undetermined_flag[]
sh->slice_type = get_ue_golomb(gb);
@@ -226,14 +227,14 @@ static inline int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx
sh->slice_type == P_SLICE ? AV_PICTURE_TYPE_P :
AV_PICTURE_TYPE_I;
- if (h->pps->output_flag_present_flag)
+ if (ps->pps->output_flag_present_flag)
sh->pic_output_flag = get_bits1(gb);
- if (h->sps->separate_colour_plane_flag)
+ if (ps->sps->separate_colour_plane_flag)
sh->colour_plane_id = get_bits(gb, 2);
if (!IS_IDR(h)) {
- sh->pic_order_cnt_lsb = get_bits(gb, h->sps->log2_max_poc_lsb);
+ sh->pic_order_cnt_lsb = get_bits(gb, ps->sps->log2_max_poc_lsb);
s->output_picture_number = h->poc = ff_hevc_compute_poc(h, sh->pic_order_cnt_lsb);
} else
s->output_picture_number = h->poc = 0;
@@ -321,19 +322,20 @@ static void hevc_close(AVCodecParserContext *s)
int i;
HEVCContext *h = &((HEVCParseContext *)s->priv_data)->h;
ParseContext *pc = &((HEVCParseContext *)s->priv_data)->pc;
+ HEVCParamSets *ps = &h->ps;
av_freep(&h->skipped_bytes_pos);
av_freep(&h->HEVClc);
av_freep(&pc->buffer);
- for (i = 0; i < FF_ARRAY_ELEMS(h->vps_list); i++)
- av_buffer_unref(&h->vps_list[i]);
- for (i = 0; i < FF_ARRAY_ELEMS(h->sps_list); i++)
- av_buffer_unref(&h->sps_list[i]);
- for (i = 0; i < FF_ARRAY_ELEMS(h->pps_list); i++)
- av_buffer_unref(&h->pps_list[i]);
+ for (i = 0; i < FF_ARRAY_ELEMS(ps->vps_list); i++)
+ av_buffer_unref(&ps->vps_list[i]);
+ for (i = 0; i < FF_ARRAY_ELEMS(ps->sps_list); i++)
+ av_buffer_unref(&ps->sps_list[i]);
+ for (i = 0; i < FF_ARRAY_ELEMS(ps->pps_list); i++)
+ av_buffer_unref(&ps->pps_list[i]);
- h->sps = NULL;
+ ps->sps = NULL;
for (i = 0; i < h->nals_allocated; i++)
av_freep(&h->nals[i].rbsp_buffer);
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 71d8c02198..f99f9915aa 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -69,14 +69,14 @@ static const AVRational vui_sar[] = {
{ 2, 1 },
};
-static void remove_pps(HEVCContext *s, int id)
+static void remove_pps(HEVCParamSets *s, int id)
{
if (s->pps_list[id] && s->pps == (const HEVCPPS*)s->pps_list[id]->data)
s->pps = NULL;
av_buffer_unref(&s->pps_list[id]);
}
-static void remove_sps(HEVCContext *s, int id)
+static void remove_sps(HEVCParamSets *s, int id)
{
int i;
if (s->sps_list[id]) {
@@ -93,7 +93,7 @@ static void remove_sps(HEVCContext *s, int id)
av_buffer_unref(&s->sps_list[id]);
}
-static void remove_vps(HEVCContext *s, int id)
+static void remove_vps(HEVCParamSets *s, int id)
{
int i;
if (s->vps_list[id]) {
@@ -389,10 +389,10 @@ static int decode_hrd(GetBitContext *gb, int common_inf_present,
return 0;
}
-int ff_hevc_decode_nal_vps(HEVCContext *s)
+int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
+ HEVCParamSets *ps)
{
int i,j;
- GetBitContext *gb = &s->HEVClc->gb;
int vps_id = 0;
HEVCVPS *vps;
AVBufferRef *vps_buf = av_buffer_allocz(sizeof(*vps));
@@ -401,16 +401,16 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
return AVERROR(ENOMEM);
vps = (HEVCVPS*)vps_buf->data;
- av_log(s->avctx, AV_LOG_DEBUG, "Decoding VPS\n");
+ av_log(avctx, AV_LOG_DEBUG, "Decoding VPS\n");
vps_id = get_bits(gb, 4);
if (vps_id >= MAX_VPS_COUNT) {
- av_log(s->avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_id);
+ av_log(avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_id);
goto err;
}
if (get_bits(gb, 2) != 3) { // vps_reserved_three_2bits
- av_log(s->avctx, AV_LOG_ERROR, "vps_reserved_three_2bits is not three\n");
+ av_log(avctx, AV_LOG_ERROR, "vps_reserved_three_2bits is not three\n");
goto err;
}
@@ -419,17 +419,17 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
vps->vps_temporal_id_nesting_flag = get_bits1(gb);
if (get_bits(gb, 16) != 0xffff) { // vps_reserved_ffff_16bits
- av_log(s->avctx, AV_LOG_ERROR, "vps_reserved_ffff_16bits is not 0xffff\n");
+ av_log(avctx, AV_LOG_ERROR, "vps_reserved_ffff_16bits is not 0xffff\n");
goto err;
}
if (vps->vps_max_sub_layers > MAX_SUB_LAYERS) {
- av_log(s->avctx, AV_LOG_ERROR, "vps_max_sub_layers out of range: %d\n",
+ av_log(avctx, AV_LOG_ERROR, "vps_max_sub_layers out of range: %d\n",
vps->vps_max_sub_layers);
goto err;
}
- if (parse_ptl(gb, s->avctx, &vps->ptl, vps->vps_max_sub_layers) < 0)
+ if (parse_ptl(gb, avctx, &vps->ptl, vps->vps_max_sub_layers) < 0)
goto err;
vps->vps_sub_layer_ordering_info_present_flag = get_bits1(gb);
@@ -441,14 +441,14 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
vps->vps_max_latency_increase[i] = get_ue_golomb_long(gb) - 1;
if (vps->vps_max_dec_pic_buffering[i] > MAX_DPB_SIZE || !vps->vps_max_dec_pic_buffering[i]) {
- av_log(s->avctx, AV_LOG_ERROR, "vps_max_dec_pic_buffering_minus1 out of range: %d\n",
+ av_log(avctx, AV_LOG_ERROR, "vps_max_dec_pic_buffering_minus1 out of range: %d\n",
vps->vps_max_dec_pic_buffering[i] - 1);
goto err;
}
if (vps->vps_num_reorder_pics[i] > vps->vps_max_dec_pic_buffering[i] - 1) {
- av_log(s->avctx, AV_LOG_WARNING, "vps_max_num_reorder_pics out of range: %d\n",
+ av_log(avctx, AV_LOG_WARNING, "vps_max_num_reorder_pics out of range: %d\n",
vps->vps_num_reorder_pics[i]);
- if (s->avctx->err_recognition & AV_EF_EXPLODE)
+ if (avctx->err_recognition & AV_EF_EXPLODE)
goto err;
}
}
@@ -457,7 +457,7 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
vps->vps_num_layer_sets = get_ue_golomb_long(gb) + 1;
if (vps->vps_num_layer_sets < 1 || vps->vps_num_layer_sets > 1024 ||
(vps->vps_num_layer_sets - 1LL) * (vps->vps_max_layer_id + 1LL) > get_bits_left(gb)) {
- av_log(s->avctx, AV_LOG_ERROR, "too many layer_id_included_flags\n");
+ av_log(avctx, AV_LOG_ERROR, "too many layer_id_included_flags\n");
goto err;
}
@@ -474,7 +474,7 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
vps->vps_num_ticks_poc_diff_one = get_ue_golomb_long(gb) + 1;
vps->vps_num_hrd_parameters = get_ue_golomb_long(gb);
if (vps->vps_num_hrd_parameters > (unsigned)vps->vps_num_layer_sets) {
- av_log(s->avctx, AV_LOG_ERROR,
+ av_log(avctx, AV_LOG_ERROR,
"vps_num_hrd_parameters %d is invalid\n", vps->vps_num_hrd_parameters);
goto err;
}
@@ -490,18 +490,18 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
get_bits1(gb); /* vps_extension_flag */
if (get_bits_left(gb) < 0) {
- av_log(s->avctx, AV_LOG_ERROR,
+ av_log(avctx, AV_LOG_ERROR,
"Overread VPS by %d bits\n", -get_bits_left(gb));
- if (s->vps_list[vps_id])
+ if (ps->vps_list[vps_id])
goto err;
}
- if (s->vps_list[vps_id] &&
- !memcmp(s->vps_list[vps_id]->data, vps_buf->data, vps_buf->size)) {
+ if (ps->vps_list[vps_id] &&
+ !memcmp(ps->vps_list[vps_id]->data, vps_buf->data, vps_buf->size)) {
av_buffer_unref(&vps_buf);
} else {
- remove_vps(s, vps_id);
- s->vps_list[vps_id] = vps_buf;
+ remove_vps(ps, vps_id);
+ ps->vps_list[vps_id] = vps_buf;
}
return 0;
@@ -1135,7 +1135,8 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
return 0;
}
-int ff_hevc_decode_nal_sps(HEVCContext *s)
+int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx,
+ HEVCParamSets *ps, int apply_defdispwin)
{
HEVCSPS *sps;
AVBufferRef *sps_buf = av_buffer_allocz(sizeof(*sps));
@@ -1146,18 +1147,18 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
return AVERROR(ENOMEM);
sps = (HEVCSPS*)sps_buf->data;
- av_log(s->avctx, AV_LOG_DEBUG, "Decoding SPS\n");
+ av_log(avctx, AV_LOG_DEBUG, "Decoding SPS\n");
- ret = ff_hevc_parse_sps(sps, &s->HEVClc->gb, &sps_id,
- s->apply_defdispwin,
- s->vps_list, s->avctx);
+ ret = ff_hevc_parse_sps(sps, gb, &sps_id,
+ apply_defdispwin,
+ ps->vps_list, avctx);
if (ret < 0) {
av_buffer_unref(&sps_buf);
return ret;
}
- if (s->avctx->debug & FF_DEBUG_BITSTREAM) {
- av_log(s->avctx, AV_LOG_DEBUG,
+ if (avctx->debug & FF_DEBUG_BITSTREAM) {
+ av_log(avctx, AV_LOG_DEBUG,
"Parsed SPS: id %d; coded wxh: %dx%d; "
"cropped wxh: %dx%d; pix_fmt: %s.\n",
sps_id, sps->width, sps->height,
@@ -1168,12 +1169,12 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
/* check if this is a repeat of an already parsed SPS, then keep the
* original one.
* otherwise drop all PPSes that depend on it */
- if (s->sps_list[sps_id] &&
- !memcmp(s->sps_list[sps_id]->data, sps_buf->data, sps_buf->size)) {
+ if (ps->sps_list[sps_id] &&
+ !memcmp(ps->sps_list[sps_id]->data, sps_buf->data, sps_buf->size)) {
av_buffer_unref(&sps_buf);
} else {
- remove_sps(s, sps_id);
- s->sps_list[sps_id] = sps_buf;
+ remove_sps(ps, sps_id);
+ ps->sps_list[sps_id] = sps_buf;
}
return 0;
@@ -1197,8 +1198,8 @@ static void hevc_pps_free(void *opaque, uint8_t *data)
av_freep(&pps);
}
-static int pps_range_extensions(HEVCContext *s, HEVCPPS *pps, HEVCSPS *sps) {
- GetBitContext *gb = &s->HEVClc->gb;
+static int pps_range_extensions(GetBitContext *gb, AVCodecContext *avctx,
+ HEVCPPS *pps, HEVCSPS *sps) {
int i;
if (pps->transform_skip_enabled_flag) {
@@ -1210,19 +1211,19 @@ static int pps_range_extensions(HEVCContext *s, HEVCPPS *pps, HEVCSPS *sps) {
pps->diff_cu_chroma_qp_offset_depth = get_ue_golomb_long(gb);
pps->chroma_qp_offset_list_len_minus1 = get_ue_golomb_long(gb);
if (pps->chroma_qp_offset_list_len_minus1 && pps->chroma_qp_offset_list_len_minus1 >= 5) {
- av_log(s->avctx, AV_LOG_ERROR,
+ av_log(avctx, AV_LOG_ERROR,
"chroma_qp_offset_list_len_minus1 shall be in the range [0, 5].\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i <= pps->chroma_qp_offset_list_len_minus1; i++) {
pps->cb_qp_offset_list[i] = get_se_golomb_long(gb);
if (pps->cb_qp_offset_list[i]) {
- av_log(s->avctx, AV_LOG_WARNING,
+ av_log(avctx, AV_LOG_WARNING,
"cb_qp_offset_list not tested yet.\n");
}
pps->cr_qp_offset_list[i] = get_se_golomb_long(gb);
if (pps->cr_qp_offset_list[i]) {
- av_log(s->avctx, AV_LOG_WARNING,
+ av_log(avctx, AV_LOG_WARNING,
"cb_qp_offset_list not tested yet.\n");
}
}
@@ -1233,9 +1234,9 @@ static int pps_range_extensions(HEVCContext *s, HEVCPPS *pps, HEVCSPS *sps) {
return(0);
}
-int ff_hevc_decode_nal_pps(HEVCContext *s)
+int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
+ HEVCParamSets *ps)
{
- GetBitContext *gb = &s->HEVClc->gb;
HEVCSPS *sps = NULL;
int pic_area_in_ctbs;
int log2_diff_ctb_min_tb_size;
@@ -1256,7 +1257,7 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
return AVERROR(ENOMEM);
}
- av_log(s->avctx, AV_LOG_DEBUG, "Decoding PPS\n");
+ av_log(avctx, AV_LOG_DEBUG, "Decoding PPS\n");
// Default values
pps->loop_filter_across_tiles_enabled_flag = 1;
@@ -1271,22 +1272,22 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
// Coded parameters
pps_id = get_ue_golomb_long(gb);
if (pps_id >= MAX_PPS_COUNT) {
- av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
+ av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->sps_id = get_ue_golomb_long(gb);
if (pps->sps_id >= MAX_SPS_COUNT) {
- av_log(s->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id);
+ av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
- if (!s->sps_list[pps->sps_id]) {
- av_log(s->avctx, AV_LOG_ERROR, "SPS %u does not exist.\n", pps->sps_id);
+ if (!ps->sps_list[pps->sps_id]) {
+ av_log(avctx, AV_LOG_ERROR, "SPS %u does not exist.\n", pps->sps_id);
ret = AVERROR_INVALIDDATA;
goto err;
}
- sps = (HEVCSPS *)s->sps_list[pps->sps_id]->data;
+ sps = (HEVCSPS *)ps->sps_list[pps->sps_id]->data;
pps->dependent_slice_segments_enabled_flag = get_bits1(gb);
pps->output_flag_present_flag = get_bits1(gb);
@@ -1311,7 +1312,7 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
if (pps->diff_cu_qp_delta_depth < 0 ||
pps->diff_cu_qp_delta_depth > sps->log2_diff_max_min_coding_block_size) {
- av_log(s->avctx, AV_LOG_ERROR, "diff_cu_qp_delta_depth %d is invalid\n",
+ av_log(avctx, AV_LOG_ERROR, "diff_cu_qp_delta_depth %d is invalid\n",
pps->diff_cu_qp_delta_depth);
ret = AVERROR_INVALIDDATA;
goto err;
@@ -1319,14 +1320,14 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
pps->cb_qp_offset = get_se_golomb(gb);
if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) {
- av_log(s->avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n",
+ av_log(avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n",
pps->cb_qp_offset);
ret = AVERROR_INVALIDDATA;
goto err;
}
pps->cr_qp_offset = get_se_golomb(gb);
if (pps->cr_qp_offset < -12 || pps->cr_qp_offset > 12) {
- av_log(s->avctx, AV_LOG_ERROR, "pps_cr_qp_offset out of range: %d\n",
+ av_log(avctx, AV_LOG_ERROR, "pps_cr_qp_offset out of range: %d\n",
pps->cr_qp_offset);
ret = AVERROR_INVALIDDATA;
goto err;
@@ -1345,14 +1346,14 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
pps->num_tile_rows = get_ue_golomb_long(gb) + 1;
if (pps->num_tile_columns <= 0 ||
pps->num_tile_columns >= sps->width) {
- av_log(s->avctx, AV_LOG_ERROR, "num_tile_columns_minus1 out of range: %d\n",
+ av_log(avctx, AV_LOG_ERROR, "num_tile_columns_minus1 out of range: %d\n",
pps->num_tile_columns - 1);
ret = AVERROR_INVALIDDATA;
goto err;
}
if (pps->num_tile_rows <= 0 ||
pps->num_tile_rows >= sps->height) {
- av_log(s->avctx, AV_LOG_ERROR, "num_tile_rows_minus1 out of range: %d\n",
+ av_log(avctx, AV_LOG_ERROR, "num_tile_rows_minus1 out of range: %d\n",
pps->num_tile_rows - 1);
ret = AVERROR_INVALIDDATA;
goto err;
@@ -1373,7 +1374,7 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
sum += pps->column_width[i];
}
if (sum >= sps->ctb_width) {
- av_log(s->avctx, AV_LOG_ERROR, "Invalid tile widths.\n");
+ av_log(avctx, AV_LOG_ERROR, "Invalid tile widths.\n");
ret = AVERROR_INVALIDDATA;
goto err;
}
@@ -1385,7 +1386,7 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
sum += pps->row_height[i];
}
if (sum >= sps->ctb_height) {
- av_log(s->avctx, AV_LOG_ERROR, "Invalid tile heights.\n");
+ av_log(avctx, AV_LOG_ERROR, "Invalid tile heights.\n");
ret = AVERROR_INVALIDDATA;
goto err;
}
@@ -1404,13 +1405,13 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
pps->beta_offset = get_se_golomb(gb) * 2;
pps->tc_offset = get_se_golomb(gb) * 2;
if (pps->beta_offset/2 < -6 || pps->beta_offset/2 > 6) {
- av_log(s->avctx, AV_LOG_ERROR, "pps_beta_offset_div2 out of range: %d\n",
+ av_log(avctx, AV_LOG_ERROR, "pps_beta_offset_div2 out of range: %d\n",
pps->beta_offset/2);
ret = AVERROR_INVALIDDATA;
goto err;
}
if (pps->tc_offset/2 < -6 || pps->tc_offset/2 > 6) {
- av_log(s->avctx, AV_LOG_ERROR, "pps_tc_offset_div2 out of range: %d\n",
+ av_log(avctx, AV_LOG_ERROR, "pps_tc_offset_div2 out of range: %d\n",
pps->tc_offset/2);
ret = AVERROR_INVALIDDATA;
goto err;
@@ -1421,14 +1422,14 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
pps->scaling_list_data_present_flag = get_bits1(gb);
if (pps->scaling_list_data_present_flag) {
set_default_scaling_list_data(&pps->scaling_list);
- ret = scaling_list_data(gb, s->avctx, &pps->scaling_list, sps);
+ ret = scaling_list_data(gb, avctx, &pps->scaling_list, sps);
if (ret < 0)
goto err;
}
pps->lists_modification_present_flag = get_bits1(gb);
pps->log2_parallel_merge_level = get_ue_golomb_long(gb) + 2;
if (pps->log2_parallel_merge_level > sps->log2_ctb_size) {
- av_log(s->avctx, AV_LOG_ERROR, "log2_parallel_merge_level_minus2 out of range: %d\n",
+ av_log(avctx, AV_LOG_ERROR, "log2_parallel_merge_level_minus2 out of range: %d\n",
pps->log2_parallel_merge_level - 2);
ret = AVERROR_INVALIDDATA;
goto err;
@@ -1440,7 +1441,7 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
int pps_range_extensions_flag = get_bits1(gb);
/* int pps_extension_7bits = */ get_bits(gb, 7);
if (sps->ptl.general_ptl.profile_idc == FF_PROFILE_HEVC_REXT && pps_range_extensions_flag) {
- if ((ret = pps_range_extensions(s, pps, sps)) < 0)
+ if ((ret = pps_range_extensions(gb, avctx, pps, sps)) < 0)
goto err;
}
}
@@ -1575,13 +1576,13 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
}
if (get_bits_left(gb) < 0) {
- av_log(s->avctx, AV_LOG_ERROR,
+ av_log(avctx, AV_LOG_ERROR,
"Overread PPS by %d bits\n", -get_bits_left(gb));
goto err;
}
- remove_pps(s, pps_id);
- s->pps_list[pps_id] = pps_buf;
+ remove_pps(ps, pps_id);
+ ps->pps_list[pps_id] = pps_buf;
return 0;
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index fea3d125ba..147877d32f 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -55,10 +55,10 @@ void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
RefPicList *ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *ref, int x0, int y0)
{
- int x_cb = x0 >> s->sps->log2_ctb_size;
- int y_cb = y0 >> s->sps->log2_ctb_size;
- int pic_width_cb = s->sps->ctb_width;
- int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[y_cb * pic_width_cb + x_cb];
+ int x_cb = x0 >> s->ps.sps->log2_ctb_size;
+ int y_cb = y0 >> s->ps.sps->log2_ctb_size;
+ int pic_width_cb = s->ps.sps->ctb_width;
+ int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[y_cb * pic_width_cb + x_cb];
return (RefPicList *)ref->rpl_tab[ctb_addr_ts];
}
@@ -104,7 +104,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
if (!frame->rpl_tab_buf)
goto fail;
frame->rpl_tab = (RefPicListTab **)frame->rpl_tab_buf->data;
- frame->ctb_count = s->sps->ctb_width * s->sps->ctb_height;
+ frame->ctb_count = s->ps.sps->ctb_width * s->ps.sps->ctb_height;
for (j = 0; j < frame->ctb_count; j++)
frame->rpl_tab[j] = (RefPicListTab *)frame->rpl_buf->data;
@@ -162,7 +162,7 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
ref->poc = poc;
ref->sequence = s->seq_decode;
- ref->window = s->sps->output_window;
+ ref->window = s->ps.sps->output_window;
return 0;
}
@@ -197,8 +197,8 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush)
}
/* wait for more frames before output */
- if (!flush && s->seq_output == s->seq_decode && s->sps &&
- nb_output <= s->sps->temporal_layer[s->sps->max_sub_layers - 1].num_reorder_pics)
+ if (!flush && s->seq_output == s->seq_decode && s->ps.sps &&
+ nb_output <= s->ps.sps->temporal_layer[s->ps.sps->max_sub_layers - 1].num_reorder_pics)
return 0;
if (nb_output) {
@@ -252,7 +252,7 @@ void ff_hevc_bump_frame(HEVCContext *s)
}
}
- if (s->sps && dpb >= s->sps->temporal_layer[s->sps->max_sub_layers - 1].max_dec_pic_buffering) {
+ if (s->ps.sps && dpb >= s->ps.sps->temporal_layer[s->ps.sps->max_sub_layers - 1].max_dec_pic_buffering) {
for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
HEVCFrame *frame = &s->DPB[i];
if ((frame->flags) &&
@@ -281,7 +281,7 @@ static int init_slice_rpl(HEVCContext *s)
{
HEVCFrame *frame = s->ref;
int ctb_count = frame->ctb_count;
- int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[s->sh.slice_segment_addr];
+ int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_segment_addr];
int i;
if (s->slice_idx >= frame->rpl_buf->size / sizeof(RefPicListTab))
@@ -368,7 +368,7 @@ int ff_hevc_slice_rpl(HEVCContext *s)
static HEVCFrame *find_ref_idx(HEVCContext *s, int poc)
{
int i;
- int LtMask = (1 << s->sps->log2_max_poc_lsb) - 1;
+ int LtMask = (1 << s->ps.sps->log2_max_poc_lsb) - 1;
for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
HEVCFrame *ref = &s->DPB[i];
@@ -408,16 +408,16 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
return NULL;
if (!s->avctx->hwaccel) {
- if (!s->sps->pixel_shift) {
+ if (!s->ps.sps->pixel_shift) {
for (i = 0; frame->frame->buf[i]; i++)
- memset(frame->frame->buf[i]->data, 1 << (s->sps->bit_depth - 1),
+ memset(frame->frame->buf[i]->data, 1 << (s->ps.sps->bit_depth - 1),
frame->frame->buf[i]->size);
} else {
for (i = 0; frame->frame->data[i]; i++)
- for (y = 0; y < (s->sps->height >> s->sps->vshift[i]); y++)
- for (x = 0; x < (s->sps->width >> s->sps->hshift[i]); x++) {
+ for (y = 0; y < (s->ps.sps->height >> s->ps.sps->vshift[i]); y++)
+ for (x = 0; x < (s->ps.sps->width >> s->ps.sps->hshift[i]); x++) {
AV_WN16(frame->frame->data[i] + y * frame->frame->linesize[i] + 2 * x,
- 1 << (s->sps->bit_depth - 1));
+ 1 << (s->ps.sps->bit_depth - 1));
}
}
}
@@ -517,7 +517,7 @@ fail:
int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb)
{
- int max_poc_lsb = 1 << s->sps->log2_max_poc_lsb;
+ int max_poc_lsb = 1 << s->ps.sps->log2_max_poc_lsb;
int prev_poc_lsb = s->pocTid0 % max_poc_lsb;
int prev_poc_msb = s->pocTid0 - prev_poc_lsb;
int poc_msb;
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 13ebcd3ede..8ae680e5eb 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -94,9 +94,9 @@ static int decode_pic_timing(HEVCContext *s)
GetBitContext *gb = &s->HEVClc->gb;
HEVCSPS *sps;
- if (!s->sps_list[s->active_seq_parameter_set_id])
+ if (!s->ps.sps_list[s->active_seq_parameter_set_id])
return(AVERROR(ENOMEM));
- sps = (HEVCSPS*)s->sps_list[s->active_seq_parameter_set_id]->data;
+ sps = (HEVCSPS*)s->ps.sps_list[s->active_seq_parameter_set_id]->data;
if (sps->vui.frame_field_info_present_flag) {
int pic_struct = get_bits(gb, 4);
diff --git a/libavcodec/hevcpred_template.c b/libavcodec/hevcpred_template.c
index 6b763b3a73..6ae87cca13 100644
--- a/libavcodec/hevcpred_template.c
+++ b/libavcodec/hevcpred_template.c
@@ -31,7 +31,7 @@ static av_always_inline void FUNC(intra_pred)(HEVCContext *s, int x0, int y0,
int log2_size, int c_idx)
{
#define PU(x) \
- ((x) >> s->sps->log2_min_pu_size)
+ ((x) >> s->ps.sps->log2_min_pu_size)
#define MVF(x, y) \
(s->ref->tab_mvf[(x) + (y) * min_pu_width])
#define MVF_PU(x, y) \
@@ -39,7 +39,7 @@ static av_always_inline void FUNC(intra_pred)(HEVCContext *s, int x0, int y0,
#define IS_INTRA(x, y) \
(MVF_PU(x, y).pred_flag == PF_INTRA)
#define MIN_TB_ADDR_ZS(x, y) \
- s->pps->min_tb_addr_zs[(y) * (s->sps->tb_mask+2) + (x)]
+ s->ps.pps->min_tb_addr_zs[(y) * (s->ps.sps->tb_mask+2) + (x)]
#define EXTEND(ptr, val, len) \
do { \
pixel4 pix = PIXEL_SPLAT_X4(val); \
@@ -72,24 +72,24 @@ do { \
HEVCLocalContext *lc = s->HEVClc;
int i;
- int hshift = s->sps->hshift[c_idx];
- int vshift = s->sps->vshift[c_idx];
+ int hshift = s->ps.sps->hshift[c_idx];
+ int vshift = s->ps.sps->vshift[c_idx];
int size = (1 << log2_size);
int size_in_luma_h = size << hshift;
- int size_in_tbs_h = size_in_luma_h >> s->sps->log2_min_tb_size;
+ int size_in_tbs_h = size_in_luma_h >> s->ps.sps->log2_min_tb_size;
int size_in_luma_v = size << vshift;
- int size_in_tbs_v = size_in_luma_v >> s->sps->log2_min_tb_size;
+ int size_in_tbs_v = size_in_luma_v >> s->ps.sps->log2_min_tb_size;
int x = x0 >> hshift;
int y = y0 >> vshift;
- int x_tb = (x0 >> s->sps->log2_min_tb_size) & s->sps->tb_mask;
- int y_tb = (y0 >> s->sps->log2_min_tb_size) & s->sps->tb_mask;
+ int x_tb = (x0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
+ int y_tb = (y0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb);
ptrdiff_t stride = s->frame->linesize[c_idx] / sizeof(pixel);
pixel *src = (pixel*)s->frame->data[c_idx] + x + y * stride;
- int min_pu_width = s->sps->min_pu_width;
+ int min_pu_width = s->ps.sps->min_pu_width;
enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c :
lc->tu.intra_pred_mode;
@@ -103,28 +103,28 @@ do { \
pixel *top = top_array + 1;
pixel *filtered_left = filtered_left_array + 1;
pixel *filtered_top = filtered_top_array + 1;
- int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS( x_tb - 1, (y_tb + size_in_tbs_v) & s->sps->tb_mask);
+ int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS( x_tb - 1, (y_tb + size_in_tbs_v) & s->ps.sps->tb_mask);
int cand_left = lc->na.cand_left;
int cand_up_left = lc->na.cand_up_left;
int cand_up = lc->na.cand_up;
- int cand_up_right = lc->na.cand_up_right && cur_tb_addr > MIN_TB_ADDR_ZS((x_tb + size_in_tbs_h) & s->sps->tb_mask, y_tb - 1);
+ int cand_up_right = lc->na.cand_up_right && cur_tb_addr > MIN_TB_ADDR_ZS((x_tb + size_in_tbs_h) & s->ps.sps->tb_mask, y_tb - 1);
- int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, s->sps->height) -
+ int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, s->ps.sps->height) -
(y0 + size_in_luma_v)) >> vshift;
- int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, s->sps->width) -
+ int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, s->ps.sps->width) -
(x0 + size_in_luma_h)) >> hshift;
- if (s->pps->constrained_intra_pred_flag == 1) {
+ if (s->ps.pps->constrained_intra_pred_flag == 1) {
int size_in_luma_pu_v = PU(size_in_luma_v);
int size_in_luma_pu_h = PU(size_in_luma_h);
- int on_pu_edge_x = !av_mod_uintp2(x0, s->sps->log2_min_pu_size);
- int on_pu_edge_y = !av_mod_uintp2(y0, s->sps->log2_min_pu_size);
+ int on_pu_edge_x = !av_mod_uintp2(x0, s->ps.sps->log2_min_pu_size);
+ int on_pu_edge_y = !av_mod_uintp2(y0, s->ps.sps->log2_min_pu_size);
if (!size_in_luma_pu_h)
size_in_luma_pu_h++;
if (cand_bottom_left == 1 && on_pu_edge_x) {
int x_left_pu = PU(x0 - 1);
int y_bottom_pu = PU(y0 + size_in_luma_v);
- int max = FFMIN(size_in_luma_pu_v, s->sps->min_pu_height - y_bottom_pu);
+ int max = FFMIN(size_in_luma_pu_v, s->ps.sps->min_pu_height - y_bottom_pu);
cand_bottom_left = 0;
for (i = 0; i < max; i += 2)
cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA);
@@ -132,7 +132,7 @@ do { \
if (cand_left == 1 && on_pu_edge_x) {
int x_left_pu = PU(x0 - 1);
int y_left_pu = PU(y0);
- int max = FFMIN(size_in_luma_pu_v, s->sps->min_pu_height - y_left_pu);
+ int max = FFMIN(size_in_luma_pu_v, s->ps.sps->min_pu_height - y_left_pu);
cand_left = 0;
for (i = 0; i < max; i += 2)
cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA);
@@ -145,7 +145,7 @@ do { \
if (cand_up == 1 && on_pu_edge_y) {
int x_top_pu = PU(x0);
int y_top_pu = PU(y0 - 1);
- int max = FFMIN(size_in_luma_pu_h, s->sps->min_pu_width - x_top_pu);
+ int max = FFMIN(size_in_luma_pu_h, s->ps.sps->min_pu_width - x_top_pu);
cand_up = 0;
for (i = 0; i < max; i += 2)
cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA);
@@ -153,7 +153,7 @@ do { \
if (cand_up_right == 1 && on_pu_edge_y) {
int y_top_pu = PU(y0 - 1);
int x_right_pu = PU(x0 + size_in_luma_h);
- int max = FFMIN(size_in_luma_pu_h, s->sps->min_pu_width - x_right_pu);
+ int max = FFMIN(size_in_luma_pu_h, s->ps.sps->min_pu_width - x_right_pu);
cand_up_right = 0;
for (i = 0; i < max; i += 2)
cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA);
@@ -183,20 +183,20 @@ do { \
size - bottom_left_size);
}
- if (s->pps->constrained_intra_pred_flag == 1) {
+ if (s->ps.pps->constrained_intra_pred_flag == 1) {
if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) {
- int size_max_x = x0 + ((2 * size) << hshift) < s->sps->width ?
- 2 * size : (s->sps->width - x0) >> hshift;
- int size_max_y = y0 + ((2 * size) << vshift) < s->sps->height ?
- 2 * size : (s->sps->height - y0) >> vshift;
+ int size_max_x = x0 + ((2 * size) << hshift) < s->ps.sps->width ?
+ 2 * size : (s->ps.sps->width - x0) >> hshift;
+ int size_max_y = y0 + ((2 * size) << vshift) < s->ps.sps->height ?
+ 2 * size : (s->ps.sps->height - y0) >> vshift;
int j = size + (cand_bottom_left? bottom_left_size: 0) -1;
if (!cand_up_right) {
- size_max_x = x0 + ((size) << hshift) < s->sps->width ?
- size : (s->sps->width - x0) >> hshift;
+ size_max_x = x0 + ((size) << hshift) < s->ps.sps->width ?
+ size : (s->ps.sps->width - x0) >> hshift;
}
if (!cand_bottom_left) {
- size_max_y = y0 + (( size) << vshift) < s->sps->height ?
- size : (s->sps->height - y0) >> vshift;
+ size_max_y = y0 + (( size) << vshift) < s->ps.sps->height ?
+ size : (s->ps.sps->height - y0) >> vshift;
}
if (cand_bottom_left || cand_left || cand_up_left) {
while (j > -1 && !IS_INTRA(-1, j))
@@ -287,14 +287,14 @@ do { \
top[-1] = left[-1];
// Filtering process
- if (!s->sps->intra_smoothing_disabled_flag && (c_idx == 0 || s->sps->chroma_format_idc == 3)) {
+ if (!s->ps.sps->intra_smoothing_disabled_flag && (c_idx == 0 || s->ps.sps->chroma_format_idc == 3)) {
if (mode != INTRA_DC && size != 4){
int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };
int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)),
FFABS((int)(mode - 10U)));
if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) {
int threshold = 1 << (BIT_DEPTH - 5);
- if (s->sps->sps_strong_intra_smoothing_enable_flag && c_idx == 0 &&
+ if (s->ps.sps->sps_strong_intra_smoothing_enable_flag && c_idx == 0 &&
log2_size == 5 &&
FFABS(top[-1] + top[63] - 2 * top[31]) < threshold &&
FFABS(left[-1] + left[63] - 2 * left[31]) < threshold) {