26 #include "config_components.h"
55 static const uint8_t
hevc_pel_weight[65] = { [2] = 0, [4] = 1, [6] = 2, [8] = 3, [12] = 4, [16] = 5, [24] = 6, [32] = 7, [48] = 8, [64] = 9 };
97 int log2_min_cb_size =
sps->log2_min_cb_size;
100 int pic_size_in_ctb = ((
width >> log2_min_cb_size) + 1) *
101 ((
height >> log2_min_cb_size) + 1);
102 int ctb_count =
sps->ctb_width *
sps->ctb_height;
103 int min_pu_size =
sps->min_pu_width *
sps->min_pu_height;
105 s->bs_width = (
width >> 2) + 1;
106 s->bs_height = (
height >> 2) + 1;
109 s->deblock =
av_calloc(ctb_count,
sizeof(*
s->deblock));
110 if (!
s->sao || !
s->deblock)
115 if (!
s->skip_flag || !
s->tab_ct_depth)
121 if (!
s->tab_ipm || !
s->cbf_luma || !
s->is_pcm)
126 sizeof(*
s->tab_slice_address));
128 sizeof(*
s->qp_y_tab));
129 if (!
s->qp_y_tab || !
s->filter_slice_edges || !
s->tab_slice_address)
132 s->horizontal_bs =
av_calloc(
s->bs_width,
s->bs_height);
134 if (!
s->horizontal_bs || !
s->vertical_bs)
139 if (!
s->tab_mvf_pool || !
s->rpl_tab_pool)
153 uint8_t luma_weight_l0_flag[16];
154 uint8_t chroma_weight_l0_flag[16];
155 uint8_t luma_weight_l1_flag[16];
156 uint8_t chroma_weight_l1_flag[16];
157 int luma_log2_weight_denom;
160 if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) {
161 av_log(
s->avctx,
AV_LOG_ERROR,
"luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom);
164 s->sh.luma_log2_weight_denom =
av_clip_uintp2(luma_log2_weight_denom, 3);
165 if (
s->ps.sps->chroma_format_idc != 0) {
167 if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) {
168 av_log(
s->avctx,
AV_LOG_ERROR,
"chroma_log2_weight_denom %"PRId64
" is invalid\n", chroma_log2_weight_denom);
171 s->sh.chroma_log2_weight_denom = chroma_log2_weight_denom;
174 for (
i = 0;
i <
s->sh.nb_refs[
L0];
i++) {
176 if (!luma_weight_l0_flag[
i]) {
177 s->sh.luma_weight_l0[
i] = 1 <<
s->sh.luma_log2_weight_denom;
178 s->sh.luma_offset_l0[
i] = 0;
181 if (
s->ps.sps->chroma_format_idc != 0) {
182 for (
i = 0;
i <
s->sh.nb_refs[
L0];
i++)
185 for (
i = 0;
i <
s->sh.nb_refs[
L0];
i++)
186 chroma_weight_l0_flag[
i] = 0;
188 for (
i = 0;
i <
s->sh.nb_refs[
L0];
i++) {
189 if (luma_weight_l0_flag[
i]) {
191 if ((int8_t)delta_luma_weight_l0 != delta_luma_weight_l0)
193 s->sh.luma_weight_l0[
i] = (1 <<
s->sh.luma_log2_weight_denom) + delta_luma_weight_l0;
196 if (chroma_weight_l0_flag[
i]) {
197 for (j = 0; j < 2; j++) {
201 if ( (int8_t)delta_chroma_weight_l0 != delta_chroma_weight_l0
202 || delta_chroma_offset_l0 < -(1<<17) || delta_chroma_offset_l0 > (1<<17)) {
206 s->sh.chroma_weight_l0[
i][j] = (1 <<
s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l0;
207 s->sh.chroma_offset_l0[
i][j] =
av_clip((delta_chroma_offset_l0 - ((128 *
s->sh.chroma_weight_l0[
i][j])
208 >>
s->sh.chroma_log2_weight_denom) + 128), -128, 127);
211 s->sh.chroma_weight_l0[
i][0] = 1 <<
s->sh.chroma_log2_weight_denom;
212 s->sh.chroma_offset_l0[
i][0] = 0;
213 s->sh.chroma_weight_l0[
i][1] = 1 <<
s->sh.chroma_log2_weight_denom;
214 s->sh.chroma_offset_l0[
i][1] = 0;
218 for (
i = 0;
i <
s->sh.nb_refs[
L1];
i++) {
220 if (!luma_weight_l1_flag[
i]) {
221 s->sh.luma_weight_l1[
i] = 1 <<
s->sh.luma_log2_weight_denom;
222 s->sh.luma_offset_l1[
i] = 0;
225 if (
s->ps.sps->chroma_format_idc != 0) {
226 for (
i = 0;
i <
s->sh.nb_refs[
L1];
i++)
229 for (
i = 0;
i <
s->sh.nb_refs[
L1];
i++)
230 chroma_weight_l1_flag[
i] = 0;
232 for (
i = 0;
i <
s->sh.nb_refs[
L1];
i++) {
233 if (luma_weight_l1_flag[
i]) {
235 if ((int8_t)delta_luma_weight_l1 != delta_luma_weight_l1)
237 s->sh.luma_weight_l1[
i] = (1 <<
s->sh.luma_log2_weight_denom) + delta_luma_weight_l1;
240 if (chroma_weight_l1_flag[
i]) {
241 for (j = 0; j < 2; j++) {
245 if ( (int8_t)delta_chroma_weight_l1 != delta_chroma_weight_l1
246 || delta_chroma_offset_l1 < -(1<<17) || delta_chroma_offset_l1 > (1<<17)) {
250 s->sh.chroma_weight_l1[
i][j] = (1 <<
s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l1;
251 s->sh.chroma_offset_l1[
i][j] =
av_clip((delta_chroma_offset_l1 - ((128 *
s->sh.chroma_weight_l1[
i][j])
252 >>
s->sh.chroma_log2_weight_denom) + 128), -128, 127);
255 s->sh.chroma_weight_l1[
i][0] = 1 <<
s->sh.chroma_log2_weight_denom;
256 s->sh.chroma_offset_l1[
i][0] = 0;
257 s->sh.chroma_weight_l1[
i][1] = 1 <<
s->sh.chroma_log2_weight_denom;
258 s->sh.chroma_offset_l1[
i][1] = 0;
268 int max_poc_lsb = 1 <<
sps->log2_max_poc_lsb;
269 int prev_delta_msb = 0;
270 unsigned int nb_sps = 0, nb_sh;
274 if (!
sps->long_term_ref_pics_present_flag)
277 if (
sps->num_long_term_ref_pics_sps > 0)
281 if (nb_sps >
sps->num_long_term_ref_pics_sps)
291 uint8_t lt_idx_sps = 0;
293 if (
sps->num_long_term_ref_pics_sps > 1)
296 rps->
poc[
i] =
sps->lt_ref_pic_poc_lsb_sps[lt_idx_sps];
297 rps->
used[
i] =
sps->used_by_curr_pic_lt_sps_flag[lt_idx_sps];
308 if (
i &&
i != nb_sps)
309 delta += prev_delta_msb;
311 poc = rps->
poc[
i] +
s->poc -
delta * max_poc_lsb -
s->sh.pic_order_cnt_lsb;
315 prev_delta_msb =
delta;
328 unsigned int num = 0, den = 0;
336 avctx->
profile =
sps->ptl.general_ptl.profile_idc;
337 avctx->
level =
sps->ptl.general_ptl.level_idc;
341 if (
sps->vui.common.video_signal_type_present_flag)
347 if (
sps->vui.common.colour_description_present_flag) {
349 avctx->
color_trc =
sps->vui.common.transfer_characteristics;
358 if (
sps->chroma_format_idc == 1) {
359 if (
sps->vui.common.chroma_loc_info_present_flag) {
360 if (
sps->vui.common.chroma_sample_loc_type_top_field <= 5)
366 if (
vps->vps_timing_info_present_flag) {
367 num =
vps->vps_num_units_in_tick;
368 den =
vps->vps_time_scale;
369 }
else if (
sps->vui.vui_timing_info_present_flag) {
370 num =
sps->vui.vui_num_units_in_tick;
371 den =
sps->vui.vui_time_scale;
374 if (num > 0 && den > 0)
383 if (
s->sei.common.a53_caption.buf_ref)
386 if (
s->sei.common.alternative_transfer.present &&
389 avctx->
color_trc =
s->sei.common.alternative_transfer.preferred_transfer_characteristics;
392 if (
s->sei.common.film_grain_characteristics.present ||
393 s->sei.common.aom_film_grain.enable)
401 #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + \
402 CONFIG_HEVC_D3D11VA_HWACCEL * 2 + \
403 CONFIG_HEVC_D3D12VA_HWACCEL + \
404 CONFIG_HEVC_NVDEC_HWACCEL + \
405 CONFIG_HEVC_VAAPI_HWACCEL + \
406 CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL + \
407 CONFIG_HEVC_VDPAU_HWACCEL + \
408 CONFIG_HEVC_VULKAN_HWACCEL)
411 switch (
sps->pix_fmt) {
414 #if CONFIG_HEVC_DXVA2_HWACCEL
417 #if CONFIG_HEVC_D3D11VA_HWACCEL
421 #if CONFIG_HEVC_D3D12VA_HWACCEL
424 #if CONFIG_HEVC_VAAPI_HWACCEL
427 #if CONFIG_HEVC_VDPAU_HWACCEL
430 #if CONFIG_HEVC_NVDEC_HWACCEL
433 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
436 #if CONFIG_HEVC_VULKAN_HWACCEL
441 #if CONFIG_HEVC_DXVA2_HWACCEL
444 #if CONFIG_HEVC_D3D11VA_HWACCEL
448 #if CONFIG_HEVC_D3D12VA_HWACCEL
451 #if CONFIG_HEVC_VAAPI_HWACCEL
454 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
457 #if CONFIG_HEVC_VULKAN_HWACCEL
460 #if CONFIG_HEVC_VDPAU_HWACCEL
463 #if CONFIG_HEVC_NVDEC_HWACCEL
468 #if CONFIG_HEVC_VAAPI_HWACCEL
471 #if CONFIG_HEVC_VDPAU_HWACCEL
474 #if CONFIG_HEVC_NVDEC_HWACCEL
477 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
480 #if CONFIG_HEVC_VULKAN_HWACCEL
486 #if CONFIG_HEVC_VAAPI_HWACCEL
489 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
492 #if CONFIG_HEVC_VULKAN_HWACCEL
497 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
503 #if CONFIG_HEVC_VAAPI_HWACCEL
506 #if CONFIG_HEVC_VDPAU_HWACCEL
509 #if CONFIG_HEVC_VULKAN_HWACCEL
512 #if CONFIG_HEVC_NVDEC_HWACCEL
517 #if CONFIG_HEVC_VAAPI_HWACCEL
520 #if CONFIG_HEVC_VULKAN_HWACCEL
526 *fmt++ =
sps->pix_fmt;
556 for (
i = 0;
i < 3;
i++) {
561 if (
sps->sao_enabled && !
s->avctx->hwaccel) {
562 int c_count = (
sps->chroma_format_idc != 0) ? 3 : 1;
565 for(c_idx = 0; c_idx < c_count; c_idx++) {
566 int w =
sps->width >>
sps->hshift[c_idx];
567 int h =
sps->height >>
sps->vshift[c_idx];
568 s->sao_pixel_buffer_h[c_idx] =
571 s->sao_pixel_buffer_v[c_idx] =
574 if (!
s->sao_pixel_buffer_h[c_idx] ||
575 !
s->sao_pixel_buffer_v[c_idx])
581 s->ps.vps =
s->ps.vps_list[
s->ps.sps->vps_id];
587 for (
i = 0;
i < 3;
i++) {
604 av_log(
s->avctx,
AV_LOG_ERROR,
"Two slices reporting being the first in the same frame.\n");
624 s->ps.pps !=
s->ps.pps_list[sh->
pps_id]) {
628 s->ps.pps =
s->ps.pps_list[sh->
pps_id];
632 if (
s->ps.sps !=
s->ps.sps_list[
s->ps.pps->sps_id]) {
657 int slice_address_length;
659 if (
s->ps.pps->dependent_slice_segments_enabled_flag)
667 s->ps.sps->ctb_height);
671 "Invalid slice segment address: %u.\n",
683 s->slice_initialized = 0;
687 s->slice_initialized = 0;
689 for (
i = 0;
i <
s->ps.pps->num_extra_slice_header_bits;
i++)
701 !
s->ps.pps->pps_curr_pic_ref_enabled_flag) {
708 if (
s->ps.pps->output_flag_present_flag)
711 if (
s->ps.sps->separate_colour_plane_flag)
721 "Ignoring POC change between slices: %d -> %d\n",
s->poc, poc);
737 int numbits, rps_idx;
739 if (!
s->ps.sps->nb_st_rps) {
745 rps_idx = numbits > 0 ?
get_bits(gb, numbits) : 0;
759 if (
s->ps.sps->sps_temporal_mvp_enabled_flag)
784 if (
s->ps.sps->sao_enabled) {
786 if (
s->ps.sps->chroma_format_idc) {
800 sh->
nb_refs[
L0] =
s->ps.pps->num_ref_idx_l0_default_active;
802 sh->
nb_refs[
L1] =
s->ps.pps->num_ref_idx_l1_default_active;
823 if (
s->ps.pps->lists_modification_present_flag && nb_refs > 1) {
841 if (
s->ps.pps->cabac_init_present_flag)
856 "Invalid collocated_ref_idx: %d.\n",
873 "Invalid number of merging MVP candidates: %d.\n",
879 if (
s->ps.sps->motion_vector_resolution_control_idc == 2)
889 if (
s->ps.pps->pic_slice_level_chroma_qp_offsets_present_flag) {
902 if (
s->ps.pps->pps_slice_act_qp_offsets_present_flag) {
908 if (
s->ps.pps->chroma_qp_offset_list_enabled_flag)
913 if (
s->ps.pps->deblocking_filter_control_present_flag) {
914 int deblocking_filter_override_flag = 0;
916 if (
s->ps.pps->deblocking_filter_override_enabled_flag)
917 deblocking_filter_override_flag =
get_bits1(gb);
919 if (deblocking_filter_override_flag) {
924 if (beta_offset_div2 < -6 || beta_offset_div2 > 6 ||
925 tc_offset_div2 < -6 || tc_offset_div2 > 6) {
927 "Invalid deblock filter offsets: %d, %d\n",
928 beta_offset_div2, tc_offset_div2);
945 if (
s->ps.pps->seq_loop_filter_across_slices_enabled_flag &&
956 if (
s->ps.pps->tiles_enabled_flag ||
s->ps.pps->entropy_coding_sync_enabled_flag) {
960 av_log(
s->avctx,
AV_LOG_ERROR,
"num_entry_point_offsets %d is invalid\n", num_entry_point_offsets);
968 if (offset_len < 1 || offset_len > 32) {
989 if (
s->threads_number > 1 && (
s->ps.pps->num_tile_rows > 1 ||
s->ps.pps->num_tile_columns > 1)) {
990 s->enable_parallel_tiles = 0;
991 s->threads_number = 1;
993 s->enable_parallel_tiles = 0;
995 s->enable_parallel_tiles = 0;
998 if (
s->ps.pps->slice_header_extension_present_flag) {
1004 for (
i = 0;
i < length;
i++)
1011 sh->
slice_qp < -
s->ps.sps->qp_bd_offset) {
1013 "The slice_qp %d is outside the valid range "
1016 -
s->ps.sps->qp_bd_offset);
1022 if (!
s->sh.slice_ctb_addr_rs &&
s->sh.dependent_slice_segment_flag) {
1033 s->HEVClc->first_qp_group = !
s->sh.dependent_slice_segment_flag;
1035 if (!
s->ps.pps->cu_qp_delta_enabled_flag)
1036 s->HEVClc->qp_y =
s->sh.slice_qp;
1038 s->slice_initialized = 1;
1039 s->HEVClc->tu.cu_qp_offset_cb = 0;
1040 s->HEVClc->tu.cu_qp_offset_cr = 0;
1045 #define CTB(tab, x, y) ((tab)[(y) * s->ps.sps->ctb_width + (x)])
1047 #define SET_SAO(elem, value) \
1049 if (!sao_merge_up_flag && !sao_merge_left_flag) \
1050 sao->elem = value; \
1051 else if (sao_merge_left_flag) \
1052 sao->elem = CTB(s->sao, rx-1, ry).elem; \
1053 else if (sao_merge_up_flag) \
1054 sao->elem = CTB(s->sao, rx, ry-1).elem; \
1062 int sao_merge_left_flag = 0;
1063 int sao_merge_up_flag = 0;
1067 if (
s->sh.slice_sample_adaptive_offset_flag[0] ||
1068 s->sh.slice_sample_adaptive_offset_flag[1]) {
1073 if (ry > 0 && !sao_merge_left_flag) {
1079 for (c_idx = 0; c_idx < (
s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) {
1080 int log2_sao_offset_scale = c_idx == 0 ?
s->ps.pps->log2_sao_offset_scale_luma :
1081 s->ps.pps->log2_sao_offset_scale_chroma;
1083 if (!
s->sh.slice_sample_adaptive_offset_flag[c_idx]) {
1098 for (
i = 0;
i < 4;
i++)
1102 for (
i = 0;
i < 4;
i++) {
1111 }
else if (c_idx != 2) {
1117 for (
i = 0;
i < 4;
i++) {
1125 sao->
offset_val[c_idx][
i + 1] *= 1 << log2_sao_offset_scale;
1137 if (log2_res_scale_abs_plus1 != 0) {
1140 (1 - 2 * res_scale_sign_flag);
1150 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1151 int log2_cb_size,
int log2_trafo_size,
1152 int blk_idx,
int cbf_luma,
int *cbf_cb,
int *cbf_cr)
1155 const int log2_trafo_size_c = log2_trafo_size -
s->ps.sps->hshift[1];
1159 int trafo_size = 1 << log2_trafo_size;
1162 s->hpc.intra_pred[log2_trafo_size - 2](lc, x0, y0, 0);
1165 if (cbf_luma || cbf_cb[0] || cbf_cr[0] ||
1166 (
s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
1169 int cbf_chroma = cbf_cb[0] || cbf_cr[0] ||
1170 (
s->ps.sps->chroma_format_idc == 2 &&
1171 (cbf_cb[1] || cbf_cr[1]));
1183 "The cu_qp_delta %d is outside the valid range "
1186 -(26 +
s->ps.sps->qp_bd_offset / 2),
1187 (25 +
s->ps.sps->qp_bd_offset / 2));
1194 if (
s->sh.cu_chroma_qp_offset_enabled_flag && cbf_chroma &&
1197 if (cu_chroma_qp_offset_flag) {
1198 int cu_chroma_qp_offset_idx = 0;
1199 if (
s->ps.pps->chroma_qp_offset_list_len_minus1 > 0) {
1202 "cu_chroma_qp_offset_idx not yet tested.\n");
1235 if (
s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 ||
s->ps.sps->chroma_format_idc == 3)) {
1236 int trafo_size_h = 1 << (log2_trafo_size_c +
s->ps.sps->hshift[1]);
1237 int trafo_size_v = 1 << (log2_trafo_size_c +
s->ps.sps->vshift[1]);
1238 lc->
tu.
cross_pf = (
s->ps.pps->cross_component_prediction_enabled_flag && cbf_luma &&
1245 for (
i = 0;
i < (
s->ps.sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1248 s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (
i << log2_trafo_size_c), 1);
1252 log2_trafo_size_c, scan_idx_c, 1);
1255 ptrdiff_t
stride =
s->frame->linesize[1];
1256 int hshift =
s->ps.sps->hshift[1];
1257 int vshift =
s->ps.sps->vshift[1];
1260 int size = 1 << log2_trafo_size_c;
1262 uint8_t *dst = &
s->frame->data[1][(y0 >> vshift) *
stride +
1263 ((x0 >> hshift) <<
s->ps.sps->pixel_shift)];
1267 s->hevcdsp.add_residual[log2_trafo_size_c-2](dst, coeffs,
stride);
1274 for (
i = 0;
i < (
s->ps.sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1277 trafo_size_h, trafo_size_v);
1278 s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (
i << log2_trafo_size_c), 2);
1282 log2_trafo_size_c, scan_idx_c, 2);
1285 ptrdiff_t
stride =
s->frame->linesize[2];
1286 int hshift =
s->ps.sps->hshift[2];
1287 int vshift =
s->ps.sps->vshift[2];
1290 int size = 1 << log2_trafo_size_c;
1292 uint8_t *dst = &
s->frame->data[2][(y0 >> vshift) *
stride +
1293 ((x0 >> hshift) <<
s->ps.sps->pixel_shift)];
1297 s->hevcdsp.add_residual[log2_trafo_size_c-2](dst, coeffs,
stride);
1300 }
else if (
s->ps.sps->chroma_format_idc && blk_idx == 3) {
1301 int trafo_size_h = 1 << (log2_trafo_size + 1);
1302 int trafo_size_v = 1 << (log2_trafo_size +
s->ps.sps->vshift[1]);
1303 for (
i = 0;
i < (
s->ps.sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1306 trafo_size_h, trafo_size_v);
1307 s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + (
i << log2_trafo_size), 1);
1311 log2_trafo_size, scan_idx_c, 1);
1313 for (
i = 0;
i < (
s->ps.sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1316 trafo_size_h, trafo_size_v);
1317 s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + (
i << log2_trafo_size), 2);
1321 log2_trafo_size, scan_idx_c, 2);
1325 if (log2_trafo_size > 2 ||
s->ps.sps->chroma_format_idc == 3) {
1326 int trafo_size_h = 1 << (log2_trafo_size_c +
s->ps.sps->hshift[1]);
1327 int trafo_size_v = 1 << (log2_trafo_size_c +
s->ps.sps->vshift[1]);
1329 s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0, 1);
1330 s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0, 2);
1331 if (
s->ps.sps->chroma_format_idc == 2) {
1333 trafo_size_h, trafo_size_v);
1334 s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (1 << log2_trafo_size_c), 1);
1335 s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (1 << log2_trafo_size_c), 2);
1337 }
else if (blk_idx == 3) {
1338 int trafo_size_h = 1 << (log2_trafo_size + 1);
1339 int trafo_size_v = 1 << (log2_trafo_size +
s->ps.sps->vshift[1]);
1341 trafo_size_h, trafo_size_v);
1342 s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase, 1);
1343 s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase, 2);
1344 if (
s->ps.sps->chroma_format_idc == 2) {
1346 trafo_size_h, trafo_size_v);
1347 s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + (1 << log2_trafo_size), 1);
1348 s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + (1 << log2_trafo_size), 2);
1358 int cb_size = 1 << log2_cb_size;
1359 int log2_min_pu_size =
s->ps.sps->log2_min_pu_size;
1361 int min_pu_width =
s->ps.sps->min_pu_width;
1362 int x_end =
FFMIN(x0 + cb_size,
s->ps.sps->width);
1363 int y_end =
FFMIN(y0 + cb_size,
s->ps.sps->height);
1366 for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
1367 for (
i = (x0 >> log2_min_pu_size);
i < (x_end >> log2_min_pu_size);
i++)
1368 s->is_pcm[
i + j * min_pu_width] = 2;
1372 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1373 int log2_cb_size,
int log2_trafo_size,
1374 int trafo_depth,
int blk_idx,
1375 const int *base_cbf_cb,
const int *base_cbf_cr)
1378 uint8_t split_transform_flag;
1383 cbf_cb[0] = base_cbf_cb[0];
1384 cbf_cb[1] = base_cbf_cb[1];
1385 cbf_cr[0] = base_cbf_cr[0];
1386 cbf_cr[1] = base_cbf_cr[1];
1389 if (trafo_depth == 1) {
1391 if (
s->ps.sps->chroma_format_idc == 3) {
1405 if (log2_trafo_size <= s->ps.sps->log2_max_trafo_size &&
1406 log2_trafo_size >
s->ps.sps->log2_min_tb_size &&
1407 trafo_depth < lc->cu.max_trafo_depth &&
1411 int inter_split =
s->ps.sps->max_transform_hierarchy_depth_inter == 0 &&
1416 split_transform_flag = log2_trafo_size >
s->ps.sps->log2_max_trafo_size ||
1421 if (
s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 ||
s->ps.sps->chroma_format_idc == 3)) {
1422 if (trafo_depth == 0 || cbf_cb[0]) {
1424 if (
s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
1429 if (trafo_depth == 0 || cbf_cr[0]) {
1431 if (
s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
1437 if (split_transform_flag) {
1438 const int trafo_size_split = 1 << (log2_trafo_size - 1);
1439 const int x1 = x0 + trafo_size_split;
1440 const int y1 = y0 + trafo_size_split;
1442 #define SUBDIVIDE(x, y, idx) \
1444 ret = hls_transform_tree(lc, x, y, x0, y0, cb_xBase, cb_yBase, log2_cb_size,\
1445 log2_trafo_size - 1, trafo_depth + 1, idx, \
1458 int min_tu_size = 1 <<
s->ps.sps->log2_min_tb_size;
1459 int log2_min_tu_size =
s->ps.sps->log2_min_tb_size;
1460 int min_tu_width =
s->ps.sps->min_tb_width;
1464 cbf_cb[0] || cbf_cr[0] ||
1465 (
s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
1470 log2_cb_size, log2_trafo_size,
1471 blk_idx, cbf_luma, cbf_cb, cbf_cr);
1477 for (
i = 0;
i < (1 << log2_trafo_size);
i += min_tu_size)
1478 for (j = 0; j < (1 << log2_trafo_size); j += min_tu_size) {
1479 int x_tu = (x0 + j) >> log2_min_tu_size;
1480 int y_tu = (y0 +
i) >> log2_min_tu_size;
1481 s->cbf_luma[y_tu * min_tu_width + x_tu] = 1;
1484 if (!
s->sh.disable_deblocking_filter_flag) {
1486 if (
s->ps.pps->transquant_bypass_enable_flag &&
1498 int cb_size = 1 << log2_cb_size;
1499 ptrdiff_t stride0 =
s->frame->linesize[0];
1500 ptrdiff_t stride1 =
s->frame->linesize[1];
1501 ptrdiff_t stride2 =
s->frame->linesize[2];
1502 uint8_t *dst0 = &
s->frame->data[0][y0 * stride0 + (x0 <<
s->ps.sps->pixel_shift)];
1503 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)];
1504 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)];
1506 int length = cb_size * cb_size *
s->ps.sps->pcm.bit_depth +
1507 (((cb_size >>
s->ps.sps->hshift[1]) * (cb_size >>
s->ps.sps->vshift[1])) +
1508 ((cb_size >>
s->ps.sps->hshift[2]) * (cb_size >>
s->ps.sps->vshift[2]))) *
1509 s->ps.sps->pcm.bit_depth_chroma;
1510 const uint8_t *pcm =
skip_bytes(&lc->
cc, (length + 7) >> 3);
1513 if (!
s->sh.disable_deblocking_filter_flag)
1520 s->hevcdsp.put_pcm(dst0, stride0, cb_size, cb_size, &gb,
s->ps.sps->pcm.bit_depth);
1521 if (
s->ps.sps->chroma_format_idc) {
1522 s->hevcdsp.put_pcm(dst1, stride1,
1523 cb_size >>
s->ps.sps->hshift[1],
1524 cb_size >>
s->ps.sps->vshift[1],
1525 &gb,
s->ps.sps->pcm.bit_depth_chroma);
1526 s->hevcdsp.put_pcm(dst2, stride2,
1527 cb_size >>
s->ps.sps->hshift[2],
1528 cb_size >>
s->ps.sps->vshift[2],
1529 &gb,
s->ps.sps->pcm.bit_depth_chroma);
1553 int block_w,
int block_h,
int luma_weight,
int luma_offset)
1556 const uint8_t *
src =
ref->data[0];
1557 ptrdiff_t srcstride =
ref->linesize[0];
1558 int pic_width =
s->ps.sps->width;
1559 int pic_height =
s->ps.sps->height;
1562 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
s->ps.pps->weighted_pred_flag) ||
1563 (
s->sh.slice_type ==
HEVC_SLICE_B &&
s->ps.pps->weighted_bipred_flag);
1566 x_off +=
mv->x >> 2;
1567 y_off +=
mv->y >> 2;
1568 src += y_off * srcstride + (x_off * (1 <<
s->ps.sps->pixel_shift));
1579 edge_emu_stride, srcstride,
1583 pic_width, pic_height);
1585 srcstride = edge_emu_stride;
1589 s->hevcdsp.put_hevc_qpel_uni[idx][!!my][!!mx](dst, dststride,
src, srcstride,
1590 block_h, mx, my, block_w);
1592 s->hevcdsp.put_hevc_qpel_uni_w[idx][!!my][!!mx](dst, dststride,
src, srcstride,
1593 block_h,
s->sh.luma_log2_weight_denom,
1594 luma_weight, luma_offset, mx, my, block_w);
1614 const AVFrame *ref0,
const Mv *mv0,
int x_off,
int y_off,
1615 int block_w,
int block_h,
const AVFrame *ref1,
1616 const Mv *mv1,
struct MvField *current_mv)
1619 ptrdiff_t src0stride = ref0->
linesize[0];
1620 ptrdiff_t src1stride = ref1->
linesize[0];
1621 int pic_width =
s->ps.sps->width;
1622 int pic_height =
s->ps.sps->height;
1623 int mx0 = mv0->
x & 3;
1624 int my0 = mv0->
y & 3;
1625 int mx1 = mv1->
x & 3;
1626 int my1 = mv1->
y & 3;
1627 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
s->ps.pps->weighted_pred_flag) ||
1628 (
s->sh.slice_type ==
HEVC_SLICE_B &&
s->ps.pps->weighted_bipred_flag);
1629 int x_off0 = x_off + (mv0->
x >> 2);
1630 int y_off0 = y_off + (mv0->
y >> 2);
1631 int x_off1 = x_off + (mv1->
x >> 2);
1632 int y_off1 = y_off + (mv1->
y >> 2);
1635 const uint8_t *
src0 = ref0->
data[0] + y_off0 * src0stride + (
int)((
unsigned)x_off0 <<
s->ps.sps->pixel_shift);
1636 const uint8_t *
src1 = ref1->
data[0] + y_off1 * src1stride + (
int)((
unsigned)x_off1 <<
s->ps.sps->pixel_shift);
1646 edge_emu_stride, src0stride,
1650 pic_width, pic_height);
1652 src0stride = edge_emu_stride;
1663 edge_emu_stride, src1stride,
1667 pic_width, pic_height);
1669 src1stride = edge_emu_stride;
1672 s->hevcdsp.put_hevc_qpel[idx][!!my0][!!mx0](lc->
tmp,
src0, src0stride,
1673 block_h, mx0, my0, block_w);
1675 s->hevcdsp.put_hevc_qpel_bi[idx][!!my1][!!mx1](dst, dststride,
src1, src1stride, lc->
tmp,
1676 block_h, mx1, my1, block_w);
1678 s->hevcdsp.put_hevc_qpel_bi_w[idx][!!my1][!!mx1](dst, dststride,
src1, src1stride, lc->
tmp,
1679 block_h,
s->sh.luma_log2_weight_denom,
1680 s->sh.luma_weight_l0[current_mv->
ref_idx[0]],
1681 s->sh.luma_weight_l1[current_mv->
ref_idx[1]],
1682 s->sh.luma_offset_l0[current_mv->
ref_idx[0]],
1683 s->sh.luma_offset_l1[current_mv->
ref_idx[1]],
1706 ptrdiff_t dststride,
const uint8_t *
src0, ptrdiff_t srcstride,
int reflist,
1707 int x_off,
int y_off,
int block_w,
int block_h,
1708 const struct MvField *current_mv,
int chroma_weight,
int chroma_offset)
1711 int pic_width =
s->ps.sps->width >>
s->ps.sps->hshift[1];
1712 int pic_height =
s->ps.sps->height >>
s->ps.sps->vshift[1];
1713 const Mv *
mv = ¤t_mv->
mv[reflist];
1714 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
s->ps.pps->weighted_pred_flag) ||
1715 (
s->sh.slice_type ==
HEVC_SLICE_B &&
s->ps.pps->weighted_bipred_flag);
1717 int hshift =
s->ps.sps->hshift[1];
1718 int vshift =
s->ps.sps->vshift[1];
1721 intptr_t _mx = mx << (1 - hshift);
1722 intptr_t _my = my << (1 - vshift);
1723 int emu =
src0 ==
s->frame->data[1] ||
src0 ==
s->frame->data[2];
1725 x_off +=
mv->x >> (2 + hshift);
1726 y_off +=
mv->y >> (2 + vshift);
1727 src0 += y_off * srcstride + (x_off * (1 <<
s->ps.sps->pixel_shift));
1736 (edge_emu_stride + (1 <<
s->ps.sps->pixel_shift));
1738 edge_emu_stride, srcstride,
1742 pic_width, pic_height);
1745 srcstride = edge_emu_stride;
1748 s->hevcdsp.put_hevc_epel_uni[idx][!!my][!!mx](dst0, dststride,
src0, srcstride,
1749 block_h, _mx, _my, block_w);
1751 s->hevcdsp.put_hevc_epel_uni_w[idx][!!my][!!mx](dst0, dststride,
src0, srcstride,
1752 block_h,
s->sh.chroma_log2_weight_denom,
1753 chroma_weight, chroma_offset, _mx, _my, block_w);
1775 int x_off,
int y_off,
int block_w,
int block_h,
const MvField *current_mv,
int cidx)
1778 const uint8_t *
src1 = ref0->
data[cidx+1];
1779 const uint8_t *
src2 = ref1->
data[cidx+1];
1780 ptrdiff_t src1stride = ref0->
linesize[cidx+1];
1781 ptrdiff_t src2stride = ref1->
linesize[cidx+1];
1782 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
s->ps.pps->weighted_pred_flag) ||
1783 (
s->sh.slice_type ==
HEVC_SLICE_B &&
s->ps.pps->weighted_bipred_flag);
1784 int pic_width =
s->ps.sps->width >>
s->ps.sps->hshift[1];
1785 int pic_height =
s->ps.sps->height >>
s->ps.sps->vshift[1];
1786 const Mv *
const mv0 = ¤t_mv->
mv[0];
1787 const Mv *
const mv1 = ¤t_mv->
mv[1];
1788 int hshift =
s->ps.sps->hshift[1];
1789 int vshift =
s->ps.sps->vshift[1];
1795 intptr_t _mx0 = mx0 << (1 - hshift);
1796 intptr_t _my0 = my0 << (1 - vshift);
1797 intptr_t _mx1 = mx1 << (1 - hshift);
1798 intptr_t _my1 = my1 << (1 - vshift);
1800 int x_off0 = x_off + (mv0->
x >> (2 + hshift));
1801 int y_off0 = y_off + (mv0->
y >> (2 + vshift));
1802 int x_off1 = x_off + (mv1->
x >> (2 + hshift));
1803 int y_off1 = y_off + (mv1->
y >> (2 + vshift));
1805 src1 += y_off0 * src1stride + (
int)((
unsigned)x_off0 <<
s->ps.sps->pixel_shift);
1806 src2 += y_off1 * src2stride + (
int)((
unsigned)x_off1 <<
s->ps.sps->pixel_shift);
1814 (edge_emu_stride + (1 <<
s->ps.sps->pixel_shift));
1817 edge_emu_stride, src1stride,
1821 pic_width, pic_height);
1824 src1stride = edge_emu_stride;
1833 (edge_emu_stride + (1 <<
s->ps.sps->pixel_shift));
1836 edge_emu_stride, src2stride,
1840 pic_width, pic_height);
1843 src2stride = edge_emu_stride;
1846 s->hevcdsp.put_hevc_epel[idx][!!my0][!!mx0](lc->
tmp,
src1, src1stride,
1847 block_h, _mx0, _my0, block_w);
1849 s->hevcdsp.put_hevc_epel_bi[idx][!!my1][!!mx1](dst0,
s->frame->linesize[cidx+1],
1851 block_h, _mx1, _my1, block_w);
1853 s->hevcdsp.put_hevc_epel_bi_w[idx][!!my1][!!mx1](dst0,
s->frame->linesize[cidx+1],
1856 s->sh.chroma_log2_weight_denom,
1857 s->sh.chroma_weight_l0[current_mv->
ref_idx[0]][cidx],
1858 s->sh.chroma_weight_l1[current_mv->
ref_idx[1]][cidx],
1859 s->sh.chroma_offset_l0[current_mv->
ref_idx[0]][cidx],
1860 s->sh.chroma_offset_l1[current_mv->
ref_idx[1]][cidx],
1861 _mx1, _my1, block_w);
1875 int nPbH,
int log2_cb_size,
int part_idx,
1887 if (inter_pred_idc !=
PRED_L1) {
1888 if (
s->sh.nb_refs[
L0])
1895 part_idx, merge_idx,
mv, mvp_flag, 0);
1900 if (inter_pred_idc !=
PRED_L0) {
1901 if (
s->sh.nb_refs[
L1])
1904 if (
s->sh.mvd_l1_zero_flag == 1 && inter_pred_idc ==
PRED_BI) {
1913 part_idx, merge_idx,
mv, mvp_flag, 1);
1921 int log2_cb_size,
int partIdx,
int idx)
1923 #define POS(c_idx, x, y) \
1924 &s->frame->data[c_idx][((y) >> s->ps.sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \
1925 (((x) >> s->ps.sps->hshift[c_idx]) << s->ps.sps->pixel_shift)]
1928 struct MvField current_mv = {{{ 0 }}};
1930 int min_pu_width =
s->ps.sps->min_pu_width;
1932 MvField *tab_mvf =
s->ref->tab_mvf;
1933 const RefPicList *refPicList =
s->ref->refPicList;
1935 uint8_t *dst0 =
POS(0, x0, y0);
1936 uint8_t *dst1 =
POS(1, x0, y0);
1937 uint8_t *dst2 =
POS(2, x0, y0);
1938 int log2_min_cb_size =
s->ps.sps->log2_min_cb_size;
1939 int min_cb_width =
s->ps.sps->min_cb_width;
1940 int x_cb = x0 >> log2_min_cb_size;
1941 int y_cb = y0 >> log2_min_cb_size;
1945 int skip_flag =
SAMPLE_CTB(
s->skip_flag, x_cb, y_cb);
1951 if (
s->sh.max_num_merge_cand > 1)
1957 partIdx, merge_idx, ¤t_mv);
1960 partIdx, merge_idx, ¤t_mv);
1963 x_pu = x0 >>
s->ps.sps->log2_min_pu_size;
1964 y_pu = y0 >>
s->ps.sps->log2_min_pu_size;
1966 for (j = 0; j < nPbH >>
s->ps.sps->log2_min_pu_size; j++)
1967 for (
i = 0; i < nPbW >>
s->ps.sps->log2_min_pu_size;
i++)
1968 tab_mvf[(y_pu + j) * min_pu_width + x_pu +
i] = current_mv;
1971 ref0 = refPicList[0].
ref[current_mv.
ref_idx[0]];
1972 if (!ref0 || !ref0->
frame)
1977 ref1 = refPicList[1].
ref[current_mv.
ref_idx[1]];
1978 if (!ref1 || !ref1->frame)
1984 int x0_c = x0 >>
s->ps.sps->hshift[1];
1985 int y0_c = y0 >>
s->ps.sps->vshift[1];
1986 int nPbW_c = nPbW >>
s->ps.sps->hshift[1];
1987 int nPbH_c = nPbH >>
s->ps.sps->vshift[1];
1990 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
1991 s->sh.luma_weight_l0[current_mv.
ref_idx[0]],
1992 s->sh.luma_offset_l0[current_mv.
ref_idx[0]]);
1994 if (
s->ps.sps->chroma_format_idc) {
1996 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1997 s->sh.chroma_weight_l0[current_mv.
ref_idx[0]][0],
s->sh.chroma_offset_l0[current_mv.
ref_idx[0]][0]);
1999 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2000 s->sh.chroma_weight_l0[current_mv.
ref_idx[0]][1],
s->sh.chroma_offset_l0[current_mv.
ref_idx[0]][1]);
2003 int x0_c = x0 >>
s->ps.sps->hshift[1];
2004 int y0_c = y0 >>
s->ps.sps->vshift[1];
2005 int nPbW_c = nPbW >>
s->ps.sps->hshift[1];
2006 int nPbH_c = nPbH >>
s->ps.sps->vshift[1];
2008 luma_mc_uni(lc, dst0,
s->frame->linesize[0], ref1->frame,
2009 ¤t_mv.
mv[1], x0, y0, nPbW, nPbH,
2010 s->sh.luma_weight_l1[current_mv.
ref_idx[1]],
2011 s->sh.luma_offset_l1[current_mv.
ref_idx[1]]);
2013 if (
s->ps.sps->chroma_format_idc) {
2014 chroma_mc_uni(lc, dst1,
s->frame->linesize[1], ref1->frame->data[1], ref1->frame->linesize[1],
2015 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2016 s->sh.chroma_weight_l1[current_mv.
ref_idx[1]][0],
s->sh.chroma_offset_l1[current_mv.
ref_idx[1]][0]);
2018 chroma_mc_uni(lc, dst2,
s->frame->linesize[2], ref1->frame->data[2], ref1->frame->linesize[2],
2019 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2020 s->sh.chroma_weight_l1[current_mv.
ref_idx[1]][1],
s->sh.chroma_offset_l1[current_mv.
ref_idx[1]][1]);
2023 int x0_c = x0 >>
s->ps.sps->hshift[1];
2024 int y0_c = y0 >>
s->ps.sps->vshift[1];
2025 int nPbW_c = nPbW >>
s->ps.sps->hshift[1];
2026 int nPbH_c = nPbH >>
s->ps.sps->vshift[1];
2029 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
2030 ref1->frame, ¤t_mv.
mv[1], ¤t_mv);
2032 if (
s->ps.sps->chroma_format_idc) {
2034 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0);
2037 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 1);
2046 int prev_intra_luma_pred_flag)
2049 int x_pu = x0 >>
s->ps.sps->log2_min_pu_size;
2050 int y_pu = y0 >>
s->ps.sps->log2_min_pu_size;
2051 int min_pu_width =
s->ps.sps->min_pu_width;
2052 int size_in_pus = pu_size >>
s->ps.sps->log2_min_pu_size;
2057 s->tab_ipm[(y_pu - 1) * min_pu_width + x_pu] :
INTRA_DC;
2059 s->tab_ipm[y_pu * min_pu_width + x_pu - 1] :
INTRA_DC;
2061 int y_ctb = (y0 >> (
s->ps.sps->log2_ctb_size)) << (
s->ps.sps->log2_ctb_size);
2063 MvField *tab_mvf =
s->ref->tab_mvf;
2064 int intra_pred_mode;
2069 if ((y0 - 1) < y_ctb)
2072 if (cand_left == cand_up) {
2073 if (cand_left < 2) {
2078 candidate[0] = cand_left;
2079 candidate[1] = 2 + ((cand_left - 2 - 1 + 32) & 31);
2080 candidate[2] = 2 + ((cand_left - 2 + 1) & 31);
2083 candidate[0] = cand_left;
2084 candidate[1] = cand_up;
2094 if (prev_intra_luma_pred_flag) {
2095 intra_pred_mode = candidate[lc->
pu.
mpm_idx];
2097 if (candidate[0] > candidate[1])
2098 FFSWAP(uint8_t, candidate[0], candidate[1]);
2099 if (candidate[0] > candidate[2])
2100 FFSWAP(uint8_t, candidate[0], candidate[2]);
2101 if (candidate[1] > candidate[2])
2102 FFSWAP(uint8_t, candidate[1], candidate[2]);
2105 for (
i = 0;
i < 3;
i++)
2106 if (intra_pred_mode >= candidate[
i])
2113 for (
i = 0;
i < size_in_pus;
i++) {
2114 memset(&
s->tab_ipm[(y_pu +
i) * min_pu_width + x_pu],
2115 intra_pred_mode, size_in_pus);
2117 for (j = 0; j < size_in_pus; j++) {
2122 return intra_pred_mode;
2126 int log2_cb_size,
int ct_depth)
2128 int length = (1 << log2_cb_size) >>
s->ps.sps->log2_min_cb_size;
2129 int x_cb = x0 >>
s->ps.sps->log2_min_cb_size;
2130 int y_cb = y0 >>
s->ps.sps->log2_min_cb_size;
2133 for (y = 0; y < length; y++)
2134 memset(&
s->tab_ct_depth[(y_cb + y) *
s->ps.sps->min_cb_width + x_cb],
2139 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20,
2140 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31};
2146 static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 };
2147 uint8_t prev_intra_luma_pred_flag[4];
2149 int pb_size = (1 << log2_cb_size) >>
split;
2150 int side =
split + 1;
2154 for (
i = 0;
i < side;
i++)
2155 for (j = 0; j < side; j++)
2158 for (
i = 0;
i < side;
i++) {
2159 for (j = 0; j < side; j++) {
2160 if (prev_intra_luma_pred_flag[2 *
i + j])
2167 prev_intra_luma_pred_flag[2 *
i + j]);
2171 if (
s->ps.sps->chroma_format_idc == 3) {
2172 for (
i = 0;
i < side;
i++) {
2173 for (j = 0; j < side; j++) {
2175 if (chroma_mode != 4) {
2185 }
else if (
s->ps.sps->chroma_format_idc == 2) {
2188 if (chroma_mode != 4) {
2192 mode_idx = intra_chroma_table[chroma_mode];
2197 }
else if (
s->ps.sps->chroma_format_idc != 0) {
2199 if (chroma_mode != 4) {
2215 int pb_size = 1 << log2_cb_size;
2216 int size_in_pus = pb_size >>
s->ps.sps->log2_min_pu_size;
2217 int min_pu_width =
s->ps.sps->min_pu_width;
2218 MvField *tab_mvf =
s->ref->tab_mvf;
2219 int x_pu = x0 >>
s->ps.sps->log2_min_pu_size;
2220 int y_pu = y0 >>
s->ps.sps->log2_min_pu_size;
2223 if (size_in_pus == 0)
2225 for (j = 0; j < size_in_pus; j++)
2226 memset(&
s->tab_ipm[(y_pu + j) * min_pu_width + x_pu],
INTRA_DC, size_in_pus);
2228 for (j = 0; j < size_in_pus; j++)
2229 for (k = 0; k < size_in_pus; k++)
2235 int cb_size = 1 << log2_cb_size;
2236 int log2_min_cb_size =
s->ps.sps->log2_min_cb_size;
2237 int length = cb_size >> log2_min_cb_size;
2238 int min_cb_width =
s->ps.sps->min_cb_width;
2239 int x_cb = x0 >> log2_min_cb_size;
2240 int y_cb = y0 >> log2_min_cb_size;
2241 int idx = log2_cb_size - 2;
2242 int qp_block_mask = (1<<(
s->ps.sps->log2_ctb_size -
s->ps.pps->diff_cu_qp_delta_depth)) - 1;
2252 for (x = 0; x < 4; x++)
2254 if (
s->ps.pps->transquant_bypass_enable_flag) {
2264 x = y_cb * min_cb_width + x_cb;
2265 for (y = 0; y < length; y++) {
2266 memset(&
s->skip_flag[x], skip_flag, length);
2271 x = y_cb * min_cb_width + x_cb;
2272 for (y = 0; y < length; y++) {
2273 memset(&
s->skip_flag[x], 0, length);
2282 if (!
s->sh.disable_deblocking_filter_flag)
2290 log2_cb_size ==
s->ps.sps->log2_min_cb_size) {
2298 log2_cb_size >=
s->ps.sps->pcm.log2_min_pcm_cb_size &&
2299 log2_cb_size <= s->ps.sps->pcm.log2_max_pcm_cb_size) {
2305 if (
s->ps.sps->pcm.loop_filter_disable_flag)
2321 hls_prediction_unit(lc, x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx);
2325 hls_prediction_unit(lc, x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);
2329 hls_prediction_unit(lc, x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);
2333 hls_prediction_unit(lc, x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx);
2337 hls_prediction_unit(lc, x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
2341 hls_prediction_unit(lc, x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
2345 hls_prediction_unit(lc, x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
2346 hls_prediction_unit(lc, x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
2347 hls_prediction_unit(lc, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
2353 int rqt_root_cbf = 1;
2360 const static int cbf[2] = { 0 };
2363 s->ps.sps->max_transform_hierarchy_depth_inter;
2366 log2_cb_size, 0, 0, cbf, cbf);
2370 if (!
s->sh.disable_deblocking_filter_flag)
2379 x = y_cb * min_cb_width + x_cb;
2380 for (y = 0; y < length; y++) {
2381 memset(&
s->qp_y_tab[x], lc->
qp_y, length);
2385 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2386 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0) {
2396 int log2_cb_size,
int cb_depth)
2399 const int cb_size = 1 << log2_cb_size;
2404 if (x0 + cb_size <= s->ps.sps->width &&
2405 y0 + cb_size <= s->ps.sps->height &&
2406 log2_cb_size >
s->ps.sps->log2_min_cb_size) {
2409 split_cu = (log2_cb_size >
s->ps.sps->log2_min_cb_size);
2411 if (
s->ps.pps->cu_qp_delta_enabled_flag &&
2412 log2_cb_size >=
s->ps.sps->log2_ctb_size -
s->ps.pps->diff_cu_qp_delta_depth) {
2417 if (
s->sh.cu_chroma_qp_offset_enabled_flag &&
2418 log2_cb_size >=
s->ps.sps->log2_ctb_size -
s->ps.pps->diff_cu_chroma_qp_offset_depth) {
2423 int qp_block_mask = (1<<(
s->ps.sps->log2_ctb_size -
s->ps.pps->diff_cu_qp_delta_depth)) - 1;
2424 const int cb_size_split = cb_size >> 1;
2425 const int x1 = x0 + cb_size_split;
2426 const int y1 = y0 + cb_size_split;
2434 if (more_data && x1 < s->ps.sps->width) {
2439 if (more_data && y1 < s->ps.sps->height) {
2444 if (more_data && x1 < s->ps.sps->width &&
2445 y1 < s->ps.sps->height) {
2451 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2452 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0)
2456 return ((x1 + cb_size_split) <
s->ps.sps->width ||
2457 (y1 + cb_size_split) <
s->ps.sps->height);
2464 if ((!((x0 + cb_size) %
2465 (1 << (
s->ps.sps->log2_ctb_size))) ||
2466 (x0 + cb_size >=
s->ps.sps->width)) &&
2468 (1 << (
s->ps.sps->log2_ctb_size))) ||
2469 (y0 + cb_size >=
s->ps.sps->height))) {
2471 return !end_of_slice_flag;
2484 int ctb_size = 1 <<
s->ps.sps->log2_ctb_size;
2485 int ctb_addr_rs =
s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2486 int ctb_addr_in_slice = ctb_addr_rs -
s->sh.slice_addr;
2488 s->tab_slice_address[ctb_addr_rs] =
s->sh.slice_addr;
2490 if (
s->ps.pps->entropy_coding_sync_enabled_flag) {
2491 if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
2494 }
else if (
s->ps.pps->tiles_enabled_flag) {
2495 if (ctb_addr_ts &&
s->ps.pps->tile_id[ctb_addr_ts] !=
s->ps.pps->tile_id[ctb_addr_ts - 1]) {
2496 int idxX =
s->ps.pps->col_idxX[x_ctb >>
s->ps.sps->log2_ctb_size];
2497 lc->
end_of_tiles_x = x_ctb + (
s->ps.pps->column_width[idxX] <<
s->ps.sps->log2_ctb_size);
2507 if (
s->ps.pps->tiles_enabled_flag) {
2508 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]])
2510 if (x_ctb > 0 &&
s->tab_slice_address[ctb_addr_rs] !=
s->tab_slice_address[ctb_addr_rs - 1])
2512 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]])
2514 if (y_ctb > 0 &&
s->tab_slice_address[ctb_addr_rs] !=
s->tab_slice_address[ctb_addr_rs -
s->ps.sps->ctb_width])
2517 if (ctb_addr_in_slice <= 0)
2519 if (ctb_addr_in_slice < s->ps.sps->ctb_width)
2525 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]]));
2526 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]]));
2533 int ctb_size = 1 <<
s->ps.sps->log2_ctb_size;
2537 int ctb_addr_ts =
s->ps.pps->ctb_addr_rs_to_ts[
s->sh.slice_ctb_addr_rs];
2540 if (!ctb_addr_ts &&
s->sh.dependent_slice_segment_flag) {
2545 if (
s->sh.dependent_slice_segment_flag) {
2546 int prev_rs =
s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
2547 if (
s->tab_slice_address[prev_rs] !=
s->sh.slice_addr) {
2553 while (more_data && ctb_addr_ts < s->ps.sps->ctb_size) {
2554 int ctb_addr_rs =
s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2556 x_ctb = (ctb_addr_rs % ((
s->ps.sps->width + ctb_size - 1) >>
s->ps.sps->log2_ctb_size)) <<
s->ps.sps->log2_ctb_size;
2557 y_ctb = (ctb_addr_rs / ((
s->ps.sps->width + ctb_size - 1) >>
s->ps.sps->log2_ctb_size)) <<
s->ps.sps->log2_ctb_size;
2562 s->tab_slice_address[ctb_addr_rs] = -1;
2566 hls_sao_param(lc, x_ctb >>
s->ps.sps->log2_ctb_size, y_ctb >>
s->ps.sps->log2_ctb_size);
2568 s->deblock[ctb_addr_rs].beta_offset =
s->sh.beta_offset;
2569 s->deblock[ctb_addr_rs].tc_offset =
s->sh.tc_offset;
2570 s->filter_slice_edges[ctb_addr_rs] =
s->sh.slice_loop_filter_across_slices_enabled_flag;
2573 if (more_data < 0) {
2574 s->tab_slice_address[ctb_addr_rs] = -1;
2584 if (x_ctb + ctb_size >=
s->ps.sps->width &&
2585 y_ctb + ctb_size >=
s->ps.sps->height)
2599 int job,
int self_id)
2603 int ctb_size = 1 <<
s->ps.sps->log2_ctb_size;
2606 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);
2607 int ctb_addr_ts =
s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs];
2608 int thread = ctb_row %
s->threads_number;
2618 while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) {
2619 int x_ctb = (ctb_addr_rs %
s->ps.sps->ctb_width) <<
s->ps.sps->log2_ctb_size;
2620 int y_ctb = (ctb_addr_rs /
s->ps.sps->ctb_width) <<
s->ps.sps->log2_ctb_size;
2637 hls_sao_param(lc, x_ctb >>
s->ps.sps->log2_ctb_size, y_ctb >>
s->ps.sps->log2_ctb_size);
2639 s->deblock[ctb_addr_rs].beta_offset =
s->sh.beta_offset;
2640 s->deblock[ctb_addr_rs].tc_offset =
s->sh.tc_offset;
2641 s->filter_slice_edges[ctb_addr_rs] =
s->sh.slice_loop_filter_across_slices_enabled_flag;
2645 if (more_data < 0) {
2656 if (!more_data && (x_ctb+ctb_size) <
s->ps.sps->width && ctb_row !=
s->sh.num_entry_point_offsets) {
2663 if ((x_ctb+ctb_size) >=
s->ps.sps->width && (y_ctb+ctb_size) >=
s->ps.sps->height ) {
2668 ctb_addr_rs =
s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2671 if(x_ctb >=
s->ps.sps->width) {
2679 s->tab_slice_address[ctb_addr_rs] = -1;
2689 int length = nal->
size;
2693 int64_t startheader, cmpt = 0;
2696 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) {
2698 s->sh.slice_ctb_addr_rs,
s->sh.num_entry_point_offsets,
2699 s->ps.sps->ctb_width,
s->ps.sps->ctb_height
2704 for (
i = 1;
i <
s->threads_number;
i++) {
2705 if (
s->HEVClcList[
i])
2708 if (!
s->HEVClcList[
i])
2710 s->HEVClcList[
i]->logctx =
s->avctx;
2711 s->HEVClcList[
i]->parent =
s;
2712 s->HEVClcList[
i]->common_cabac_state = &
s->cabac;
2717 for (j = 0, cmpt = 0, startheader =
offset +
s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) {
2724 for (
i = 1;
i <
s->sh.num_entry_point_offsets;
i++) {
2725 offset += (
s->sh.entry_point_offset[
i - 1] - cmpt);
2726 for (j = 0, cmpt = 0, startheader =
offset
2727 +
s->sh.entry_point_offset[
i]; j < nal->skipped_bytes; j++) {
2733 s->sh.size[
i - 1] =
s->sh.entry_point_offset[
i] - cmpt;
2737 if (
s->sh.num_entry_point_offsets != 0) {
2738 offset +=
s->sh.entry_point_offset[
s->sh.num_entry_point_offsets - 1] - cmpt;
2743 s->sh.size[
s->sh.num_entry_point_offsets - 1] = length -
offset;
2744 s->sh.offset[
s->sh.num_entry_point_offsets - 1] =
offset;
2749 for (
i = 1;
i <
s->threads_number;
i++) {
2750 s->HEVClcList[
i]->first_qp_group = 1;
2751 s->HEVClcList[
i]->qp_y =
s->HEVClc->qp_y;
2763 if (
s->ps.pps->entropy_coding_sync_enabled_flag)
2766 for (
i = 0;
i <=
s->sh.num_entry_point_offsets;
i++)
2781 if (
IS_IRAP(
s) &&
s->no_rasl_output_flag) {
2782 if (
s->sei.common.mastering_display.present > 0)
2783 s->sei.common.mastering_display.present--;
2785 if (
s->sei.common.content_light.present > 0)
2786 s->sei.common.content_light.present--;
2790 &
s->ps.sps->vui.common,
2791 s->ps.sps->bit_depth,
s->ps.sps->bit_depth_chroma,
2796 if (
s->sei.timecode.present) {
2801 sizeof(uint32_t) * 4, &tcside);
2806 tc_sd = (uint32_t*)tcside->
data;
2807 tc_sd[0] =
s->sei.timecode.num_clock_ts;
2809 for (
int i = 0;
i < tc_sd[0];
i++) {
2810 int drop =
s->sei.timecode.cnt_dropped_flag[
i];
2811 int hh =
s->sei.timecode.hours_value[
i];
2812 int mm =
s->sei.timecode.minutes_value[
i];
2813 int ss =
s->sei.timecode.seconds_value[
i];
2814 int ff =
s->sei.timecode.n_frames[
i];
2822 s->sei.timecode.num_clock_ts = 0;
2825 if (
s->sei.common.dynamic_hdr_plus.info) {
2846 if (
s->sei.common.dynamic_hdr_vivid.info) {
2863 int pic_size_in_ctb = ((
s->ps.sps->width >>
s->ps.sps->log2_min_cb_size) + 1) *
2864 ((
s->ps.sps->height >>
s->ps.sps->log2_min_cb_size) + 1);
2867 memset(
s->horizontal_bs, 0,
s->bs_width *
s->bs_height);
2868 memset(
s->vertical_bs, 0,
s->bs_width *
s->bs_height);
2869 memset(
s->cbf_luma, 0,
s->ps.sps->min_tb_width *
s->ps.sps->min_tb_height);
2870 memset(
s->is_pcm, 0, (
s->ps.sps->min_pu_width + 1) * (
s->ps.sps->min_pu_height + 1));
2871 memset(
s->tab_slice_address, -1, pic_size_in_ctb *
sizeof(*
s->tab_slice_address));
2874 s->first_nal_type =
s->nal_unit_type;
2878 if (
s->ps.pps->tiles_enabled_flag)
2879 lc->
end_of_tiles_x =
s->ps.pps->column_width[0] <<
s->ps.sps->log2_ctb_size;
2896 s->ref->needs_fg = (
s->sei.common.film_grain_characteristics.present ||
2897 s->sei.common.aom_film_grain.enable) &&
2905 if (
s->ref->needs_fg &&
2906 (
s->sei.common.film_grain_characteristics.present &&
2908 s->ref->frame->format)
2911 "Unsupported film grain parameters. Ignoring film grain.\n");
2912 s->ref->needs_fg = 0;
2915 if (
s->ref->needs_fg) {
2916 s->ref->frame_grain->format =
s->ref->frame->format;
2917 s->ref->frame_grain->width =
s->ref->frame->width;
2918 s->ref->frame_grain->height =
s->ref->frame->height;
2923 s->frame->pict_type = 3 -
s->sh.slice_type;
2933 if (!
s->avctx->hwaccel)
2941 s->ref =
s->collocated_ref =
NULL;
2951 if (
out->needs_fg) {
2954 switch (fgp->
type) {
2976 int ctb_addr_ts,
ret;
2979 s->nal_unit_type = nal->
type;
2982 switch (
s->nal_unit_type) {
3002 s->apply_defdispwin);
3048 s->slice_initialized = 0;
3064 if (
s->sh.first_slice_in_pic_flag) {
3065 if (
s->max_ra == INT_MAX) {
3070 s->max_ra = INT_MIN;
3075 s->poc <=
s->max_ra) {
3080 s->max_ra = INT_MIN;
3087 }
else if (!
s->ref) {
3092 if (
s->nal_unit_type !=
s->first_nal_type) {
3094 "Non-matching NAL types of the VCL NALUs: %d %d\n",
3095 s->first_nal_type,
s->nal_unit_type);
3099 if (!
s->sh.dependent_slice_segment_flag &&
3104 "Error constructing the reference lists for the current slice.\n");
3109 if (
s->sh.first_slice_in_pic_flag &&
s->avctx->hwaccel) {
3115 if (
s->avctx->hwaccel) {
3122 "SCC profile is not yet implemented in hevc native decoder.\n");
3127 if (
s->threads_number > 1 &&
s->sh.num_entry_point_offsets > 0)
3131 if (ctb_addr_ts >= (
s->ps.sps->ctb_width *
s->ps.sps->ctb_height)) {
3138 if (ctb_addr_ts < 0) {
3147 s->max_ra = INT_MAX;
3155 "Skipping NAL unit %d\n",
s->nal_unit_type);
3168 int eos_at_start = 1;
3170 s->ref =
s->collocated_ref =
NULL;
3171 s->last_eos =
s->eos;
3178 s->nal_length_size,
s->avctx->codec_id, 1, 0);
3181 "Error splitting the input into NAL units.\n");
3185 for (
i = 0;
i <
s->pkt.nb_nals;
i++) {
3207 s->pkt.nals[
s->pkt.nb_nals - 1].size > 2 && !
s->pkt.nals[
s->pkt.nb_nals - 1].nuh_layer_id
3208 && !
s->pkt.nals[
s->pkt.nb_nals - 1].temporal_id) {
3209 H2645NAL *nal = &
s->pkt.nals[
s->pkt.nb_nals - 1];
3212 av_log(
s->avctx,
AV_LOG_WARNING,
"Multiple Dolby Vision RPUs found in one AU. Skipping previous.\n");
3229 for (
i = 0;
i <
s->pkt.nb_nals;
i++) {
3238 if (
ret >= 0 &&
s->overlap > 2)
3242 "Error parsing NAL unit #%d.\n",
i);
3257 char msg_buf[4 * (50 + 2 * 2 * 16 )];
3265 pixel_shift =
desc->comp[0].depth > 8;
3270 if (pixel_shift && !
s->checksum_buf) {
3274 if (!
s->checksum_buf)
3281 int width =
s->avctx->coded_width;
3282 int height =
s->avctx->coded_height;
3288 for (j = 0; j <
h; j++) {
3292 s->bdsp.bswap16_buf((uint16_t *)
s->checksum_buf,
3293 (
const uint16_t *)
src,
w);
3294 src =
s->checksum_buf;
3301 #define MD5_PRI "%016" PRIx64 "%016" PRIx64
3302 #define MD5_PRI_ARG(buf) AV_RB64(buf), AV_RB64((const uint8_t*)(buf) + 8)
3304 if (!memcmp(
md5,
s->sei.picture_hash.md5[
i], 16)) {
3306 "plane %d - correct " MD5_PRI "; ",
3310 "mismatching checksum of plane %d - " MD5_PRI " != " MD5_PRI "; ",
3317 "Verifying checksum for frame with POC %d: %s\n",
3328 &
s->nal_length_size,
s->avctx->err_recognition,
3329 s->apply_defdispwin,
s->avctx);
3335 if (
first &&
s->ps.sps_list[
i]) {
3368 if (sd && sd_size > 0) {
3375 if (sd && sd_size > 0) {
3376 int old =
s->dovi_ctx.dv_profile;
3381 "New DOVI configuration record from input packet (profile %d -> %u).\n",
3382 old,
s->dovi_ctx.dv_profile);
3385 s->ref =
s->collocated_ref =
NULL;
3393 "hardware accelerator failed to decode picture\n");
3400 s->sei.picture_hash.is_md5) {
3408 s->sei.picture_hash.is_md5 = 0;
3410 if (
s->is_decoded) {
3415 if (
s->output_frame->buf[0]) {
3431 if (
src->needs_fg) {
3449 src->hwaccel_picture_private);
3466 for (
i = 0;
i < 3;
i++) {
3484 if (
s->HEVClcList) {
3485 for (
i = 1;
i <
s->threads_number;
i++) {
3508 if (!
s->HEVClc || !
s->HEVClcList)
3510 s->HEVClc->parent =
s;
3511 s->HEVClc->logctx = avctx;
3512 s->HEVClc->common_cabac_state = &
s->cabac;
3513 s->HEVClcList[0] =
s->HEVClc;
3516 if (!
s->output_frame)
3521 if (!
s->DPB[
i].frame)
3523 s->DPB[
i].tf.f =
s->DPB[
i].frame;
3526 if (!
s->DPB[
i].frame_grain)
3530 s->max_ra = INT_MAX;
3538 s->dovi_ctx.logctx = avctx;
3556 if (
s0->DPB[
i].frame->buf[0]) {
3563 if (
s->ps.sps !=
s0->ps.sps)
3574 if (
s->ps.sps !=
s0->ps.sps)
3578 s->seq_decode =
s0->seq_decode;
3579 s->seq_output =
s0->seq_output;
3580 s->pocTid0 =
s0->pocTid0;
3581 s->max_ra =
s0->max_ra;
3583 s->no_rasl_output_flag =
s0->no_rasl_output_flag;
3585 s->is_nalff =
s0->is_nalff;
3586 s->nal_length_size =
s0->nal_length_size;
3588 s->threads_number =
s0->threads_number;
3589 s->threads_type =
s0->threads_type;
3591 s->film_grain_warning_shown =
s0->film_grain_warning_shown;
3595 s->max_ra = INT_MAX;
3603 s0->sei.common.dynamic_hdr_plus.info);
3614 s0->sei.common.dynamic_hdr_vivid.info);
3618 s->sei.common.frame_packing =
s0->sei.common.frame_packing;
3619 s->sei.common.display_orientation =
s0->sei.common.display_orientation;
3620 s->sei.common.alternative_transfer =
s0->sei.common.alternative_transfer;
3621 s->sei.common.mastering_display =
s0->sei.common.mastering_display;
3622 s->sei.common.content_light =
s0->sei.common.content_light;
3623 s->sei.common.aom_film_grain =
s0->sei.common.aom_film_grain;
3644 s->threads_number = 1;
3655 s->enable_parallel_tiles = 0;
3656 s->sei.picture_timing.picture_struct = 0;
3672 if (sd && sd->
size > 0)
3686 s->max_ra = INT_MAX;
3693 #define OFFSET(x) offsetof(HEVCContext, x)
3694 #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
3697 {
"apply_defdispwin",
"Apply default display window from VUI",
OFFSET(apply_defdispwin),
3699 {
"strict-displaywin",
"stricly apply default display window size",
OFFSET(apply_defdispwin),
3729 #if CONFIG_HEVC_DXVA2_HWACCEL
3732 #if CONFIG_HEVC_D3D11VA_HWACCEL
3735 #if CONFIG_HEVC_D3D11VA2_HWACCEL
3738 #if CONFIG_HEVC_D3D12VA_HWACCEL
3741 #if CONFIG_HEVC_NVDEC_HWACCEL
3744 #if CONFIG_HEVC_VAAPI_HWACCEL
3747 #if CONFIG_HEVC_VDPAU_HWACCEL
3750 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
3753 #if CONFIG_HEVC_VULKAN_HWACCEL