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)
141 if (!
s->tab_mvf_pool || !
s->rpl_tab_pool)
155 uint8_t luma_weight_l0_flag[16];
156 uint8_t chroma_weight_l0_flag[16];
157 uint8_t luma_weight_l1_flag[16];
158 uint8_t chroma_weight_l1_flag[16];
159 int luma_log2_weight_denom;
162 if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) {
163 av_log(
s->avctx,
AV_LOG_ERROR,
"luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom);
166 s->sh.luma_log2_weight_denom =
av_clip_uintp2(luma_log2_weight_denom, 3);
167 if (
s->ps.sps->chroma_format_idc != 0) {
168 int64_t chroma_log2_weight_denom = luma_log2_weight_denom + (int64_t)
get_se_golomb(gb);
169 if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) {
170 av_log(
s->avctx,
AV_LOG_ERROR,
"chroma_log2_weight_denom %"PRId64
" is invalid\n", chroma_log2_weight_denom);
173 s->sh.chroma_log2_weight_denom = chroma_log2_weight_denom;
176 for (
i = 0;
i <
s->sh.nb_refs[
L0];
i++) {
178 if (!luma_weight_l0_flag[
i]) {
179 s->sh.luma_weight_l0[
i] = 1 <<
s->sh.luma_log2_weight_denom;
180 s->sh.luma_offset_l0[
i] = 0;
183 if (
s->ps.sps->chroma_format_idc != 0) {
184 for (
i = 0;
i <
s->sh.nb_refs[
L0];
i++)
187 for (
i = 0;
i <
s->sh.nb_refs[
L0];
i++)
188 chroma_weight_l0_flag[
i] = 0;
190 for (
i = 0;
i <
s->sh.nb_refs[
L0];
i++) {
191 if (luma_weight_l0_flag[
i]) {
193 if ((int8_t)delta_luma_weight_l0 != delta_luma_weight_l0)
195 s->sh.luma_weight_l0[
i] = (1 <<
s->sh.luma_log2_weight_denom) + delta_luma_weight_l0;
198 if (chroma_weight_l0_flag[
i]) {
199 for (j = 0; j < 2; j++) {
203 if ( (int8_t)delta_chroma_weight_l0 != delta_chroma_weight_l0
204 || delta_chroma_offset_l0 < -(1<<17) || delta_chroma_offset_l0 > (1<<17)) {
208 s->sh.chroma_weight_l0[
i][j] = (1 <<
s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l0;
209 s->sh.chroma_offset_l0[
i][j] =
av_clip((delta_chroma_offset_l0 - ((128 *
s->sh.chroma_weight_l0[
i][j])
210 >>
s->sh.chroma_log2_weight_denom) + 128), -128, 127);
213 s->sh.chroma_weight_l0[
i][0] = 1 <<
s->sh.chroma_log2_weight_denom;
214 s->sh.chroma_offset_l0[
i][0] = 0;
215 s->sh.chroma_weight_l0[
i][1] = 1 <<
s->sh.chroma_log2_weight_denom;
216 s->sh.chroma_offset_l0[
i][1] = 0;
220 for (
i = 0;
i <
s->sh.nb_refs[
L1];
i++) {
222 if (!luma_weight_l1_flag[
i]) {
223 s->sh.luma_weight_l1[
i] = 1 <<
s->sh.luma_log2_weight_denom;
224 s->sh.luma_offset_l1[
i] = 0;
227 if (
s->ps.sps->chroma_format_idc != 0) {
228 for (
i = 0;
i <
s->sh.nb_refs[
L1];
i++)
231 for (
i = 0;
i <
s->sh.nb_refs[
L1];
i++)
232 chroma_weight_l1_flag[
i] = 0;
234 for (
i = 0;
i <
s->sh.nb_refs[
L1];
i++) {
235 if (luma_weight_l1_flag[
i]) {
237 if ((int8_t)delta_luma_weight_l1 != delta_luma_weight_l1)
239 s->sh.luma_weight_l1[
i] = (1 <<
s->sh.luma_log2_weight_denom) + delta_luma_weight_l1;
242 if (chroma_weight_l1_flag[
i]) {
243 for (j = 0; j < 2; j++) {
247 if ( (int8_t)delta_chroma_weight_l1 != delta_chroma_weight_l1
248 || delta_chroma_offset_l1 < -(1<<17) || delta_chroma_offset_l1 > (1<<17)) {
252 s->sh.chroma_weight_l1[
i][j] = (1 <<
s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l1;
253 s->sh.chroma_offset_l1[
i][j] =
av_clip((delta_chroma_offset_l1 - ((128 *
s->sh.chroma_weight_l1[
i][j])
254 >>
s->sh.chroma_log2_weight_denom) + 128), -128, 127);
257 s->sh.chroma_weight_l1[
i][0] = 1 <<
s->sh.chroma_log2_weight_denom;
258 s->sh.chroma_offset_l1[
i][0] = 0;
259 s->sh.chroma_weight_l1[
i][1] = 1 <<
s->sh.chroma_log2_weight_denom;
260 s->sh.chroma_offset_l1[
i][1] = 0;
270 int max_poc_lsb = 1 <<
sps->log2_max_poc_lsb;
271 int prev_delta_msb = 0;
272 unsigned int nb_sps = 0, nb_sh;
276 if (!
sps->long_term_ref_pics_present_flag)
279 if (
sps->num_long_term_ref_pics_sps > 0)
283 if (nb_sps >
sps->num_long_term_ref_pics_sps)
293 uint8_t lt_idx_sps = 0;
295 if (
sps->num_long_term_ref_pics_sps > 1)
298 rps->
poc[
i] =
sps->lt_ref_pic_poc_lsb_sps[lt_idx_sps];
299 rps->
used[
i] =
sps->used_by_curr_pic_lt_sps_flag[lt_idx_sps];
310 if (
i &&
i != nb_sps)
311 delta += prev_delta_msb;
313 poc = rps->
poc[
i] +
s->poc -
delta * max_poc_lsb -
s->sh.pic_order_cnt_lsb;
317 prev_delta_msb =
delta;
330 unsigned int num = 0, den = 0;
335 avctx->
width =
sps->width - ow->left_offset - ow->right_offset;
336 avctx->
height =
sps->height - ow->top_offset - ow->bottom_offset;
338 avctx->
profile =
sps->ptl.general_ptl.profile_idc;
339 avctx->
level =
sps->ptl.general_ptl.level_idc;
343 if (
sps->vui.video_signal_type_present_flag)
349 if (
sps->vui.colour_description_present_flag) {
360 if (
sps->chroma_format_idc == 1) {
361 if (
sps->vui.chroma_loc_info_present_flag) {
362 if (
sps->vui.chroma_sample_loc_type_top_field <= 5)
368 if (
vps->vps_timing_info_present_flag) {
369 num =
vps->vps_num_units_in_tick;
370 den =
vps->vps_time_scale;
371 }
else if (
sps->vui.vui_timing_info_present_flag) {
372 num =
sps->vui.vui_num_units_in_tick;
373 den =
sps->vui.vui_time_scale;
376 if (num != 0 && den != 0)
385 if (
s->sei.a53_caption.buf_ref)
388 if (
s->sei.alternative_transfer.present &&
391 avctx->
color_trc =
s->sei.alternative_transfer.preferred_transfer_characteristics;
394 if (
s->sei.film_grain_characteristics.present)
402 #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + \
403 CONFIG_HEVC_D3D11VA_HWACCEL * 2 + \
404 CONFIG_HEVC_NVDEC_HWACCEL + \
405 CONFIG_HEVC_VAAPI_HWACCEL + \
406 CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL + \
407 CONFIG_HEVC_VDPAU_HWACCEL)
410 switch (
sps->pix_fmt) {
413 #if CONFIG_HEVC_DXVA2_HWACCEL
416 #if CONFIG_HEVC_D3D11VA_HWACCEL
420 #if CONFIG_HEVC_VAAPI_HWACCEL
423 #if CONFIG_HEVC_VDPAU_HWACCEL
426 #if CONFIG_HEVC_NVDEC_HWACCEL
429 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
434 #if CONFIG_HEVC_DXVA2_HWACCEL
437 #if CONFIG_HEVC_D3D11VA_HWACCEL
441 #if CONFIG_HEVC_VAAPI_HWACCEL
444 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
447 #if CONFIG_HEVC_VDPAU_HWACCEL
450 #if CONFIG_HEVC_NVDEC_HWACCEL
455 #if CONFIG_HEVC_VDPAU_HWACCEL
458 #if CONFIG_HEVC_NVDEC_HWACCEL
461 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
467 #if CONFIG_HEVC_VAAPI_HWACCEL
470 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
475 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
480 #if CONFIG_HEVC_VDPAU_HWACCEL
483 #if CONFIG_HEVC_NVDEC_HWACCEL
489 *fmt++ =
sps->pix_fmt;
519 for (
i = 0;
i < 3;
i++) {
524 if (
sps->sao_enabled && !
s->avctx->hwaccel) {
525 int c_count = (
sps->chroma_format_idc != 0) ? 3 : 1;
528 for(c_idx = 0; c_idx < c_count; c_idx++) {
529 int w =
sps->width >>
sps->hshift[c_idx];
530 int h =
sps->height >>
sps->vshift[c_idx];
531 s->sao_pixel_buffer_h[c_idx] =
534 s->sao_pixel_buffer_v[c_idx] =
537 if (!
s->sao_pixel_buffer_h[c_idx] ||
538 !
s->sao_pixel_buffer_v[c_idx])
544 s->ps.vps = (
HEVCVPS*)
s->ps.vps_list[
s->ps.sps->vps_id]->data;
550 for (
i = 0;
i < 3;
i++) {
567 av_log(
s->avctx,
AV_LOG_ERROR,
"Two slices reporting being the first in the same frame.\n");
572 s->seq_decode = (
s->seq_decode + 1) & 0xff;
595 if (
s->ps.sps != (
HEVCSPS*)
s->ps.sps_list[
s->ps.pps->sps_id]->data) {
597 const HEVCSPS *last_sps =
s->ps.sps;
601 if (
sps->width != last_sps->width ||
sps->height != last_sps->height ||
602 sps->temporal_layer[
sps->max_sub_layers - 1].max_dec_pic_buffering !=
603 last_sps->temporal_layer[last_sps->max_sub_layers - 1].max_dec_pic_buffering)
617 s->seq_decode = (
s->seq_decode + 1) & 0xff;
627 int slice_address_length;
629 if (
s->ps.pps->dependent_slice_segments_enabled_flag)
633 s->ps.sps->ctb_height);
637 "Invalid slice segment address: %u.\n",
649 s->slice_initialized = 0;
653 s->slice_initialized = 0;
655 for (
i = 0;
i <
s->ps.pps->num_extra_slice_header_bits;
i++)
673 if (
s->ps.pps->output_flag_present_flag)
676 if (
s->ps.sps->separate_colour_plane_flag)
686 "Ignoring POC change between slices: %d -> %d\n",
s->poc, poc);
702 int numbits, rps_idx;
704 if (!
s->ps.sps->nb_st_rps) {
710 rps_idx = numbits > 0 ?
get_bits(gb, numbits) : 0;
724 if (
s->ps.sps->sps_temporal_mvp_enabled_flag)
729 s->sh.short_term_rps =
NULL;
744 if (
s->ps.sps->sao_enabled) {
746 if (
s->ps.sps->chroma_format_idc) {
760 sh->
nb_refs[
L0] =
s->ps.pps->num_ref_idx_l0_default_active;
762 sh->
nb_refs[
L1] =
s->ps.pps->num_ref_idx_l1_default_active;
783 if (
s->ps.pps->lists_modification_present_flag && nb_refs > 1) {
801 if (
s->ps.pps->cabac_init_present_flag)
816 "Invalid collocated_ref_idx: %d.\n",
833 "Invalid number of merging MVP candidates: %d.\n",
841 if (
s->ps.pps->pic_slice_level_chroma_qp_offsets_present_flag) {
854 if (
s->ps.pps->chroma_qp_offset_list_enabled_flag)
859 if (
s->ps.pps->deblocking_filter_control_present_flag) {
860 int deblocking_filter_override_flag = 0;
862 if (
s->ps.pps->deblocking_filter_override_enabled_flag)
863 deblocking_filter_override_flag =
get_bits1(gb);
865 if (deblocking_filter_override_flag) {
870 if (beta_offset_div2 < -6 || beta_offset_div2 > 6 ||
871 tc_offset_div2 < -6 || tc_offset_div2 > 6) {
873 "Invalid deblock filter offsets: %d, %d\n",
874 beta_offset_div2, tc_offset_div2);
891 if (
s->ps.pps->seq_loop_filter_across_slices_enabled_flag &&
899 }
else if (!
s->slice_initialized) {
905 if (
s->ps.pps->tiles_enabled_flag ||
s->ps.pps->entropy_coding_sync_enabled_flag) {
909 av_log(
s->avctx,
AV_LOG_ERROR,
"num_entry_point_offsets %d is invalid\n", num_entry_point_offsets);
917 if (offset_len < 1 || offset_len > 32) {
938 if (
s->threads_number > 1 && (
s->ps.pps->num_tile_rows > 1 ||
s->ps.pps->num_tile_columns > 1)) {
939 s->enable_parallel_tiles = 0;
940 s->threads_number = 1;
942 s->enable_parallel_tiles = 0;
944 s->enable_parallel_tiles = 0;
947 if (
s->ps.pps->slice_header_extension_present_flag) {
953 for (
i = 0;
i < length;
i++)
960 sh->
slice_qp < -
s->ps.sps->qp_bd_offset) {
962 "The slice_qp %d is outside the valid range "
965 -
s->ps.sps->qp_bd_offset);
971 if (!
s->sh.slice_ctb_addr_rs &&
s->sh.dependent_slice_segment_flag) {
982 s->HEVClc->first_qp_group = !
s->sh.dependent_slice_segment_flag;
984 if (!
s->ps.pps->cu_qp_delta_enabled_flag)
985 s->HEVClc->qp_y =
s->sh.slice_qp;
987 s->slice_initialized = 1;
988 s->HEVClc->tu.cu_qp_offset_cb = 0;
989 s->HEVClc->tu.cu_qp_offset_cr = 0;
994 #define CTB(tab, x, y) ((tab)[(y) * s->ps.sps->ctb_width + (x)])
996 #define SET_SAO(elem, value) \
998 if (!sao_merge_up_flag && !sao_merge_left_flag) \
1000 else if (sao_merge_left_flag) \
1001 sao->elem = CTB(s->sao, rx-1, ry).elem; \
1002 else if (sao_merge_up_flag) \
1003 sao->elem = CTB(s->sao, rx, ry-1).elem; \
1011 int sao_merge_left_flag = 0;
1012 int sao_merge_up_flag = 0;
1016 if (
s->sh.slice_sample_adaptive_offset_flag[0] ||
1017 s->sh.slice_sample_adaptive_offset_flag[1]) {
1022 if (ry > 0 && !sao_merge_left_flag) {
1028 for (c_idx = 0; c_idx < (
s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) {
1029 int log2_sao_offset_scale = c_idx == 0 ?
s->ps.pps->log2_sao_offset_scale_luma :
1030 s->ps.pps->log2_sao_offset_scale_chroma;
1032 if (!
s->sh.slice_sample_adaptive_offset_flag[c_idx]) {
1047 for (
i = 0;
i < 4;
i++)
1051 for (
i = 0;
i < 4;
i++) {
1060 }
else if (c_idx != 2) {
1066 for (
i = 0;
i < 4;
i++) {
1074 sao->
offset_val[c_idx][
i + 1] *= 1 << log2_sao_offset_scale;
1086 if (log2_res_scale_abs_plus1 != 0) {
1089 (1 - 2 * res_scale_sign_flag);
1099 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1100 int log2_cb_size,
int log2_trafo_size,
1101 int blk_idx,
int cbf_luma,
int *cbf_cb,
int *cbf_cr)
1104 const int log2_trafo_size_c = log2_trafo_size -
s->ps.sps->hshift[1];
1108 int trafo_size = 1 << log2_trafo_size;
1111 s->hpc.intra_pred[log2_trafo_size - 2](
s, x0, y0, 0);
1114 if (cbf_luma || cbf_cb[0] || cbf_cr[0] ||
1115 (
s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
1118 int cbf_chroma = cbf_cb[0] || cbf_cr[0] ||
1119 (
s->ps.sps->chroma_format_idc == 2 &&
1120 (cbf_cb[1] || cbf_cr[1]));
1132 "The cu_qp_delta %d is outside the valid range "
1135 -(26 +
s->ps.sps->qp_bd_offset / 2),
1136 (25 +
s->ps.sps->qp_bd_offset / 2));
1143 if (
s->sh.cu_chroma_qp_offset_enabled_flag && cbf_chroma &&
1146 if (cu_chroma_qp_offset_flag) {
1147 int cu_chroma_qp_offset_idx = 0;
1148 if (
s->ps.pps->chroma_qp_offset_list_len_minus1 > 0) {
1151 "cu_chroma_qp_offset_idx not yet tested.\n");
1184 if (
s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 ||
s->ps.sps->chroma_format_idc == 3)) {
1185 int trafo_size_h = 1 << (log2_trafo_size_c +
s->ps.sps->hshift[1]);
1186 int trafo_size_v = 1 << (log2_trafo_size_c +
s->ps.sps->vshift[1]);
1187 lc->
tu.
cross_pf = (
s->ps.pps->cross_component_prediction_enabled_flag && cbf_luma &&
1194 for (
i = 0;
i < (
s->ps.sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1197 s->hpc.intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (
i << log2_trafo_size_c), 1);
1201 log2_trafo_size_c, scan_idx_c, 1);
1204 ptrdiff_t
stride =
s->frame->linesize[1];
1205 int hshift =
s->ps.sps->hshift[1];
1206 int vshift =
s->ps.sps->vshift[1];
1209 int size = 1 << log2_trafo_size_c;
1211 uint8_t *dst = &
s->frame->data[1][(y0 >> vshift) *
stride +
1212 ((x0 >> hshift) <<
s->ps.sps->pixel_shift)];
1216 s->hevcdsp.add_residual[log2_trafo_size_c-2](dst, coeffs,
stride);
1223 for (
i = 0;
i < (
s->ps.sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1226 s->hpc.intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (
i << log2_trafo_size_c), 2);
1230 log2_trafo_size_c, scan_idx_c, 2);
1233 ptrdiff_t
stride =
s->frame->linesize[2];
1234 int hshift =
s->ps.sps->hshift[2];
1235 int vshift =
s->ps.sps->vshift[2];
1238 int size = 1 << log2_trafo_size_c;
1240 uint8_t *dst = &
s->frame->data[2][(y0 >> vshift) *
stride +
1241 ((x0 >> hshift) <<
s->ps.sps->pixel_shift)];
1245 s->hevcdsp.add_residual[log2_trafo_size_c-2](dst, coeffs,
stride);
1248 }
else if (
s->ps.sps->chroma_format_idc && blk_idx == 3) {
1249 int trafo_size_h = 1 << (log2_trafo_size + 1);
1250 int trafo_size_v = 1 << (log2_trafo_size +
s->ps.sps->vshift[1]);
1251 for (
i = 0;
i < (
s->ps.sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1254 trafo_size_h, trafo_size_v);
1255 s->hpc.intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (
i << log2_trafo_size), 1);
1259 log2_trafo_size, scan_idx_c, 1);
1261 for (
i = 0;
i < (
s->ps.sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1264 trafo_size_h, trafo_size_v);
1265 s->hpc.intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (
i << log2_trafo_size), 2);
1269 log2_trafo_size, scan_idx_c, 2);
1273 if (log2_trafo_size > 2 ||
s->ps.sps->chroma_format_idc == 3) {
1274 int trafo_size_h = 1 << (log2_trafo_size_c +
s->ps.sps->hshift[1]);
1275 int trafo_size_v = 1 << (log2_trafo_size_c +
s->ps.sps->vshift[1]);
1277 s->hpc.intra_pred[log2_trafo_size_c - 2](
s, x0, y0, 1);
1278 s->hpc.intra_pred[log2_trafo_size_c - 2](
s, x0, y0, 2);
1279 if (
s->ps.sps->chroma_format_idc == 2) {
1281 trafo_size_h, trafo_size_v);
1282 s->hpc.intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (1 << log2_trafo_size_c), 1);
1283 s->hpc.intra_pred[log2_trafo_size_c - 2](
s, x0, y0 + (1 << log2_trafo_size_c), 2);
1285 }
else if (blk_idx == 3) {
1286 int trafo_size_h = 1 << (log2_trafo_size + 1);
1287 int trafo_size_v = 1 << (log2_trafo_size +
s->ps.sps->vshift[1]);
1289 trafo_size_h, trafo_size_v);
1290 s->hpc.intra_pred[log2_trafo_size - 2](
s, xBase, yBase, 1);
1291 s->hpc.intra_pred[log2_trafo_size - 2](
s, xBase, yBase, 2);
1292 if (
s->ps.sps->chroma_format_idc == 2) {
1294 trafo_size_h, trafo_size_v);
1295 s->hpc.intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (1 << (log2_trafo_size)), 1);
1296 s->hpc.intra_pred[log2_trafo_size - 2](
s, xBase, yBase + (1 << (log2_trafo_size)), 2);
1306 int cb_size = 1 << log2_cb_size;
1307 int log2_min_pu_size =
s->ps.sps->log2_min_pu_size;
1309 int min_pu_width =
s->ps.sps->min_pu_width;
1310 int x_end =
FFMIN(x0 + cb_size,
s->ps.sps->width);
1311 int y_end =
FFMIN(y0 + cb_size,
s->ps.sps->height);
1314 for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
1315 for (
i = (x0 >> log2_min_pu_size);
i < (x_end >> log2_min_pu_size);
i++)
1316 s->is_pcm[
i + j * min_pu_width] = 2;
1320 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1321 int log2_cb_size,
int log2_trafo_size,
1322 int trafo_depth,
int blk_idx,
1323 const int *base_cbf_cb,
const int *base_cbf_cr)
1326 uint8_t split_transform_flag;
1331 cbf_cb[0] = base_cbf_cb[0];
1332 cbf_cb[1] = base_cbf_cb[1];
1333 cbf_cr[0] = base_cbf_cr[0];
1334 cbf_cr[1] = base_cbf_cr[1];
1337 if (trafo_depth == 1) {
1339 if (
s->ps.sps->chroma_format_idc == 3) {
1353 if (log2_trafo_size <= s->ps.sps->log2_max_trafo_size &&
1354 log2_trafo_size >
s->ps.sps->log2_min_tb_size &&
1355 trafo_depth < lc->cu.max_trafo_depth &&
1359 int inter_split =
s->ps.sps->max_transform_hierarchy_depth_inter == 0 &&
1364 split_transform_flag = log2_trafo_size >
s->ps.sps->log2_max_trafo_size ||
1369 if (
s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 ||
s->ps.sps->chroma_format_idc == 3)) {
1370 if (trafo_depth == 0 || cbf_cb[0]) {
1372 if (
s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
1377 if (trafo_depth == 0 || cbf_cr[0]) {
1379 if (
s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
1385 if (split_transform_flag) {
1386 const int trafo_size_split = 1 << (log2_trafo_size - 1);
1387 const int x1 = x0 + trafo_size_split;
1388 const int y1 = y0 + trafo_size_split;
1390 #define SUBDIVIDE(x, y, idx) \
1392 ret = hls_transform_tree(s, x, y, x0, y0, cb_xBase, cb_yBase, log2_cb_size, \
1393 log2_trafo_size - 1, trafo_depth + 1, idx, \
1406 int min_tu_size = 1 <<
s->ps.sps->log2_min_tb_size;
1407 int log2_min_tu_size =
s->ps.sps->log2_min_tb_size;
1408 int min_tu_width =
s->ps.sps->min_tb_width;
1412 cbf_cb[0] || cbf_cr[0] ||
1413 (
s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
1418 log2_cb_size, log2_trafo_size,
1419 blk_idx, cbf_luma, cbf_cb, cbf_cr);
1425 for (
i = 0;
i < (1 << log2_trafo_size);
i += min_tu_size)
1426 for (j = 0; j < (1 << log2_trafo_size); j += min_tu_size) {
1427 int x_tu = (x0 + j) >> log2_min_tu_size;
1428 int y_tu = (y0 +
i) >> log2_min_tu_size;
1429 s->cbf_luma[y_tu * min_tu_width + x_tu] = 1;
1432 if (!
s->sh.disable_deblocking_filter_flag) {
1434 if (
s->ps.pps->transquant_bypass_enable_flag &&
1446 int cb_size = 1 << log2_cb_size;
1447 ptrdiff_t stride0 =
s->frame->linesize[0];
1448 ptrdiff_t stride1 =
s->frame->linesize[1];
1449 ptrdiff_t stride2 =
s->frame->linesize[2];
1450 uint8_t *dst0 = &
s->frame->data[0][y0 * stride0 + (x0 <<
s->ps.sps->pixel_shift)];
1451 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)];
1452 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)];
1454 int length = cb_size * cb_size *
s->ps.sps->pcm.bit_depth +
1455 (((cb_size >>
s->ps.sps->hshift[1]) * (cb_size >>
s->ps.sps->vshift[1])) +
1456 ((cb_size >>
s->ps.sps->hshift[2]) * (cb_size >>
s->ps.sps->vshift[2]))) *
1457 s->ps.sps->pcm.bit_depth_chroma;
1458 const uint8_t *pcm =
skip_bytes(&lc->
cc, (length + 7) >> 3);
1461 if (!
s->sh.disable_deblocking_filter_flag)
1468 s->hevcdsp.put_pcm(dst0, stride0, cb_size, cb_size, &gb,
s->ps.sps->pcm.bit_depth);
1469 if (
s->ps.sps->chroma_format_idc) {
1470 s->hevcdsp.put_pcm(dst1, stride1,
1471 cb_size >>
s->ps.sps->hshift[1],
1472 cb_size >>
s->ps.sps->vshift[1],
1473 &gb,
s->ps.sps->pcm.bit_depth_chroma);
1474 s->hevcdsp.put_pcm(dst2, stride2,
1475 cb_size >>
s->ps.sps->hshift[2],
1476 cb_size >>
s->ps.sps->vshift[2],
1477 &gb,
s->ps.sps->pcm.bit_depth_chroma);
1501 int block_w,
int block_h,
int luma_weight,
int luma_offset)
1504 uint8_t *
src =
ref->data[0];
1505 ptrdiff_t srcstride =
ref->linesize[0];
1506 int pic_width =
s->ps.sps->width;
1507 int pic_height =
s->ps.sps->height;
1510 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
s->ps.pps->weighted_pred_flag) ||
1511 (
s->sh.slice_type ==
HEVC_SLICE_B &&
s->ps.pps->weighted_bipred_flag);
1514 x_off +=
mv->x >> 2;
1515 y_off +=
mv->y >> 2;
1516 src += y_off * srcstride + (x_off * (1 <<
s->ps.sps->pixel_shift));
1526 edge_emu_stride, srcstride,
1530 pic_width, pic_height);
1532 srcstride = edge_emu_stride;
1536 s->hevcdsp.put_hevc_qpel_uni[idx][!!my][!!mx](dst, dststride,
src, srcstride,
1537 block_h, mx, my, block_w);
1539 s->hevcdsp.put_hevc_qpel_uni_w[idx][!!my][!!mx](dst, dststride,
src, srcstride,
1540 block_h,
s->sh.luma_log2_weight_denom,
1541 luma_weight, luma_offset, mx, my, block_w);
1561 AVFrame *ref0,
const Mv *mv0,
int x_off,
int y_off,
1562 int block_w,
int block_h,
AVFrame *ref1,
const Mv *mv1,
struct MvField *current_mv)
1565 ptrdiff_t src0stride = ref0->
linesize[0];
1566 ptrdiff_t src1stride = ref1->
linesize[0];
1567 int pic_width =
s->ps.sps->width;
1568 int pic_height =
s->ps.sps->height;
1569 int mx0 = mv0->
x & 3;
1570 int my0 = mv0->
y & 3;
1571 int mx1 = mv1->
x & 3;
1572 int my1 = mv1->
y & 3;
1573 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
s->ps.pps->weighted_pred_flag) ||
1574 (
s->sh.slice_type ==
HEVC_SLICE_B &&
s->ps.pps->weighted_bipred_flag);
1575 int x_off0 = x_off + (mv0->
x >> 2);
1576 int y_off0 = y_off + (mv0->
y >> 2);
1577 int x_off1 = x_off + (mv1->
x >> 2);
1578 int y_off1 = y_off + (mv1->
y >> 2);
1581 uint8_t *
src0 = ref0->
data[0] + y_off0 * src0stride + (
int)((
unsigned)x_off0 <<
s->ps.sps->pixel_shift);
1582 uint8_t *
src1 = ref1->
data[0] + y_off1 * src1stride + (
int)((
unsigned)x_off1 <<
s->ps.sps->pixel_shift);
1592 edge_emu_stride, src0stride,
1596 pic_width, pic_height);
1598 src0stride = edge_emu_stride;
1609 edge_emu_stride, src1stride,
1613 pic_width, pic_height);
1615 src1stride = edge_emu_stride;
1618 s->hevcdsp.put_hevc_qpel[idx][!!my0][!!mx0](lc->
tmp,
src0, src0stride,
1619 block_h, mx0, my0, block_w);
1621 s->hevcdsp.put_hevc_qpel_bi[idx][!!my1][!!mx1](dst, dststride,
src1, src1stride, lc->
tmp,
1622 block_h, mx1, my1, block_w);
1624 s->hevcdsp.put_hevc_qpel_bi_w[idx][!!my1][!!mx1](dst, dststride,
src1, src1stride, lc->
tmp,
1625 block_h,
s->sh.luma_log2_weight_denom,
1626 s->sh.luma_weight_l0[current_mv->
ref_idx[0]],
1627 s->sh.luma_weight_l1[current_mv->
ref_idx[1]],
1628 s->sh.luma_offset_l0[current_mv->
ref_idx[0]],
1629 s->sh.luma_offset_l1[current_mv->
ref_idx[1]],
1652 ptrdiff_t dststride, uint8_t *
src0, ptrdiff_t srcstride,
int reflist,
1653 int x_off,
int y_off,
int block_w,
int block_h,
struct MvField *current_mv,
int chroma_weight,
int chroma_offset)
1656 int pic_width =
s->ps.sps->width >>
s->ps.sps->hshift[1];
1657 int pic_height =
s->ps.sps->height >>
s->ps.sps->vshift[1];
1658 const Mv *
mv = ¤t_mv->
mv[reflist];
1659 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
s->ps.pps->weighted_pred_flag) ||
1660 (
s->sh.slice_type ==
HEVC_SLICE_B &&
s->ps.pps->weighted_bipred_flag);
1662 int hshift =
s->ps.sps->hshift[1];
1663 int vshift =
s->ps.sps->vshift[1];
1666 intptr_t _mx = mx << (1 - hshift);
1667 intptr_t _my = my << (1 - vshift);
1669 x_off +=
mv->x >> (2 + hshift);
1670 y_off +=
mv->y >> (2 + vshift);
1671 src0 += y_off * srcstride + (x_off * (1 <<
s->ps.sps->pixel_shift));
1679 (edge_emu_stride + (1 <<
s->ps.sps->pixel_shift));
1681 edge_emu_stride, srcstride,
1685 pic_width, pic_height);
1688 srcstride = edge_emu_stride;
1691 s->hevcdsp.put_hevc_epel_uni[idx][!!my][!!mx](dst0, dststride,
src0, srcstride,
1692 block_h, _mx, _my, block_w);
1694 s->hevcdsp.put_hevc_epel_uni_w[idx][!!my][!!mx](dst0, dststride,
src0, srcstride,
1695 block_h,
s->sh.chroma_log2_weight_denom,
1696 chroma_weight, chroma_offset, _mx, _my, block_w);
1717 int x_off,
int y_off,
int block_w,
int block_h,
struct MvField *current_mv,
int cidx)
1720 uint8_t *
src1 = ref0->
data[cidx+1];
1721 uint8_t *
src2 = ref1->
data[cidx+1];
1722 ptrdiff_t src1stride = ref0->
linesize[cidx+1];
1723 ptrdiff_t src2stride = ref1->
linesize[cidx+1];
1724 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
s->ps.pps->weighted_pred_flag) ||
1725 (
s->sh.slice_type ==
HEVC_SLICE_B &&
s->ps.pps->weighted_bipred_flag);
1726 int pic_width =
s->ps.sps->width >>
s->ps.sps->hshift[1];
1727 int pic_height =
s->ps.sps->height >>
s->ps.sps->vshift[1];
1728 Mv *mv0 = ¤t_mv->
mv[0];
1729 Mv *mv1 = ¤t_mv->
mv[1];
1730 int hshift =
s->ps.sps->hshift[1];
1731 int vshift =
s->ps.sps->vshift[1];
1737 intptr_t _mx0 = mx0 << (1 - hshift);
1738 intptr_t _my0 = my0 << (1 - vshift);
1739 intptr_t _mx1 = mx1 << (1 - hshift);
1740 intptr_t _my1 = my1 << (1 - vshift);
1742 int x_off0 = x_off + (mv0->
x >> (2 + hshift));
1743 int y_off0 = y_off + (mv0->
y >> (2 + vshift));
1744 int x_off1 = x_off + (mv1->
x >> (2 + hshift));
1745 int y_off1 = y_off + (mv1->
y >> (2 + vshift));
1747 src1 += y_off0 * src1stride + (
int)((
unsigned)x_off0 <<
s->ps.sps->pixel_shift);
1748 src2 += y_off1 * src2stride + (
int)((
unsigned)x_off1 <<
s->ps.sps->pixel_shift);
1756 (edge_emu_stride + (1 <<
s->ps.sps->pixel_shift));
1759 edge_emu_stride, src1stride,
1763 pic_width, pic_height);
1766 src1stride = edge_emu_stride;
1775 (edge_emu_stride + (1 <<
s->ps.sps->pixel_shift));
1778 edge_emu_stride, src2stride,
1782 pic_width, pic_height);
1785 src2stride = edge_emu_stride;
1788 s->hevcdsp.put_hevc_epel[idx][!!my0][!!mx0](lc->
tmp,
src1, src1stride,
1789 block_h, _mx0, _my0, block_w);
1791 s->hevcdsp.put_hevc_epel_bi[idx][!!my1][!!mx1](dst0,
s->frame->linesize[cidx+1],
1793 block_h, _mx1, _my1, block_w);
1795 s->hevcdsp.put_hevc_epel_bi_w[idx][!!my1][!!mx1](dst0,
s->frame->linesize[cidx+1],
1798 s->sh.chroma_log2_weight_denom,
1799 s->sh.chroma_weight_l0[current_mv->
ref_idx[0]][cidx],
1800 s->sh.chroma_weight_l1[current_mv->
ref_idx[1]][cidx],
1801 s->sh.chroma_offset_l0[current_mv->
ref_idx[0]][cidx],
1802 s->sh.chroma_offset_l1[current_mv->
ref_idx[1]][cidx],
1803 _mx1, _my1, block_w);
1817 int nPbH,
int log2_cb_size,
int part_idx,
1829 if (inter_pred_idc !=
PRED_L1) {
1830 if (
s->sh.nb_refs[
L0])
1837 part_idx, merge_idx,
mv, mvp_flag, 0);
1842 if (inter_pred_idc !=
PRED_L0) {
1843 if (
s->sh.nb_refs[
L1])
1846 if (
s->sh.mvd_l1_zero_flag == 1 && inter_pred_idc ==
PRED_BI) {
1855 part_idx, merge_idx,
mv, mvp_flag, 1);
1863 int log2_cb_size,
int partIdx,
int idx)
1865 #define POS(c_idx, x, y) \
1866 &s->frame->data[c_idx][((y) >> s->ps.sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \
1867 (((x) >> s->ps.sps->hshift[c_idx]) << s->ps.sps->pixel_shift)]
1870 struct MvField current_mv = {{{ 0 }}};
1872 int min_pu_width =
s->ps.sps->min_pu_width;
1874 MvField *tab_mvf =
s->ref->tab_mvf;
1877 uint8_t *dst0 =
POS(0, x0, y0);
1878 uint8_t *dst1 =
POS(1, x0, y0);
1879 uint8_t *dst2 =
POS(2, x0, y0);
1880 int log2_min_cb_size =
s->ps.sps->log2_min_cb_size;
1881 int min_cb_width =
s->ps.sps->min_cb_width;
1882 int x_cb = x0 >> log2_min_cb_size;
1883 int y_cb = y0 >> log2_min_cb_size;
1887 int skip_flag =
SAMPLE_CTB(
s->skip_flag, x_cb, y_cb);
1893 if (
s->sh.max_num_merge_cand > 1)
1899 partIdx, merge_idx, ¤t_mv);
1902 partIdx, merge_idx, ¤t_mv);
1905 x_pu = x0 >>
s->ps.sps->log2_min_pu_size;
1906 y_pu = y0 >>
s->ps.sps->log2_min_pu_size;
1908 for (j = 0; j < nPbH >>
s->ps.sps->log2_min_pu_size; j++)
1909 for (
i = 0; i < nPbW >>
s->ps.sps->log2_min_pu_size;
i++)
1910 tab_mvf[(y_pu + j) * min_pu_width + x_pu +
i] = current_mv;
1913 ref0 = refPicList[0].
ref[current_mv.
ref_idx[0]];
1919 ref1 = refPicList[1].
ref[current_mv.
ref_idx[1]];
1926 int x0_c = x0 >>
s->ps.sps->hshift[1];
1927 int y0_c = y0 >>
s->ps.sps->vshift[1];
1928 int nPbW_c = nPbW >>
s->ps.sps->hshift[1];
1929 int nPbH_c = nPbH >>
s->ps.sps->vshift[1];
1932 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
1933 s->sh.luma_weight_l0[current_mv.
ref_idx[0]],
1934 s->sh.luma_offset_l0[current_mv.
ref_idx[0]]);
1936 if (
s->ps.sps->chroma_format_idc) {
1938 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1939 s->sh.chroma_weight_l0[current_mv.
ref_idx[0]][0],
s->sh.chroma_offset_l0[current_mv.
ref_idx[0]][0]);
1941 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1942 s->sh.chroma_weight_l0[current_mv.
ref_idx[0]][1],
s->sh.chroma_offset_l0[current_mv.
ref_idx[0]][1]);
1945 int x0_c = x0 >>
s->ps.sps->hshift[1];
1946 int y0_c = y0 >>
s->ps.sps->vshift[1];
1947 int nPbW_c = nPbW >>
s->ps.sps->hshift[1];
1948 int nPbH_c = nPbH >>
s->ps.sps->vshift[1];
1951 ¤t_mv.
mv[1], x0, y0, nPbW, nPbH,
1952 s->sh.luma_weight_l1[current_mv.
ref_idx[1]],
1953 s->sh.luma_offset_l1[current_mv.
ref_idx[1]]);
1955 if (
s->ps.sps->chroma_format_idc) {
1956 chroma_mc_uni(
s, dst1,
s->frame->linesize[1], ref1->frame->data[1], ref1->frame->linesize[1],
1957 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1958 s->sh.chroma_weight_l1[current_mv.
ref_idx[1]][0],
s->sh.chroma_offset_l1[current_mv.
ref_idx[1]][0]);
1960 chroma_mc_uni(
s, dst2,
s->frame->linesize[2], ref1->frame->data[2], ref1->frame->linesize[2],
1961 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
1962 s->sh.chroma_weight_l1[current_mv.
ref_idx[1]][1],
s->sh.chroma_offset_l1[current_mv.
ref_idx[1]][1]);
1965 int x0_c = x0 >>
s->ps.sps->hshift[1];
1966 int y0_c = y0 >>
s->ps.sps->vshift[1];
1967 int nPbW_c = nPbW >>
s->ps.sps->hshift[1];
1968 int nPbH_c = nPbH >>
s->ps.sps->vshift[1];
1971 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
1972 ref1->frame, ¤t_mv.
mv[1], ¤t_mv);
1974 if (
s->ps.sps->chroma_format_idc) {
1976 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0);
1979 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 1);
1988 int prev_intra_luma_pred_flag)
1991 int x_pu = x0 >>
s->ps.sps->log2_min_pu_size;
1992 int y_pu = y0 >>
s->ps.sps->log2_min_pu_size;
1993 int min_pu_width =
s->ps.sps->min_pu_width;
1994 int size_in_pus = pu_size >>
s->ps.sps->log2_min_pu_size;
1999 s->tab_ipm[(y_pu - 1) * min_pu_width + x_pu] :
INTRA_DC;
2001 s->tab_ipm[y_pu * min_pu_width + x_pu - 1] :
INTRA_DC;
2003 int y_ctb = (y0 >> (
s->ps.sps->log2_ctb_size)) << (
s->ps.sps->log2_ctb_size);
2005 MvField *tab_mvf =
s->ref->tab_mvf;
2006 int intra_pred_mode;
2011 if ((y0 - 1) < y_ctb)
2014 if (cand_left == cand_up) {
2015 if (cand_left < 2) {
2020 candidate[0] = cand_left;
2021 candidate[1] = 2 + ((cand_left - 2 - 1 + 32) & 31);
2022 candidate[2] = 2 + ((cand_left - 2 + 1) & 31);
2025 candidate[0] = cand_left;
2026 candidate[1] = cand_up;
2036 if (prev_intra_luma_pred_flag) {
2037 intra_pred_mode = candidate[lc->
pu.
mpm_idx];
2039 if (candidate[0] > candidate[1])
2040 FFSWAP(uint8_t, candidate[0], candidate[1]);
2041 if (candidate[0] > candidate[2])
2042 FFSWAP(uint8_t, candidate[0], candidate[2]);
2043 if (candidate[1] > candidate[2])
2044 FFSWAP(uint8_t, candidate[1], candidate[2]);
2047 for (
i = 0;
i < 3;
i++)
2048 if (intra_pred_mode >= candidate[
i])
2055 for (
i = 0;
i < size_in_pus;
i++) {
2056 memset(&
s->tab_ipm[(y_pu +
i) * min_pu_width + x_pu],
2057 intra_pred_mode, size_in_pus);
2059 for (j = 0; j < size_in_pus; j++) {
2064 return intra_pred_mode;
2068 int log2_cb_size,
int ct_depth)
2070 int length = (1 << log2_cb_size) >>
s->ps.sps->log2_min_cb_size;
2071 int x_cb = x0 >>
s->ps.sps->log2_min_cb_size;
2072 int y_cb = y0 >>
s->ps.sps->log2_min_cb_size;
2075 for (y = 0; y < length; y++)
2076 memset(&
s->tab_ct_depth[(y_cb + y) *
s->ps.sps->min_cb_width + x_cb],
2081 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20,
2082 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31};
2088 static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 };
2089 uint8_t prev_intra_luma_pred_flag[4];
2091 int pb_size = (1 << log2_cb_size) >>
split;
2092 int side =
split + 1;
2096 for (
i = 0;
i < side;
i++)
2097 for (j = 0; j < side; j++)
2100 for (
i = 0;
i < side;
i++) {
2101 for (j = 0; j < side; j++) {
2102 if (prev_intra_luma_pred_flag[2 *
i + j])
2109 prev_intra_luma_pred_flag[2 *
i + j]);
2113 if (
s->ps.sps->chroma_format_idc == 3) {
2114 for (
i = 0;
i < side;
i++) {
2115 for (j = 0; j < side; j++) {
2117 if (chroma_mode != 4) {
2127 }
else if (
s->ps.sps->chroma_format_idc == 2) {
2130 if (chroma_mode != 4) {
2134 mode_idx = intra_chroma_table[chroma_mode];
2139 }
else if (
s->ps.sps->chroma_format_idc != 0) {
2141 if (chroma_mode != 4) {
2157 int pb_size = 1 << log2_cb_size;
2158 int size_in_pus = pb_size >>
s->ps.sps->log2_min_pu_size;
2159 int min_pu_width =
s->ps.sps->min_pu_width;
2160 MvField *tab_mvf =
s->ref->tab_mvf;
2161 int x_pu = x0 >>
s->ps.sps->log2_min_pu_size;
2162 int y_pu = y0 >>
s->ps.sps->log2_min_pu_size;
2165 if (size_in_pus == 0)
2167 for (j = 0; j < size_in_pus; j++)
2168 memset(&
s->tab_ipm[(y_pu + j) * min_pu_width + x_pu],
INTRA_DC, size_in_pus);
2170 for (j = 0; j < size_in_pus; j++)
2171 for (k = 0; k < size_in_pus; k++)
2177 int cb_size = 1 << log2_cb_size;
2179 int log2_min_cb_size =
s->ps.sps->log2_min_cb_size;
2180 int length = cb_size >> log2_min_cb_size;
2181 int min_cb_width =
s->ps.sps->min_cb_width;
2182 int x_cb = x0 >> log2_min_cb_size;
2183 int y_cb = y0 >> log2_min_cb_size;
2184 int idx = log2_cb_size - 2;
2185 int qp_block_mask = (1<<(
s->ps.sps->log2_ctb_size -
s->ps.pps->diff_cu_qp_delta_depth)) - 1;
2195 for (x = 0; x < 4; x++)
2197 if (
s->ps.pps->transquant_bypass_enable_flag) {
2207 x = y_cb * min_cb_width + x_cb;
2208 for (y = 0; y < length; y++) {
2209 memset(&
s->skip_flag[x], skip_flag, length);
2214 x = y_cb * min_cb_width + x_cb;
2215 for (y = 0; y < length; y++) {
2216 memset(&
s->skip_flag[x], 0, length);
2225 if (!
s->sh.disable_deblocking_filter_flag)
2233 log2_cb_size ==
s->ps.sps->log2_min_cb_size) {
2241 log2_cb_size >=
s->ps.sps->pcm.log2_min_pcm_cb_size &&
2242 log2_cb_size <= s->ps.sps->pcm.log2_max_pcm_cb_size) {
2248 if (
s->ps.sps->pcm.loop_filter_disable_flag)
2280 hls_prediction_unit(
s, x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
2284 hls_prediction_unit(
s, x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
2288 hls_prediction_unit(
s, x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
2289 hls_prediction_unit(
s, x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
2290 hls_prediction_unit(
s, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
2296 int rqt_root_cbf = 1;
2303 const static int cbf[2] = { 0 };
2306 s->ps.sps->max_transform_hierarchy_depth_inter;
2309 log2_cb_size, 0, 0, cbf, cbf);
2313 if (!
s->sh.disable_deblocking_filter_flag)
2322 x = y_cb * min_cb_width + x_cb;
2323 for (y = 0; y < length; y++) {
2324 memset(&
s->qp_y_tab[x], lc->
qp_y, length);
2328 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2329 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0) {
2339 int log2_cb_size,
int cb_depth)
2342 const int cb_size = 1 << log2_cb_size;
2347 if (x0 + cb_size <= s->ps.sps->width &&
2348 y0 + cb_size <= s->ps.sps->height &&
2349 log2_cb_size >
s->ps.sps->log2_min_cb_size) {
2352 split_cu = (log2_cb_size >
s->ps.sps->log2_min_cb_size);
2354 if (
s->ps.pps->cu_qp_delta_enabled_flag &&
2355 log2_cb_size >=
s->ps.sps->log2_ctb_size -
s->ps.pps->diff_cu_qp_delta_depth) {
2360 if (
s->sh.cu_chroma_qp_offset_enabled_flag &&
2361 log2_cb_size >=
s->ps.sps->log2_ctb_size -
s->ps.pps->diff_cu_chroma_qp_offset_depth) {
2366 int qp_block_mask = (1<<(
s->ps.sps->log2_ctb_size -
s->ps.pps->diff_cu_qp_delta_depth)) - 1;
2367 const int cb_size_split = cb_size >> 1;
2368 const int x1 = x0 + cb_size_split;
2369 const int y1 = y0 + cb_size_split;
2377 if (more_data && x1 < s->ps.sps->width) {
2382 if (more_data && y1 < s->ps.sps->height) {
2387 if (more_data && x1 < s->ps.sps->width &&
2388 y1 < s->ps.sps->height) {
2394 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2395 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0)
2399 return ((x1 + cb_size_split) <
s->ps.sps->width ||
2400 (y1 + cb_size_split) <
s->ps.sps->height);
2407 if ((!((x0 + cb_size) %
2408 (1 << (
s->ps.sps->log2_ctb_size))) ||
2409 (x0 + cb_size >=
s->ps.sps->width)) &&
2411 (1 << (
s->ps.sps->log2_ctb_size))) ||
2412 (y0 + cb_size >=
s->ps.sps->height))) {
2414 return !end_of_slice_flag;
2427 int ctb_size = 1 <<
s->ps.sps->log2_ctb_size;
2428 int ctb_addr_rs =
s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2429 int ctb_addr_in_slice = ctb_addr_rs -
s->sh.slice_addr;
2431 s->tab_slice_address[ctb_addr_rs] =
s->sh.slice_addr;
2433 if (
s->ps.pps->entropy_coding_sync_enabled_flag) {
2434 if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
2437 }
else if (
s->ps.pps->tiles_enabled_flag) {
2438 if (ctb_addr_ts &&
s->ps.pps->tile_id[ctb_addr_ts] !=
s->ps.pps->tile_id[ctb_addr_ts - 1]) {
2439 int idxX =
s->ps.pps->col_idxX[x_ctb >>
s->ps.sps->log2_ctb_size];
2440 lc->
end_of_tiles_x = x_ctb + (
s->ps.pps->column_width[idxX] <<
s->ps.sps->log2_ctb_size);
2450 if (
s->ps.pps->tiles_enabled_flag) {
2451 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]])
2453 if (x_ctb > 0 &&
s->tab_slice_address[ctb_addr_rs] !=
s->tab_slice_address[ctb_addr_rs - 1])
2455 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]])
2457 if (y_ctb > 0 &&
s->tab_slice_address[ctb_addr_rs] !=
s->tab_slice_address[ctb_addr_rs -
s->ps.sps->ctb_width])
2460 if (ctb_addr_in_slice <= 0)
2462 if (ctb_addr_in_slice < s->ps.sps->ctb_width)
2468 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]]));
2469 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]]));
2475 int ctb_size = 1 <<
s->ps.sps->log2_ctb_size;
2479 int ctb_addr_ts =
s->ps.pps->ctb_addr_rs_to_ts[
s->sh.slice_ctb_addr_rs];
2482 if (!ctb_addr_ts &&
s->sh.dependent_slice_segment_flag) {
2487 if (
s->sh.dependent_slice_segment_flag) {
2488 int prev_rs =
s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
2489 if (
s->tab_slice_address[prev_rs] !=
s->sh.slice_addr) {
2495 while (more_data && ctb_addr_ts < s->ps.sps->ctb_size) {
2496 int ctb_addr_rs =
s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2498 x_ctb = (ctb_addr_rs % ((
s->ps.sps->width + ctb_size - 1) >>
s->ps.sps->log2_ctb_size)) <<
s->ps.sps->log2_ctb_size;
2499 y_ctb = (ctb_addr_rs / ((
s->ps.sps->width + ctb_size - 1) >>
s->ps.sps->log2_ctb_size)) <<
s->ps.sps->log2_ctb_size;
2504 s->tab_slice_address[ctb_addr_rs] = -1;
2508 hls_sao_param(
s, x_ctb >>
s->ps.sps->log2_ctb_size, y_ctb >>
s->ps.sps->log2_ctb_size);
2510 s->deblock[ctb_addr_rs].beta_offset =
s->sh.beta_offset;
2511 s->deblock[ctb_addr_rs].tc_offset =
s->sh.tc_offset;
2512 s->filter_slice_edges[ctb_addr_rs] =
s->sh.slice_loop_filter_across_slices_enabled_flag;
2515 if (more_data < 0) {
2516 s->tab_slice_address[ctb_addr_rs] = -1;
2526 if (x_ctb + ctb_size >=
s->ps.sps->width &&
2527 y_ctb + ctb_size >=
s->ps.sps->height)
2548 int ctb_size = 1<<
s1->ps.sps->log2_ctb_size;
2550 int *ctb_row_p = input_ctb_row;
2551 int ctb_row = ctb_row_p[job];
2552 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);
2553 int ctb_addr_ts =
s1->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs];
2554 int thread = ctb_row %
s1->threads_number;
2557 s =
s1->sList[self_id];
2567 while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) {
2568 int x_ctb = (ctb_addr_rs %
s->ps.sps->ctb_width) <<
s->ps.sps->log2_ctb_size;
2569 int y_ctb = (ctb_addr_rs /
s->ps.sps->ctb_width) <<
s->ps.sps->log2_ctb_size;
2583 hls_sao_param(
s, x_ctb >>
s->ps.sps->log2_ctb_size, y_ctb >>
s->ps.sps->log2_ctb_size);
2586 if (more_data < 0) {
2597 if (!more_data && (x_ctb+ctb_size) <
s->ps.sps->width && ctb_row !=
s->sh.num_entry_point_offsets) {
2603 if ((x_ctb+ctb_size) >=
s->ps.sps->width && (y_ctb+ctb_size) >=
s->ps.sps->height ) {
2608 ctb_addr_rs =
s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2611 if(x_ctb >=
s->ps.sps->width) {
2619 s->tab_slice_address[ctb_addr_rs] = -1;
2628 int length = nal->
size;
2633 int64_t startheader, cmpt = 0;
2642 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) {
2644 s->sh.slice_ctb_addr_rs,
s->sh.num_entry_point_offsets,
2645 s->ps.sps->ctb_width,
s->ps.sps->ctb_height
2653 for (
i = 1;
i <
s->threads_number;
i++) {
2654 if (
s->sList[
i] &&
s->HEVClcList[
i])
2660 if (!
s->sList[
i] || !
s->HEVClcList[
i]) {
2665 s->sList[
i]->HEVClc =
s->HEVClcList[
i];
2670 for (j = 0, cmpt = 0, startheader =
offset +
s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) {
2677 for (
i = 1;
i <
s->sh.num_entry_point_offsets;
i++) {
2678 offset += (
s->sh.entry_point_offset[
i - 1] - cmpt);
2679 for (j = 0, cmpt = 0, startheader =
offset
2680 +
s->sh.entry_point_offset[
i]; j < nal->skipped_bytes; j++) {
2686 s->sh.size[
i - 1] =
s->sh.entry_point_offset[
i] - cmpt;
2690 if (
s->sh.num_entry_point_offsets != 0) {
2691 offset +=
s->sh.entry_point_offset[
s->sh.num_entry_point_offsets - 1] - cmpt;
2697 s->sh.size[
s->sh.num_entry_point_offsets - 1] = length -
offset;
2698 s->sh.offset[
s->sh.num_entry_point_offsets - 1] =
offset;
2703 for (
i = 1;
i <
s->threads_number;
i++) {
2704 s->sList[
i]->HEVClc->first_qp_group = 1;
2705 s->sList[
i]->HEVClc->qp_y =
s->sList[0]->HEVClc->qp_y;
2707 s->sList[
i]->HEVClc =
s->HEVClcList[
i];
2713 for (
i = 0;
i <=
s->sh.num_entry_point_offsets;
i++) {
2718 if (
s->ps.pps->entropy_coding_sync_enabled_flag)
2721 for (
i = 0;
i <=
s->sh.num_entry_point_offsets;
i++)
2734 if (
s->sei.frame_packing.present &&
2735 s->sei.frame_packing.arrangement_type >= 3 &&
2736 s->sei.frame_packing.arrangement_type <= 5 &&
2737 s->sei.frame_packing.content_interpretation_type > 0 &&
2738 s->sei.frame_packing.content_interpretation_type < 3) {
2743 switch (
s->sei.frame_packing.arrangement_type) {
2745 if (
s->sei.frame_packing.quincunx_subsampling)
2758 if (
s->sei.frame_packing.content_interpretation_type == 2)
2761 if (
s->sei.frame_packing.arrangement_type == 5) {
2762 if (
s->sei.frame_packing.current_frame_is_frame0_flag)
2769 if (
s->sei.display_orientation.present &&
2770 (
s->sei.display_orientation.anticlockwise_rotation ||
2771 s->sei.display_orientation.hflip ||
s->sei.display_orientation.vflip)) {
2772 double angle =
s->sei.display_orientation.anticlockwise_rotation * 360 / (
double) (1 << 16);
2787 angle = -angle * (1 - 2 * !!
s->sei.display_orientation.hflip)
2788 * (1 - 2 * !!
s->sei.display_orientation.vflip);
2791 s->sei.display_orientation.hflip,
2792 s->sei.display_orientation.vflip);
2797 if (
s->sei.mastering_display.present > 0 &&
2799 s->sei.mastering_display.present--;
2801 if (
s->sei.mastering_display.present) {
2803 const int mapping[3] = {2, 0, 1};
2804 const int chroma_den = 50000;
2805 const int luma_den = 10000;
2812 for (
i = 0;
i < 3;
i++) {
2813 const int j = mapping[
i];
2819 metadata->
white_point[0].
num =
s->sei.mastering_display.white_point[0];
2821 metadata->
white_point[1].
num =
s->sei.mastering_display.white_point[1];
2833 "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f)\n",
2842 "min_luminance=%f, max_luminance=%f\n",
2847 if (
s->sei.content_light.present > 0 &&
2849 s->sei.content_light.present--;
2851 if (
s->sei.content_light.present) {
2856 metadata->
MaxCLL =
s->sei.content_light.max_content_light_level;
2857 metadata->
MaxFALL =
s->sei.content_light.max_pic_average_light_level;
2864 if (
s->sei.a53_caption.buf_ref) {
2873 for (
int i = 0;
i <
s->sei.unregistered.nb_buf_ref;
i++) {
2885 s->sei.unregistered.nb_buf_ref = 0;
2887 if (
s->sei.timecode.present) {
2891 sizeof(uint32_t) * 4);
2895 tc_sd = (uint32_t*)tcside->
data;
2896 tc_sd[0] =
s->sei.timecode.num_clock_ts;
2898 for (
int i = 0;
i < tc_sd[0];
i++) {
2899 int drop =
s->sei.timecode.cnt_dropped_flag[
i];
2900 int hh =
s->sei.timecode.hours_value[
i];
2901 int mm =
s->sei.timecode.minutes_value[
i];
2902 int ss =
s->sei.timecode.seconds_value[
i];
2903 int ff =
s->sei.timecode.n_frames[
i];
2910 s->sei.timecode.num_clock_ts = 0;
2913 if (
s->sei.film_grain_characteristics.present) {
2920 fgp->
seed =
s->ref->poc;
2932 const VUI *vui = &
sps->vui;
2968 if (
s->sei.dynamic_hdr_plus.info) {
2990 if (
s->sei.dynamic_hdr_vivid.info) {
3007 int pic_size_in_ctb = ((
s->ps.sps->width >>
s->ps.sps->log2_min_cb_size) + 1) *
3008 ((
s->ps.sps->height >>
s->ps.sps->log2_min_cb_size) + 1);
3011 memset(
s->horizontal_bs, 0,
s->bs_width *
s->bs_height);
3012 memset(
s->vertical_bs, 0,
s->bs_width *
s->bs_height);
3013 memset(
s->cbf_luma, 0,
s->ps.sps->min_tb_width *
s->ps.sps->min_tb_height);
3014 memset(
s->is_pcm, 0, (
s->ps.sps->min_pu_width + 1) * (
s->ps.sps->min_pu_height + 1));
3015 memset(
s->tab_slice_address, -1, pic_size_in_ctb *
sizeof(*
s->tab_slice_address));
3018 s->first_nal_type =
s->nal_unit_type;
3022 if (
s->ps.pps->tiles_enabled_flag)
3023 lc->
end_of_tiles_x =
s->ps.pps->column_width[0] <<
s->ps.sps->log2_ctb_size;
3037 s->ref->needs_fg =
s->sei.film_grain_characteristics.present &&
3041 if (
s->ref->needs_fg) {
3042 s->ref->frame_grain->format =
s->ref->frame->format;
3043 s->ref->frame_grain->width =
s->ref->frame->width;
3044 s->ref->frame_grain->height =
s->ref->frame->height;
3053 s->frame->pict_type = 3 -
s->sh.slice_type;
3063 if (!
s->avctx->hwaccel)
3081 if (
out->needs_fg) {
3101 int ctb_addr_ts,
ret;
3104 s->nal_unit_type = nal->
type;
3107 switch (
s->nal_unit_type) {
3109 if (
s->avctx->hwaccel &&
s->avctx->hwaccel->decode_params) {
3110 ret =
s->avctx->hwaccel->decode_params(
s->avctx,
3122 if (
s->avctx->hwaccel &&
s->avctx->hwaccel->decode_params) {
3123 ret =
s->avctx->hwaccel->decode_params(
s->avctx,
3131 s->apply_defdispwin);
3136 if (
s->avctx->hwaccel &&
s->avctx->hwaccel->decode_params) {
3137 ret =
s->avctx->hwaccel->decode_params(
s->avctx,
3150 if (
s->avctx->hwaccel &&
s->avctx->hwaccel->decode_params) {
3151 ret =
s->avctx->hwaccel->decode_params(
s->avctx,
3194 if (
s->sh.first_slice_in_pic_flag) {
3195 if (
s->max_ra == INT_MAX) {
3200 s->max_ra = INT_MIN;
3205 s->poc <=
s->max_ra) {
3210 s->max_ra = INT_MIN;
3217 }
else if (!
s->ref) {
3222 if (
s->nal_unit_type !=
s->first_nal_type) {
3224 "Non-matching NAL types of the VCL NALUs: %d %d\n",
3225 s->first_nal_type,
s->nal_unit_type);
3229 if (!
s->sh.dependent_slice_segment_flag &&
3234 "Error constructing the reference lists for the current slice.\n");
3239 if (
s->sh.first_slice_in_pic_flag &&
s->avctx->hwaccel) {
3240 ret =
s->avctx->hwaccel->start_frame(
s->avctx,
NULL, 0);
3245 if (
s->avctx->hwaccel) {
3250 if (
s->threads_number > 1 &&
s->sh.num_entry_point_offsets > 0)
3254 if (ctb_addr_ts >= (
s->ps.sps->ctb_width *
s->ps.sps->ctb_height)) {
3261 if (ctb_addr_ts < 0) {
3269 s->seq_decode = (
s->seq_decode + 1) & 0xff;
3270 s->max_ra = INT_MAX;
3278 "Skipping NAL unit %d\n",
s->nal_unit_type);
3291 int eos_at_start = 1;
3294 s->last_eos =
s->eos;
3301 s->nal_length_size,
s->avctx->codec_id, 1, 0);
3304 "Error splitting the input into NAL units.\n");
3308 for (
i = 0;
i <
s->pkt.nb_nals;
i++) {
3330 s->pkt.nals[
s->pkt.nb_nals - 1].size > 2 && !
s->pkt.nals[
s->pkt.nb_nals - 1].nuh_layer_id
3331 && !
s->pkt.nals[
s->pkt.nb_nals - 1].temporal_id) {
3332 H2645NAL *nal = &
s->pkt.nals[
s->pkt.nb_nals - 1];
3335 av_log(
s->avctx,
AV_LOG_WARNING,
"Multiple Dolby Vision RPUs found in one AU. Skipping previous.\n");
3352 for (
i = 0;
i <
s->pkt.nb_nals;
i++) {
3361 if (
ret >= 0 &&
s->overlap > 2)
3365 "Error parsing NAL unit #%d.\n",
i);
3380 for (
i = 0;
i < 16;
i++)
3393 pixel_shift =
desc->comp[0].depth > 8;
3401 if (pixel_shift && !
s->checksum_buf) {
3404 frame->linesize[2]));
3405 if (!
s->checksum_buf)
3411 int width =
s->avctx->coded_width;
3412 int height =
s->avctx->coded_height;
3418 for (j = 0; j <
h; j++) {
3422 s->bdsp.bswap16_buf((uint16_t *)
s->checksum_buf,
3423 (
const uint16_t *)
src,
w);
3424 src =
s->checksum_buf;
3431 if (!memcmp(
md5,
s->sei.picture_hash.md5[
i], 16)) {
3455 &
s->nal_length_size,
s->avctx->err_recognition,
3456 s->apply_defdispwin,
s->avctx);
3462 if (
first &&
s->ps.sps_list[
i]) {
3495 if (sd && sd_size > 0) {
3502 if (sd && sd_size > 0)
3513 "hardware accelerator failed to decode picture\n");
3520 s->sei.picture_hash.is_md5) {
3528 s->sei.picture_hash.is_md5 = 0;
3530 if (
s->is_decoded) {
3535 if (
s->output_frame->buf[0]) {
3551 if (
src->needs_fg) {
3577 if (
src->hwaccel_picture_private) {
3604 for (
i = 0;
i < 3;
i++) {
3622 if (
s->HEVClcList &&
s->sList) {
3623 for (
i = 1;
i <
s->threads_number;
i++) {
3649 if (!
s->HEVClc || !
s->HEVClcList || !
s->sList)
3651 s->HEVClcList[0] =
s->HEVClc;
3655 if (!
s->cabac_state)
3659 if (!
s->output_frame)
3664 if (!
s->DPB[
i].frame)
3666 s->DPB[
i].tf.f =
s->DPB[
i].frame;
3669 if (!
s->DPB[
i].frame_grain)
3673 s->max_ra = INT_MAX;
3681 s->dovi_ctx.logctx = avctx;
3699 if (
s0->DPB[
i].frame->buf[0]) {
3706 if (
s->ps.sps !=
s0->ps.sps)
3726 if (
s->ps.sps !=
s0->ps.sps)
3730 s->seq_decode =
s0->seq_decode;
3731 s->seq_output =
s0->seq_output;
3732 s->pocTid0 =
s0->pocTid0;
3733 s->max_ra =
s0->max_ra;
3735 s->no_rasl_output_flag =
s0->no_rasl_output_flag;
3737 s->is_nalff =
s0->is_nalff;
3738 s->nal_length_size =
s0->nal_length_size;
3740 s->threads_number =
s0->threads_number;
3741 s->threads_type =
s0->threads_type;
3744 s->seq_decode = (
s->seq_decode + 1) & 0xff;
3745 s->max_ra = INT_MAX;
3752 for (
i = 0;
i <
s->sei.unregistered.nb_buf_ref;
i++)
3754 s->sei.unregistered.nb_buf_ref = 0;
3756 if (
s0->sei.unregistered.nb_buf_ref) {
3758 s0->sei.unregistered.nb_buf_ref,
3759 sizeof(*
s->sei.unregistered.buf_ref));
3763 for (
i = 0;
i <
s0->sei.unregistered.nb_buf_ref;
i++) {
3765 if (!
s->sei.unregistered.buf_ref[
i])
3767 s->sei.unregistered.nb_buf_ref++;
3787 s->sei.frame_packing =
s0->sei.frame_packing;
3788 s->sei.display_orientation =
s0->sei.display_orientation;
3789 s->sei.mastering_display =
s0->sei.mastering_display;
3790 s->sei.content_light =
s0->sei.content_light;
3791 s->sei.alternative_transfer =
s0->sei.alternative_transfer;
3812 s->threads_number = 1;
3823 s->enable_parallel_tiles = 0;
3824 s->sei.picture_timing.picture_struct = 0;
3848 s->max_ra = INT_MAX;
3852 #define OFFSET(x) offsetof(HEVCContext, x)
3853 #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
3856 {
"apply_defdispwin",
"Apply default display window from VUI",
OFFSET(apply_defdispwin),
3858 {
"strict-displaywin",
"stricly apply default display window size",
OFFSET(apply_defdispwin),
3888 #if CONFIG_HEVC_DXVA2_HWACCEL
3891 #if CONFIG_HEVC_D3D11VA_HWACCEL
3894 #if CONFIG_HEVC_D3D11VA2_HWACCEL
3897 #if CONFIG_HEVC_NVDEC_HWACCEL
3900 #if CONFIG_HEVC_VAAPI_HWACCEL
3903 #if CONFIG_HEVC_VDPAU_HWACCEL
3906 #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL