49 const uint8_t
ff_hevc_pel_weight[65] = { [2] = 0, [4] = 1, [6] = 2, [8] = 3, [12] = 4, [16] = 5, [24] = 6, [32] = 7, [48] = 8, [64] = 9 };
91 int log2_min_cb_size =
sps->log2_min_cb_size;
94 int pic_size_in_ctb = ((
width >> log2_min_cb_size) + 1) *
95 ((
height >> log2_min_cb_size) + 1);
96 int ctb_count =
sps->ctb_width *
sps->ctb_height;
97 int min_pu_size =
sps->min_pu_width *
sps->min_pu_height;
99 s->bs_width = (
width >> 2) + 1;
100 s->bs_height = (
height >> 2) + 1;
103 s->deblock =
av_calloc(ctb_count,
sizeof(*
s->deblock));
104 if (!
s->sao || !
s->deblock)
109 if (!
s->skip_flag || !
s->tab_ct_depth)
115 if (!
s->tab_ipm || !
s->cbf_luma || !
s->is_pcm)
120 sizeof(*
s->tab_slice_address));
122 sizeof(*
s->qp_y_tab));
123 if (!
s->qp_y_tab || !
s->filter_slice_edges || !
s->tab_slice_address)
126 s->horizontal_bs =
av_calloc(
s->bs_width,
s->bs_height);
128 if (!
s->horizontal_bs || !
s->vertical_bs)
135 if (!
s->tab_mvf_pool || !
s->rpl_tab_pool)
149 uint8_t luma_weight_l0_flag[16];
150 uint8_t chroma_weight_l0_flag[16];
151 uint8_t luma_weight_l1_flag[16];
152 uint8_t chroma_weight_l1_flag[16];
153 int luma_log2_weight_denom;
156 if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) {
157 av_log(
s->avctx,
AV_LOG_ERROR,
"luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom);
160 s->sh.luma_log2_weight_denom =
av_clip_uintp2(luma_log2_weight_denom, 3);
161 if (
s->ps.sps->chroma_format_idc != 0) {
162 int64_t chroma_log2_weight_denom = luma_log2_weight_denom + (int64_t)
get_se_golomb(gb);
163 if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) {
164 av_log(
s->avctx,
AV_LOG_ERROR,
"chroma_log2_weight_denom %"PRId64
" is invalid\n", chroma_log2_weight_denom);
167 s->sh.chroma_log2_weight_denom = chroma_log2_weight_denom;
170 for (
i = 0;
i <
s->sh.nb_refs[
L0];
i++) {
172 if (!luma_weight_l0_flag[
i]) {
173 s->sh.luma_weight_l0[
i] = 1 <<
s->sh.luma_log2_weight_denom;
174 s->sh.luma_offset_l0[
i] = 0;
177 if (
s->ps.sps->chroma_format_idc != 0) {
178 for (
i = 0;
i <
s->sh.nb_refs[
L0];
i++)
181 for (
i = 0;
i <
s->sh.nb_refs[
L0];
i++)
182 chroma_weight_l0_flag[
i] = 0;
184 for (
i = 0;
i <
s->sh.nb_refs[
L0];
i++) {
185 if (luma_weight_l0_flag[
i]) {
187 if ((int8_t)delta_luma_weight_l0 != delta_luma_weight_l0)
189 s->sh.luma_weight_l0[
i] = (1 <<
s->sh.luma_log2_weight_denom) + delta_luma_weight_l0;
192 if (chroma_weight_l0_flag[
i]) {
193 for (j = 0; j < 2; j++) {
197 if ( (int8_t)delta_chroma_weight_l0 != delta_chroma_weight_l0
198 || delta_chroma_offset_l0 < -(1<<17) || delta_chroma_offset_l0 > (1<<17)) {
202 s->sh.chroma_weight_l0[
i][j] = (1 <<
s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l0;
203 s->sh.chroma_offset_l0[
i][j] =
av_clip((delta_chroma_offset_l0 - ((128 *
s->sh.chroma_weight_l0[
i][j])
204 >>
s->sh.chroma_log2_weight_denom) + 128), -128, 127);
207 s->sh.chroma_weight_l0[
i][0] = 1 <<
s->sh.chroma_log2_weight_denom;
208 s->sh.chroma_offset_l0[
i][0] = 0;
209 s->sh.chroma_weight_l0[
i][1] = 1 <<
s->sh.chroma_log2_weight_denom;
210 s->sh.chroma_offset_l0[
i][1] = 0;
214 for (
i = 0;
i <
s->sh.nb_refs[
L1];
i++) {
216 if (!luma_weight_l1_flag[
i]) {
217 s->sh.luma_weight_l1[
i] = 1 <<
s->sh.luma_log2_weight_denom;
218 s->sh.luma_offset_l1[
i] = 0;
221 if (
s->ps.sps->chroma_format_idc != 0) {
222 for (
i = 0;
i <
s->sh.nb_refs[
L1];
i++)
225 for (
i = 0;
i <
s->sh.nb_refs[
L1];
i++)
226 chroma_weight_l1_flag[
i] = 0;
228 for (
i = 0;
i <
s->sh.nb_refs[
L1];
i++) {
229 if (luma_weight_l1_flag[
i]) {
231 if ((int8_t)delta_luma_weight_l1 != delta_luma_weight_l1)
233 s->sh.luma_weight_l1[
i] = (1 <<
s->sh.luma_log2_weight_denom) + delta_luma_weight_l1;
236 if (chroma_weight_l1_flag[
i]) {
237 for (j = 0; j < 2; j++) {
241 if ( (int8_t)delta_chroma_weight_l1 != delta_chroma_weight_l1
242 || delta_chroma_offset_l1 < -(1<<17) || delta_chroma_offset_l1 > (1<<17)) {
246 s->sh.chroma_weight_l1[
i][j] = (1 <<
s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l1;
247 s->sh.chroma_offset_l1[
i][j] =
av_clip((delta_chroma_offset_l1 - ((128 *
s->sh.chroma_weight_l1[
i][j])
248 >>
s->sh.chroma_log2_weight_denom) + 128), -128, 127);
251 s->sh.chroma_weight_l1[
i][0] = 1 <<
s->sh.chroma_log2_weight_denom;
252 s->sh.chroma_offset_l1[
i][0] = 0;
253 s->sh.chroma_weight_l1[
i][1] = 1 <<
s->sh.chroma_log2_weight_denom;
254 s->sh.chroma_offset_l1[
i][1] = 0;
264 int max_poc_lsb = 1 <<
sps->log2_max_poc_lsb;
265 int prev_delta_msb = 0;
266 unsigned int nb_sps = 0, nb_sh;
270 if (!
sps->long_term_ref_pics_present_flag)
273 if (
sps->num_long_term_ref_pics_sps > 0)
277 if (nb_sps >
sps->num_long_term_ref_pics_sps)
287 uint8_t lt_idx_sps = 0;
289 if (
sps->num_long_term_ref_pics_sps > 1)
292 rps->
poc[
i] =
sps->lt_ref_pic_poc_lsb_sps[lt_idx_sps];
293 rps->
used[
i] =
sps->used_by_curr_pic_lt_sps_flag[lt_idx_sps];
304 if (
i &&
i != nb_sps)
305 delta += prev_delta_msb;
307 poc = rps->
poc[
i] +
s->poc -
delta * max_poc_lsb -
s->sh.pic_order_cnt_lsb;
311 prev_delta_msb =
delta;
324 unsigned int num = 0, den = 0;
329 avctx->
width =
sps->width - ow->left_offset - ow->right_offset;
330 avctx->
height =
sps->height - ow->top_offset - ow->bottom_offset;
332 avctx->
profile =
sps->ptl.general_ptl.profile_idc;
333 avctx->
level =
sps->ptl.general_ptl.level_idc;
337 if (
sps->vui.video_signal_type_present_flag)
343 if (
sps->vui.colour_description_present_flag) {
354 if (
sps->chroma_format_idc == 1) {
355 if (
sps->vui.chroma_loc_info_present_flag) {
356 if (
sps->vui.chroma_sample_loc_type_top_field <= 5)
362 if (
vps->vps_timing_info_present_flag) {
363 num =
vps->vps_num_units_in_tick;
364 den =
vps->vps_time_scale;
365 }
else if (
sps->vui.vui_timing_info_present_flag) {
366 num =
sps->vui.vui_num_units_in_tick;
367 den =
sps->vui.vui_time_scale;
370 if (num != 0 && den != 0)
379 if (
s->sei.a53_caption.buf_ref)
382 if (
s->sei.alternative_transfer.present &&
385 avctx->
color_trc =
s->sei.alternative_transfer.preferred_transfer_characteristics;
388 if (
s->sei.film_grain_characteristics.present)
396 #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + \
397 CONFIG_HEVC_D3D11VA_HWACCEL * 2 + \
398 CONFIG_HEVC_NVDEC_HWACCEL + \
399 CONFIG_HEVC_VAAPI_HWACCEL + \
400 CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL + \
401 CONFIG_HEVC_VDPAU_HWACCEL)
404 switch (
sps->pix_fmt) {
407 #if CONFIG_HEVC_DXVA2_HWACCEL
410 #if CONFIG_HEVC_D3D11VA_HWACCEL
414 #if CONFIG_HEVC_VAAPI_HWACCEL
417 #if CONFIG_HEVC_VDPAU_HWACCEL
420 #if CONFIG_HEVC_NVDEC_HWACCEL
423 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
428 #if CONFIG_HEVC_DXVA2_HWACCEL
431 #if CONFIG_HEVC_D3D11VA_HWACCEL
435 #if CONFIG_HEVC_VAAPI_HWACCEL
438 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
441 #if CONFIG_HEVC_VDPAU_HWACCEL
444 #if CONFIG_HEVC_NVDEC_HWACCEL
449 #if CONFIG_HEVC_VDPAU_HWACCEL
452 #if CONFIG_HEVC_NVDEC_HWACCEL
455 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
461 #if CONFIG_HEVC_VAAPI_HWACCEL
464 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
469 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
474 #if CONFIG_HEVC_VDPAU_HWACCEL
477 #if CONFIG_HEVC_NVDEC_HWACCEL
483 *fmt++ =
sps->pix_fmt;
513 for (
i = 0;
i < 3;
i++) {
518 if (
sps->sao_enabled && !
s->avctx->hwaccel) {
519 int c_count = (
sps->chroma_format_idc != 0) ? 3 : 1;
522 for(c_idx = 0; c_idx < c_count; c_idx++) {
523 int w =
sps->width >>
sps->hshift[c_idx];
524 int h =
sps->height >>
sps->vshift[c_idx];
525 s->sao_pixel_buffer_h[c_idx] =
528 s->sao_pixel_buffer_v[c_idx] =
531 if (!
s->sao_pixel_buffer_h[c_idx] ||
532 !
s->sao_pixel_buffer_v[c_idx])
538 s->ps.vps = (
HEVCVPS*)
s->ps.vps_list[
s->ps.sps->vps_id]->data;
544 for (
i = 0;
i < 3;
i++) {
561 av_log(
s->avctx,
AV_LOG_ERROR,
"Two slices reporting being the first in the same frame.\n");
566 s->seq_decode = (
s->seq_decode + 1) & 0xff;
589 if (
s->ps.sps != (
HEVCSPS*)
s->ps.sps_list[
s->ps.pps->sps_id]->data) {
591 const HEVCSPS *last_sps =
s->ps.sps;
595 if (
sps->width != last_sps->width ||
sps->height != last_sps->height ||
596 sps->temporal_layer[
sps->max_sub_layers - 1].max_dec_pic_buffering !=
597 last_sps->temporal_layer[last_sps->max_sub_layers - 1].max_dec_pic_buffering)
611 s->seq_decode = (
s->seq_decode + 1) & 0xff;
621 int slice_address_length;
623 if (
s->ps.pps->dependent_slice_segments_enabled_flag)
627 s->ps.sps->ctb_height);
631 "Invalid slice segment address: %u.\n",
643 s->slice_initialized = 0;
647 s->slice_initialized = 0;
649 for (
i = 0;
i <
s->ps.pps->num_extra_slice_header_bits;
i++)
667 if (
s->ps.pps->output_flag_present_flag)
670 if (
s->ps.sps->separate_colour_plane_flag)
680 "Ignoring POC change between slices: %d -> %d\n",
s->poc, poc);
696 int numbits, rps_idx;
698 if (!
s->ps.sps->nb_st_rps) {
704 rps_idx = numbits > 0 ?
get_bits(gb, numbits) : 0;
718 if (
s->ps.sps->sps_temporal_mvp_enabled_flag)
723 s->sh.short_term_rps =
NULL;
738 if (
s->ps.sps->sao_enabled) {
740 if (
s->ps.sps->chroma_format_idc) {
754 sh->
nb_refs[
L0] =
s->ps.pps->num_ref_idx_l0_default_active;
756 sh->
nb_refs[
L1] =
s->ps.pps->num_ref_idx_l1_default_active;
777 if (
s->ps.pps->lists_modification_present_flag && nb_refs > 1) {
795 if (
s->ps.pps->cabac_init_present_flag)
810 "Invalid collocated_ref_idx: %d.\n",
827 "Invalid number of merging MVP candidates: %d.\n",
835 if (
s->ps.pps->pic_slice_level_chroma_qp_offsets_present_flag) {
848 if (
s->ps.pps->chroma_qp_offset_list_enabled_flag)
853 if (
s->ps.pps->deblocking_filter_control_present_flag) {
854 int deblocking_filter_override_flag = 0;
856 if (
s->ps.pps->deblocking_filter_override_enabled_flag)
857 deblocking_filter_override_flag =
get_bits1(gb);
859 if (deblocking_filter_override_flag) {
864 if (beta_offset_div2 < -6 || beta_offset_div2 > 6 ||
865 tc_offset_div2 < -6 || tc_offset_div2 > 6) {
867 "Invalid deblock filter offsets: %d, %d\n",
868 beta_offset_div2, tc_offset_div2);
885 if (
s->ps.pps->seq_loop_filter_across_slices_enabled_flag &&
893 }
else if (!
s->slice_initialized) {
899 if (
s->ps.pps->tiles_enabled_flag ||
s->ps.pps->entropy_coding_sync_enabled_flag) {
903 av_log(
s->avctx,
AV_LOG_ERROR,
"num_entry_point_offsets %d is invalid\n", num_entry_point_offsets);
911 if (offset_len < 1 || offset_len > 32) {
932 if (
s->threads_number > 1 && (
s->ps.pps->num_tile_rows > 1 ||
s->ps.pps->num_tile_columns > 1)) {
933 s->enable_parallel_tiles = 0;
934 s->threads_number = 1;
936 s->enable_parallel_tiles = 0;
938 s->enable_parallel_tiles = 0;
941 if (
s->ps.pps->slice_header_extension_present_flag) {
947 for (
i = 0;
i < length;
i++)
954 sh->
slice_qp < -
s->ps.sps->qp_bd_offset) {
956 "The slice_qp %d is outside the valid range "
959 -
s->ps.sps->qp_bd_offset);
965 if (!
s->sh.slice_ctb_addr_rs &&
s->sh.dependent_slice_segment_flag) {
976 s->HEVClc->first_qp_group = !
s->sh.dependent_slice_segment_flag;
978 if (!
s->ps.pps->cu_qp_delta_enabled_flag)
979 s->HEVClc->qp_y =
s->sh.slice_qp;
981 s->slice_initialized = 1;
982 s->HEVClc->tu.cu_qp_offset_cb = 0;
983 s->HEVClc->tu.cu_qp_offset_cr = 0;
988 #define CTB(tab, x, y) ((tab)[(y) * s->ps.sps->ctb_width + (x)])
990 #define SET_SAO(elem, value) \
992 if (!sao_merge_up_flag && !sao_merge_left_flag) \
994 else if (sao_merge_left_flag) \
995 sao->elem = CTB(s->sao, rx-1, ry).elem; \
996 else if (sao_merge_up_flag) \
997 sao->elem = CTB(s->sao, rx, ry-1).elem; \
1005 int sao_merge_left_flag = 0;
1006 int sao_merge_up_flag = 0;
1010 if (
s->sh.slice_sample_adaptive_offset_flag[0] ||
1011 s->sh.slice_sample_adaptive_offset_flag[1]) {
1016 if (ry > 0 && !sao_merge_left_flag) {
1022 for (c_idx = 0; c_idx < (
s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) {
1023 int log2_sao_offset_scale = c_idx == 0 ?
s->ps.pps->log2_sao_offset_scale_luma :
1024 s->ps.pps->log2_sao_offset_scale_chroma;
1026 if (!
s->sh.slice_sample_adaptive_offset_flag[c_idx]) {
1041 for (
i = 0;
i < 4;
i++)
1045 for (
i = 0;
i < 4;
i++) {
1054 }
else if (c_idx != 2) {
1060 for (
i = 0;
i < 4;
i++) {
1068 sao->
offset_val[c_idx][
i + 1] *= 1 << log2_sao_offset_scale;
1080 if (log2_res_scale_abs_plus1 != 0) {
1083 (1 - 2 * res_scale_sign_flag);
1093 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1094 int log2_cb_size,
int log2_trafo_size,
1095 int blk_idx,
int cbf_luma,
int *cbf_cb,
int *cbf_cr)
1098 const int log2_trafo_size_c = log2_trafo_size -
s->ps.sps->hshift[1];
1102 int trafo_size = 1 << log2_trafo_size;
1105 s->hpc.intra_pred[log2_trafo_size - 2](
s, x0, y0, 0);
1108 if (cbf_luma || cbf_cb[0] || cbf_cr[0] ||
1109 (
s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
1112 int cbf_chroma = cbf_cb[0] || cbf_cr[0] ||
1113 (
s->ps.sps->chroma_format_idc == 2 &&
1114 (cbf_cb[1] || cbf_cr[1]));
1126 "The cu_qp_delta %d is outside the valid range "
1129 -(26 +
s->ps.sps->qp_bd_offset / 2),
1130 (25 +
s->ps.sps->qp_bd_offset / 2));
1137 if (
s->sh.cu_chroma_qp_offset_enabled_flag && cbf_chroma &&
1140 if (cu_chroma_qp_offset_flag) {
1141 int cu_chroma_qp_offset_idx = 0;
1142 if (
s->ps.pps->chroma_qp_offset_list_len_minus1 > 0) {
1145 "cu_chroma_qp_offset_idx not yet tested.\n");
1178 if (
s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 ||
s->ps.sps->chroma_format_idc == 3)) {
1179 int trafo_size_h = 1 << (log2_trafo_size_c +
s->ps.sps->hshift[1]);
1180 int trafo_size_v = 1 << (log2_trafo_size_c +
s->ps.sps->vshift[1]);
1181 lc->
tu.
cross_pf = (
s->ps.pps->cross_component_prediction_enabled_flag && cbf_luma &&
1188 for (
i = 0;
i < (
s->ps.sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1191 s->hpc.intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (
i << log2_trafo_size_c), 1);
1195 log2_trafo_size_c, scan_idx_c, 1);
1198 ptrdiff_t
stride =
s->frame->linesize[1];
1199 int hshift =
s->ps.sps->hshift[1];
1200 int vshift =
s->ps.sps->vshift[1];
1203 int size = 1 << log2_trafo_size_c;
1205 uint8_t *dst = &
s->frame->data[1][(y0 >> vshift) *
stride +
1206 ((x0 >> hshift) <<
s->ps.sps->pixel_shift)];
1210 s->hevcdsp.add_residual[log2_trafo_size_c-2](dst, coeffs,
stride);
1217 for (
i = 0;
i < (
s->ps.sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1220 s->hpc.intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (
i << log2_trafo_size_c), 2);
1224 log2_trafo_size_c, scan_idx_c, 2);
1227 ptrdiff_t
stride =
s->frame->linesize[2];
1228 int hshift =
s->ps.sps->hshift[2];
1229 int vshift =
s->ps.sps->vshift[2];
1232 int size = 1 << log2_trafo_size_c;
1234 uint8_t *dst = &
s->frame->data[2][(y0 >> vshift) *
stride +
1235 ((x0 >> hshift) <<
s->ps.sps->pixel_shift)];
1239 s->hevcdsp.add_residual[log2_trafo_size_c-2](dst, coeffs,
stride);
1242 }
else if (
s->ps.sps->chroma_format_idc && blk_idx == 3) {
1243 int trafo_size_h = 1 << (log2_trafo_size + 1);
1244 int trafo_size_v = 1 << (log2_trafo_size +
s->ps.sps->vshift[1]);
1245 for (
i = 0;
i < (
s->ps.sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1248 trafo_size_h, trafo_size_v);
1249 s->hpc.intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (
i << log2_trafo_size), 1);
1253 log2_trafo_size, scan_idx_c, 1);
1255 for (
i = 0;
i < (
s->ps.sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1258 trafo_size_h, trafo_size_v);
1259 s->hpc.intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (
i << log2_trafo_size), 2);
1263 log2_trafo_size, scan_idx_c, 2);
1267 if (log2_trafo_size > 2 ||
s->ps.sps->chroma_format_idc == 3) {
1268 int trafo_size_h = 1 << (log2_trafo_size_c +
s->ps.sps->hshift[1]);
1269 int trafo_size_v = 1 << (log2_trafo_size_c +
s->ps.sps->vshift[1]);
1271 s->hpc.intra_pred[log2_trafo_size_c - 2](
s, x0, y0, 1);
1272 s->hpc.intra_pred[log2_trafo_size_c - 2](
s, x0, y0, 2);
1273 if (
s->ps.sps->chroma_format_idc == 2) {
1275 trafo_size_h, trafo_size_v);
1276 s->hpc.intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (1 << log2_trafo_size_c), 1);
1277 s->hpc.intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (1 << log2_trafo_size_c), 2);
1279 }
else if (blk_idx == 3) {
1280 int trafo_size_h = 1 << (log2_trafo_size + 1);
1281 int trafo_size_v = 1 << (log2_trafo_size +
s->ps.sps->vshift[1]);
1283 trafo_size_h, trafo_size_v);
1284 s->hpc.intra_pred[log2_trafo_size - 2](
s, xBase, yBase, 1);
1285 s->hpc.intra_pred[log2_trafo_size - 2](
s, xBase, yBase, 2);
1286 if (
s->ps.sps->chroma_format_idc == 2) {
1288 trafo_size_h, trafo_size_v);
1289 s->hpc.intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (1 << (log2_trafo_size)), 1);
1290 s->hpc.intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (1 << (log2_trafo_size)), 2);
1300 int cb_size = 1 << log2_cb_size;
1301 int log2_min_pu_size =
s->ps.sps->log2_min_pu_size;
1303 int min_pu_width =
s->ps.sps->min_pu_width;
1304 int x_end =
FFMIN(x0 + cb_size,
s->ps.sps->width);
1305 int y_end =
FFMIN(y0 + cb_size,
s->ps.sps->height);
1308 for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
1309 for (
i = (x0 >> log2_min_pu_size);
i < (x_end >> log2_min_pu_size);
i++)
1310 s->is_pcm[
i + j * min_pu_width] = 2;
1314 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1315 int log2_cb_size,
int log2_trafo_size,
1316 int trafo_depth,
int blk_idx,
1317 const int *base_cbf_cb,
const int *base_cbf_cr)
1320 uint8_t split_transform_flag;
1325 cbf_cb[0] = base_cbf_cb[0];
1326 cbf_cb[1] = base_cbf_cb[1];
1327 cbf_cr[0] = base_cbf_cr[0];
1328 cbf_cr[1] = base_cbf_cr[1];
1331 if (trafo_depth == 1) {
1333 if (
s->ps.sps->chroma_format_idc == 3) {
1347 if (log2_trafo_size <= s->ps.sps->log2_max_trafo_size &&
1348 log2_trafo_size >
s->ps.sps->log2_min_tb_size &&
1349 trafo_depth < lc->cu.max_trafo_depth &&
1353 int inter_split =
s->ps.sps->max_transform_hierarchy_depth_inter == 0 &&
1358 split_transform_flag = log2_trafo_size >
s->ps.sps->log2_max_trafo_size ||
1363 if (
s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 ||
s->ps.sps->chroma_format_idc == 3)) {
1364 if (trafo_depth == 0 || cbf_cb[0]) {
1366 if (
s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
1371 if (trafo_depth == 0 || cbf_cr[0]) {
1373 if (
s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
1379 if (split_transform_flag) {
1380 const int trafo_size_split = 1 << (log2_trafo_size - 1);
1381 const int x1 = x0 + trafo_size_split;
1382 const int y1 = y0 + trafo_size_split;
1384 #define SUBDIVIDE(x, y, idx) \
1386 ret = hls_transform_tree(s, x, y, x0, y0, cb_xBase, cb_yBase, log2_cb_size, \
1387 log2_trafo_size - 1, trafo_depth + 1, idx, \
1400 int min_tu_size = 1 <<
s->ps.sps->log2_min_tb_size;
1401 int log2_min_tu_size =
s->ps.sps->log2_min_tb_size;
1402 int min_tu_width =
s->ps.sps->min_tb_width;
1406 cbf_cb[0] || cbf_cr[0] ||
1407 (
s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
1412 log2_cb_size, log2_trafo_size,
1413 blk_idx, cbf_luma, cbf_cb, cbf_cr);
1419 for (
i = 0;
i < (1 << log2_trafo_size);
i += min_tu_size)
1420 for (j = 0; j < (1 << log2_trafo_size); j += min_tu_size) {
1421 int x_tu = (x0 + j) >> log2_min_tu_size;
1422 int y_tu = (y0 +
i) >> log2_min_tu_size;
1423 s->cbf_luma[y_tu * min_tu_width + x_tu] = 1;
1426 if (!
s->sh.disable_deblocking_filter_flag) {
1428 if (
s->ps.pps->transquant_bypass_enable_flag &&
1440 int cb_size = 1 << log2_cb_size;
1441 ptrdiff_t stride0 =
s->frame->linesize[0];
1442 ptrdiff_t stride1 =
s->frame->linesize[1];
1443 ptrdiff_t stride2 =
s->frame->linesize[2];
1444 uint8_t *dst0 = &
s->frame->data[0][y0 * stride0 + (x0 <<
s->ps.sps->pixel_shift)];
1445 uint8_t *dst1 = &
s->frame->data[1][(y0 >>
s->ps.sps->vshift[1]) * stride1 + ((x0 >>
s->ps.sps->hshift[1]) <<
s->ps.sps->pixel_shift)];
1446 uint8_t *dst2 = &
s->frame->data[2][(y0 >>
s->ps.sps->vshift[2]) * stride2 + ((x0 >>
s->ps.sps->hshift[2]) <<
s->ps.sps->pixel_shift)];
1448 int length = cb_size * cb_size *
s->ps.sps->pcm.bit_depth +
1449 (((cb_size >>
s->ps.sps->hshift[1]) * (cb_size >>
s->ps.sps->vshift[1])) +
1450 ((cb_size >>
s->ps.sps->hshift[2]) * (cb_size >>
s->ps.sps->vshift[2]))) *
1451 s->ps.sps->pcm.bit_depth_chroma;
1452 const uint8_t *pcm =
skip_bytes(&lc->
cc, (length + 7) >> 3);
1455 if (!
s->sh.disable_deblocking_filter_flag)
1462 s->hevcdsp.put_pcm(dst0, stride0, cb_size, cb_size, &gb,
s->ps.sps->pcm.bit_depth);
1463 if (
s->ps.sps->chroma_format_idc) {
1464 s->hevcdsp.put_pcm(dst1, stride1,
1465 cb_size >>
s->ps.sps->hshift[1],
1466 cb_size >>
s->ps.sps->vshift[1],
1467 &gb,
s->ps.sps->pcm.bit_depth_chroma);
1468 s->hevcdsp.put_pcm(dst2, stride2,
1469 cb_size >>
s->ps.sps->hshift[2],
1470 cb_size >>
s->ps.sps->vshift[2],
1471 &gb,
s->ps.sps->pcm.bit_depth_chroma);
1495 int block_w,
int block_h,
int luma_weight,
int luma_offset)
1498 uint8_t *
src =
ref->data[0];
1499 ptrdiff_t srcstride =
ref->linesize[0];
1500 int pic_width =
s->ps.sps->width;
1501 int pic_height =
s->ps.sps->height;
1504 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
s->ps.pps->weighted_pred_flag) ||
1505 (
s->sh.slice_type ==
HEVC_SLICE_B &&
s->ps.pps->weighted_bipred_flag);
1508 x_off +=
mv->x >> 2;
1509 y_off +=
mv->y >> 2;
1510 src += y_off * srcstride + (x_off * (1 <<
s->ps.sps->pixel_shift));
1520 edge_emu_stride, srcstride,
1524 pic_width, pic_height);
1526 srcstride = edge_emu_stride;
1530 s->hevcdsp.put_hevc_qpel_uni[idx][!!my][!!mx](dst, dststride,
src, srcstride,
1531 block_h, mx, my, block_w);
1533 s->hevcdsp.put_hevc_qpel_uni_w[idx][!!my][!!mx](dst, dststride,
src, srcstride,
1534 block_h,
s->sh.luma_log2_weight_denom,
1535 luma_weight, luma_offset, mx, my, block_w);
1555 AVFrame *ref0,
const Mv *mv0,
int x_off,
int y_off,
1556 int block_w,
int block_h,
AVFrame *ref1,
const Mv *mv1,
struct MvField *current_mv)
1559 ptrdiff_t src0stride = ref0->
linesize[0];
1560 ptrdiff_t src1stride = ref1->
linesize[0];
1561 int pic_width =
s->ps.sps->width;
1562 int pic_height =
s->ps.sps->height;
1563 int mx0 = mv0->
x & 3;
1564 int my0 = mv0->
y & 3;
1565 int mx1 = mv1->
x & 3;
1566 int my1 = mv1->
y & 3;
1567 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
s->ps.pps->weighted_pred_flag) ||
1568 (
s->sh.slice_type ==
HEVC_SLICE_B &&
s->ps.pps->weighted_bipred_flag);
1569 int x_off0 = x_off + (mv0->
x >> 2);
1570 int y_off0 = y_off + (mv0->
y >> 2);
1571 int x_off1 = x_off + (mv1->
x >> 2);
1572 int y_off1 = y_off + (mv1->
y >> 2);
1575 uint8_t *
src0 = ref0->
data[0] + y_off0 * src0stride + (
int)((
unsigned)x_off0 <<
s->ps.sps->pixel_shift);
1576 uint8_t *
src1 = ref1->
data[0] + y_off1 * src1stride + (
int)((
unsigned)x_off1 <<
s->ps.sps->pixel_shift);
1586 edge_emu_stride, src0stride,
1590 pic_width, pic_height);
1592 src0stride = edge_emu_stride;
1603 edge_emu_stride, src1stride,
1607 pic_width, pic_height);
1609 src1stride = edge_emu_stride;
1612 s->hevcdsp.put_hevc_qpel[idx][!!my0][!!mx0](lc->
tmp,
src0, src0stride,
1613 block_h, mx0, my0, block_w);
1615 s->hevcdsp.put_hevc_qpel_bi[idx][!!my1][!!mx1](dst, dststride,
src1, src1stride, lc->
tmp,
1616 block_h, mx1, my1, block_w);
1618 s->hevcdsp.put_hevc_qpel_bi_w[idx][!!my1][!!mx1](dst, dststride,
src1, src1stride, lc->
tmp,
1619 block_h,
s->sh.luma_log2_weight_denom,
1620 s->sh.luma_weight_l0[current_mv->
ref_idx[0]],
1621 s->sh.luma_weight_l1[current_mv->
ref_idx[1]],
1622 s->sh.luma_offset_l0[current_mv->
ref_idx[0]],
1623 s->sh.luma_offset_l1[current_mv->
ref_idx[1]],
1646 ptrdiff_t dststride, uint8_t *
src0, ptrdiff_t srcstride,
int reflist,
1647 int x_off,
int y_off,
int block_w,
int block_h,
struct MvField *current_mv,
int chroma_weight,
int chroma_offset)
1650 int pic_width =
s->ps.sps->width >>
s->ps.sps->hshift[1];
1651 int pic_height =
s->ps.sps->height >>
s->ps.sps->vshift[1];
1652 const Mv *
mv = ¤t_mv->
mv[reflist];
1653 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
s->ps.pps->weighted_pred_flag) ||
1654 (
s->sh.slice_type ==
HEVC_SLICE_B &&
s->ps.pps->weighted_bipred_flag);
1656 int hshift =
s->ps.sps->hshift[1];
1657 int vshift =
s->ps.sps->vshift[1];
1660 intptr_t _mx = mx << (1 - hshift);
1661 intptr_t _my = my << (1 - vshift);
1663 x_off +=
mv->x >> (2 + hshift);
1664 y_off +=
mv->y >> (2 + vshift);
1665 src0 += y_off * srcstride + (x_off * (1 <<
s->ps.sps->pixel_shift));
1673 (edge_emu_stride + (1 <<
s->ps.sps->pixel_shift));
1675 edge_emu_stride, srcstride,
1679 pic_width, pic_height);
1682 srcstride = edge_emu_stride;
1685 s->hevcdsp.put_hevc_epel_uni[idx][!!my][!!mx](dst0, dststride,
src0, srcstride,
1686 block_h, _mx, _my, block_w);
1688 s->hevcdsp.put_hevc_epel_uni_w[idx][!!my][!!mx](dst0, dststride,
src0, srcstride,
1689 block_h,
s->sh.chroma_log2_weight_denom,
1690 chroma_weight, chroma_offset, _mx, _my, block_w);
1711 int x_off,
int y_off,
int block_w,
int block_h,
struct MvField *current_mv,
int cidx)
1714 uint8_t *
src1 = ref0->
data[cidx+1];
1715 uint8_t *src2 = ref1->
data[cidx+1];
1716 ptrdiff_t src1stride = ref0->
linesize[cidx+1];
1717 ptrdiff_t src2stride = ref1->
linesize[cidx+1];
1718 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
s->ps.pps->weighted_pred_flag) ||
1719 (
s->sh.slice_type ==
HEVC_SLICE_B &&
s->ps.pps->weighted_bipred_flag);
1720 int pic_width =
s->ps.sps->width >>
s->ps.sps->hshift[1];
1721 int pic_height =
s->ps.sps->height >>
s->ps.sps->vshift[1];
1722 Mv *mv0 = ¤t_mv->
mv[0];
1723 Mv *mv1 = ¤t_mv->
mv[1];
1724 int hshift =
s->ps.sps->hshift[1];
1725 int vshift =
s->ps.sps->vshift[1];
1731 intptr_t _mx0 = mx0 << (1 - hshift);
1732 intptr_t _my0 = my0 << (1 - vshift);
1733 intptr_t _mx1 = mx1 << (1 - hshift);
1734 intptr_t _my1 = my1 << (1 - vshift);
1736 int x_off0 = x_off + (mv0->
x >> (2 + hshift));
1737 int y_off0 = y_off + (mv0->
y >> (2 + vshift));
1738 int x_off1 = x_off + (mv1->
x >> (2 + hshift));
1739 int y_off1 = y_off + (mv1->
y >> (2 + vshift));
1741 src1 += y_off0 * src1stride + (
int)((
unsigned)x_off0 <<
s->ps.sps->pixel_shift);
1742 src2 += y_off1 * src2stride + (
int)((
unsigned)x_off1 <<
s->ps.sps->pixel_shift);
1750 (edge_emu_stride + (1 <<
s->ps.sps->pixel_shift));
1753 edge_emu_stride, src1stride,
1757 pic_width, pic_height);
1760 src1stride = edge_emu_stride;
1769 (edge_emu_stride + (1 <<
s->ps.sps->pixel_shift));
1772 edge_emu_stride, src2stride,
1776 pic_width, pic_height);
1779 src2stride = edge_emu_stride;
1782 s->hevcdsp.put_hevc_epel[idx][!!my0][!!mx0](lc->
tmp,
src1, src1stride,
1783 block_h, _mx0, _my0, block_w);
1785 s->hevcdsp.put_hevc_epel_bi[idx][!!my1][!!mx1](dst0,
s->frame->linesize[cidx+1],
1786 src2, src2stride, lc->
tmp,
1787 block_h, _mx1, _my1, block_w);
1789 s->hevcdsp.put_hevc_epel_bi_w[idx][!!my1][!!mx1](dst0,
s->frame->linesize[cidx+1],
1790 src2, src2stride, lc->
tmp,
1792 s->sh.chroma_log2_weight_denom,
1793 s->sh.chroma_weight_l0[current_mv->
ref_idx[0]][cidx],
1794 s->sh.chroma_weight_l1[current_mv->
ref_idx[1]][cidx],
1795 s->sh.chroma_offset_l0[current_mv->
ref_idx[0]][cidx],
1796 s->sh.chroma_offset_l1[current_mv->
ref_idx[1]][cidx],
1797 _mx1, _my1, block_w);
1811 int nPbH,
int log2_cb_size,
int part_idx,
1823 if (inter_pred_idc !=
PRED_L1) {
1824 if (
s->sh.nb_refs[
L0])
1831 part_idx, merge_idx,
mv, mvp_flag, 0);
1836 if (inter_pred_idc !=
PRED_L0) {
1837 if (
s->sh.nb_refs[
L1])
1840 if (
s->sh.mvd_l1_zero_flag == 1 && inter_pred_idc ==
PRED_BI) {
1849 part_idx, merge_idx,
mv, mvp_flag, 1);
1857 int log2_cb_size,
int partIdx,
int idx)
1859 #define POS(c_idx, x, y) \
1860 &s->frame->data[c_idx][((y) >> s->ps.sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \
1861 (((x) >> s->ps.sps->hshift[c_idx]) << s->ps.sps->pixel_shift)]
1864 struct MvField current_mv = {{{ 0 }}};
1866 int min_pu_width =
s->ps.sps->min_pu_width;
1868 MvField *tab_mvf =
s->ref->tab_mvf;
1871 uint8_t *dst0 =
POS(0, x0, y0);
1872 uint8_t *dst1 =
POS(1, x0, y0);
1873 uint8_t *dst2 =
POS(2, x0, y0);
1874 int log2_min_cb_size =
s->ps.sps->log2_min_cb_size;
1875 int min_cb_width =
s->ps.sps->min_cb_width;
1876 int x_cb = x0 >> log2_min_cb_size;
1877 int y_cb = y0 >> log2_min_cb_size;
1881 int skip_flag =
SAMPLE_CTB(
s->skip_flag, x_cb, y_cb);
1887 if (
s->sh.max_num_merge_cand > 1)
1893 partIdx, merge_idx, ¤t_mv);
1896 partIdx, merge_idx, ¤t_mv);
1899 x_pu = x0 >>
s->ps.sps->log2_min_pu_size;
1900 y_pu = y0 >>
s->ps.sps->log2_min_pu_size;
1902 for (j = 0; j < nPbH >>
s->ps.sps->log2_min_pu_size; j++)
1903 for (
i = 0; i < nPbW >>
s->ps.sps->log2_min_pu_size;
i++)
1904 tab_mvf[(y_pu + j) * min_pu_width + x_pu +
i] = current_mv;
1907 ref0 = refPicList[0].
ref[current_mv.
ref_idx[0]];
1913 ref1 = refPicList[1].
ref[current_mv.
ref_idx[1]];
1920 int x0_c = x0 >>
s->ps.sps->hshift[1];
1921 int y0_c = y0 >>
s->ps.sps->vshift[1];
1922 int nPbW_c = nPbW >>
s->ps.sps->hshift[1];
1923 int nPbH_c = nPbH >>
s->ps.sps->vshift[1];
1926 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
1927 s->sh.luma_weight_l0[current_mv.
ref_idx[0]],
1928 s->sh.luma_offset_l0[current_mv.
ref_idx[0]]);
1930 if (
s->ps.sps->chroma_format_idc) {
1932 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1933 s->sh.chroma_weight_l0[current_mv.
ref_idx[0]][0],
s->sh.chroma_offset_l0[current_mv.
ref_idx[0]][0]);
1935 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1936 s->sh.chroma_weight_l0[current_mv.
ref_idx[0]][1],
s->sh.chroma_offset_l0[current_mv.
ref_idx[0]][1]);
1939 int x0_c = x0 >>
s->ps.sps->hshift[1];
1940 int y0_c = y0 >>
s->ps.sps->vshift[1];
1941 int nPbW_c = nPbW >>
s->ps.sps->hshift[1];
1942 int nPbH_c = nPbH >>
s->ps.sps->vshift[1];
1945 ¤t_mv.
mv[1], x0, y0, nPbW, nPbH,
1946 s->sh.luma_weight_l1[current_mv.
ref_idx[1]],
1947 s->sh.luma_offset_l1[current_mv.
ref_idx[1]]);
1949 if (
s->ps.sps->chroma_format_idc) {
1950 chroma_mc_uni(
s, dst1,
s->frame->linesize[1], ref1->frame->data[1], ref1->frame->linesize[1],
1951 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1952 s->sh.chroma_weight_l1[current_mv.
ref_idx[1]][0],
s->sh.chroma_offset_l1[current_mv.
ref_idx[1]][0]);
1954 chroma_mc_uni(
s, dst2,
s->frame->linesize[2], ref1->frame->data[2], ref1->frame->linesize[2],
1955 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1956 s->sh.chroma_weight_l1[current_mv.
ref_idx[1]][1],
s->sh.chroma_offset_l1[current_mv.
ref_idx[1]][1]);
1959 int x0_c = x0 >>
s->ps.sps->hshift[1];
1960 int y0_c = y0 >>
s->ps.sps->vshift[1];
1961 int nPbW_c = nPbW >>
s->ps.sps->hshift[1];
1962 int nPbH_c = nPbH >>
s->ps.sps->vshift[1];
1965 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
1966 ref1->frame, ¤t_mv.
mv[1], ¤t_mv);
1968 if (
s->ps.sps->chroma_format_idc) {
1970 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0);
1973 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 1);
1982 int prev_intra_luma_pred_flag)
1985 int x_pu = x0 >>
s->ps.sps->log2_min_pu_size;
1986 int y_pu = y0 >>
s->ps.sps->log2_min_pu_size;
1987 int min_pu_width =
s->ps.sps->min_pu_width;
1988 int size_in_pus = pu_size >>
s->ps.sps->log2_min_pu_size;
1993 s->tab_ipm[(y_pu - 1) * min_pu_width + x_pu] :
INTRA_DC;
1995 s->tab_ipm[y_pu * min_pu_width + x_pu - 1] :
INTRA_DC;
1997 int y_ctb = (y0 >> (
s->ps.sps->log2_ctb_size)) << (
s->ps.sps->log2_ctb_size);
1999 MvField *tab_mvf =
s->ref->tab_mvf;
2000 int intra_pred_mode;
2005 if ((y0 - 1) < y_ctb)
2008 if (cand_left == cand_up) {
2009 if (cand_left < 2) {
2014 candidate[0] = cand_left;
2015 candidate[1] = 2 + ((cand_left - 2 - 1 + 32) & 31);
2016 candidate[2] = 2 + ((cand_left - 2 + 1) & 31);
2019 candidate[0] = cand_left;
2020 candidate[1] = cand_up;
2030 if (prev_intra_luma_pred_flag) {
2031 intra_pred_mode = candidate[lc->
pu.
mpm_idx];
2033 if (candidate[0] > candidate[1])
2034 FFSWAP(uint8_t, candidate[0], candidate[1]);
2035 if (candidate[0] > candidate[2])
2036 FFSWAP(uint8_t, candidate[0], candidate[2]);
2037 if (candidate[1] > candidate[2])
2038 FFSWAP(uint8_t, candidate[1], candidate[2]);
2041 for (
i = 0;
i < 3;
i++)
2042 if (intra_pred_mode >= candidate[
i])
2049 for (
i = 0;
i < size_in_pus;
i++) {
2050 memset(&
s->tab_ipm[(y_pu +
i) * min_pu_width + x_pu],
2051 intra_pred_mode, size_in_pus);
2053 for (j = 0; j < size_in_pus; j++) {
2058 return intra_pred_mode;
2062 int log2_cb_size,
int ct_depth)
2064 int length = (1 << log2_cb_size) >>
s->ps.sps->log2_min_cb_size;
2065 int x_cb = x0 >>
s->ps.sps->log2_min_cb_size;
2066 int y_cb = y0 >>
s->ps.sps->log2_min_cb_size;
2069 for (y = 0; y < length; y++)
2070 memset(&
s->tab_ct_depth[(y_cb + y) *
s->ps.sps->min_cb_width + x_cb],
2075 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20,
2076 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31};
2082 static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 };
2083 uint8_t prev_intra_luma_pred_flag[4];
2085 int pb_size = (1 << log2_cb_size) >>
split;
2086 int side =
split + 1;
2090 for (
i = 0;
i < side;
i++)
2091 for (j = 0; j < side; j++)
2094 for (
i = 0;
i < side;
i++) {
2095 for (j = 0; j < side; j++) {
2096 if (prev_intra_luma_pred_flag[2 *
i + j])
2103 prev_intra_luma_pred_flag[2 *
i + j]);
2107 if (
s->ps.sps->chroma_format_idc == 3) {
2108 for (
i = 0;
i < side;
i++) {
2109 for (j = 0; j < side; j++) {
2111 if (chroma_mode != 4) {
2121 }
else if (
s->ps.sps->chroma_format_idc == 2) {
2124 if (chroma_mode != 4) {
2128 mode_idx = intra_chroma_table[chroma_mode];
2133 }
else if (
s->ps.sps->chroma_format_idc != 0) {
2135 if (chroma_mode != 4) {
2151 int pb_size = 1 << log2_cb_size;
2152 int size_in_pus = pb_size >>
s->ps.sps->log2_min_pu_size;
2153 int min_pu_width =
s->ps.sps->min_pu_width;
2154 MvField *tab_mvf =
s->ref->tab_mvf;
2155 int x_pu = x0 >>
s->ps.sps->log2_min_pu_size;
2156 int y_pu = y0 >>
s->ps.sps->log2_min_pu_size;
2159 if (size_in_pus == 0)
2161 for (j = 0; j < size_in_pus; j++)
2162 memset(&
s->tab_ipm[(y_pu + j) * min_pu_width + x_pu],
INTRA_DC, size_in_pus);
2164 for (j = 0; j < size_in_pus; j++)
2165 for (k = 0; k < size_in_pus; k++)
2171 int cb_size = 1 << log2_cb_size;
2173 int log2_min_cb_size =
s->ps.sps->log2_min_cb_size;
2174 int length = cb_size >> log2_min_cb_size;
2175 int min_cb_width =
s->ps.sps->min_cb_width;
2176 int x_cb = x0 >> log2_min_cb_size;
2177 int y_cb = y0 >> log2_min_cb_size;
2178 int idx = log2_cb_size - 2;
2179 int qp_block_mask = (1<<(
s->ps.sps->log2_ctb_size -
s->ps.pps->diff_cu_qp_delta_depth)) - 1;
2189 for (x = 0; x < 4; x++)
2191 if (
s->ps.pps->transquant_bypass_enable_flag) {
2201 x = y_cb * min_cb_width + x_cb;
2202 for (y = 0; y < length; y++) {
2203 memset(&
s->skip_flag[x], skip_flag, length);
2208 x = y_cb * min_cb_width + x_cb;
2209 for (y = 0; y < length; y++) {
2210 memset(&
s->skip_flag[x], 0, length);
2219 if (!
s->sh.disable_deblocking_filter_flag)
2227 log2_cb_size ==
s->ps.sps->log2_min_cb_size) {
2235 log2_cb_size >=
s->ps.sps->pcm.log2_min_pcm_cb_size &&
2236 log2_cb_size <= s->ps.sps->pcm.log2_max_pcm_cb_size) {
2242 if (
s->ps.sps->pcm.loop_filter_disable_flag)
2274 hls_prediction_unit(
s, x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
2278 hls_prediction_unit(
s, x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
2282 hls_prediction_unit(
s, x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
2283 hls_prediction_unit(
s, x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
2284 hls_prediction_unit(
s, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
2290 int rqt_root_cbf = 1;
2297 const static int cbf[2] = { 0 };
2300 s->ps.sps->max_transform_hierarchy_depth_inter;
2303 log2_cb_size, 0, 0, cbf, cbf);
2307 if (!
s->sh.disable_deblocking_filter_flag)
2316 x = y_cb * min_cb_width + x_cb;
2317 for (y = 0; y < length; y++) {
2318 memset(&
s->qp_y_tab[x], lc->
qp_y, length);
2322 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2323 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0) {
2333 int log2_cb_size,
int cb_depth)
2336 const int cb_size = 1 << log2_cb_size;
2341 if (x0 + cb_size <= s->ps.sps->width &&
2342 y0 + cb_size <= s->ps.sps->height &&
2343 log2_cb_size >
s->ps.sps->log2_min_cb_size) {
2346 split_cu = (log2_cb_size >
s->ps.sps->log2_min_cb_size);
2348 if (
s->ps.pps->cu_qp_delta_enabled_flag &&
2349 log2_cb_size >=
s->ps.sps->log2_ctb_size -
s->ps.pps->diff_cu_qp_delta_depth) {
2354 if (
s->sh.cu_chroma_qp_offset_enabled_flag &&
2355 log2_cb_size >=
s->ps.sps->log2_ctb_size -
s->ps.pps->diff_cu_chroma_qp_offset_depth) {
2360 int qp_block_mask = (1<<(
s->ps.sps->log2_ctb_size -
s->ps.pps->diff_cu_qp_delta_depth)) - 1;
2361 const int cb_size_split = cb_size >> 1;
2362 const int x1 = x0 + cb_size_split;
2363 const int y1 = y0 + cb_size_split;
2371 if (more_data && x1 < s->ps.sps->width) {
2376 if (more_data && y1 < s->ps.sps->height) {
2381 if (more_data && x1 < s->ps.sps->width &&
2382 y1 < s->ps.sps->height) {
2388 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2389 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0)
2393 return ((x1 + cb_size_split) <
s->ps.sps->width ||
2394 (y1 + cb_size_split) <
s->ps.sps->height);
2401 if ((!((x0 + cb_size) %
2402 (1 << (
s->ps.sps->log2_ctb_size))) ||
2403 (x0 + cb_size >=
s->ps.sps->width)) &&
2405 (1 << (
s->ps.sps->log2_ctb_size))) ||
2406 (y0 + cb_size >=
s->ps.sps->height))) {
2408 return !end_of_slice_flag;
2421 int ctb_size = 1 <<
s->ps.sps->log2_ctb_size;
2422 int ctb_addr_rs =
s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2423 int ctb_addr_in_slice = ctb_addr_rs -
s->sh.slice_addr;
2425 s->tab_slice_address[ctb_addr_rs] =
s->sh.slice_addr;
2427 if (
s->ps.pps->entropy_coding_sync_enabled_flag) {
2428 if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
2431 }
else if (
s->ps.pps->tiles_enabled_flag) {
2432 if (ctb_addr_ts &&
s->ps.pps->tile_id[ctb_addr_ts] !=
s->ps.pps->tile_id[ctb_addr_ts - 1]) {
2433 int idxX =
s->ps.pps->col_idxX[x_ctb >>
s->ps.sps->log2_ctb_size];
2434 lc->
end_of_tiles_x = x_ctb + (
s->ps.pps->column_width[idxX] <<
s->ps.sps->log2_ctb_size);
2444 if (
s->ps.pps->tiles_enabled_flag) {
2445 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]])
2447 if (x_ctb > 0 &&
s->tab_slice_address[ctb_addr_rs] !=
s->tab_slice_address[ctb_addr_rs - 1])
2449 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]])
2451 if (y_ctb > 0 &&
s->tab_slice_address[ctb_addr_rs] !=
s->tab_slice_address[ctb_addr_rs -
s->ps.sps->ctb_width])
2454 if (ctb_addr_in_slice <= 0)
2456 if (ctb_addr_in_slice < s->ps.sps->ctb_width)
2462 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]]));
2463 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]]));
2469 int ctb_size = 1 <<
s->ps.sps->log2_ctb_size;
2473 int ctb_addr_ts =
s->ps.pps->ctb_addr_rs_to_ts[
s->sh.slice_ctb_addr_rs];
2476 if (!ctb_addr_ts &&
s->sh.dependent_slice_segment_flag) {
2481 if (
s->sh.dependent_slice_segment_flag) {
2482 int prev_rs =
s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
2483 if (
s->tab_slice_address[prev_rs] !=
s->sh.slice_addr) {
2489 while (more_data && ctb_addr_ts < s->ps.sps->ctb_size) {
2490 int ctb_addr_rs =
s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2492 x_ctb = (ctb_addr_rs % ((
s->ps.sps->width + ctb_size - 1) >>
s->ps.sps->log2_ctb_size)) <<
s->ps.sps->log2_ctb_size;
2493 y_ctb = (ctb_addr_rs / ((
s->ps.sps->width + ctb_size - 1) >>
s->ps.sps->log2_ctb_size)) <<
s->ps.sps->log2_ctb_size;
2498 s->tab_slice_address[ctb_addr_rs] = -1;
2502 hls_sao_param(
s, x_ctb >>
s->ps.sps->log2_ctb_size, y_ctb >>
s->ps.sps->log2_ctb_size);
2504 s->deblock[ctb_addr_rs].beta_offset =
s->sh.beta_offset;
2505 s->deblock[ctb_addr_rs].tc_offset =
s->sh.tc_offset;
2506 s->filter_slice_edges[ctb_addr_rs] =
s->sh.slice_loop_filter_across_slices_enabled_flag;
2509 if (more_data < 0) {
2510 s->tab_slice_address[ctb_addr_rs] = -1;
2520 if (x_ctb + ctb_size >=
s->ps.sps->width &&
2521 y_ctb + ctb_size >=
s->ps.sps->height)
2542 int ctb_size = 1<<
s1->ps.sps->log2_ctb_size;
2544 int *ctb_row_p = input_ctb_row;
2545 int ctb_row = ctb_row_p[job];
2546 int ctb_addr_rs =
s1->sh.slice_ctb_addr_rs + ctb_row * ((
s1->ps.sps->width + ctb_size - 1) >>
s1->ps.sps->log2_ctb_size);
2547 int ctb_addr_ts =
s1->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs];
2548 int thread = ctb_row %
s1->threads_number;
2551 s =
s1->sList[self_id];
2561 while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) {
2562 int x_ctb = (ctb_addr_rs %
s->ps.sps->ctb_width) <<
s->ps.sps->log2_ctb_size;
2563 int y_ctb = (ctb_addr_rs /
s->ps.sps->ctb_width) <<
s->ps.sps->log2_ctb_size;
2577 hls_sao_param(
s, x_ctb >>
s->ps.sps->log2_ctb_size, y_ctb >>
s->ps.sps->log2_ctb_size);
2580 if (more_data < 0) {
2591 if (!more_data && (x_ctb+ctb_size) <
s->ps.sps->width && ctb_row !=
s->sh.num_entry_point_offsets) {
2597 if ((x_ctb+ctb_size) >=
s->ps.sps->width && (y_ctb+ctb_size) >=
s->ps.sps->height ) {
2602 ctb_addr_rs =
s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2605 if(x_ctb >=
s->ps.sps->width) {
2613 s->tab_slice_address[ctb_addr_rs] = -1;
2622 int length = nal->
size;
2627 int64_t startheader, cmpt = 0;
2636 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) {
2638 s->sh.slice_ctb_addr_rs,
s->sh.num_entry_point_offsets,
2639 s->ps.sps->ctb_width,
s->ps.sps->ctb_height
2647 for (
i = 1;
i <
s->threads_number;
i++) {
2648 if (
s->sList[
i] &&
s->HEVClcList[
i])
2654 if (!
s->sList[
i] || !
s->HEVClcList[
i]) {
2659 s->sList[
i]->HEVClc =
s->HEVClcList[
i];
2664 for (j = 0, cmpt = 0, startheader =
offset +
s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) {
2671 for (
i = 1;
i <
s->sh.num_entry_point_offsets;
i++) {
2672 offset += (
s->sh.entry_point_offset[
i - 1] - cmpt);
2673 for (j = 0, cmpt = 0, startheader =
offset
2674 +
s->sh.entry_point_offset[
i]; j < nal->skipped_bytes; j++) {
2680 s->sh.size[
i - 1] =
s->sh.entry_point_offset[
i] - cmpt;
2684 if (
s->sh.num_entry_point_offsets != 0) {
2685 offset +=
s->sh.entry_point_offset[
s->sh.num_entry_point_offsets - 1] - cmpt;
2691 s->sh.size[
s->sh.num_entry_point_offsets - 1] = length -
offset;
2692 s->sh.offset[
s->sh.num_entry_point_offsets - 1] =
offset;
2697 for (
i = 1;
i <
s->threads_number;
i++) {
2698 s->sList[
i]->HEVClc->first_qp_group = 1;
2699 s->sList[
i]->HEVClc->qp_y =
s->sList[0]->HEVClc->qp_y;
2701 s->sList[
i]->HEVClc =
s->HEVClcList[
i];
2707 for (
i = 0;
i <=
s->sh.num_entry_point_offsets;
i++) {
2712 if (
s->ps.pps->entropy_coding_sync_enabled_flag)
2715 for (
i = 0;
i <=
s->sh.num_entry_point_offsets;
i++)
2728 if (
s->sei.frame_packing.present &&
2729 s->sei.frame_packing.arrangement_type >= 3 &&
2730 s->sei.frame_packing.arrangement_type <= 5 &&
2731 s->sei.frame_packing.content_interpretation_type > 0 &&
2732 s->sei.frame_packing.content_interpretation_type < 3) {
2737 switch (
s->sei.frame_packing.arrangement_type) {
2739 if (
s->sei.frame_packing.quincunx_subsampling)
2752 if (
s->sei.frame_packing.content_interpretation_type == 2)
2755 if (
s->sei.frame_packing.arrangement_type == 5) {
2756 if (
s->sei.frame_packing.current_frame_is_frame0_flag)
2763 if (
s->sei.display_orientation.present &&
2764 (
s->sei.display_orientation.anticlockwise_rotation ||
2765 s->sei.display_orientation.hflip ||
s->sei.display_orientation.vflip)) {
2766 double angle =
s->sei.display_orientation.anticlockwise_rotation * 360 / (double) (1 << 16);
2781 angle = -angle * (1 - 2 * !!
s->sei.display_orientation.hflip)
2782 * (1 - 2 * !!
s->sei.display_orientation.vflip);
2785 s->sei.display_orientation.hflip,
2786 s->sei.display_orientation.vflip);
2791 if (
s->sei.mastering_display.present > 0 &&
2793 s->sei.mastering_display.present--;
2795 if (
s->sei.mastering_display.present) {
2797 const int mapping[3] = {2, 0, 1};
2798 const int chroma_den = 50000;
2799 const int luma_den = 10000;
2806 for (
i = 0;
i < 3;
i++) {
2807 const int j = mapping[
i];
2813 metadata->
white_point[0].
num =
s->sei.mastering_display.white_point[0];
2815 metadata->
white_point[1].
num =
s->sei.mastering_display.white_point[1];
2827 "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f)\n",
2836 "min_luminance=%f, max_luminance=%f\n",
2841 if (
s->sei.content_light.present > 0 &&
2843 s->sei.content_light.present--;
2845 if (
s->sei.content_light.present) {
2850 metadata->
MaxCLL =
s->sei.content_light.max_content_light_level;
2851 metadata->
MaxFALL =
s->sei.content_light.max_pic_average_light_level;
2858 if (
s->sei.a53_caption.buf_ref) {
2867 for (
int i = 0;
i <
s->sei.unregistered.nb_buf_ref;
i++) {
2879 s->sei.unregistered.nb_buf_ref = 0;
2881 if (
s->sei.timecode.present) {
2885 sizeof(uint32_t) * 4);
2889 tc_sd = (uint32_t*)tcside->
data;
2890 tc_sd[0] =
s->sei.timecode.num_clock_ts;
2892 for (
int i = 0;
i < tc_sd[0];
i++) {
2893 int drop =
s->sei.timecode.cnt_dropped_flag[
i];
2894 int hh =
s->sei.timecode.hours_value[
i];
2895 int mm =
s->sei.timecode.minutes_value[
i];
2896 int ss =
s->sei.timecode.seconds_value[
i];
2897 int ff =
s->sei.timecode.n_frames[
i];
2904 s->sei.timecode.num_clock_ts = 0;
2907 if (
s->sei.film_grain_characteristics.present) {
2914 fgp->
seed =
s->ref->poc;
2926 const VUI *vui = &
sps->vui;
2962 if (
s->sei.dynamic_hdr_plus.info) {
2990 int pic_size_in_ctb = ((
s->ps.sps->width >>
s->ps.sps->log2_min_cb_size) + 1) *
2991 ((
s->ps.sps->height >>
s->ps.sps->log2_min_cb_size) + 1);
2994 memset(
s->horizontal_bs, 0,
s->bs_width *
s->bs_height);
2995 memset(
s->vertical_bs, 0,
s->bs_width *
s->bs_height);
2996 memset(
s->cbf_luma, 0,
s->ps.sps->min_tb_width *
s->ps.sps->min_tb_height);
2997 memset(
s->is_pcm, 0, (
s->ps.sps->min_pu_width + 1) * (
s->ps.sps->min_pu_height + 1));
2998 memset(
s->tab_slice_address, -1, pic_size_in_ctb *
sizeof(*
s->tab_slice_address));
3001 s->first_nal_type =
s->nal_unit_type;
3005 if (
s->ps.pps->tiles_enabled_flag)
3006 lc->
end_of_tiles_x =
s->ps.pps->column_width[0] <<
s->ps.sps->log2_ctb_size;
3020 s->ref->needs_fg =
s->sei.film_grain_characteristics.present &&
3024 if (
s->ref->needs_fg) {
3025 s->ref->frame_grain->format =
s->ref->frame->format;
3026 s->ref->frame_grain->width =
s->ref->frame->width;
3027 s->ref->frame_grain->height =
s->ref->frame->height;
3036 s->frame->pict_type = 3 -
s->sh.slice_type;
3046 if (!
s->avctx->hwaccel)
3064 if (
out->needs_fg) {
3084 int ctb_addr_ts,
ret;
3087 s->nal_unit_type = nal->
type;
3090 switch (
s->nal_unit_type) {
3092 if (
s->avctx->hwaccel &&
s->avctx->hwaccel->decode_params) {
3093 ret =
s->avctx->hwaccel->decode_params(
s->avctx,
3105 if (
s->avctx->hwaccel &&
s->avctx->hwaccel->decode_params) {
3106 ret =
s->avctx->hwaccel->decode_params(
s->avctx,
3114 s->apply_defdispwin);
3119 if (
s->avctx->hwaccel &&
s->avctx->hwaccel->decode_params) {
3120 ret =
s->avctx->hwaccel->decode_params(
s->avctx,
3133 if (
s->avctx->hwaccel &&
s->avctx->hwaccel->decode_params) {
3134 ret =
s->avctx->hwaccel->decode_params(
s->avctx,
3177 if (
s->sh.first_slice_in_pic_flag) {
3178 if (
s->max_ra == INT_MAX) {
3183 s->max_ra = INT_MIN;
3188 s->poc <=
s->max_ra) {
3193 s->max_ra = INT_MIN;
3200 }
else if (!
s->ref) {
3205 if (
s->nal_unit_type !=
s->first_nal_type) {
3207 "Non-matching NAL types of the VCL NALUs: %d %d\n",
3208 s->first_nal_type,
s->nal_unit_type);
3212 if (!
s->sh.dependent_slice_segment_flag &&
3217 "Error constructing the reference lists for the current slice.\n");
3222 if (
s->sh.first_slice_in_pic_flag &&
s->avctx->hwaccel) {
3223 ret =
s->avctx->hwaccel->start_frame(
s->avctx,
NULL, 0);
3228 if (
s->avctx->hwaccel) {
3233 if (
s->threads_number > 1 &&
s->sh.num_entry_point_offsets > 0)
3237 if (ctb_addr_ts >= (
s->ps.sps->ctb_width *
s->ps.sps->ctb_height)) {
3244 if (ctb_addr_ts < 0) {
3252 s->seq_decode = (
s->seq_decode + 1) & 0xff;
3253 s->max_ra = INT_MAX;
3261 "Skipping NAL unit %d\n",
s->nal_unit_type);
3274 int eos_at_start = 1;
3277 s->last_eos =
s->eos;
3284 s->nal_length_size,
s->avctx->codec_id, 1, 0);
3287 "Error splitting the input into NAL units.\n");
3291 for (
i = 0;
i <
s->pkt.nb_nals;
i++) {
3313 s->pkt.nals[
s->pkt.nb_nals - 1].size > 2 && !
s->pkt.nals[
s->pkt.nb_nals - 1].nuh_layer_id
3314 && !
s->pkt.nals[
s->pkt.nb_nals - 1].temporal_id) {
3315 H2645NAL *nal = &
s->pkt.nals[
s->pkt.nb_nals - 1];
3318 av_log(
s->avctx,
AV_LOG_WARNING,
"Multiple Dolby Vision RPUs found in one AU. Skipping previous.\n");
3335 for (
i = 0;
i <
s->pkt.nb_nals;
i++) {
3344 if (
ret >= 0 &&
s->overlap > 2)
3348 "Error parsing NAL unit #%d.\n",
i);
3363 for (
i = 0;
i < 16;
i++)
3376 pixel_shift =
desc->comp[0].depth > 8;
3384 if (pixel_shift && !
s->checksum_buf) {
3387 frame->linesize[2]));
3388 if (!
s->checksum_buf)
3394 int width =
s->avctx->coded_width;
3395 int height =
s->avctx->coded_height;
3401 for (j = 0; j <
h; j++) {
3405 s->bdsp.bswap16_buf((uint16_t *)
s->checksum_buf,
3406 (
const uint16_t *)
src,
w);
3407 src =
s->checksum_buf;
3414 if (!memcmp(
md5,
s->sei.picture_hash.md5[
i], 16)) {
3438 &
s->nal_length_size,
s->avctx->err_recognition,
3439 s->apply_defdispwin,
s->avctx);
3445 if (
first &&
s->ps.sps_list[
i]) {
3478 if (sd && sd_size > 0) {
3485 if (sd && sd_size > 0)
3496 "hardware accelerator failed to decode picture\n");
3503 s->sei.picture_hash.is_md5) {
3511 s->sei.picture_hash.is_md5 = 0;
3513 if (
s->is_decoded) {
3518 if (
s->output_frame->buf[0]) {
3534 if (
src->needs_fg) {
3560 if (
src->hwaccel_picture_private) {
3587 for (
i = 0;
i < 3;
i++) {
3605 if (
s->HEVClcList &&
s->sList) {
3606 for (
i = 1;
i <
s->threads_number;
i++) {
3632 if (!
s->HEVClc || !
s->HEVClcList || !
s->sList)
3634 s->HEVClcList[0] =
s->HEVClc;
3638 if (!
s->cabac_state)
3642 if (!
s->output_frame)
3647 if (!
s->DPB[
i].frame)
3649 s->DPB[
i].tf.f =
s->DPB[
i].frame;
3652 if (!
s->DPB[
i].frame_grain)
3654 s->DPB[
i].tf_grain.f =
s->DPB[
i].frame_grain;
3657 s->max_ra = INT_MAX;
3665 s->dovi_ctx.logctx = avctx;
3666 s->context_initialized = 1;
3686 if (!
s->context_initialized) {
3694 if (
s0->DPB[
i].frame->buf[0]) {
3701 if (
s->ps.sps !=
s0->ps.sps)
3721 if (
s->ps.sps !=
s0->ps.sps)
3725 s->seq_decode =
s0->seq_decode;
3726 s->seq_output =
s0->seq_output;
3727 s->pocTid0 =
s0->pocTid0;
3728 s->max_ra =
s0->max_ra;
3730 s->no_rasl_output_flag =
s0->no_rasl_output_flag;
3732 s->is_nalff =
s0->is_nalff;
3733 s->nal_length_size =
s0->nal_length_size;
3735 s->threads_number =
s0->threads_number;
3736 s->threads_type =
s0->threads_type;
3739 s->seq_decode = (
s->seq_decode + 1) & 0xff;
3740 s->max_ra = INT_MAX;
3747 for (
i = 0;
i <
s->sei.unregistered.nb_buf_ref;
i++)
3749 s->sei.unregistered.nb_buf_ref = 0;
3751 if (
s0->sei.unregistered.nb_buf_ref) {
3753 s0->sei.unregistered.nb_buf_ref,
3754 sizeof(*
s->sei.unregistered.buf_ref));
3758 for (
i = 0;
i <
s0->sei.unregistered.nb_buf_ref;
i++) {
3760 if (!
s->sei.unregistered.buf_ref[
i])
3762 s->sei.unregistered.nb_buf_ref++;
3778 s->sei.frame_packing =
s0->sei.frame_packing;
3779 s->sei.display_orientation =
s0->sei.display_orientation;
3780 s->sei.mastering_display =
s0->sei.mastering_display;
3781 s->sei.content_light =
s0->sei.content_light;
3782 s->sei.alternative_transfer =
s0->sei.alternative_transfer;
3800 s->threads_number = 1;
3811 s->enable_parallel_tiles = 0;
3812 s->sei.picture_timing.picture_struct = 0;
3836 s->max_ra = INT_MAX;
3840 #define OFFSET(x) offsetof(HEVCContext, x)
3841 #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
3844 {
"apply_defdispwin",
"Apply default display window from VUI",
OFFSET(apply_defdispwin),
3846 {
"strict-displaywin",
"stricly apply default display window size",
OFFSET(apply_defdispwin),
3876 #if CONFIG_HEVC_DXVA2_HWACCEL
3879 #if CONFIG_HEVC_D3D11VA_HWACCEL
3882 #if CONFIG_HEVC_D3D11VA2_HWACCEL
3885 #if CONFIG_HEVC_NVDEC_HWACCEL
3888 #if CONFIG_HEVC_VAAPI_HWACCEL
3891 #if CONFIG_HEVC_VDPAU_HWACCEL
3894 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL