History

lavc/hevcdec: stop accessing parameter sets through HEVCParamSets

Instead, accept PPS/SPS as function arguments. Makes the code shorter and significantly reduces diff in future commits.

Anton Khirnov committed 2 years ago

Commit 0f473421 parent 38b8ae41 file · +470 −408Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/hevc/hevcdec.c+470−408
@@ -143,7 +143,7 @@ fail: · 142 unmodified lines
143143 return AVERROR(ENOMEM);
144144 }
145145
146−static int pred_weight_table(HEVCContext *s, GetBitContext *gb)
146+static int pred_weight_table(HEVCContext *s, const HEVCSPS *sps, GetBitContext *gb)
147147 {
148148 int i = 0;
149149 int j = 0;
@@ -159,7 +159,7 @@ static int pred_weight_table(HEVCContext *s, GetBitContext *gb) · 9 unmodified lines
159159 return AVERROR_INVALIDDATA;
160160 }
161161 s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3);
162− if (s->ps.sps->chroma_format_idc != 0) {
162+ if (sps->chroma_format_idc != 0) {
163163 int64_t chroma_log2_weight_denom = luma_log2_weight_denom + (int64_t)get_se_golomb(gb);
164164 if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) {
165165 av_log(s->avctx, AV_LOG_ERROR, "chroma_log2_weight_denom %"PRId64" is invalid\n", chroma_log2_weight_denom);
@@ -175,7 +175,7 @@ static int pred_weight_table(HEVCContext *s, GetBitContext *gb) · 9 unmodified lines
175175 s->sh.luma_offset_l0[i] = 0;
176176 }
177177 }
178− if (s->ps.sps->chroma_format_idc != 0) {
178+ if (sps->chroma_format_idc != 0) {
179179 for (i = 0; i < s->sh.nb_refs[L0]; i++)
180180 chroma_weight_l0_flag[i] = get_bits1(gb);
181181 } else {
@@ -219,7 +219,7 @@ static int pred_weight_table(HEVCContext *s, GetBitContext *gb) · 37 unmodified lines
219219 s->sh.luma_offset_l1[i] = 0;
220220 }
221221 }
222− if (s->ps.sps->chroma_format_idc != 0) {
222+ if (sps->chroma_format_idc != 0) {
223223 for (i = 0; i < s->sh.nb_refs[L1]; i++)
224224 chroma_weight_l1_flag[i] = get_bits1(gb);
225225 } else {
@@ -259,9 +259,9 @@ static int pred_weight_table(HEVCContext *s, GetBitContext *gb) · 33 unmodified lines
259259 return 0;
260260 }
261261
262−static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
262+static int decode_lt_rps(HEVCContext *s, const HEVCSPS *sps, LongTermRPS *rps,
263+ GetBitContext *gb)
263264 {
264− const HEVCSPS *sps = s->ps.sps;
265265 int max_poc_lsb = 1 << sps->log2_max_poc_lsb;
266266 int prev_delta_msb = 0;
267267 unsigned int nb_sps = 0, nb_sh;
@@ -591,6 +591,8 @@ fail: · 323 unmodified lines
591591 static int hls_slice_header(HEVCContext *s, GetBitContext *gb)
592592 {
593593 SliceHeader *sh = &s->sh;
594+ const HEVCPPS *pps;
595+ const HEVCSPS *sps;
594596 int i, ret;
595597
596598 // Coded parameters
@@ -621,11 +623,13 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 24 unmodified lines
621623 return AVERROR_INVALIDDATA;
622624 }
623625 s->ps.pps = s->ps.pps_list[sh->pps_id];
626+ pps = s->ps.pps;
627+ sps = pps->sps;
628+
624629 if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1)
625630 sh->no_output_of_prior_pics_flag = 1;
626631
627− if (s->ps.sps != s->ps.pps->sps) {
628− const HEVCSPS *sps = s->ps.pps->sps;
632+ if (s->ps.sps != sps) {
629633 enum AVPixelFormat pix_fmt;
630634
631635 ff_hevc_clear_refs(s);
@@ -651,13 +655,13 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 19 unmodified lines
651655 if (!sh->first_slice_in_pic_flag) {
652656 int slice_address_length;
653657
654− if (s->ps.pps->dependent_slice_segments_enabled_flag)
658+ if (pps->dependent_slice_segments_enabled_flag)
655659 sh->dependent_slice_segment_flag = get_bits1(gb);
656660
657− slice_address_length = av_ceil_log2(s->ps.sps->ctb_width *
658− s->ps.sps->ctb_height);
661+ slice_address_length = av_ceil_log2(sps->ctb_width *
662+ sps->ctb_height);
659663 sh->slice_segment_addr = get_bitsz(gb, slice_address_length);
660− if (sh->slice_segment_addr >= s->ps.sps->ctb_width * s->ps.sps->ctb_height) {
664+ if (sh->slice_segment_addr >= sps->ctb_width * sps->ctb_height) {
661665 av_log(s->avctx, AV_LOG_ERROR,
662666 "Invalid slice segment address: %u.\n",
663667 sh->slice_segment_addr);
@@ -677,7 +681,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 13 unmodified lines
677681 if (!sh->dependent_slice_segment_flag) {
678682 s->slice_initialized = 0;
679683
680− for (i = 0; i < s->ps.pps->num_extra_slice_header_bits; i++)
684+ for (i = 0; i < pps->num_extra_slice_header_bits; i++)
681685 skip_bits(gb, 1); // slice_reserved_undetermined_flag[]
682686
683687 sh->slice_type = get_ue_golomb_long(gb);
@@ -689,24 +693,24 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 5 unmodified lines
689693 return AVERROR_INVALIDDATA;
690694 }
691695 if (IS_IRAP(s) && sh->slice_type != HEVC_SLICE_I &&
692− !s->ps.pps->pps_curr_pic_ref_enabled_flag) {
696+ !pps->pps_curr_pic_ref_enabled_flag) {
693697 av_log(s->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n");
694698 return AVERROR_INVALIDDATA;
695699 }
696700
697701 // when flag is not present, picture is inferred to be output
698702 sh->pic_output_flag = 1;
699− if (s->ps.pps->output_flag_present_flag)
703+ if (pps->output_flag_present_flag)
700704 sh->pic_output_flag = get_bits1(gb);
701705
702− if (s->ps.sps->separate_colour_plane)
706+ if (sps->separate_colour_plane)
703707 sh->colour_plane_id = get_bits(gb, 2);
704708
705709 if (!IS_IDR(s)) {
706710 int poc, pos;
707711
708− sh->pic_order_cnt_lsb = get_bits(gb, s->ps.sps->log2_max_poc_lsb);
709− poc = ff_hevc_compute_poc(s->ps.sps, s->pocTid0, sh->pic_order_cnt_lsb, s->nal_unit_type);
712+ sh->pic_order_cnt_lsb = get_bits(gb, sps->log2_max_poc_lsb);
713+ poc = ff_hevc_compute_poc(sps, s->pocTid0, sh->pic_order_cnt_lsb, s->nal_unit_type);
710714 if (!sh->first_slice_in_pic_flag && poc != s->poc) {
711715 av_log(s->avctx, AV_LOG_WARNING,
712716 "Ignoring POC change between slices: %d -> %d\n", s->poc, poc);
@@ -719,7 +723,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 6 unmodified lines
719723 sh->short_term_ref_pic_set_sps_flag = get_bits1(gb);
720724 pos = get_bits_left(gb);
721725 if (!sh->short_term_ref_pic_set_sps_flag) {
722− ret = ff_hevc_decode_short_term_rps(gb, s->avctx, &sh->slice_rps, s->ps.sps, 1);
726+ ret = ff_hevc_decode_short_term_rps(gb, s->avctx, &sh->slice_rps, sps, 1);
723727 if (ret < 0)
724728 return ret;
725729
@@ -727,19 +731,19 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 1 unmodified line
727731 } else {
728732 int numbits, rps_idx;
729733
730− if (!s->ps.sps->nb_st_rps) {
734+ if (!sps->nb_st_rps) {
731735 av_log(s->avctx, AV_LOG_ERROR, "No ref lists in the SPS.\n");
732736 return AVERROR_INVALIDDATA;
733737 }
734738
735− numbits = av_ceil_log2(s->ps.sps->nb_st_rps);
739+ numbits = av_ceil_log2(sps->nb_st_rps);
736740 rps_idx = numbits > 0 ? get_bits(gb, numbits) : 0;
737− sh->short_term_rps = &s->ps.sps->st_rps[rps_idx];
741+ sh->short_term_rps = &sps->st_rps[rps_idx];
738742 }
739743 sh->short_term_ref_pic_set_size = pos - get_bits_left(gb);
740744
741745 pos = get_bits_left(gb);
742− ret = decode_lt_rps(s, &sh->long_term_rps, gb);
746+ ret = decode_lt_rps(s, sps, &sh->long_term_rps, gb);
743747 if (ret < 0) {
744748 av_log(s->avctx, AV_LOG_WARNING, "Invalid long term RPS.\n");
745749 if (s->avctx->err_recognition & AV_EF_EXPLODE)
@@ -747,7 +751,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 1 unmodified line
747751 }
748752 sh->long_term_ref_pic_set_size = pos - get_bits_left(gb);
749753
750− if (s->ps.sps->temporal_mvp_enabled)
754+ if (sps->temporal_mvp_enabled)
751755 sh->slice_temporal_mvp_enabled_flag = get_bits1(gb);
752756 else
753757 sh->slice_temporal_mvp_enabled_flag = 0;
@@ -772,9 +776,9 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 18 unmodified lines
772776 s->nal_unit_type != HEVC_NAL_RASL_R)
773777 s->pocTid0 = s->poc;
774778
775− if (s->ps.sps->sao_enabled) {
779+ if (sps->sao_enabled) {
776780 sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);
777− if (s->ps.sps->chroma_format_idc) {
781+ if (sps->chroma_format_idc) {
778782 sh->slice_sample_adaptive_offset_flag[1] =
779783 sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb);
780784 }
@@ -788,9 +792,9 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 7 unmodified lines
788792 if (sh->slice_type == HEVC_SLICE_P || sh->slice_type == HEVC_SLICE_B) {
789793 int nb_refs;
790794
791− sh->nb_refs[L0] = s->ps.pps->num_ref_idx_l0_default_active;
795+ sh->nb_refs[L0] = pps->num_ref_idx_l0_default_active;
792796 if (sh->slice_type == HEVC_SLICE_B)
793− sh->nb_refs[L1] = s->ps.pps->num_ref_idx_l1_default_active;
797+ sh->nb_refs[L1] = pps->num_ref_idx_l1_default_active;
794798
795799 if (get_bits1(gb)) { // num_ref_idx_active_override_flag
796800 sh->nb_refs[L0] = get_ue_golomb_31(gb) + 1;
@@ -811,7 +815,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 14 unmodified lines
811815 return AVERROR_INVALIDDATA;
812816 }
813817
814− if (s->ps.pps->lists_modification_present_flag && nb_refs > 1) {
818+ if (pps->lists_modification_present_flag && nb_refs > 1) {
815819 sh->rpl_modification_flag[0] = get_bits1(gb);
816820 if (sh->rpl_modification_flag[0]) {
817821 for (i = 0; i < sh->nb_refs[L0]; i++)
@@ -829,7 +833,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 11 unmodified lines
829833 if (sh->slice_type == HEVC_SLICE_B)
830834 sh->mvd_l1_zero_flag = get_bits1(gb);
831835
832− if (s->ps.pps->cabac_init_present_flag)
836+ if (pps->cabac_init_present_flag)
833837 sh->cabac_init_flag = get_bits1(gb);
834838 else
835839 sh->cabac_init_flag = 0;
@@ -851,9 +855,9 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 15 unmodified lines
851855 }
852856 }
853857
854− if ((s->ps.pps->weighted_pred_flag && sh->slice_type == HEVC_SLICE_P) ||
855− (s->ps.pps->weighted_bipred_flag && sh->slice_type == HEVC_SLICE_B)) {
856− int ret = pred_weight_table(s, gb);
858+ if ((pps->weighted_pred_flag && sh->slice_type == HEVC_SLICE_P) ||
859+ (pps->weighted_bipred_flag && sh->slice_type == HEVC_SLICE_B)) {
860+ int ret = pred_weight_table(s, sps, gb);
857861 if (ret < 0)
858862 return ret;
859863 }
@@ -867,17 +871,17 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 7 unmodified lines
867871 }
868872
869873 // Syntax in 7.3.6.1
870− if (s->ps.sps->motion_vector_resolution_control_idc == 2)
874+ if (sps->motion_vector_resolution_control_idc == 2)
871875 sh->use_integer_mv_flag = get_bits1(gb);
872876 else
873877 // Inferred to be equal to motion_vector_resolution_control_idc if not present
874− sh->use_integer_mv_flag = s->ps.sps->motion_vector_resolution_control_idc;
878+ sh->use_integer_mv_flag = sps->motion_vector_resolution_control_idc;
875879
876880 }
877881
878882 sh->slice_qp_delta = get_se_golomb(gb);
879883
880− if (s->ps.pps->pic_slice_level_chroma_qp_offsets_present_flag) {
884+ if (pps->pic_slice_level_chroma_qp_offsets_present_flag) {
881885 sh->slice_cb_qp_offset = get_se_golomb(gb);
882886 sh->slice_cr_qp_offset = get_se_golomb(gb);
883887 if (sh->slice_cb_qp_offset < -12 || sh->slice_cb_qp_offset > 12 ||
@@ -890,21 +894,21 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 6 unmodified lines
890894 sh->slice_cr_qp_offset = 0;
891895 }
892896
893− if (s->ps.pps->pps_slice_act_qp_offsets_present_flag) {
897+ if (pps->pps_slice_act_qp_offsets_present_flag) {
894898 sh->slice_act_y_qp_offset = get_se_golomb(gb);
895899 sh->slice_act_cb_qp_offset = get_se_golomb(gb);
896900 sh->slice_act_cr_qp_offset = get_se_golomb(gb);
897901 }
898902
899− if (s->ps.pps->chroma_qp_offset_list_enabled_flag)
903+ if (pps->chroma_qp_offset_list_enabled_flag)
900904 sh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb);
901905 else
902906 sh->cu_chroma_qp_offset_enabled_flag = 0;
903907
904− if (s->ps.pps->deblocking_filter_control_present_flag) {
908+ if (pps->deblocking_filter_control_present_flag) {
905909 int deblocking_filter_override_flag = 0;
906910
907− if (s->ps.pps->deblocking_filter_override_enabled_flag)
911+ if (pps->deblocking_filter_override_enabled_flag)
908912 deblocking_filter_override_flag = get_bits1(gb);
909913
910914 if (deblocking_filter_override_flag) {
@@ -923,9 +927,9 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 12 unmodified lines
923927 sh->tc_offset = tc_offset_div2 * 2;
924928 }
925929 } else {
926− sh->disable_deblocking_filter_flag = s->ps.pps->disable_dbf;
927− sh->beta_offset = s->ps.pps->beta_offset;
928− sh->tc_offset = s->ps.pps->tc_offset;
930+ sh->disable_deblocking_filter_flag = pps->disable_dbf;
931+ sh->beta_offset = pps->beta_offset;
932+ sh->tc_offset = pps->tc_offset;
929933 }
930934 } else {
931935 sh->disable_deblocking_filter_flag = 0;
@@ -933,13 +937,13 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 1 unmodified line
933937 sh->tc_offset = 0;
934938 }
935939
936− if (s->ps.pps->seq_loop_filter_across_slices_enabled_flag &&
940+ if (pps->seq_loop_filter_across_slices_enabled_flag &&
937941 (sh->slice_sample_adaptive_offset_flag[0] ||
938942 sh->slice_sample_adaptive_offset_flag[1] ||
939943 !sh->disable_deblocking_filter_flag)) {
940944 sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb);
941945 } else {
942− sh->slice_loop_filter_across_slices_enabled_flag = s->ps.pps->seq_loop_filter_across_slices_enabled_flag;
946+ sh->slice_loop_filter_across_slices_enabled_flag = pps->seq_loop_filter_across_slices_enabled_flag;
943947 }
944948 } else if (!s->slice_initialized) {
945949 av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n");
@@ -947,7 +951,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 1 unmodified line
947951 }
948952
949953 sh->num_entry_point_offsets = 0;
950− if (s->ps.pps->tiles_enabled_flag || s->ps.pps->entropy_coding_sync_enabled_flag) {
954+ if (pps->tiles_enabled_flag || pps->entropy_coding_sync_enabled_flag) {
951955 unsigned num_entry_point_offsets = get_ue_golomb_long(gb);
952956 // It would be possible to bound this tighter but this here is simpler
953957 if (num_entry_point_offsets > get_bits_left(gb)) {
@@ -980,7 +984,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 26 unmodified lines
980984 unsigned val = get_bits_long(gb, offset_len);
981985 sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the size
982986 }
983− if (s->threads_number > 1 && (s->ps.pps->num_tile_rows > 1 || s->ps.pps->num_tile_columns > 1)) {
987+ if (s->threads_number > 1 && (pps->num_tile_rows > 1 || pps->num_tile_columns > 1)) {
984988 s->enable_parallel_tiles = 0; // TODO: you can enable tiles in parallel here
985989 s->threads_number = 1;
986990 } else
@@ -989,7 +993,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 2 unmodified lines
989993 s->enable_parallel_tiles = 0;
990994 }
991995
992− if (s->ps.pps->slice_header_extension_present_flag) {
996+ if (pps->slice_header_extension_present_flag) {
993997 unsigned int length = get_ue_golomb_long(gb);
994998 if (length*8LL > get_bits_left(gb)) {
995999 av_log(s->avctx, AV_LOG_ERROR, "too many slice_header_extension_data_bytes\n");
@@ -1007,14 +1011,14 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 11 unmodified lines
10071011 sh->data_offset = align_get_bits(gb) - gb->buffer;
10081012
10091013 // Inferred parameters
1010− sh->slice_qp = 26U + s->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta;
1014+ sh->slice_qp = 26U + pps->pic_init_qp_minus26 + sh->slice_qp_delta;
10111015 if (sh->slice_qp > 51 ||
1012− sh->slice_qp < -s->ps.sps->qp_bd_offset) {
1016+ sh->slice_qp < -sps->qp_bd_offset) {
10131017 av_log(s->avctx, AV_LOG_ERROR,
10141018 "The slice_qp %d is outside the valid range "
10151019 "[%d, 51].\n",
10161020 sh->slice_qp,
1017− -s->ps.sps->qp_bd_offset);
1021+ -sps->qp_bd_offset);
10181022 return AVERROR_INVALIDDATA;
10191023 }
10201024
@@ -1033,7 +1037,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 12 unmodified lines
10331037
10341038 s->local_ctx[0].first_qp_group = !s->sh.dependent_slice_segment_flag;
10351039
1036− if (!s->ps.pps->cu_qp_delta_enabled_flag)
1040+ if (!pps->cu_qp_delta_enabled_flag)
10371041 s->local_ctx[0].qp_y = s->sh.slice_qp;
10381042
10391043 s->slice_initialized = 1;
@@ -1043,7 +1047,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 3 unmodified lines
10431047 return 0;
10441048 }
10451049
1046−#define CTB(tab, x, y) ((tab)[(y) * s->ps.sps->ctb_width + (x)])
1050+#define CTB(tab, x, y) ((tab)[(y) * sps->ctb_width + (x)])
10471051
10481052 #define SET_SAO(elem, value) \
10491053 do { \
@@ -1057,7 +1061,9 @@ do { \ · 7 unmodified lines
10571061 sao->elem = 0; \
10581062 } while (0)
10591063
1060−static void hls_sao_param(HEVCLocalContext *lc, int rx, int ry)
1064+static void hls_sao_param(HEVCLocalContext *lc,
1065+ const HEVCPPS *pps, const HEVCSPS *sps,
1066+ int rx, int ry)
10611067 {
10621068 const HEVCContext *const s = lc->parent;
10631069 int sao_merge_left_flag = 0;
@@ -1077,9 +1083,9 @@ static void hls_sao_param(HEVCLocalContext *lc, int rx, int ry) · 13 unmodified lines
10771083 }
10781084 }
10791085
1080− for (c_idx = 0; c_idx < (s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) {
1081− int log2_sao_offset_scale = c_idx == 0 ? s->ps.pps->log2_sao_offset_scale_luma :
1082− s->ps.pps->log2_sao_offset_scale_chroma;
1086+ for (c_idx = 0; c_idx < (sps->chroma_format_idc ? 3 : 1); c_idx++) {
1087+ int log2_sao_offset_scale = c_idx == 0 ? pps->log2_sao_offset_scale_luma :
1088+ pps->log2_sao_offset_scale_chroma;
10831089
10841090 if (!s->sh.slice_sample_adaptive_offset_flag[c_idx]) {
10851091 sao->type_idx[c_idx] = SAO_NOT_APPLIED;
@@ -1097,7 +1103,7 @@ static void hls_sao_param(HEVCLocalContext *lc, int rx, int ry) · 11 unmodified lines
10971103 continue;
10981104
10991105 for (i = 0; i < 4; i++)
1100− SET_SAO(offset_abs[c_idx][i], ff_hevc_sao_offset_abs_decode(lc, s->ps.sps->bit_depth));
1106+ SET_SAO(offset_abs[c_idx][i], ff_hevc_sao_offset_abs_decode(lc, sps->bit_depth));
11011107
11021108 if (sao->type_idx[c_idx] == SAO_BAND) {
11031109 for (i = 0; i < 4; i++) {
@@ -1147,49 +1153,51 @@ static int hls_cross_component_pred(HEVCLocalContext *lc, int idx) · 43 unmodified lines
11471153 return 0;
11481154 }
11491155
1150−static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
1156+static int hls_transform_unit(HEVCLocalContext *lc,
1157+ const HEVCPPS *pps, const HEVCSPS *sps,
1158+ int x0, int y0,
11511159 int xBase, int yBase, int cb_xBase, int cb_yBase,
11521160 int log2_cb_size, int log2_trafo_size,
11531161 int blk_idx, int cbf_luma, int *cbf_cb, int *cbf_cr)
11541162 {
11551163 const HEVCContext *const s = lc->parent;
1156− const int log2_trafo_size_c = log2_trafo_size - s->ps.sps->hshift[1];
1164+ const int log2_trafo_size_c = log2_trafo_size - sps->hshift[1];
11571165 int i;
11581166
11591167 if (lc->cu.pred_mode == MODE_INTRA) {
11601168 int trafo_size = 1 << log2_trafo_size;
1161− ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size, trafo_size, s->ps.sps->log2_ctb_size);
1169+ ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size, trafo_size, sps->log2_ctb_size);
11621170
1163− s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, x0, y0, 0);
1171+ s->hpc.intra_pred[log2_trafo_size - 2](lc, pps, x0, y0, 0);
11641172 }
11651173
11661174 if (cbf_luma || cbf_cb[0] || cbf_cr[0] ||
1167− (s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
1175+ (sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
11681176 int scan_idx = SCAN_DIAG;
11691177 int scan_idx_c = SCAN_DIAG;
11701178 int cbf_chroma = cbf_cb[0] || cbf_cr[0] ||
1171− (s->ps.sps->chroma_format_idc == 2 &&
1179+ (sps->chroma_format_idc == 2 &&
11721180 (cbf_cb[1] || cbf_cr[1]));
11731181
1174− if (s->ps.pps->cu_qp_delta_enabled_flag && !lc->tu.is_cu_qp_delta_coded) {
1182+ if (pps->cu_qp_delta_enabled_flag && !lc->tu.is_cu_qp_delta_coded) {
11751183 lc->tu.cu_qp_delta = ff_hevc_cu_qp_delta_abs(lc);
11761184 if (lc->tu.cu_qp_delta != 0)
11771185 if (ff_hevc_cu_qp_delta_sign_flag(lc) == 1)
11781186 lc->tu.cu_qp_delta = -lc->tu.cu_qp_delta;
11791187 lc->tu.is_cu_qp_delta_coded = 1;
11801188
1181− if (lc->tu.cu_qp_delta < -(26 + s->ps.sps->qp_bd_offset / 2) ||
1182− lc->tu.cu_qp_delta > (25 + s->ps.sps->qp_bd_offset / 2)) {
1189+ if (lc->tu.cu_qp_delta < -(26 + sps->qp_bd_offset / 2) ||
1190+ lc->tu.cu_qp_delta > (25 + sps->qp_bd_offset / 2)) {
11831191 av_log(s->avctx, AV_LOG_ERROR,
11841192 "The cu_qp_delta %d is outside the valid range "
11851193 "[%d, %d].\n",
11861194 lc->tu.cu_qp_delta,
1187− -(26 + s->ps.sps->qp_bd_offset / 2),
1188− (25 + s->ps.sps->qp_bd_offset / 2));
1195+ -(26 + sps->qp_bd_offset / 2),
1196+ (25 + sps->qp_bd_offset / 2));
11891197 return AVERROR_INVALIDDATA;
11901198 }
11911199
1192− ff_hevc_set_qPy(lc, s->ps.pps, cb_xBase, cb_yBase, log2_cb_size);
1200+ ff_hevc_set_qPy(lc, pps, cb_xBase, cb_yBase, log2_cb_size);
11931201 }
11941202
11951203 if (s->sh.cu_chroma_qp_offset_enabled_flag && cbf_chroma &&
@@ -1197,13 +1205,13 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0, · 1 unmodified line
11971205 int cu_chroma_qp_offset_flag = ff_hevc_cu_chroma_qp_offset_flag(lc);
11981206 if (cu_chroma_qp_offset_flag) {
11991207 int cu_chroma_qp_offset_idx = 0;
1200− if (s->ps.pps->chroma_qp_offset_list_len_minus1 > 0) {
1201− cu_chroma_qp_offset_idx = ff_hevc_cu_chroma_qp_offset_idx(lc, s->ps.pps->chroma_qp_offset_list_len_minus1);
1208+ if (pps->chroma_qp_offset_list_len_minus1 > 0) {
1209+ cu_chroma_qp_offset_idx = ff_hevc_cu_chroma_qp_offset_idx(lc, pps->chroma_qp_offset_list_len_minus1);
12021210 av_log(s->avctx, AV_LOG_ERROR,
12031211 "cu_chroma_qp_offset_idx not yet tested.\n");
12041212 }
1205− lc->tu.cu_qp_offset_cb = s->ps.pps->cb_qp_offset_list[cu_chroma_qp_offset_idx];
1206− lc->tu.cu_qp_offset_cr = s->ps.pps->cr_qp_offset_list[cu_chroma_qp_offset_idx];
1213+ lc->tu.cu_qp_offset_cb = pps->cb_qp_offset_list[cu_chroma_qp_offset_idx];
1214+ lc->tu.cu_qp_offset_cr = pps->cr_qp_offset_list[cu_chroma_qp_offset_idx];
12071215 } else {
12081216 lc->tu.cu_qp_offset_cb = 0;
12091217 lc->tu.cu_qp_offset_cr = 0;
@@ -1232,37 +1240,37 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0, · 22 unmodified lines
12321240 lc->tu.cross_pf = 0;
12331241
12341242 if (cbf_luma)
1235− ff_hevc_hls_residual_coding(lc, s->ps.pps, x0, y0, log2_trafo_size, scan_idx, 0);
1236− if (s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 || s->ps.sps->chroma_format_idc == 3)) {
1237− int trafo_size_h = 1 << (log2_trafo_size_c + s->ps.sps->hshift[1]);
1238− int trafo_size_v = 1 << (log2_trafo_size_c + s->ps.sps->vshift[1]);
1239− lc->tu.cross_pf = (s->ps.pps->cross_component_prediction_enabled_flag && cbf_luma &&
1243+ ff_hevc_hls_residual_coding(lc, pps, x0, y0, log2_trafo_size, scan_idx, 0);
1244+ if (sps->chroma_format_idc && (log2_trafo_size > 2 || sps->chroma_format_idc == 3)) {
1245+ int trafo_size_h = 1 << (log2_trafo_size_c + sps->hshift[1]);
1246+ int trafo_size_v = 1 << (log2_trafo_size_c + sps->vshift[1]);
1247+ lc->tu.cross_pf = (pps->cross_component_prediction_enabled_flag && cbf_luma &&
12401248 (lc->cu.pred_mode == MODE_INTER ||
12411249 (lc->tu.chroma_mode_c == 4)));
12421250
12431251 if (lc->tu.cross_pf) {
12441252 hls_cross_component_pred(lc, 0);
12451253 }
1246− for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) {
1254+ for (i = 0; i < (sps->chroma_format_idc == 2 ? 2 : 1); i++) {
12471255 if (lc->cu.pred_mode == MODE_INTRA) {
12481256 ff_hevc_set_neighbour_available(lc, x0, y0 + (i << log2_trafo_size_c),
1249− trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size);
1250− s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0 + (i << log2_trafo_size_c), 1);
1257+ trafo_size_h, trafo_size_v, sps->log2_ctb_size);
1258+ s->hpc.intra_pred[log2_trafo_size_c - 2](lc, pps, x0, y0 + (i << log2_trafo_size_c), 1);
12511259 }
12521260 if (cbf_cb[i])
1253− ff_hevc_hls_residual_coding(lc, s->ps.pps, x0, y0 + (i << log2_trafo_size_c),
1261+ ff_hevc_hls_residual_coding(lc, pps, x0, y0 + (i << log2_trafo_size_c),
12541262 log2_trafo_size_c, scan_idx_c, 1);
12551263 else
12561264 if (lc->tu.cross_pf) {
12571265 ptrdiff_t stride = s->cur_frame->f->linesize[1];
1258− int hshift = s->ps.sps->hshift[1];
1259− int vshift = s->ps.sps->vshift[1];
1266+ int hshift = sps->hshift[1];
1267+ int vshift = sps->vshift[1];
12601268 const int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer;
12611269 int16_t *coeffs = (int16_t*)lc->edge_emu_buffer2;
12621270 int size = 1 << log2_trafo_size_c;
12631271
12641272 uint8_t *dst = &s->cur_frame->f->data[1][(y0 >> vshift) * stride +
1265− ((x0 >> hshift) << s->ps.sps->pixel_shift)];
1273+ ((x0 >> hshift) << sps->pixel_shift)];
12661274 for (i = 0; i < (size * size); i++) {
12671275 coeffs[i] = ((lc->tu.res_scale_val * coeffs_y[i]) >> 3);
12681276 }
@@ -1273,82 +1281,82 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0, · 4 unmodified lines
12731281 if (lc->tu.cross_pf) {
12741282 hls_cross_component_pred(lc, 1);
12751283 }
1276− for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) {
1284+ for (i = 0; i < (sps->chroma_format_idc == 2 ? 2 : 1); i++) {
12771285 if (lc->cu.pred_mode == MODE_INTRA) {
12781286 ff_hevc_set_neighbour_available(lc, x0, y0 + (i << log2_trafo_size_c),
1279− trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size);
1280− s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0 + (i << log2_trafo_size_c), 2);
1287+ trafo_size_h, trafo_size_v, sps->log2_ctb_size);
1288+ s->hpc.intra_pred[log2_trafo_size_c - 2](lc, pps, x0, y0 + (i << log2_trafo_size_c), 2);
12811289 }
12821290 if (cbf_cr[i])
1283− ff_hevc_hls_residual_coding(lc, s->ps.pps, x0, y0 + (i << log2_trafo_size_c),
1291+ ff_hevc_hls_residual_coding(lc, pps, x0, y0 + (i << log2_trafo_size_c),
12841292 log2_trafo_size_c, scan_idx_c, 2);
12851293 else
12861294 if (lc->tu.cross_pf) {
12871295 ptrdiff_t stride = s->cur_frame->f->linesize[2];
1288− int hshift = s->ps.sps->hshift[2];
1289− int vshift = s->ps.sps->vshift[2];
1296+ int hshift = sps->hshift[2];
1297+ int vshift = sps->vshift[2];
12901298 const int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer;
12911299 int16_t *coeffs = (int16_t*)lc->edge_emu_buffer2;
12921300 int size = 1 << log2_trafo_size_c;
12931301
12941302 uint8_t *dst = &s->cur_frame->f->data[2][(y0 >> vshift) * stride +
1295− ((x0 >> hshift) << s->ps.sps->pixel_shift)];
1303+ ((x0 >> hshift) << sps->pixel_shift)];
12961304 for (i = 0; i < (size * size); i++) {
12971305 coeffs[i] = ((lc->tu.res_scale_val * coeffs_y[i]) >> 3);
12981306 }
12991307 s->hevcdsp.add_residual[log2_trafo_size_c-2](dst, coeffs, stride);
13001308 }
13011309 }
1302− } else if (s->ps.sps->chroma_format_idc && blk_idx == 3) {
1310+ } else if (sps->chroma_format_idc && blk_idx == 3) {
13031311 int trafo_size_h = 1 << (log2_trafo_size + 1);
1304− int trafo_size_v = 1 << (log2_trafo_size + s->ps.sps->vshift[1]);
1305− for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) {
1312+ int trafo_size_v = 1 << (log2_trafo_size + sps->vshift[1]);
1313+ for (i = 0; i < (sps->chroma_format_idc == 2 ? 2 : 1); i++) {
13061314 if (lc->cu.pred_mode == MODE_INTRA) {
13071315 ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << log2_trafo_size),
1308− trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size);
1309− s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase + (i << log2_trafo_size), 1);
1316+ trafo_size_h, trafo_size_v, sps->log2_ctb_size);
1317+ s->hpc.intra_pred[log2_trafo_size - 2](lc, pps, xBase, yBase + (i << log2_trafo_size), 1);
13101318 }
13111319 if (cbf_cb[i])
1312− ff_hevc_hls_residual_coding(lc, s->ps.pps, xBase, yBase + (i << log2_trafo_size),
1320+ ff_hevc_hls_residual_coding(lc, pps, xBase, yBase + (i << log2_trafo_size),
13131321 log2_trafo_size, scan_idx_c, 1);
13141322 }
1315− for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) {
1323+ for (i = 0; i < (sps->chroma_format_idc == 2 ? 2 : 1); i++) {
13161324 if (lc->cu.pred_mode == MODE_INTRA) {
13171325 ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << log2_trafo_size),
1318− trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size);
1319− s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase + (i << log2_trafo_size), 2);
1326+ trafo_size_h, trafo_size_v, sps->log2_ctb_size);
1327+ s->hpc.intra_pred[log2_trafo_size - 2](lc, pps, xBase, yBase + (i << log2_trafo_size), 2);
13201328 }
13211329 if (cbf_cr[i])
1322− ff_hevc_hls_residual_coding(lc, s->ps.pps, xBase, yBase + (i << log2_trafo_size),
1330+ ff_hevc_hls_residual_coding(lc, pps, xBase, yBase + (i << log2_trafo_size),
13231331 log2_trafo_size, scan_idx_c, 2);
13241332 }
13251333 }
1326− } else if (s->ps.sps->chroma_format_idc && lc->cu.pred_mode == MODE_INTRA) {
1327− if (log2_trafo_size > 2 || s->ps.sps->chroma_format_idc == 3) {
1328− int trafo_size_h = 1 << (log2_trafo_size_c + s->ps.sps->hshift[1]);
1329− int trafo_size_v = 1 << (log2_trafo_size_c + s->ps.sps->vshift[1]);
1334+ } else if (sps->chroma_format_idc && lc->cu.pred_mode == MODE_INTRA) {
1335+ if (log2_trafo_size > 2 || sps->chroma_format_idc == 3) {
1336+ int trafo_size_h = 1 << (log2_trafo_size_c + sps->hshift[1]);
1337+ int trafo_size_v = 1 << (log2_trafo_size_c + sps->vshift[1]);
13301338 ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size_h, trafo_size_v,
1331− s->ps.sps->log2_ctb_size);
1332− s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0, 1);
1333− s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0, 2);
1334− if (s->ps.sps->chroma_format_idc == 2) {
1339+ sps->log2_ctb_size);
1340+ s->hpc.intra_pred[log2_trafo_size_c - 2](lc, pps, x0, y0, 1);
1341+ s->hpc.intra_pred[log2_trafo_size_c - 2](lc, pps, x0, y0, 2);
1342+ if (sps->chroma_format_idc == 2) {
13351343 ff_hevc_set_neighbour_available(lc, x0, y0 + (1 << log2_trafo_size_c),
1336− trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size);
1337− s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0 + (1 << log2_trafo_size_c), 1);
1338− s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0 + (1 << log2_trafo_size_c), 2);
1344+ trafo_size_h, trafo_size_v, sps->log2_ctb_size);
1345+ s->hpc.intra_pred[log2_trafo_size_c - 2](lc, pps, x0, y0 + (1 << log2_trafo_size_c), 1);
1346+ s->hpc.intra_pred[log2_trafo_size_c - 2](lc, pps, x0, y0 + (1 << log2_trafo_size_c), 2);
13391347 }
13401348 } else if (blk_idx == 3) {
13411349 int trafo_size_h = 1 << (log2_trafo_size + 1);
1342− int trafo_size_v = 1 << (log2_trafo_size + s->ps.sps->vshift[1]);
1350+ int trafo_size_v = 1 << (log2_trafo_size + sps->vshift[1]);
13431351 ff_hevc_set_neighbour_available(lc, xBase, yBase,
1344− trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size);
1345− s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase, 1);
1346− s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase, 2);
1347− if (s->ps.sps->chroma_format_idc == 2) {
1352+ trafo_size_h, trafo_size_v, sps->log2_ctb_size);
1353+ s->hpc.intra_pred[log2_trafo_size - 2](lc, pps, xBase, yBase, 1);
1354+ s->hpc.intra_pred[log2_trafo_size - 2](lc, pps, xBase, yBase, 2);
1355+ if (sps->chroma_format_idc == 2) {
13481356 ff_hevc_set_neighbour_available(lc, xBase, yBase + (1 << log2_trafo_size),
1349− trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size);
1350− s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase + (1 << log2_trafo_size), 1);
1351− s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase + (1 << log2_trafo_size), 2);
1357+ trafo_size_h, trafo_size_v, sps->log2_ctb_size);
1358+ s->hpc.intra_pred[log2_trafo_size - 2](lc, pps, xBase, yBase + (1 << log2_trafo_size), 1);
1359+ s->hpc.intra_pred[log2_trafo_size - 2](lc, pps, xBase, yBase + (1 << log2_trafo_size), 2);
13521360 }
13531361 }
13541362 }
@@ -1356,14 +1364,15 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0, · 1 unmodified line
13561364 return 0;
13571365 }
13581366
1359−static void set_deblocking_bypass(const HEVCContext *s, int x0, int y0, int log2_cb_size)
1367+static void set_deblocking_bypass(const HEVCContext *s, const HEVCSPS *sps,
1368+ int x0, int y0, int log2_cb_size)
13601369 {
13611370 int cb_size = 1 << log2_cb_size;
1362− int log2_min_pu_size = s->ps.sps->log2_min_pu_size;
1371+ int log2_min_pu_size = sps->log2_min_pu_size;
13631372
1364− int min_pu_width = s->ps.sps->min_pu_width;
1365− int x_end = FFMIN(x0 + cb_size, s->ps.sps->width);
1366− int y_end = FFMIN(y0 + cb_size, s->ps.sps->height);
1373+ int min_pu_width = sps->min_pu_width;
1374+ int x_end = FFMIN(x0 + cb_size, sps->width);
1375+ int y_end = FFMIN(y0 + cb_size, sps->height);
13671376 int i, j;
13681377
13691378 for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
@@ -1371,7 +1380,9 @@ static void set_deblocking_bypass(const HEVCContext *s, int x0, int y0, int log2 · 1 unmodified line
13711380 s->is_pcm[i + j * min_pu_width] = 2;
13721381 }
13731382
1374−static int hls_transform_tree(HEVCLocalContext *lc, int x0, int y0,
1383+static int hls_transform_tree(HEVCLocalContext *lc,
1384+ const HEVCPPS *pps, const HEVCSPS *sps,
1385+ int x0, int y0,
13751386 int xBase, int yBase, int cb_xBase, int cb_yBase,
13761387 int log2_cb_size, int log2_trafo_size,
13771388 int trafo_depth, int blk_idx,
@@ -1391,7 +1402,7 @@ static int hls_transform_tree(HEVCLocalContext *lc, int x0, int y0, · 13 unmodified lines
13911402 if (lc->cu.intra_split_flag) {
13921403 if (trafo_depth == 1) {
13931404 lc->tu.intra_pred_mode = lc->pu.intra_pred_mode[blk_idx];
1394− if (s->ps.sps->chroma_format_idc == 3) {
1405+ if (sps->chroma_format_idc == 3) {
13951406 lc->tu.intra_pred_mode_c = lc->pu.intra_pred_mode_c[blk_idx];
13961407 lc->tu.chroma_mode_c = lc->pu.chroma_mode_c[blk_idx];
13971408 } else {
@@ -1405,33 +1416,33 @@ static int hls_transform_tree(HEVCLocalContext *lc, int x0, int y0, · 7 unmodified lines
14051416 lc->tu.chroma_mode_c = lc->pu.chroma_mode_c[0];
14061417 }
14071418
1408− if (log2_trafo_size <= s->ps.sps->log2_max_trafo_size &&
1409− log2_trafo_size > s->ps.sps->log2_min_tb_size &&
1419+ if (log2_trafo_size <= sps->log2_max_trafo_size &&
1420+ log2_trafo_size > sps->log2_min_tb_size &&
14101421 trafo_depth < lc->cu.max_trafo_depth &&
14111422 !(lc->cu.intra_split_flag && trafo_depth == 0)) {
14121423 split_transform_flag = ff_hevc_split_transform_flag_decode(lc, log2_trafo_size);
14131424 } else {
1414− int inter_split = s->ps.sps->max_transform_hierarchy_depth_inter == 0 &&
1425+ int inter_split = sps->max_transform_hierarchy_depth_inter == 0 &&
14151426 lc->cu.pred_mode == MODE_INTER &&
14161427 lc->cu.part_mode != PART_2Nx2N &&
14171428 trafo_depth == 0;
14181429
1419− split_transform_flag = log2_trafo_size > s->ps.sps->log2_max_trafo_size ||
1430+ split_transform_flag = log2_trafo_size > sps->log2_max_trafo_size ||
14201431 (lc->cu.intra_split_flag && trafo_depth == 0) ||
14211432 inter_split;
14221433 }
14231434
1424− if (s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 || s->ps.sps->chroma_format_idc == 3)) {
1435+ if (sps->chroma_format_idc && (log2_trafo_size > 2 || sps->chroma_format_idc == 3)) {
14251436 if (trafo_depth == 0 || cbf_cb[0]) {
14261437 cbf_cb[0] = ff_hevc_cbf_cb_cr_decode(lc, trafo_depth);
1427− if (s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
1438+ if (sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
14281439 cbf_cb[1] = ff_hevc_cbf_cb_cr_decode(lc, trafo_depth);
14291440 }
14301441 }
14311442
14321443 if (trafo_depth == 0 || cbf_cr[0]) {
14331444 cbf_cr[0] = ff_hevc_cbf_cb_cr_decode(lc, trafo_depth);
1434− if (s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
1445+ if (sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
14351446 cbf_cr[1] = ff_hevc_cbf_cb_cr_decode(lc, trafo_depth);
14361447 }
14371448 }
@@ -1444,7 +1455,8 @@ static int hls_transform_tree(HEVCLocalContext *lc, int x0, int y0, · 6 unmodified lines
14441455
14451456 #define SUBDIVIDE(x, y, idx) \
14461457 do { \
1447− ret = hls_transform_tree(lc, x, y, x0, y0, cb_xBase, cb_yBase, log2_cb_size,\
1458+ ret = hls_transform_tree(lc, pps, sps, \
1459+ x, y, x0, y0, cb_xBase, cb_yBase, log2_cb_size, \
14481460 log2_trafo_size - 1, trafo_depth + 1, idx, \
14491461 cbf_cb, cbf_cr); \
14501462 if (ret < 0) \
@@ -1458,18 +1470,19 @@ do { · 7 unmodified lines
14581470
14591471 #undef SUBDIVIDE
14601472 } else {
1461− int min_tu_size = 1 << s->ps.sps->log2_min_tb_size;
1462− int log2_min_tu_size = s->ps.sps->log2_min_tb_size;
1463− int min_tu_width = s->ps.sps->min_tb_width;
1473+ int min_tu_size = 1 << sps->log2_min_tb_size;
1474+ int log2_min_tu_size = sps->log2_min_tb_size;
1475+ int min_tu_width = sps->min_tb_width;
14641476 int cbf_luma = 1;
14651477
14661478 if (lc->cu.pred_mode == MODE_INTRA || trafo_depth != 0 ||
14671479 cbf_cb[0] || cbf_cr[0] ||
1468− (s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
1480+ (sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
14691481 cbf_luma = ff_hevc_cbf_luma_decode(lc, trafo_depth);
14701482 }
14711483
1472− ret = hls_transform_unit(lc, x0, y0, xBase, yBase, cb_xBase, cb_yBase,
1484+ ret = hls_transform_unit(lc, pps, sps,
1485+ x0, y0, xBase, yBase, cb_xBase, cb_yBase,
14731486 log2_cb_size, log2_trafo_size,
14741487 blk_idx, cbf_luma, cbf_cb, cbf_cr);
14751488 if (ret < 0)
@@ -1485,51 +1498,53 @@ do { · 9 unmodified lines
14851498 }
14861499 }
14871500 if (!s->sh.disable_deblocking_filter_flag) {
1488− ff_hevc_deblocking_boundary_strengths(lc, s->ps.pps, x0, y0, log2_trafo_size);
1489− if (s->ps.pps->transquant_bypass_enable_flag &&
1501+ ff_hevc_deblocking_boundary_strengths(lc, pps, x0, y0, log2_trafo_size);
1502+ if (pps->transquant_bypass_enable_flag &&
14901503 lc->cu.cu_transquant_bypass_flag)
1491− set_deblocking_bypass(s, x0, y0, log2_trafo_size);
1504+ set_deblocking_bypass(s, sps, x0, y0, log2_trafo_size);
14921505 }
14931506 }
14941507 return 0;
14951508 }
14961509
1497−static int hls_pcm_sample(HEVCLocalContext *lc, int x0, int y0, int log2_cb_size)
1510+static int hls_pcm_sample(HEVCLocalContext *lc, const HEVCPPS *pps,
1511+ int x0, int y0, int log2_cb_size)
14981512 {
14991513 const HEVCContext *const s = lc->parent;
1514+ const HEVCSPS *const sps = pps->sps;
15001515 GetBitContext gb;
15011516 int cb_size = 1 << log2_cb_size;
15021517 ptrdiff_t stride0 = s->cur_frame->f->linesize[0];
15031518 ptrdiff_t stride1 = s->cur_frame->f->linesize[1];
15041519 ptrdiff_t stride2 = s->cur_frame->f->linesize[2];
1505− uint8_t *dst0 = &s->cur_frame->f->data[0][y0 * stride0 + (x0 << s->ps.sps->pixel_shift)];
1506− uint8_t *dst1 = &s->cur_frame->f->data[1][(y0 >> s->ps.sps->vshift[1]) * stride1 + ((x0 >> s->ps.sps->hshift[1]) << s->ps.sps->pixel_shift)];
1507− uint8_t *dst2 = &s->cur_frame->f->data[2][(y0 >> s->ps.sps->vshift[2]) * stride2 + ((x0 >> s->ps.sps->hshift[2]) << s->ps.sps->pixel_shift)];
1508−
1509− int length = cb_size * cb_size * s->ps.sps->pcm.bit_depth +
1510− (((cb_size >> s->ps.sps->hshift[1]) * (cb_size >> s->ps.sps->vshift[1])) +
1511− ((cb_size >> s->ps.sps->hshift[2]) * (cb_size >> s->ps.sps->vshift[2]))) *
1512− s->ps.sps->pcm.bit_depth_chroma;
1520+ uint8_t *dst0 = &s->cur_frame->f->data[0][y0 * stride0 + (x0 << sps->pixel_shift)];
1521+ uint8_t *dst1 = &s->cur_frame->f->data[1][(y0 >> sps->vshift[1]) * stride1 + ((x0 >> sps->hshift[1]) << sps->pixel_shift)];
1522+ uint8_t *dst2 = &s->cur_frame->f->data[2][(y0 >> sps->vshift[2]) * stride2 + ((x0 >> sps->hshift[2]) << sps->pixel_shift)];
1523+
1524+ int length = cb_size * cb_size * sps->pcm.bit_depth +
1525+ (((cb_size >> sps->hshift[1]) * (cb_size >> sps->vshift[1])) +
1526+ ((cb_size >> sps->hshift[2]) * (cb_size >> sps->vshift[2]))) *
1527+ sps->pcm.bit_depth_chroma;
15131528 const uint8_t *pcm = skip_bytes(&lc->cc, (length + 7) >> 3);
15141529 int ret;
15151530
15161531 if (!s->sh.disable_deblocking_filter_flag)
1517− ff_hevc_deblocking_boundary_strengths(lc, s->ps.pps, x0, y0, log2_cb_size);
1532+ ff_hevc_deblocking_boundary_strengths(lc, pps, x0, y0, log2_cb_size);
15181533
15191534 ret = init_get_bits(&gb, pcm, length);
15201535 if (ret < 0)
15211536 return ret;
15221537
1523− s->hevcdsp.put_pcm(dst0, stride0, cb_size, cb_size, &gb, s->ps.sps->pcm.bit_depth);
1524− if (s->ps.sps->chroma_format_idc) {
1538+ s->hevcdsp.put_pcm(dst0, stride0, cb_size, cb_size, &gb, sps->pcm.bit_depth);
1539+ if (sps->chroma_format_idc) {
15251540 s->hevcdsp.put_pcm(dst1, stride1,
1526− cb_size >> s->ps.sps->hshift[1],
1527− cb_size >> s->ps.sps->vshift[1],
1528− &gb, s->ps.sps->pcm.bit_depth_chroma);
1541+ cb_size >> sps->hshift[1],
1542+ cb_size >> sps->vshift[1],
1543+ &gb, sps->pcm.bit_depth_chroma);
15291544 s->hevcdsp.put_pcm(dst2, stride2,
1530− cb_size >> s->ps.sps->hshift[2],
1531− cb_size >> s->ps.sps->vshift[2],
1532− &gb, s->ps.sps->pcm.bit_depth_chroma);
1545+ cb_size >> sps->hshift[2],
1546+ cb_size >> sps->vshift[2],
1547+ &gb, sps->pcm.bit_depth_chroma);
15331548 }
15341549
15351550 return 0;
@@ -1551,32 +1566,34 @@ static int hls_pcm_sample(HEVCLocalContext *lc, int x0, int y0, int log2_cb_size · 15 unmodified lines
15511566 * @param luma_offset additive offset applied to the luma prediction value
15521567 */
15531568
1554−static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride,
1569+static void luma_mc_uni(HEVCLocalContext *lc,
1570+ const HEVCPPS *pps, const HEVCSPS *sps,
1571+ uint8_t *dst, ptrdiff_t dststride,
15551572 const AVFrame *ref, const Mv *mv, int x_off, int y_off,
15561573 int block_w, int block_h, int luma_weight, int luma_offset)
15571574 {
15581575 const HEVCContext *const s = lc->parent;
15591576 const uint8_t *src = ref->data[0];
15601577 ptrdiff_t srcstride = ref->linesize[0];
1561− int pic_width = s->ps.sps->width;
1562− int pic_height = s->ps.sps->height;
1578+ int pic_width = sps->width;
1579+ int pic_height = sps->height;
15631580 int mx = mv->x & 3;
15641581 int my = mv->y & 3;
1565− int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) ||
1566− (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag);
1582+ int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && pps->weighted_pred_flag) ||
1583+ (s->sh.slice_type == HEVC_SLICE_B && pps->weighted_bipred_flag);
15671584 int idx = hevc_pel_weight[block_w];
15681585
15691586 x_off += mv->x >> 2;
15701587 y_off += mv->y >> 2;
1571− src += y_off * srcstride + (x_off * (1 << s->ps.sps->pixel_shift));
1588+ src += y_off * srcstride + (x_off * (1 << sps->pixel_shift));
15721589
15731590 if (x_off < QPEL_EXTRA_BEFORE || y_off < QPEL_EXTRA_AFTER ||
15741591 x_off >= pic_width - block_w - QPEL_EXTRA_AFTER ||
15751592 y_off >= pic_height - block_h - QPEL_EXTRA_AFTER ||
15761593 ref == s->cur_frame->f) {
1577− const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;
1578− int offset = QPEL_EXTRA_BEFORE * srcstride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
1579− int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
1594+ const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << sps->pixel_shift;
1595+ int offset = QPEL_EXTRA_BEFORE * srcstride + (QPEL_EXTRA_BEFORE << sps->pixel_shift);
1596+ int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << sps->pixel_shift);
15801597
15811598 s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src - offset,
15821599 edge_emu_stride, srcstride,
@@ -1613,7 +1630,9 @@ static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride, · 30 unmodified lines
16131630 * @param mv1 motion vector1 (relative to block position) to get pixel data from
16141631 * @param current_mv current motion vector structure
16151632 */
1616− static void luma_mc_bi(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride,
1633+static void luma_mc_bi(HEVCLocalContext *lc,
1634+ const HEVCPPS *pps, const HEVCSPS *sps,
1635+ uint8_t *dst, ptrdiff_t dststride,
16171636 const AVFrame *ref0, const Mv *mv0, int x_off, int y_off,
16181637 int block_w, int block_h, const AVFrame *ref1,
16191638 const Mv *mv1, struct MvField *current_mv)
@@ -1621,29 +1640,29 @@ static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride, · 1 unmodified line
16211640 const HEVCContext *const s = lc->parent;
16221641 ptrdiff_t src0stride = ref0->linesize[0];
16231642 ptrdiff_t src1stride = ref1->linesize[0];
1624− int pic_width = s->ps.sps->width;
1625− int pic_height = s->ps.sps->height;
1643+ int pic_width = sps->width;
1644+ int pic_height = sps->height;
16261645 int mx0 = mv0->x & 3;
16271646 int my0 = mv0->y & 3;
16281647 int mx1 = mv1->x & 3;
16291648 int my1 = mv1->y & 3;
1630− int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) ||
1631− (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag);
1649+ int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && pps->weighted_pred_flag) ||
1650+ (s->sh.slice_type == HEVC_SLICE_B && pps->weighted_bipred_flag);
16321651 int x_off0 = x_off + (mv0->x >> 2);
16331652 int y_off0 = y_off + (mv0->y >> 2);
16341653 int x_off1 = x_off + (mv1->x >> 2);
16351654 int y_off1 = y_off + (mv1->y >> 2);
16361655 int idx = hevc_pel_weight[block_w];
16371656
1638− const uint8_t *src0 = ref0->data[0] + y_off0 * src0stride + (int)((unsigned)x_off0 << s->ps.sps->pixel_shift);
1639− const uint8_t *src1 = ref1->data[0] + y_off1 * src1stride + (int)((unsigned)x_off1 << s->ps.sps->pixel_shift);
1657+ const uint8_t *src0 = ref0->data[0] + y_off0 * src0stride + (int)((unsigned)x_off0 << sps->pixel_shift);
1658+ const uint8_t *src1 = ref1->data[0] + y_off1 * src1stride + (int)((unsigned)x_off1 << sps->pixel_shift);
16401659
16411660 if (x_off0 < QPEL_EXTRA_BEFORE || y_off0 < QPEL_EXTRA_AFTER ||
16421661 x_off0 >= pic_width - block_w - QPEL_EXTRA_AFTER ||
16431662 y_off0 >= pic_height - block_h - QPEL_EXTRA_AFTER) {
1644− const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;
1645− int offset = QPEL_EXTRA_BEFORE * src0stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
1646− int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
1663+ const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << sps->pixel_shift;
1664+ int offset = QPEL_EXTRA_BEFORE * src0stride + (QPEL_EXTRA_BEFORE << sps->pixel_shift);
1665+ int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << sps->pixel_shift);
16471666
16481667 s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src0 - offset,
16491668 edge_emu_stride, src0stride,
@@ -1658,9 +1677,9 @@ static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride, · 8 unmodified lines
16581677 if (x_off1 < QPEL_EXTRA_BEFORE || y_off1 < QPEL_EXTRA_AFTER ||
16591678 x_off1 >= pic_width - block_w - QPEL_EXTRA_AFTER ||
16601679 y_off1 >= pic_height - block_h - QPEL_EXTRA_AFTER) {
1661− const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;
1662− int offset = QPEL_EXTRA_BEFORE * src1stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
1663− int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift);
1680+ const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << sps->pixel_shift;
1681+ int offset = QPEL_EXTRA_BEFORE * src1stride + (QPEL_EXTRA_BEFORE << sps->pixel_shift);
1682+ int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << sps->pixel_shift);
16641683
16651684 s->vdsp.emulated_edge_mc(lc->edge_emu_buffer2, src1 - offset,
16661685 edge_emu_stride, src1stride,
@@ -1705,20 +1724,22 @@ static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride, · 38 unmodified lines
17051724 * @param chroma_offset additive offset applied to the chroma prediction value
17061725 */
17071726
1708−static void chroma_mc_uni(HEVCLocalContext *lc, uint8_t *dst0,
1727+static void chroma_mc_uni(HEVCLocalContext *lc,
1728+ const HEVCPPS *pps, const HEVCSPS *sps,
1729+ uint8_t *dst0,
17091730 ptrdiff_t dststride, const uint8_t *src0, ptrdiff_t srcstride, int reflist,
17101731 int x_off, int y_off, int block_w, int block_h,
17111732 const struct MvField *current_mv, int chroma_weight, int chroma_offset)
17121733 {
17131734 const HEVCContext *const s = lc->parent;
1714− int pic_width = s->ps.sps->width >> s->ps.sps->hshift[1];
1715− int pic_height = s->ps.sps->height >> s->ps.sps->vshift[1];
1735+ int pic_width = sps->width >> sps->hshift[1];
1736+ int pic_height = sps->height >> sps->vshift[1];
17161737 const Mv *mv = &current_mv->mv[reflist];
1717− int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) ||
1718− (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag);
1738+ int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && pps->weighted_pred_flag) ||
1739+ (s->sh.slice_type == HEVC_SLICE_B && pps->weighted_bipred_flag);
17191740 int idx = hevc_pel_weight[block_w];
1720− int hshift = s->ps.sps->hshift[1];
1721− int vshift = s->ps.sps->vshift[1];
1741+ int hshift = sps->hshift[1];
1742+ int vshift = sps->vshift[1];
17221743 intptr_t mx = av_mod_uintp2(mv->x, 2 + hshift);
17231744 intptr_t my = av_mod_uintp2(mv->y, 2 + vshift);
17241745 intptr_t _mx = mx << (1 - hshift);
@@ -1727,16 +1748,16 @@ static void chroma_mc_uni(HEVCLocalContext *lc, uint8_t *dst0, · 2 unmodified lines
17271748
17281749 x_off += mv->x >> (2 + hshift);
17291750 y_off += mv->y >> (2 + vshift);
1730− src0 += y_off * srcstride + (x_off * (1 << s->ps.sps->pixel_shift));
1751+ src0 += y_off * srcstride + (x_off * (1 << sps->pixel_shift));
17311752
17321753 if (x_off < EPEL_EXTRA_BEFORE || y_off < EPEL_EXTRA_AFTER ||
17331754 x_off >= pic_width - block_w - EPEL_EXTRA_AFTER ||
17341755 y_off >= pic_height - block_h - EPEL_EXTRA_AFTER ||
17351756 emu) {
1736− const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;
1737− int offset0 = EPEL_EXTRA_BEFORE * (srcstride + (1 << s->ps.sps->pixel_shift));
1757+ const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << sps->pixel_shift;
1758+ int offset0 = EPEL_EXTRA_BEFORE * (srcstride + (1 << sps->pixel_shift));
17381759 int buf_offset0 = EPEL_EXTRA_BEFORE *
1739− (edge_emu_stride + (1 << s->ps.sps->pixel_shift));
1760+ (edge_emu_stride + (1 << sps->pixel_shift));
17401761 s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src0 - offset0,
17411762 edge_emu_stride, srcstride,
17421763 block_w + EPEL_EXTRA, block_h + EPEL_EXTRA,
@@ -1773,7 +1794,9 @@ static void chroma_mc_uni(HEVCLocalContext *lc, uint8_t *dst0, · 30 unmodified lines
17731794 * @param current_mv current motion vector structure
17741795 * @param cidx chroma component(cb, cr)
17751796 */
1776−static void chroma_mc_bi(HEVCLocalContext *lc, uint8_t *dst0, ptrdiff_t dststride,
1797+static void chroma_mc_bi(HEVCLocalContext *lc,
1798+ const HEVCPPS *pps, const HEVCSPS *sps,
1799+ uint8_t *dst0, ptrdiff_t dststride,
17771800 const AVFrame *ref0, const AVFrame *ref1,
17781801 int x_off, int y_off, int block_w, int block_h, const MvField *current_mv, int cidx)
17791802 {
@@ -1782,14 +1805,14 @@ static void chroma_mc_bi(HEVCLocalContext *lc, uint8_t *dst0, ptrdiff_t dststrid · 2 unmodified lines
17821805 const uint8_t *src2 = ref1->data[cidx+1];
17831806 ptrdiff_t src1stride = ref0->linesize[cidx+1];
17841807 ptrdiff_t src2stride = ref1->linesize[cidx+1];
1785− int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) ||
1786− (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag);
1787− int pic_width = s->ps.sps->width >> s->ps.sps->hshift[1];
1788− int pic_height = s->ps.sps->height >> s->ps.sps->vshift[1];
1808+ int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && pps->weighted_pred_flag) ||
1809+ (s->sh.slice_type == HEVC_SLICE_B && pps->weighted_bipred_flag);
1810+ int pic_width = sps->width >> sps->hshift[1];
1811+ int pic_height = sps->height >> sps->vshift[1];
17891812 const Mv *const mv0 = &current_mv->mv[0];
17901813 const Mv *const mv1 = &current_mv->mv[1];
1791− int hshift = s->ps.sps->hshift[1];
1792− int vshift = s->ps.sps->vshift[1];
1814+ int hshift = sps->hshift[1];
1815+ int vshift = sps->vshift[1];
17931816
17941817 intptr_t mx0 = av_mod_uintp2(mv0->x, 2 + hshift);
17951818 intptr_t my0 = av_mod_uintp2(mv0->y, 2 + vshift);
@@ -1805,16 +1828,16 @@ static void chroma_mc_bi(HEVCLocalContext *lc, uint8_t *dst0, ptrdiff_t dststrid · 9 unmodified lines
18051828 int x_off1 = x_off + (mv1->x >> (2 + hshift));
18061829 int y_off1 = y_off + (mv1->y >> (2 + vshift));
18071830 int idx = hevc_pel_weight[block_w];
1808− src1 += y_off0 * src1stride + (int)((unsigned)x_off0 << s->ps.sps->pixel_shift);
1809− src2 += y_off1 * src2stride + (int)((unsigned)x_off1 << s->ps.sps->pixel_shift);
1831+ src1 += y_off0 * src1stride + (int)((unsigned)x_off0 << sps->pixel_shift);
1832+ src2 += y_off1 * src2stride + (int)((unsigned)x_off1 << sps->pixel_shift);
18101833
18111834 if (x_off0 < EPEL_EXTRA_BEFORE || y_off0 < EPEL_EXTRA_AFTER ||
18121835 x_off0 >= pic_width - block_w - EPEL_EXTRA_AFTER ||
18131836 y_off0 >= pic_height - block_h - EPEL_EXTRA_AFTER) {
1814− const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;
1815− int offset1 = EPEL_EXTRA_BEFORE * (src1stride + (1 << s->ps.sps->pixel_shift));
1837+ const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << sps->pixel_shift;
1838+ int offset1 = EPEL_EXTRA_BEFORE * (src1stride + (1 << sps->pixel_shift));
18161839 int buf_offset1 = EPEL_EXTRA_BEFORE *
1817− (edge_emu_stride + (1 << s->ps.sps->pixel_shift));
1840+ (edge_emu_stride + (1 << sps->pixel_shift));
18181841
18191842 s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src1 - offset1,
18201843 edge_emu_stride, src1stride,
@@ -1830,10 +1853,10 @@ static void chroma_mc_bi(HEVCLocalContext *lc, uint8_t *dst0, ptrdiff_t dststrid · 9 unmodified lines
18301853 if (x_off1 < EPEL_EXTRA_BEFORE || y_off1 < EPEL_EXTRA_AFTER ||
18311854 x_off1 >= pic_width - block_w - EPEL_EXTRA_AFTER ||
18321855 y_off1 >= pic_height - block_h - EPEL_EXTRA_AFTER) {
1833− const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;
1834− int offset1 = EPEL_EXTRA_BEFORE * (src2stride + (1 << s->ps.sps->pixel_shift));
1856+ const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << sps->pixel_shift;
1857+ int offset1 = EPEL_EXTRA_BEFORE * (src2stride + (1 << sps->pixel_shift));
18351858 int buf_offset1 = EPEL_EXTRA_BEFORE *
1836− (edge_emu_stride + (1 << s->ps.sps->pixel_shift));
1859+ (edge_emu_stride + (1 << sps->pixel_shift));
18371860
18381861 s->vdsp.emulated_edge_mc(lc->edge_emu_buffer2, src2 - offset1,
18391862 edge_emu_stride, src2stride,
@@ -1874,7 +1897,9 @@ static void hevc_await_progress(const HEVCContext *s, const HEVCFrame *ref, · 34 unmodified lines
18741897 }
18751898 }
18761899
1877−static void hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, int x0, int y0, int nPbW,
1900+static void hevc_luma_mv_mvp_mode(HEVCLocalContext *lc,
1901+ const HEVCPPS *pps, const HEVCSPS *sps,
1902+ int x0, int y0, int nPbW,
18781903 int nPbH, int log2_cb_size, int part_idx,
18791904 int merge_idx, MvField *mv)
18801905 {
@@ -1882,7 +1907,7 @@ static void hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, int x0, int y0, int nPbW · 1 unmodified line
18821907 enum InterPredIdc inter_pred_idc = PRED_L0;
18831908 int mvp_flag;
18841909
1885− ff_hevc_set_neighbour_available(lc, x0, y0, nPbW, nPbH, s->ps.sps->log2_ctb_size);
1910+ ff_hevc_set_neighbour_available(lc, x0, y0, nPbW, nPbH, sps->log2_ctb_size);
18861911 mv->pred_flag = 0;
18871912 if (s->sh.slice_type == HEVC_SLICE_B)
18881913 inter_pred_idc = ff_hevc_inter_pred_idc_decode(lc, nPbW, nPbH);
@@ -1894,7 +1919,7 @@ static void hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, int x0, int y0, int nPbW · 5 unmodified lines
18941919 mv->pred_flag = PF_L0;
18951920 ff_hevc_hls_mvd_coding(lc, x0, y0, 0);
18961921 mvp_flag = ff_hevc_mvp_lx_flag_decode(lc);
1897− ff_hevc_luma_mv_mvp_mode(lc, s->ps.pps, x0, y0, nPbW, nPbH, log2_cb_size,
1922+ ff_hevc_luma_mv_mvp_mode(lc, pps, x0, y0, nPbW, nPbH, log2_cb_size,
18981923 part_idx, merge_idx, mv, mvp_flag, 0);
18991924 mv->mv[0].x += lc->pu.mvd.x;
19001925 mv->mv[0].y += lc->pu.mvd.y;
@@ -1912,25 +1937,26 @@ static void hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, int x0, int y0, int nPbW · 11 unmodified lines
19121937
19131938 mv->pred_flag += PF_L1;
19141939 mvp_flag = ff_hevc_mvp_lx_flag_decode(lc);
1915− ff_hevc_luma_mv_mvp_mode(lc, s->ps.pps, x0, y0, nPbW, nPbH, log2_cb_size,
1940+ ff_hevc_luma_mv_mvp_mode(lc, pps, x0, y0, nPbW, nPbH, log2_cb_size,
19161941 part_idx, merge_idx, mv, mvp_flag, 1);
19171942 mv->mv[1].x += lc->pu.mvd.x;
19181943 mv->mv[1].y += lc->pu.mvd.y;
19191944 }
19201945 }
19211946
1922−static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0,
1923− int nPbW, int nPbH,
1947+static void hls_prediction_unit(HEVCLocalContext *lc,
1948+ const HEVCPPS *pps, const HEVCSPS *sps,
1949+ int x0, int y0, int nPbW, int nPbH,
19241950 int log2_cb_size, int partIdx, int idx)
19251951 {
19261952 #define POS(c_idx, x, y) \
1927− &s->cur_frame->f->data[c_idx][((y) >> s->ps.sps->vshift[c_idx]) * linesize[c_idx] + \
1928− (((x) >> s->ps.sps->hshift[c_idx]) << s->ps.sps->pixel_shift)]
1953+ &s->cur_frame->f->data[c_idx][((y) >> sps->vshift[c_idx]) * linesize[c_idx] + \
1954+ (((x) >> sps->hshift[c_idx]) << sps->pixel_shift)]
19291955 const HEVCContext *const s = lc->parent;
19301956 int merge_idx = 0;
19311957 struct MvField current_mv = {{{ 0 }}};
19321958
1933− int min_pu_width = s->ps.sps->min_pu_width;
1959+ int min_pu_width = sps->min_pu_width;
19341960
19351961 MvField *tab_mvf = s->cur_frame->tab_mvf;
19361962 const RefPicList *refPicList = s->cur_frame->refPicList;
@@ -1939,8 +1965,8 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 2 unmodified lines
19391965 uint8_t *dst0 = POS(0, x0, y0);
19401966 uint8_t *dst1 = POS(1, x0, y0);
19411967 uint8_t *dst2 = POS(2, x0, y0);
1942− int log2_min_cb_size = s->ps.sps->log2_min_cb_size;
1943− int min_cb_width = s->ps.sps->min_cb_width;
1968+ int log2_min_cb_size = sps->log2_min_cb_size;
1969+ int min_cb_width = sps->min_cb_width;
19441970 int x_cb = x0 >> log2_min_cb_size;
19451971 int y_cb = y0 >> log2_min_cb_size;
19461972 int x_pu, y_pu;
@@ -1957,18 +1983,18 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 10 unmodified lines
19571983 else
19581984 merge_idx = 0;
19591985
1960− ff_hevc_luma_mv_merge_mode(lc, s->ps.pps, x0, y0, nPbW, nPbH, log2_cb_size,
1986+ ff_hevc_luma_mv_merge_mode(lc, pps, x0, y0, nPbW, nPbH, log2_cb_size,
19611987 partIdx, merge_idx, &current_mv);
19621988 } else {
1963− hevc_luma_mv_mvp_mode(lc, x0, y0, nPbW, nPbH, log2_cb_size,
1989+ hevc_luma_mv_mvp_mode(lc, pps, sps, x0, y0, nPbW, nPbH, log2_cb_size,
19641990 partIdx, merge_idx, &current_mv);
19651991 }
19661992
1967− x_pu = x0 >> s->ps.sps->log2_min_pu_size;
1968− y_pu = y0 >> s->ps.sps->log2_min_pu_size;
1993+ x_pu = x0 >> sps->log2_min_pu_size;
1994+ y_pu = y0 >> sps->log2_min_pu_size;
19691995
1970− for (j = 0; j < nPbH >> s->ps.sps->log2_min_pu_size; j++)
1971− for (i = 0; i < nPbW >> s->ps.sps->log2_min_pu_size; i++)
1996+ for (j = 0; j < nPbH >> sps->log2_min_pu_size; j++)
1997+ for (i = 0; i < nPbW >> sps->log2_min_pu_size; i++)
19721998 tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
19731999
19742000 if (current_mv.pred_flag & PF_L0) {
@@ -1985,59 +2011,59 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 10 unmodified lines
19852011 }
19862012
19872013 if (current_mv.pred_flag == PF_L0) {
1988− int x0_c = x0 >> s->ps.sps->hshift[1];
1989− int y0_c = y0 >> s->ps.sps->vshift[1];
1990− int nPbW_c = nPbW >> s->ps.sps->hshift[1];
1991− int nPbH_c = nPbH >> s->ps.sps->vshift[1];
2014+ int x0_c = x0 >> sps->hshift[1];
2015+ int y0_c = y0 >> sps->vshift[1];
2016+ int nPbW_c = nPbW >> sps->hshift[1];
2017+ int nPbH_c = nPbH >> sps->vshift[1];
19922018
1993− luma_mc_uni(lc, dst0, linesize[0], ref0->f,
2019+ luma_mc_uni(lc, pps, sps, dst0, linesize[0], ref0->f,
19942020 &current_mv.mv[0], x0, y0, nPbW, nPbH,
19952021 s->sh.luma_weight_l0[current_mv.ref_idx[0]],
19962022 s->sh.luma_offset_l0[current_mv.ref_idx[0]]);
19972023
1998− if (s->ps.sps->chroma_format_idc) {
1999− chroma_mc_uni(lc, dst1, linesize[1], ref0->f->data[1], ref0->f->linesize[1],
2024+ if (sps->chroma_format_idc) {
2025+ chroma_mc_uni(lc, pps, sps, dst1, linesize[1], ref0->f->data[1], ref0->f->linesize[1],
20002026 0, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
20012027 s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0]);
2002− chroma_mc_uni(lc, dst2, linesize[2], ref0->f->data[2], ref0->f->linesize[2],
2028+ chroma_mc_uni(lc, pps, sps, dst2, linesize[2], ref0->f->data[2], ref0->f->linesize[2],
20032029 0, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
20042030 s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1]);
20052031 }
20062032 } else if (current_mv.pred_flag == PF_L1) {
2007− int x0_c = x0 >> s->ps.sps->hshift[1];
2008− int y0_c = y0 >> s->ps.sps->vshift[1];
2009− int nPbW_c = nPbW >> s->ps.sps->hshift[1];
2010− int nPbH_c = nPbH >> s->ps.sps->vshift[1];
2033+ int x0_c = x0 >> sps->hshift[1];
2034+ int y0_c = y0 >> sps->vshift[1];
2035+ int nPbW_c = nPbW >> sps->hshift[1];
2036+ int nPbH_c = nPbH >> sps->vshift[1];
20112037
2012− luma_mc_uni(lc, dst0, linesize[0], ref1->f,
2038+ luma_mc_uni(lc, pps, sps, dst0, linesize[0], ref1->f,
20132039 &current_mv.mv[1], x0, y0, nPbW, nPbH,
20142040 s->sh.luma_weight_l1[current_mv.ref_idx[1]],
20152041 s->sh.luma_offset_l1[current_mv.ref_idx[1]]);
20162042
2017− if (s->ps.sps->chroma_format_idc) {
2018− chroma_mc_uni(lc, dst1, linesize[1], ref1->f->data[1], ref1->f->linesize[1],
2043+ if (sps->chroma_format_idc) {
2044+ chroma_mc_uni(lc, pps, sps, dst1, linesize[1], ref1->f->data[1], ref1->f->linesize[1],
20192045 1, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
20202046 s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0]);
20212047
2022− chroma_mc_uni(lc, dst2, linesize[2], ref1->f->data[2], ref1->f->linesize[2],
2048+ chroma_mc_uni(lc, pps, sps, dst2, linesize[2], ref1->f->data[2], ref1->f->linesize[2],
20232049 1, x0_c, y0_c, nPbW_c, nPbH_c, &current_mv,
20242050 s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1]);
20252051 }
20262052 } else if (current_mv.pred_flag == PF_BI) {
2027− int x0_c = x0 >> s->ps.sps->hshift[1];
2028− int y0_c = y0 >> s->ps.sps->vshift[1];
2029− int nPbW_c = nPbW >> s->ps.sps->hshift[1];
2030− int nPbH_c = nPbH >> s->ps.sps->vshift[1];
2053+ int x0_c = x0 >> sps->hshift[1];
2054+ int y0_c = y0 >> sps->vshift[1];
2055+ int nPbW_c = nPbW >> sps->hshift[1];
2056+ int nPbH_c = nPbH >> sps->vshift[1];
20312057
2032− luma_mc_bi(lc, dst0, linesize[0], ref0->f,
2058+ luma_mc_bi(lc, pps, sps, dst0, linesize[0], ref0->f,
20332059 &current_mv.mv[0], x0, y0, nPbW, nPbH,
20342060 ref1->f, &current_mv.mv[1], &current_mv);
20352061
2036− if (s->ps.sps->chroma_format_idc) {
2037− chroma_mc_bi(lc, dst1, linesize[1], ref0->f, ref1->f,
2062+ if (sps->chroma_format_idc) {
2063+ chroma_mc_bi(lc, pps, sps, dst1, linesize[1], ref0->f, ref1->f,
20382064 x0_c, y0_c, nPbW_c, nPbH_c, &current_mv, 0);
20392065
2040− chroma_mc_bi(lc, dst2, linesize[2], ref0->f, ref1->f,
2066+ chroma_mc_bi(lc, pps, sps, dst2, linesize[2], ref0->f, ref1->f,
20412067 x0_c, y0_c, nPbW_c, nPbH_c, &current_mv, 1);
20422068 }
20432069 }
@@ -2046,23 +2072,24 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 2 unmodified lines
20462072 /**
20472073 * 8.4.1
20482074 */
2049−static int luma_intra_pred_mode(HEVCLocalContext *lc, int x0, int y0, int pu_size,
2075+static int luma_intra_pred_mode(HEVCLocalContext *lc, const HEVCSPS *sps,
2076+ int x0, int y0, int pu_size,
20502077 int prev_intra_luma_pred_flag)
20512078 {
20522079 const HEVCContext *const s = lc->parent;
2053− int x_pu = x0 >> s->ps.sps->log2_min_pu_size;
2054− int y_pu = y0 >> s->ps.sps->log2_min_pu_size;
2055− int min_pu_width = s->ps.sps->min_pu_width;
2056− int size_in_pus = pu_size >> s->ps.sps->log2_min_pu_size;
2057− int x0b = av_mod_uintp2(x0, s->ps.sps->log2_ctb_size);
2058− int y0b = av_mod_uintp2(y0, s->ps.sps->log2_ctb_size);
2080+ int x_pu = x0 >> sps->log2_min_pu_size;
2081+ int y_pu = y0 >> sps->log2_min_pu_size;
2082+ int min_pu_width = sps->min_pu_width;
2083+ int size_in_pus = pu_size >> sps->log2_min_pu_size;
2084+ int x0b = av_mod_uintp2(x0, sps->log2_ctb_size);
2085+ int y0b = av_mod_uintp2(y0, sps->log2_ctb_size);
20592086
20602087 int cand_up = (lc->ctb_up_flag || y0b) ?
20612088 s->tab_ipm[(y_pu - 1) * min_pu_width + x_pu] : INTRA_DC;
20622089 int cand_left = (lc->ctb_left_flag || x0b) ?
20632090 s->tab_ipm[y_pu * min_pu_width + x_pu - 1] : INTRA_DC;
20642091
2065− int y_ctb = (y0 >> (s->ps.sps->log2_ctb_size)) << (s->ps.sps->log2_ctb_size);
2092+ int y_ctb = (y0 >> (sps->log2_ctb_size)) << (sps->log2_ctb_size);
20662093
20672094 MvField *tab_mvf = s->cur_frame->tab_mvf;
20682095 int intra_pred_mode;
@@ -2126,16 +2153,17 @@ static int luma_intra_pred_mode(HEVCLocalContext *lc, int x0, int y0, int pu_siz · 57 unmodified lines
21262153 return intra_pred_mode;
21272154 }
21282155
2129−static av_always_inline void set_ct_depth(const HEVCContext *s, int x0, int y0,
2156+static av_always_inline void set_ct_depth(const HEVCSPS *sps, uint8_t *tab_ct_depth,
2157+ int x0, int y0,
21302158 int log2_cb_size, int ct_depth)
21312159 {
2132− int length = (1 << log2_cb_size) >> s->ps.sps->log2_min_cb_size;
2133− int x_cb = x0 >> s->ps.sps->log2_min_cb_size;
2134− int y_cb = y0 >> s->ps.sps->log2_min_cb_size;
2160+ int length = (1 << log2_cb_size) >> sps->log2_min_cb_size;
2161+ int x_cb = x0 >> sps->log2_min_cb_size;
2162+ int y_cb = y0 >> sps->log2_min_cb_size;
21352163 int y;
21362164
21372165 for (y = 0; y < length; y++)
2138− memset(&s->tab_ct_depth[(y_cb + y) * s->ps.sps->min_cb_width + x_cb],
2166+ memset(&tab_ct_depth[(y_cb + y) * sps->min_cb_width + x_cb],
21392167 ct_depth, length);
21402168 }
21412169
@@ -2143,10 +2171,10 @@ static const uint8_t tab_mode_idx[] = { · 1 unmodified line
21432171 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20,
21442172 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31};
21452173
2146−static void intra_prediction_unit(HEVCLocalContext *lc, int x0, int y0,
2174+static void intra_prediction_unit(HEVCLocalContext *lc, const HEVCSPS *sps,
2175+ int x0, int y0,
21472176 int log2_cb_size)
21482177 {
2149− const HEVCContext *const s = lc->parent;
21502178 static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 };
21512179 uint8_t prev_intra_luma_pred_flag[4];
21522180 int split = lc->cu.part_mode == PART_NxN;
@@ -2167,12 +2195,12 @@ static void intra_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 14 unmodified lines
21672195 lc->pu.rem_intra_luma_pred_mode = ff_hevc_rem_intra_luma_pred_mode_decode(lc);
21682196
21692197 lc->pu.intra_pred_mode[2 * i + j] =
2170− luma_intra_pred_mode(lc, x0 + pb_size * j, y0 + pb_size * i, pb_size,
2198+ luma_intra_pred_mode(lc, sps, x0 + pb_size * j, y0 + pb_size * i, pb_size,
21712199 prev_intra_luma_pred_flag[2 * i + j]);
21722200 }
21732201 }
21742202
2175− if (s->ps.sps->chroma_format_idc == 3) {
2203+ if (sps->chroma_format_idc == 3) {
21762204 for (i = 0; i < side; i++) {
21772205 for (j = 0; j < side; j++) {
21782206 lc->pu.chroma_mode_c[2 * i + j] = chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(lc);
@@ -2186,7 +2214,7 @@ static void intra_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 7 unmodified lines
21862214 }
21872215 }
21882216 }
2189− } else if (s->ps.sps->chroma_format_idc == 2) {
2217+ } else if (sps->chroma_format_idc == 2) {
21902218 int mode_idx;
21912219 lc->pu.chroma_mode_c[0] = chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(lc);
21922220 if (chroma_mode != 4) {
@@ -2198,7 +2226,7 @@ static void intra_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 5 unmodified lines
21982226 mode_idx = lc->pu.intra_pred_mode[0];
21992227 }
22002228 lc->pu.intra_pred_mode_c[0] = tab_mode_idx[mode_idx];
2201− } else if (s->ps.sps->chroma_format_idc != 0) {
2229+ } else if (sps->chroma_format_idc != 0) {
22022230 chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(lc);
22032231 if (chroma_mode != 4) {
22042232 if (lc->pu.intra_pred_mode[0] == intra_chroma_table[chroma_mode])
@@ -2212,16 +2240,17 @@ static void intra_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 7 unmodified lines
22122240 }
22132241
22142242 static void intra_prediction_unit_default_value(HEVCLocalContext *lc,
2243+ const HEVCSPS *sps,
22152244 int x0, int y0,
22162245 int log2_cb_size)
22172246 {
22182247 const HEVCContext *const s = lc->parent;
22192248 int pb_size = 1 << log2_cb_size;
2220− int size_in_pus = pb_size >> s->ps.sps->log2_min_pu_size;
2221− int min_pu_width = s->ps.sps->min_pu_width;
2249+ int size_in_pus = pb_size >> sps->log2_min_pu_size;
2250+ int min_pu_width = sps->min_pu_width;
22222251 MvField *tab_mvf = s->cur_frame->tab_mvf;
2223− int x_pu = x0 >> s->ps.sps->log2_min_pu_size;
2224− int y_pu = y0 >> s->ps.sps->log2_min_pu_size;
2252+ int x_pu = x0 >> sps->log2_min_pu_size;
2253+ int y_pu = y0 >> sps->log2_min_pu_size;
22252254 int j, k;
22262255
22272256 if (size_in_pus == 0)
@@ -2234,16 +2263,18 @@ static void intra_prediction_unit_default_value(HEVCLocalContext *lc, · 6 unmodified lines
22342263 tab_mvf[(y_pu + j) * min_pu_width + x_pu + k].pred_flag = PF_INTRA;
22352264 }
22362265
2237−static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, int y0, int log2_cb_size)
2266+static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s,
2267+ const HEVCPPS *pps, const HEVCSPS *sps,
2268+ int x0, int y0, int log2_cb_size)
22382269 {
22392270 int cb_size = 1 << log2_cb_size;
2240− int log2_min_cb_size = s->ps.sps->log2_min_cb_size;
2271+ int log2_min_cb_size = sps->log2_min_cb_size;
22412272 int length = cb_size >> log2_min_cb_size;
2242− int min_cb_width = s->ps.sps->min_cb_width;
2273+ int min_cb_width = sps->min_cb_width;
22432274 int x_cb = x0 >> log2_min_cb_size;
22442275 int y_cb = y0 >> log2_min_cb_size;
22452276 int idx = log2_cb_size - 2;
2246− int qp_block_mask = (1<<(s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_qp_delta_depth)) - 1;
2277+ int qp_block_mask = (1 << (sps->log2_ctb_size - pps->diff_cu_qp_delta_depth)) - 1;
22472278 int x, y, ret;
22482279
22492280 lc->cu.x = x0;
@@ -2255,16 +2286,16 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, i · 5 unmodified lines
22552286 SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0;
22562287 for (x = 0; x < 4; x++)
22572288 lc->pu.intra_pred_mode[x] = 1;
2258− if (s->ps.pps->transquant_bypass_enable_flag) {
2289+ if (pps->transquant_bypass_enable_flag) {
22592290 lc->cu.cu_transquant_bypass_flag = ff_hevc_cu_transquant_bypass_flag_decode(lc);
22602291 if (lc->cu.cu_transquant_bypass_flag)
2261− set_deblocking_bypass(s, x0, y0, log2_cb_size);
2292+ set_deblocking_bypass(s, sps, x0, y0, log2_cb_size);
22622293 } else
22632294 lc->cu.cu_transquant_bypass_flag = 0;
22642295
22652296 if (s->sh.slice_type != HEVC_SLICE_I) {
2266− const int x0b = av_mod_uintp2(x0, s->ps.sps->log2_ctb_size);
2267− const int y0b = av_mod_uintp2(y0, s->ps.sps->log2_ctb_size);
2297+ const int x0b = av_mod_uintp2(x0, sps->log2_ctb_size);
2298+ const int y0b = av_mod_uintp2(y0, sps->log2_ctb_size);
22682299 uint8_t skip_flag = ff_hevc_skip_flag_decode(lc, x0b, y0b, x_cb, y_cb,
22692300 min_cb_width);
22702301
@@ -2283,75 +2314,93 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, i · 12 unmodified lines
22832314 }
22842315
22852316 if (SAMPLE_CTB(s->skip_flag, x_cb, y_cb)) {
2286− hls_prediction_unit(lc, x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
2287− intra_prediction_unit_default_value(lc, x0, y0, log2_cb_size);
2317+ hls_prediction_unit(lc, pps, sps,
2318+ x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
2319+ intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size);
22882320
22892321 if (!s->sh.disable_deblocking_filter_flag)
2290− ff_hevc_deblocking_boundary_strengths(lc, s->ps.pps, x0, y0, log2_cb_size);
2322+ ff_hevc_deblocking_boundary_strengths(lc, pps, x0, y0, log2_cb_size);
22912323 } else {
22922324 int pcm_flag = 0;
22932325
22942326 if (s->sh.slice_type != HEVC_SLICE_I)
22952327 lc->cu.pred_mode = ff_hevc_pred_mode_decode(lc);
22962328 if (lc->cu.pred_mode != MODE_INTRA ||
2297− log2_cb_size == s->ps.sps->log2_min_cb_size) {
2298− lc->cu.part_mode = ff_hevc_part_mode_decode(lc, s->ps.sps, log2_cb_size);
2329+ log2_cb_size == sps->log2_min_cb_size) {
2330+ lc->cu.part_mode = ff_hevc_part_mode_decode(lc, sps, log2_cb_size);
22992331 lc->cu.intra_split_flag = lc->cu.part_mode == PART_NxN &&
23002332 lc->cu.pred_mode == MODE_INTRA;
23012333 }
23022334
23032335 if (lc->cu.pred_mode == MODE_INTRA) {
2304− if (lc->cu.part_mode == PART_2Nx2N && s->ps.sps->pcm_enabled &&
2305− log2_cb_size >= s->ps.sps->pcm.log2_min_pcm_cb_size &&
2306− log2_cb_size <= s->ps.sps->pcm.log2_max_pcm_cb_size) {
2336+ if (lc->cu.part_mode == PART_2Nx2N && sps->pcm_enabled &&
2337+ log2_cb_size >= sps->pcm.log2_min_pcm_cb_size &&
2338+ log2_cb_size <= sps->pcm.log2_max_pcm_cb_size) {
23072339 pcm_flag = ff_hevc_pcm_flag_decode(lc);
23082340 }
23092341 if (pcm_flag) {
2310− intra_prediction_unit_default_value(lc, x0, y0, log2_cb_size);
2311− ret = hls_pcm_sample(lc, x0, y0, log2_cb_size);
2312− if (s->ps.sps->pcm_loop_filter_disabled)
2313− set_deblocking_bypass(s, x0, y0, log2_cb_size);
2342+ intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size);
2343+ ret = hls_pcm_sample(lc, pps, x0, y0, log2_cb_size);
2344+ if (sps->pcm_loop_filter_disabled)
2345+ set_deblocking_bypass(s, sps, x0, y0, log2_cb_size);
23142346
23152347 if (ret < 0)
23162348 return ret;
23172349 } else {
2318− intra_prediction_unit(lc, x0, y0, log2_cb_size);
2350+ intra_prediction_unit(lc, sps, x0, y0, log2_cb_size);
23192351 }
23202352 } else {
2321− intra_prediction_unit_default_value(lc, x0, y0, log2_cb_size);
2353+ intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size);
23222354 switch (lc->cu.part_mode) {
23232355 case PART_2Nx2N:
2324− hls_prediction_unit(lc, x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
2356+ hls_prediction_unit(lc, pps, sps,
2357+ x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
23252358 break;
23262359 case PART_2NxN:
2327− hls_prediction_unit(lc, x0, y0, cb_size, cb_size / 2, log2_cb_size, 0, idx);
2328− hls_prediction_unit(lc, x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx);
2360+ hls_prediction_unit(lc, pps, sps,
2361+ x0, y0, cb_size, cb_size / 2, log2_cb_size, 0, idx);
2362+ hls_prediction_unit(lc, pps, sps,
2363+ x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx);
23292364 break;
23302365 case PART_Nx2N:
2331− hls_prediction_unit(lc, x0, y0, cb_size / 2, cb_size, log2_cb_size, 0, idx - 1);
2332− hls_prediction_unit(lc, x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);
2366+ hls_prediction_unit(lc, pps, sps,
2367+ x0, y0, cb_size / 2, cb_size, log2_cb_size, 0, idx - 1);
2368+ hls_prediction_unit(lc, pps, sps,
2369+ x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);
23332370 break;
23342371 case PART_2NxnU:
2335− hls_prediction_unit(lc, x0, y0, cb_size, cb_size / 4, log2_cb_size, 0, idx);
2336− hls_prediction_unit(lc, x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);
2372+ hls_prediction_unit(lc, pps, sps,
2373+ x0, y0, cb_size, cb_size / 4, log2_cb_size, 0, idx);
2374+ hls_prediction_unit(lc, pps, sps,
2375+ x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);
23372376 break;
23382377 case PART_2NxnD:
2339− hls_prediction_unit(lc, x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0, idx);
2340− hls_prediction_unit(lc, x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx);
2378+ hls_prediction_unit(lc, pps, sps,
2379+ x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0, idx);
2380+ hls_prediction_unit(lc, pps, sps,
2381+ x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx);
23412382 break;
23422383 case PART_nLx2N:
2343− hls_prediction_unit(lc, x0, y0, cb_size / 4, cb_size, log2_cb_size, 0, idx - 2);
2344− hls_prediction_unit(lc, x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
2384+ hls_prediction_unit(lc, pps, sps,
2385+ x0, y0, cb_size / 4, cb_size, log2_cb_size, 0, idx - 2);
2386+ hls_prediction_unit(lc, pps, sps,
2387+ x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
23452388 break;
23462389 case PART_nRx2N:
2347− hls_prediction_unit(lc, x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0, idx - 2);
2348− hls_prediction_unit(lc, x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
2390+ hls_prediction_unit(lc, pps, sps,
2391+ x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0, idx - 2);
2392+ hls_prediction_unit(lc, pps, sps,
2393+ x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
23492394 break;
23502395 case PART_NxN:
2351− hls_prediction_unit(lc, x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0, idx - 1);
2352− hls_prediction_unit(lc, x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
2353− hls_prediction_unit(lc, x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
2354− hls_prediction_unit(lc, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
2396+ hls_prediction_unit(lc, pps, sps,
2397+ x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0, idx - 1);
2398+ hls_prediction_unit(lc, pps, sps,
2399+ x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
2400+ hls_prediction_unit(lc, pps, sps,
2401+ x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
2402+ hls_prediction_unit(lc, pps, sps,
2403+ x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
23552404 break;
23562405 }
23572406 }
@@ -2366,22 +2415,22 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, i · 8 unmodified lines
23662415 if (rqt_root_cbf) {
23672416 const static int cbf[2] = { 0 };
23682417 lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ?
2369− s->ps.sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag :
2370− s->ps.sps->max_transform_hierarchy_depth_inter;
2371− ret = hls_transform_tree(lc, x0, y0, x0, y0, x0, y0,
2418+ sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag :
2419+ sps->max_transform_hierarchy_depth_inter;
2420+ ret = hls_transform_tree(lc, pps, sps, x0, y0, x0, y0, x0, y0,
23722421 log2_cb_size,
23732422 log2_cb_size, 0, 0, cbf, cbf);
23742423 if (ret < 0)
23752424 return ret;
23762425 } else {
23772426 if (!s->sh.disable_deblocking_filter_flag)
2378− ff_hevc_deblocking_boundary_strengths(lc, s->ps.pps, x0, y0, log2_cb_size);
2427+ ff_hevc_deblocking_boundary_strengths(lc, pps, x0, y0, log2_cb_size);
23792428 }
23802429 }
23812430 }
23822431
2383− if (s->ps.pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0)
2384− ff_hevc_set_qPy(lc, s->ps.pps, x0, y0, log2_cb_size);
2432+ if (pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0)
2433+ ff_hevc_set_qPy(lc, pps, x0, y0, log2_cb_size);
23852434
23862435 x = y_cb * min_cb_width + x_cb;
23872436 for (y = 0; y < length; y++) {
@@ -2394,12 +2443,14 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, i · 6 unmodified lines
23942443 lc->qPy_pred = lc->qp_y;
23952444 }
23962445
2397− set_ct_depth(s, x0, y0, log2_cb_size, lc->ct_depth);
2446+ set_ct_depth(sps, s->tab_ct_depth, x0, y0, log2_cb_size, lc->ct_depth);
23982447
23992448 return 0;
24002449 }
24012450
2402−static int hls_coding_quadtree(HEVCLocalContext *lc, int x0, int y0,
2451+static int hls_coding_quadtree(HEVCLocalContext *lc,
2452+ const HEVCPPS *pps, const HEVCSPS *sps,
2453+ int x0, int y0,
24032454 int log2_cb_size, int cb_depth)
24042455 {
24052456 const HEVCContext *const s = lc->parent;
@@ -2408,49 +2459,49 @@ static int hls_coding_quadtree(HEVCLocalContext *lc, int x0, int y0, · 2 unmodified lines
24082459 int split_cu;
24092460
24102461 lc->ct_depth = cb_depth;
2411− if (x0 + cb_size <= s->ps.sps->width &&
2412− y0 + cb_size <= s->ps.sps->height &&
2413− log2_cb_size > s->ps.sps->log2_min_cb_size) {
2414− split_cu = ff_hevc_split_coding_unit_flag_decode(lc, s->ps.sps, cb_depth, x0, y0);
2462+ if (x0 + cb_size <= sps->width &&
2463+ y0 + cb_size <= sps->height &&
2464+ log2_cb_size > sps->log2_min_cb_size) {
2465+ split_cu = ff_hevc_split_coding_unit_flag_decode(lc, sps, cb_depth, x0, y0);
24152466 } else {
2416− split_cu = (log2_cb_size > s->ps.sps->log2_min_cb_size);
2467+ split_cu = (log2_cb_size > sps->log2_min_cb_size);
24172468 }
2418− if (s->ps.pps->cu_qp_delta_enabled_flag &&
2419− log2_cb_size >= s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_qp_delta_depth) {
2469+ if (pps->cu_qp_delta_enabled_flag &&
2470+ log2_cb_size >= sps->log2_ctb_size - pps->diff_cu_qp_delta_depth) {
24202471 lc->tu.is_cu_qp_delta_coded = 0;
24212472 lc->tu.cu_qp_delta = 0;
24222473 }
24232474
24242475 if (s->sh.cu_chroma_qp_offset_enabled_flag &&
2425− log2_cb_size >= s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_chroma_qp_offset_depth) {
2476+ log2_cb_size >= sps->log2_ctb_size - pps->diff_cu_chroma_qp_offset_depth) {
24262477 lc->tu.is_cu_chroma_qp_offset_coded = 0;
24272478 }
24282479
24292480 if (split_cu) {
2430− int qp_block_mask = (1<<(s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_qp_delta_depth)) - 1;
2481+ int qp_block_mask = (1 << (sps->log2_ctb_size - pps->diff_cu_qp_delta_depth)) - 1;
24312482 const int cb_size_split = cb_size >> 1;
24322483 const int x1 = x0 + cb_size_split;
24332484 const int y1 = y0 + cb_size_split;
24342485
24352486 int more_data = 0;
24362487
2437− more_data = hls_coding_quadtree(lc, x0, y0, log2_cb_size - 1, cb_depth + 1);
2488+ more_data = hls_coding_quadtree(lc, pps, sps, x0, y0, log2_cb_size - 1, cb_depth + 1);
24382489 if (more_data < 0)
24392490 return more_data;
24402491
2441− if (more_data && x1 < s->ps.sps->width) {
2442− more_data = hls_coding_quadtree(lc, x1, y0, log2_cb_size - 1, cb_depth + 1);
2492+ if (more_data && x1 < sps->width) {
2493+ more_data = hls_coding_quadtree(lc, pps, sps, x1, y0, log2_cb_size - 1, cb_depth + 1);
24432494 if (more_data < 0)
24442495 return more_data;
24452496 }
2446− if (more_data && y1 < s->ps.sps->height) {
2447− more_data = hls_coding_quadtree(lc, x0, y1, log2_cb_size - 1, cb_depth + 1);
2497+ if (more_data && y1 < sps->height) {
2498+ more_data = hls_coding_quadtree(lc, pps, sps, x0, y1, log2_cb_size - 1, cb_depth + 1);
24482499 if (more_data < 0)
24492500 return more_data;
24502501 }
2451− if (more_data && x1 < s->ps.sps->width &&
2452− y1 < s->ps.sps->height) {
2453− more_data = hls_coding_quadtree(lc, x1, y1, log2_cb_size - 1, cb_depth + 1);
2502+ if (more_data && x1 < sps->width &&
2503+ y1 < sps->height) {
2504+ more_data = hls_coding_quadtree(lc, pps, sps, x1, y1, log2_cb_size - 1, cb_depth + 1);
24542505 if (more_data < 0)
24552506 return more_data;
24562507 }
@@ -2460,20 +2511,20 @@ static int hls_coding_quadtree(HEVCLocalContext *lc, int x0, int y0, · 3 unmodified lines
24602511 lc->qPy_pred = lc->qp_y;
24612512
24622513 if (more_data)
2463− return ((x1 + cb_size_split) < s->ps.sps->width ||
2464− (y1 + cb_size_split) < s->ps.sps->height);
2514+ return ((x1 + cb_size_split) < sps->width ||
2515+ (y1 + cb_size_split) < sps->height);
24652516 else
24662517 return 0;
24672518 } else {
2468− ret = hls_coding_unit(lc, s, x0, y0, log2_cb_size);
2519+ ret = hls_coding_unit(lc, s, pps, sps, x0, y0, log2_cb_size);
24692520 if (ret < 0)
24702521 return ret;
24712522 if ((!((x0 + cb_size) %
2472− (1 << (s->ps.sps->log2_ctb_size))) ||
2473− (x0 + cb_size >= s->ps.sps->width)) &&
2523+ (1 << (sps->log2_ctb_size))) ||
2524+ (x0 + cb_size >= sps->width)) &&
24742525 (!((y0 + cb_size) %
2475− (1 << (s->ps.sps->log2_ctb_size))) ||
2476− (y0 + cb_size >= s->ps.sps->height))) {
2526+ (1 << (sps->log2_ctb_size))) ||
2527+ (y0 + cb_size >= sps->height))) {
24772528 int end_of_slice_flag = ff_hevc_end_of_slice_flag_decode(lc);
24782529 return !end_of_slice_flag;
24792530 } else {
@@ -2484,65 +2535,68 @@ static int hls_coding_quadtree(HEVCLocalContext *lc, int x0, int y0, · 4 unmodified lines
24842535 return 0;
24852536 }
24862537
2487−static void hls_decode_neighbour(HEVCLocalContext *lc, int x_ctb, int y_ctb,
2488− int ctb_addr_ts)
2538+static void hls_decode_neighbour(HEVCLocalContext *lc,
2539+ const HEVCPPS *pps, const HEVCSPS *sps,
2540+ int x_ctb, int y_ctb, int ctb_addr_ts)
24892541 {
24902542 const HEVCContext *const s = lc->parent;
2491− int ctb_size = 1 << s->ps.sps->log2_ctb_size;
2492− int ctb_addr_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2543+ int ctb_size = 1 << sps->log2_ctb_size;
2544+ int ctb_addr_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts];
24932545 int ctb_addr_in_slice = ctb_addr_rs - s->sh.slice_addr;
24942546
24952547 s->tab_slice_address[ctb_addr_rs] = s->sh.slice_addr;
24962548
2497− if (s->ps.pps->entropy_coding_sync_enabled_flag) {
2549+ if (pps->entropy_coding_sync_enabled_flag) {
24982550 if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
24992551 lc->first_qp_group = 1;
2500− lc->end_of_tiles_x = s->ps.sps->width;
2501− } else if (s->ps.pps->tiles_enabled_flag) {
2502− if (ctb_addr_ts && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]) {
2503− int idxX = s->ps.pps->col_idxX[x_ctb >> s->ps.sps->log2_ctb_size];
2504− lc->end_of_tiles_x = x_ctb + (s->ps.pps->column_width[idxX] << s->ps.sps->log2_ctb_size);
2552+ lc->end_of_tiles_x = sps->width;
2553+ } else if (pps->tiles_enabled_flag) {
2554+ if (ctb_addr_ts && pps->tile_id[ctb_addr_ts] != pps->tile_id[ctb_addr_ts - 1]) {
2555+ int idxX = pps->col_idxX[x_ctb >> sps->log2_ctb_size];
2556+ lc->end_of_tiles_x = x_ctb + (pps->column_width[idxX] << sps->log2_ctb_size);
25052557 lc->first_qp_group = 1;
25062558 }
25072559 } else {
2508− lc->end_of_tiles_x = s->ps.sps->width;
2560+ lc->end_of_tiles_x = sps->width;
25092561 }
25102562
2511− lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, s->ps.sps->height);
2563+ lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, sps->height);
25122564
25132565 lc->boundary_flags = 0;
2514− if (s->ps.pps->tiles_enabled_flag) {
2515− 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]])
2566+ if (pps->tiles_enabled_flag) {
2567+ if (x_ctb > 0 && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs - 1]])
25162568 lc->boundary_flags |= BOUNDARY_LEFT_TILE;
25172569 if (x_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - 1])
25182570 lc->boundary_flags |= BOUNDARY_LEFT_SLICE;
2519− 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]])
2571+ if (y_ctb > 0 && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs - sps->ctb_width]])
25202572 lc->boundary_flags |= BOUNDARY_UPPER_TILE;
2521− if (y_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - s->ps.sps->ctb_width])
2573+ if (y_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - sps->ctb_width])
25222574 lc->boundary_flags |= BOUNDARY_UPPER_SLICE;
25232575 } else {
25242576 if (ctb_addr_in_slice <= 0)
25252577 lc->boundary_flags |= BOUNDARY_LEFT_SLICE;
2526− if (ctb_addr_in_slice < s->ps.sps->ctb_width)
2578+ if (ctb_addr_in_slice < sps->ctb_width)
25272579 lc->boundary_flags |= BOUNDARY_UPPER_SLICE;
25282580 }
25292581
25302582 lc->ctb_left_flag = ((x_ctb > 0) && (ctb_addr_in_slice > 0) && !(lc->boundary_flags & BOUNDARY_LEFT_TILE));
2531− lc->ctb_up_flag = ((y_ctb > 0) && (ctb_addr_in_slice >= s->ps.sps->ctb_width) && !(lc->boundary_flags & BOUNDARY_UPPER_TILE));
2532− 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]]));
2533− 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]]));
2583+ lc->ctb_up_flag = ((y_ctb > 0) && (ctb_addr_in_slice >= sps->ctb_width) && !(lc->boundary_flags & BOUNDARY_UPPER_TILE));
2584+ lc->ctb_up_right_flag = ((y_ctb > 0) && (ctb_addr_in_slice+1 >= sps->ctb_width) && (pps->tile_id[ctb_addr_ts] == pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs+1 - sps->ctb_width]]));
2585+ lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0) && (ctb_addr_in_slice-1 >= sps->ctb_width) && (pps->tile_id[ctb_addr_ts] == pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - sps->ctb_width]]));
25342586 }
25352587
25362588 static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
25372589 {
25382590 HEVCLocalContext *const lc = &s->local_ctx[0];
2591+ const HEVCPPS *const pps = s->ps.pps;
2592+ const HEVCSPS *const sps = pps->sps;
25392593 const uint8_t *slice_data = gb->buffer + s->sh.data_offset;
25402594 const size_t slice_size = gb->buffer_end - gb->buffer - s->sh.data_offset;
2541− int ctb_size = 1 << s->ps.sps->log2_ctb_size;
2595+ int ctb_size = 1 << sps->log2_ctb_size;
25422596 int more_data = 1;
25432597 int x_ctb = 0;
25442598 int y_ctb = 0;
2545− int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
2599+ int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
25462600 int ret;
25472601
25482602 if (!ctb_addr_ts && s->sh.dependent_slice_segment_flag) {
@@ -2551,33 +2605,34 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) · 2 unmodified lines
25512605 }
25522606
25532607 if (s->sh.dependent_slice_segment_flag) {
2554− int prev_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
2608+ int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
25552609 if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {
25562610 av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n");
25572611 return AVERROR_INVALIDDATA;
25582612 }
25592613 }
25602614
2561− while (more_data && ctb_addr_ts < s->ps.sps->ctb_size) {
2562− int ctb_addr_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2615+ while (more_data && ctb_addr_ts < sps->ctb_size) {
2616+ int ctb_addr_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts];
25632617
2564− x_ctb = (ctb_addr_rs % ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size;
2565− y_ctb = (ctb_addr_rs / ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size;
2566− hls_decode_neighbour(lc, x_ctb, y_ctb, ctb_addr_ts);
2618+ x_ctb = (ctb_addr_rs % ((sps->width + ctb_size - 1) >> sps->log2_ctb_size)) << sps->log2_ctb_size;
2619+ y_ctb = (ctb_addr_rs / ((sps->width + ctb_size - 1) >> sps->log2_ctb_size)) << sps->log2_ctb_size;
2620+ hls_decode_neighbour(lc, pps, sps, x_ctb, y_ctb, ctb_addr_ts);
25672621
2568− ret = ff_hevc_cabac_init(lc, s->ps.pps, ctb_addr_ts, slice_data, slice_size);
2622+ ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, slice_data, slice_size);
25692623 if (ret < 0) {
25702624 s->tab_slice_address[ctb_addr_rs] = -1;
25712625 return ret;
25722626 }
25732627
2574− hls_sao_param(lc, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size);
2628+ hls_sao_param(lc, pps, sps,
2629+ x_ctb >> sps->log2_ctb_size, y_ctb >> sps->log2_ctb_size);
25752630
25762631 s->deblock[ctb_addr_rs].beta_offset = s->sh.beta_offset;
25772632 s->deblock[ctb_addr_rs].tc_offset = s->sh.tc_offset;
25782633 s->filter_slice_edges[ctb_addr_rs] = s->sh.slice_loop_filter_across_slices_enabled_flag;
25792634
2580− more_data = hls_coding_quadtree(lc, x_ctb, y_ctb, s->ps.sps->log2_ctb_size, 0);
2635+ more_data = hls_coding_quadtree(lc, pps, sps, x_ctb, y_ctb, sps->log2_ctb_size, 0);
25812636 if (more_data < 0) {
25822637 s->tab_slice_address[ctb_addr_rs] = -1;
25832638 return more_data;
@@ -2585,13 +2640,13 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) · 1 unmodified line
25852640
25862641
25872642 ctb_addr_ts++;
2588− ff_hevc_save_states(lc, s->ps.pps, ctb_addr_ts);
2589− ff_hevc_hls_filters(lc, s->ps.pps, x_ctb, y_ctb, ctb_size);
2643+ ff_hevc_save_states(lc, pps, ctb_addr_ts);
2644+ ff_hevc_hls_filters(lc, pps, x_ctb, y_ctb, ctb_size);
25902645 }
25912646
2592− if (x_ctb + ctb_size >= s->ps.sps->width &&
2593− y_ctb + ctb_size >= s->ps.sps->height)
2594− ff_hevc_hls_filter(lc, s->ps.pps, x_ctb, y_ctb, ctb_size);
2647+ if (x_ctb + ctb_size >= sps->width &&
2648+ y_ctb + ctb_size >= sps->height)
2649+ ff_hevc_hls_filter(lc, pps, x_ctb, y_ctb, ctb_size);
25952650
25962651 return ctb_addr_ts;
25972652 }
@@ -2601,11 +2656,13 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, · 3 unmodified lines
26012656 {
26022657 HEVCLocalContext *lc = &((HEVCLocalContext*)hevc_lclist)[self_id];
26032658 const HEVCContext *const s = lc->parent;
2604− int ctb_size = 1 << s->ps.sps->log2_ctb_size;
2659+ const HEVCPPS *const pps = s->ps.pps;
2660+ const HEVCSPS *const sps = pps->sps;
2661+ int ctb_size = 1 << sps->log2_ctb_size;
26052662 int more_data = 1;
26062663 int ctb_row = job;
2607− int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size);
2608− int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs];
2664+ int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * ((sps->width + ctb_size - 1) >> sps->log2_ctb_size);
2665+ int ctb_addr_ts = pps->ctb_addr_rs_to_ts[ctb_addr_rs];
26092666 int thread = ctb_row % s->threads_number;
26102667
26112668 const uint8_t *data = s->data + s->sh.offset[ctb_row];
@@ -2616,11 +2673,11 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, · 4 unmodified lines
26162673 if (ctb_row)
26172674 ff_init_cabac_decoder(&lc->cc, data, data_size);
26182675
2619− while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) {
2620− int x_ctb = (ctb_addr_rs % s->ps.sps->ctb_width) << s->ps.sps->log2_ctb_size;
2621− int y_ctb = (ctb_addr_rs / s->ps.sps->ctb_width) << s->ps.sps->log2_ctb_size;
2676+ while(more_data && ctb_addr_ts < sps->ctb_size) {
2677+ int x_ctb = (ctb_addr_rs % sps->ctb_width) << sps->log2_ctb_size;
2678+ int y_ctb = (ctb_addr_rs / sps->ctb_width) << sps->log2_ctb_size;
26222679
2623− hls_decode_neighbour(lc, x_ctb, y_ctb, ctb_addr_ts);
2680+ hls_decode_neighbour(lc, pps, sps, x_ctb, y_ctb, ctb_addr_ts);
26242681
26252682 ff_thread_await_progress2(s->avctx, ctb_row, thread, SHIFT_CTB_WPP);
26262683
@@ -2632,11 +2689,12 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, · 5 unmodified lines
26322689 return 0;
26332690 }
26342691
2635− ret = ff_hevc_cabac_init(lc, s->ps.pps, ctb_addr_ts, data, data_size);
2692+ ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, data, data_size);
26362693 if (ret < 0)
26372694 goto error;
2638− hls_sao_param(lc, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size);
2639− more_data = hls_coding_quadtree(lc, x_ctb, y_ctb, s->ps.sps->log2_ctb_size, 0);
2695+ hls_sao_param(lc, pps, sps,
2696+ x_ctb >> sps->log2_ctb_size, y_ctb >> sps->log2_ctb_size);
2697+ more_data = hls_coding_quadtree(lc, pps, sps, x_ctb, y_ctb, sps->log2_ctb_size, 0);
26402698
26412699 if (more_data < 0) {
26422700 ret = more_data;
@@ -2645,26 +2703,26 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, · 2 unmodified lines
26452703
26462704 ctb_addr_ts++;
26472705
2648− ff_hevc_save_states(lc, s->ps.pps, ctb_addr_ts);
2706+ ff_hevc_save_states(lc, pps, ctb_addr_ts);
26492707 ff_thread_report_progress2(s->avctx, ctb_row, thread, 1);
2650− ff_hevc_hls_filters(lc, s->ps.pps, x_ctb, y_ctb, ctb_size);
2708+ ff_hevc_hls_filters(lc, pps, x_ctb, y_ctb, ctb_size);
26512709
2652− if (!more_data && (x_ctb+ctb_size) < s->ps.sps->width && ctb_row != s->sh.num_entry_point_offsets) {
2710+ if (!more_data && (x_ctb+ctb_size) < sps->width && ctb_row != s->sh.num_entry_point_offsets) {
26532711 /* Casting const away here is safe, because it is an atomic operation. */
26542712 atomic_store((atomic_int*)&s->wpp_err, 1);
26552713 ff_thread_report_progress2(s->avctx, ctb_row ,thread, SHIFT_CTB_WPP);
26562714 return 0;
26572715 }
26582716
2659− if ((x_ctb+ctb_size) >= s->ps.sps->width && (y_ctb+ctb_size) >= s->ps.sps->height ) {
2660− ff_hevc_hls_filter(lc, s->ps.pps, x_ctb, y_ctb, ctb_size);
2717+ if ((x_ctb+ctb_size) >= sps->width && (y_ctb+ctb_size) >= sps->height ) {
2718+ ff_hevc_hls_filter(lc, pps, x_ctb, y_ctb, ctb_size);
26612719 ff_thread_report_progress2(s->avctx, ctb_row , thread, SHIFT_CTB_WPP);
26622720 return ctb_addr_ts;
26632721 }
2664− ctb_addr_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2722+ ctb_addr_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts];
26652723 x_ctb+=ctb_size;
26662724
2667− if(x_ctb >= s->ps.sps->width) {
2725+ if(x_ctb >= sps->width) {
26682726 break;
26692727 }
26702728 }
@@ -2681,6 +2739,8 @@ error: · 10 unmodified lines
26812739
26822740 static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
26832741 {
2742+ const HEVCPPS *const pps = s->ps.pps;
2743+ const HEVCSPS *const sps = pps->sps;
26842744 const uint8_t *data = nal->data;
26852745 int length = nal->size;
26862746 int *ret;
@@ -2688,10 +2748,10 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 1 unmodified line
26882748 int64_t startheader, cmpt = 0;
26892749 int i, j, res = 0;
26902750
2691− if (s->sh.slice_ctb_addr_rs + s->sh.num_entry_point_offsets * s->ps.sps->ctb_width >= s->ps.sps->ctb_width * s->ps.sps->ctb_height) {
2751+ if (s->sh.slice_ctb_addr_rs + s->sh.num_entry_point_offsets * sps->ctb_width >= sps->ctb_width * sps->ctb_height) {
26922752 av_log(s->avctx, AV_LOG_ERROR, "WPP ctb addresses are wrong (%d %d %d %d)\n",
26932753 s->sh.slice_ctb_addr_rs, s->sh.num_entry_point_offsets,
2694− s->ps.sps->ctb_width, s->ps.sps->ctb_height
2754+ sps->ctb_width, sps->ctb_height
26952755 );
26962756 return AVERROR_INVALIDDATA;
26972757 }
@@ -2769,7 +2829,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 71 unmodified lines
27692829 if (!ret)
27702830 return AVERROR(ENOMEM);
27712831
2772− if (s->ps.pps->entropy_coding_sync_enabled_flag)
2832+ if (pps->entropy_coding_sync_enabled_flag)
27732833 s->avctx->execute2(s->avctx, hls_decode_entry_wpp, s->local_ctx, ret, s->sh.num_entry_point_offsets + 1);
27742834
27752835 for (i = 0; i <= s->sh.num_entry_point_offsets; i++)
@@ -2868,14 +2928,16 @@ static int set_side_data(HEVCContext *s) · 92 unmodified lines
28682928
28692929 static int hevc_frame_start(HEVCContext *s)
28702930 {
2871− int pic_size_in_ctb = ((s->ps.sps->width >> s->ps.sps->log2_min_cb_size) + 1) *
2872− ((s->ps.sps->height >> s->ps.sps->log2_min_cb_size) + 1);
2931+ const HEVCPPS *const pps = s->ps.pps;
2932+ const HEVCSPS *const sps = pps->sps;
2933+ int pic_size_in_ctb = ((sps->width >> sps->log2_min_cb_size) + 1) *
2934+ ((sps->height >> sps->log2_min_cb_size) + 1);
28732935 int ret;
28742936
28752937 memset(s->horizontal_bs, 0, s->bs_width * s->bs_height);
28762938 memset(s->vertical_bs, 0, s->bs_width * s->bs_height);
2877− memset(s->cbf_luma, 0, s->ps.sps->min_tb_width * s->ps.sps->min_tb_height);
2878− memset(s->is_pcm, 0, (s->ps.sps->min_pu_width + 1) * (s->ps.sps->min_pu_height + 1));
2939+ memset(s->cbf_luma, 0, sps->min_tb_width * sps->min_tb_height);
2940+ memset(s->is_pcm, 0, (sps->min_pu_width + 1) * (sps->min_pu_height + 1));
28792941 memset(s->tab_slice_address, -1, pic_size_in_ctb * sizeof(*s->tab_slice_address));
28802942
28812943 s->is_decoded = 0;
@@ -2883,8 +2945,8 @@ static int hevc_frame_start(HEVCContext *s) · 1 unmodified line
28832945
28842946 s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) || (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos);
28852947
2886− if (s->ps.pps->tiles_enabled_flag)
2887− s->local_ctx[0].end_of_tiles_x = s->ps.pps->column_width[0] << s->ps.sps->log2_ctb_size;
2948+ if (pps->tiles_enabled_flag)
2949+ s->local_ctx[0].end_of_tiles_x = pps->column_width[0] << sps->log2_ctb_size;
28882950
28892951 ret = ff_hevc_set_new_ref(s, s->poc);
28902952 if (ret < 0)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t