26#include "config_components.h"
62static 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 };
93 for (
int i = 0;
i < 3;
i++) {
105 int log2_min_cb_size =
sps->log2_min_cb_size;
108 int pic_size_in_ctb = ((
width >> log2_min_cb_size) + 1) *
109 ((
height >> log2_min_cb_size) + 1);
110 int ctb_count =
sps->ctb_width *
sps->ctb_height;
111 int min_pu_size =
sps->min_pu_width *
sps->min_pu_height;
150 if (
sps->sao_enabled) {
151 int c_count = (
sps->chroma_format_idc != 0) ? 3 : 1;
153 for (
int c_idx = 0; c_idx < c_count; c_idx++) {
154 int w =
sps->width >>
sps->hshift[c_idx];
155 int h =
sps->height >>
sps->vshift[c_idx];
180 int luma_log2_weight_denom;
181 unsigned luma_weight_flags, chroma_weight_flags;
184 if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) {
185 av_log(logctx,
AV_LOG_ERROR,
"luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom);
189 if (
sps->chroma_format_idc != 0) {
191 if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) {
192 av_log(logctx,
AV_LOG_ERROR,
"chroma_log2_weight_denom %"PRId64
" is invalid\n", chroma_log2_weight_denom);
201 unsigned flag_bit = 1 << (sh->
nb_refs[
L0] - 1 -
i);
203 if (luma_weight_flags & flag_bit) {
205 if ((int8_t)delta_luma_weight_l0 != delta_luma_weight_l0)
213 if (chroma_weight_flags & flag_bit) {
214 for (j = 0; j < 2; j++) {
218 if ( (int8_t)delta_chroma_weight_l0 != delta_chroma_weight_l0
219 || delta_chroma_offset_l0 < -(1<<17) || delta_chroma_offset_l0 > (1<<17)) {
238 unsigned flag_bit = 1 << (sh->
nb_refs[
L1] - 1 -
i);
240 if (luma_weight_flags & flag_bit) {
242 if ((int8_t)delta_luma_weight_l1 != delta_luma_weight_l1)
250 if (chroma_weight_flags & flag_bit) {
251 for (j = 0; j < 2; j++) {
255 if ( (int8_t)delta_chroma_weight_l1 != delta_chroma_weight_l1
256 || delta_chroma_offset_l1 < -(1<<17) || delta_chroma_offset_l1 > (1<<17)) {
278 int max_poc_lsb = 1 <<
sps->log2_max_poc_lsb;
279 int prev_delta_msb = 0;
280 unsigned int nb_sps = 0, nb_sh;
284 if (!
sps->long_term_ref_pics_present)
287 if (
sps->num_long_term_ref_pics_sps > 0)
291 if (nb_sps >
sps->num_long_term_ref_pics_sps)
301 uint8_t lt_idx_sps = 0;
303 if (
sps->num_long_term_ref_pics_sps > 1)
306 rps->
poc[
i] =
sps->lt_ref_pic_poc_lsb_sps[lt_idx_sps];
307 rps->
used[
i] = !!(
sps->used_by_curr_pic_lt & (1U << lt_idx_sps));
318 if (
i &&
i != nb_sps)
319 delta += prev_delta_msb;
321 poc = rps->
poc[
i] + cur_poc -
delta * max_poc_lsb - poc_lsb;
325 prev_delta_msb =
delta;
337 unsigned int num = 0, den = 0;
345 avctx->
profile =
sps->ptl.general_ptl.profile_idc;
346 avctx->
level =
sps->ptl.general_ptl.level_idc;
350 if (
sps->vui.common.video_signal_type_present_flag)
356 if (
sps->vui.common.colour_description_present_flag) {
358 avctx->
color_trc =
sps->vui.common.transfer_characteristics;
367 if (
sps->chroma_format_idc == 1) {
368 if (
sps->vui.common.chroma_loc_info_present_flag) {
369 if (
sps->vui.common.chroma_sample_loc_type_top_field <= 5)
375 if (
vps->vps_timing_info_present_flag) {
376 num =
vps->vps_num_units_in_tick;
377 den =
vps->vps_time_scale;
378 }
else if (
sps->vui.vui_timing_info_present_flag) {
379 num =
sps->vui.vui_num_units_in_tick;
380 den =
sps->vui.vui_time_scale;
383 if (num > 0 && den > 0)
392 if (
s->sei.common.alternative_transfer.present &&
395 avctx->
color_trc =
s->sei.common.alternative_transfer.preferred_transfer_characteristics;
406 s->nb_view_ids_available = 0;
408 s->nb_view_pos_available = 0;
411 if (
vps->nb_layers < 2 && !
vps->view_id[0])
414 s->view_ids_available =
av_calloc(
vps->nb_layers,
sizeof(*
s->view_ids_available));
415 if (!
s->view_ids_available)
419 s->view_pos_available =
av_calloc(
vps->nb_layers,
sizeof(*
s->view_pos_available));
420 if (!
s->view_pos_available)
424 for (
int i = 0;
i <
vps->nb_layers;
i++) {
425 s->view_ids_available[
i] =
vps->view_id[
i];
427 if (
s->view_pos_available) {
434 s->nb_view_ids_available =
vps->nb_layers;
435 s->nb_view_pos_available =
s->view_pos_available ?
vps->nb_layers : 0;
445 if (
vps->nb_layers != 2 || !
vps->layer_id_in_nuh[1])
461 unsigned layers_active_output = 0, highest_layer;
463 s->layers_active_output = 1;
464 s->layers_active_decode = 1;
472 s->layers_active_decode = (1 <<
vps->nb_layers) - 1;
473 s->layers_active_output = 1;
482 if (
s->nb_view_ids == 1 &&
s->view_ids[0] == -1) {
483 layers_active_output = (1 <<
vps->nb_layers) - 1;
485 for (
int i = 0;
i <
s->nb_view_ids;
i++) {
486 int view_id =
s->view_ids[
i];
491 "Invalid view ID requested: %d\n", view_id);
495 for (
int j = 0; j <
vps->nb_layers; j++) {
496 if (
vps->view_id[j] == view_id) {
503 "View ID %d not present in VPS\n", view_id);
506 layers_active_output |= 1 << layer_idx;
510 if (!layers_active_output) {
515 highest_layer =
ff_log2(layers_active_output);
518 "Too many layers requested: %u\n", layers_active_output);
526 s->layers_active_decode = (1 << (highest_layer + 1)) - 1;
527 s->layers_active_output = layers_active_output;
530 s->layers_active_decode,
s->layers_active_output);
565#define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + \
566 CONFIG_HEVC_D3D11VA_HWACCEL * 2 + \
567 CONFIG_HEVC_D3D12VA_HWACCEL + \
568 CONFIG_HEVC_NVDEC_HWACCEL + \
569 CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL + \
570 CONFIG_HEVC_VAAPI_HWACCEL + \
571 CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL + \
572 CONFIG_HEVC_VDPAU_HWACCEL + \
573 CONFIG_HEVC_VULKAN_HWACCEL)
581 switch (
sps->pix_fmt) {
584#if CONFIG_HEVC_DXVA2_HWACCEL
587#if CONFIG_HEVC_D3D11VA_HWACCEL
591#if CONFIG_HEVC_D3D12VA_HWACCEL
594#if CONFIG_HEVC_VAAPI_HWACCEL
597#if CONFIG_HEVC_VDPAU_HWACCEL
600#if CONFIG_HEVC_NVDEC_HWACCEL
603#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
606#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
609#if CONFIG_HEVC_VULKAN_HWACCEL
614#if CONFIG_HEVC_DXVA2_HWACCEL
617#if CONFIG_HEVC_D3D11VA_HWACCEL
621#if CONFIG_HEVC_D3D12VA_HWACCEL
624#if CONFIG_HEVC_VAAPI_HWACCEL
627#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
630#if CONFIG_HEVC_VULKAN_HWACCEL
633#if CONFIG_HEVC_VDPAU_HWACCEL
636#if CONFIG_HEVC_NVDEC_HWACCEL
639#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
644#if CONFIG_HEVC_VAAPI_HWACCEL
647#if CONFIG_HEVC_VDPAU_HWACCEL
650#if CONFIG_HEVC_NVDEC_HWACCEL
653#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
656#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
659#if CONFIG_HEVC_VULKAN_HWACCEL
665#if CONFIG_HEVC_VAAPI_HWACCEL
668#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
671#if CONFIG_HEVC_VULKAN_HWACCEL
674#if CONFIG_HEVC_NVDEC_HWACCEL
677#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
682#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
688#if CONFIG_HEVC_VAAPI_HWACCEL
691#if CONFIG_HEVC_VDPAU_HWACCEL
694#if CONFIG_HEVC_VULKAN_HWACCEL
697#if CONFIG_HEVC_NVDEC_HWACCEL
700#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
705#if CONFIG_HEVC_VAAPI_HWACCEL
708#if CONFIG_HEVC_VULKAN_HWACCEL
711#if CONFIG_HEVC_NVDEC_HWACCEL
714#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
722 *fmt++ =
sps->pix_fmt;
734 s->avctx->pix_fmt = ret;
779 unsigned pps_id, layer_idx;
800 pps =
s->ps.pps_list[pps_id];
803 layer_idx =
vps->layer_idx[
s->nuh_layer_id];
810 int slice_address_length;
812 if (
pps->dependent_slice_segments_enabled_flag)
824 "Invalid slice segment address: %u.\n",
837 for (
i = 0;
i <
pps->num_extra_slice_header_bits;
i++)
849 !
pps->pps_curr_pic_ref_enabled_flag &&
850 s->nuh_layer_id == 0) {
857 if (
pps->output_flag_present_flag)
860 if (
sps->separate_colour_plane)
864 (
s->nuh_layer_id > 0 &&
865 !(
vps->poc_lsb_not_present & (1 << layer_idx)))) {
872 "Ignoring POC change between slices: %d -> %d\n", poc, sh->
poc);
892 int numbits, rps_idx;
894 if (!
sps->nb_st_rps) {
900 rps_idx = numbits > 0 ?
get_bits(gb, numbits) : 0;
914 if (
sps->temporal_mvp_enabled)
930 if (
s->nuh_layer_id > 0) {
931 int num_direct_ref_layers =
vps->num_direct_ref_layers[layer_idx];
933 if (
vps->default_ref_layers_active)
935 else if (num_direct_ref_layers) {
940 "NumDirectRefLayers>1 not supported\n");
946 if (
sps->sao_enabled) {
948 if (
sps->chroma_format_idc) {
985 if (
pps->lists_modification_present_flag && nb_refs > 1) {
1003 if (
pps->cabac_init_present_flag)
1018 "Invalid collocated_ref_idx: %d.\n",
1035 "Invalid number of merging MVP candidates: %d.\n",
1041 if (
sps->motion_vector_resolution_control_idc == 2)
1051 if (
pps->pic_slice_level_chroma_qp_offsets_present_flag) {
1064 if (
pps->pps_slice_act_qp_offsets_present_flag) {
1070 if (
pps->chroma_qp_offset_list_enabled_flag)
1075 if (
pps->deblocking_filter_control_present_flag) {
1076 int deblocking_filter_override_flag = 0;
1078 if (
pps->deblocking_filter_override_enabled_flag)
1079 deblocking_filter_override_flag =
get_bits1(gb);
1081 if (deblocking_filter_override_flag) {
1086 if (beta_offset_div2 < -6 || beta_offset_div2 > 6 ||
1087 tc_offset_div2 < -6 || tc_offset_div2 > 6) {
1089 "Invalid deblock filter offsets: %d, %d\n",
1090 beta_offset_div2, tc_offset_div2);
1107 if (
pps->seq_loop_filter_across_slices_enabled_flag &&
1118 if (
pps->tiles_enabled_flag ||
pps->entropy_coding_sync_enabled_flag) {
1121 if (num_entry_point_offsets >
get_bits_left(gb) || num_entry_point_offsets > UINT16_MAX) {
1122 av_log(
s->avctx,
AV_LOG_ERROR,
"num_entry_point_offsets %d is invalid\n", num_entry_point_offsets);
1130 if (offset_len < 1 || offset_len > 32) {
1154 if (
pps->slice_header_extension_present_flag) {
1160 for (
i = 0;
i < length;
i++)
1182 "The slice_qp %d is outside the valid range "
1185 -
sps->qp_bd_offset);
1200#define CTB(tab, x, y) ((tab)[(y) * sps->ctb_width + (x)])
1202#define SET_SAO(elem, value) \
1204 if (!sao_merge_up_flag && !sao_merge_left_flag) \
1205 sao->elem = value; \
1206 else if (sao_merge_left_flag) \
1207 sao->elem = CTB(l->sao, rx-1, ry).elem; \
1208 else if (sao_merge_up_flag) \
1209 sao->elem = CTB(l->sao, rx, ry-1).elem; \
1219 int sao_merge_left_flag = 0;
1220 int sao_merge_up_flag = 0;
1224 if (
s->sh.slice_sample_adaptive_offset_flag[0] ||
1225 s->sh.slice_sample_adaptive_offset_flag[1]) {
1230 if (ry > 0 && !sao_merge_left_flag) {
1236 for (c_idx = 0; c_idx < (
sps->chroma_format_idc ? 3 : 1); c_idx++) {
1237 int log2_sao_offset_scale = c_idx == 0 ?
pps->log2_sao_offset_scale_luma :
1238 pps->log2_sao_offset_scale_chroma;
1240 if (!
s->sh.slice_sample_adaptive_offset_flag[c_idx]) {
1255 for (
i = 0;
i < 4;
i++)
1259 for (
i = 0;
i < 4;
i++) {
1268 }
else if (c_idx != 2) {
1274 for (
i = 0;
i < 4;
i++) {
1282 sao->
offset_val[c_idx][
i + 1] *= 1 << log2_sao_offset_scale;
1294 if (log2_res_scale_abs_plus1 != 0) {
1297 (1 - 2 * res_scale_sign_flag);
1310 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1311 int log2_cb_size,
int log2_trafo_size,
1312 int blk_idx,
int cbf_luma,
int *cbf_cb,
int *cbf_cr)
1315 const int log2_trafo_size_c = log2_trafo_size -
sps->hshift[1];
1319 int trafo_size = 1 << log2_trafo_size;
1322 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, x0, y0, 0);
1325 if (cbf_luma || cbf_cb[0] || cbf_cr[0] ||
1326 (
sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
1329 int cbf_chroma = cbf_cb[0] || cbf_cr[0] ||
1330 (
sps->chroma_format_idc == 2 &&
1331 (cbf_cb[1] || cbf_cr[1]));
1343 "The cu_qp_delta %d is outside the valid range "
1346 -(26 +
sps->qp_bd_offset / 2),
1347 (25 +
sps->qp_bd_offset / 2));
1354 if (
s->sh.cu_chroma_qp_offset_enabled_flag && cbf_chroma &&
1357 if (cu_chroma_qp_offset_flag) {
1358 int cu_chroma_qp_offset_idx = 0;
1359 if (
pps->chroma_qp_offset_list_len_minus1 > 0) {
1362 "cu_chroma_qp_offset_idx not yet tested.\n");
1395 if (
sps->chroma_format_idc && (log2_trafo_size > 2 ||
sps->chroma_format_idc == 3)) {
1396 int trafo_size_h = 1 << (log2_trafo_size_c +
sps->hshift[1]);
1397 int trafo_size_v = 1 << (log2_trafo_size_c +
sps->vshift[1]);
1398 lc->
tu.
cross_pf = (
pps->cross_component_prediction_enabled_flag && cbf_luma &&
1405 for (
i = 0;
i < (
sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1408 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1409 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0 + (
i << log2_trafo_size_c), 1);
1413 log2_trafo_size_c, scan_idx_c, 1);
1416 ptrdiff_t
stride =
s->cur_frame->f->linesize[1];
1417 int hshift =
sps->hshift[1];
1418 int vshift =
sps->vshift[1];
1421 int size = 1 << log2_trafo_size_c;
1423 uint8_t *
dst = &
s->cur_frame->f->data[1][(y0 >> vshift) *
stride +
1424 ((x0 >> hshift) <<
sps->pixel_shift)];
1428 s->hevcdsp.add_residual[log2_trafo_size_c-2](
dst, coeffs,
stride);
1435 for (
i = 0;
i < (
sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1438 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1439 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0 + (
i << log2_trafo_size_c), 2);
1443 log2_trafo_size_c, scan_idx_c, 2);
1446 ptrdiff_t
stride =
s->cur_frame->f->linesize[2];
1447 int hshift =
sps->hshift[2];
1448 int vshift =
sps->vshift[2];
1451 int size = 1 << log2_trafo_size_c;
1453 uint8_t *
dst = &
s->cur_frame->f->data[2][(y0 >> vshift) *
stride +
1454 ((x0 >> hshift) <<
sps->pixel_shift)];
1458 s->hevcdsp.add_residual[log2_trafo_size_c-2](
dst, coeffs,
stride);
1461 }
else if (
sps->chroma_format_idc && blk_idx == 3) {
1462 int trafo_size_h = 1 << (log2_trafo_size + 1);
1463 int trafo_size_v = 1 << (log2_trafo_size +
sps->vshift[1]);
1464 for (
i = 0;
i < (
sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1467 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1468 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase + (
i << log2_trafo_size), 1);
1472 log2_trafo_size, scan_idx_c, 1);
1474 for (
i = 0;
i < (
sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1477 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1478 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase + (
i << log2_trafo_size), 2);
1482 log2_trafo_size, scan_idx_c, 2);
1486 if (log2_trafo_size > 2 ||
sps->chroma_format_idc == 3) {
1487 int trafo_size_h = 1 << (log2_trafo_size_c +
sps->hshift[1]);
1488 int trafo_size_v = 1 << (log2_trafo_size_c +
sps->vshift[1]);
1490 sps->log2_ctb_size);
1491 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0, 1);
1492 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0, 2);
1493 if (
sps->chroma_format_idc == 2) {
1495 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1496 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0 + (1 << log2_trafo_size_c), 1);
1497 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0 + (1 << log2_trafo_size_c), 2);
1499 }
else if (blk_idx == 3) {
1500 int trafo_size_h = 1 << (log2_trafo_size + 1);
1501 int trafo_size_v = 1 << (log2_trafo_size +
sps->vshift[1]);
1503 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1504 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase, 1);
1505 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase, 2);
1506 if (
sps->chroma_format_idc == 2) {
1508 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1509 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase + (1 << log2_trafo_size), 1);
1510 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase + (1 << log2_trafo_size), 2);
1519 int x0,
int y0,
int log2_cb_size)
1521 int cb_size = 1 << log2_cb_size;
1522 int log2_min_pu_size =
sps->log2_min_pu_size;
1524 int min_pu_width =
sps->min_pu_width;
1525 int x_end =
FFMIN(x0 + cb_size,
sps->width);
1526 int y_end =
FFMIN(y0 + cb_size,
sps->height);
1529 for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
1530 for (
i = (x0 >> log2_min_pu_size);
i < (x_end >> log2_min_pu_size);
i++)
1531 is_pcm[
i + j * min_pu_width] = 2;
1538 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1539 int log2_cb_size,
int log2_trafo_size,
1540 int trafo_depth,
int blk_idx,
1541 const int *base_cbf_cb,
const int *base_cbf_cr)
1544 uint8_t split_transform_flag;
1549 cbf_cb[0] = base_cbf_cb[0];
1550 cbf_cb[1] = base_cbf_cb[1];
1551 cbf_cr[0] = base_cbf_cr[0];
1552 cbf_cr[1] = base_cbf_cr[1];
1555 if (trafo_depth == 1) {
1557 if (
sps->chroma_format_idc == 3) {
1571 if (log2_trafo_size <= sps->log2_max_trafo_size &&
1572 log2_trafo_size >
sps->log2_min_tb_size &&
1573 trafo_depth < lc->cu.max_trafo_depth &&
1577 int inter_split =
sps->max_transform_hierarchy_depth_inter == 0 &&
1582 split_transform_flag = log2_trafo_size >
sps->log2_max_trafo_size ||
1587 if (
sps->chroma_format_idc && (log2_trafo_size > 2 ||
sps->chroma_format_idc == 3)) {
1588 if (trafo_depth == 0 || cbf_cb[0]) {
1590 if (
sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
1595 if (trafo_depth == 0 || cbf_cr[0]) {
1597 if (
sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
1603 if (split_transform_flag) {
1604 const int trafo_size_split = 1 << (log2_trafo_size - 1);
1605 const int x1 = x0 + trafo_size_split;
1606 const int y1 = y0 + trafo_size_split;
1608#define SUBDIVIDE(x, y, idx) \
1610 ret = hls_transform_tree(lc, l, pps, sps, \
1611 x, y, x0, y0, cb_xBase, cb_yBase, log2_cb_size, \
1612 log2_trafo_size - 1, trafo_depth + 1, idx, \
1625 int min_tu_size = 1 <<
sps->log2_min_tb_size;
1626 int log2_min_tu_size =
sps->log2_min_tb_size;
1627 int min_tu_width =
sps->min_tb_width;
1631 cbf_cb[0] || cbf_cr[0] ||
1632 (
sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
1637 x0, y0, xBase, yBase, cb_xBase, cb_yBase,
1638 log2_cb_size, log2_trafo_size,
1639 blk_idx, cbf_luma, cbf_cb, cbf_cr);
1645 for (
i = 0;
i < (1 << log2_trafo_size);
i += min_tu_size)
1646 for (j = 0; j < (1 << log2_trafo_size); j += min_tu_size) {
1647 int x_tu = (x0 + j) >> log2_min_tu_size;
1648 int y_tu = (y0 +
i) >> log2_min_tu_size;
1649 l->
cbf_luma[y_tu * min_tu_width + x_tu] = 1;
1652 if (!
s->sh.disable_deblocking_filter_flag) {
1654 if (
pps->transquant_bypass_enable_flag &&
1663 const HEVCPPS *
pps,
int x0,
int y0,
int log2_cb_size)
1668 int cb_size = 1 << log2_cb_size;
1669 ptrdiff_t stride0 =
s->cur_frame->f->linesize[0];
1670 uint8_t *dst0 = &
s->cur_frame->f->data[0][y0 * stride0 + (x0 <<
sps->pixel_shift)];
1672 int length = cb_size * cb_size *
sps->pcm.bit_depth + (
sps->chroma_format_idc != 0 ?
1673 (((cb_size >>
sps->hshift[1]) * (cb_size >>
sps->vshift[1])) +
1674 ((cb_size >>
sps->hshift[2]) * (cb_size >>
sps->vshift[2]))) *
1675 sps->pcm.bit_depth_chroma : 0);
1676 const uint8_t *pcm =
skip_bytes(&lc->
cc, (length + 7) >> 3);
1679 if (!
s->sh.disable_deblocking_filter_flag)
1686 s->hevcdsp.put_pcm(dst0, stride0, cb_size, cb_size, &gb,
sps->pcm.bit_depth);
1687 if (
sps->chroma_format_idc) {
1688 ptrdiff_t stride1 =
s->cur_frame->f->linesize[1];
1689 ptrdiff_t stride2 =
s->cur_frame->f->linesize[2];
1690 uint8_t *dst1 = &
s->cur_frame->f->data[1][(y0 >>
sps->vshift[1]) * stride1 + ((x0 >>
sps->hshift[1]) <<
sps->pixel_shift)];
1691 uint8_t *dst2 = &
s->cur_frame->f->data[2][(y0 >>
sps->vshift[2]) * stride2 + ((x0 >>
sps->hshift[2]) <<
sps->pixel_shift)];
1693 s->hevcdsp.put_pcm(dst1, stride1,
1694 cb_size >>
sps->hshift[1],
1695 cb_size >>
sps->vshift[1],
1696 &gb,
sps->pcm.bit_depth_chroma);
1697 s->hevcdsp.put_pcm(dst2, stride2,
1698 cb_size >>
sps->hshift[2],
1699 cb_size >>
sps->vshift[2],
1700 &gb,
sps->pcm.bit_depth_chroma);
1724 uint8_t *
dst, ptrdiff_t dststride,
1726 int block_w,
int block_h,
int luma_weight,
int luma_offset)
1729 const uint8_t *
src =
ref->data[0];
1731 int pic_width =
sps->width;
1732 int pic_height =
sps->height;
1735 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
pps->weighted_pred_flag) ||
1739 x_off +=
mv->x >> 2;
1740 y_off +=
mv->y >> 2;
1746 ref ==
s->cur_frame->f) {
1756 pic_width, pic_height);
1763 block_h,
mx,
my, block_w);
1766 block_h,
s->sh.luma_log2_weight_denom,
1767 luma_weight, luma_offset,
mx,
my, block_w);
1788 uint8_t *
dst, ptrdiff_t dststride,
1789 const AVFrame *ref0,
const Mv *mv0,
int x_off,
int y_off,
1790 int block_w,
int block_h,
const AVFrame *ref1,
1791 const Mv *mv1,
struct MvField *current_mv)
1794 ptrdiff_t src0stride = ref0->
linesize[0];
1795 ptrdiff_t src1stride = ref1->
linesize[0];
1796 int pic_width =
sps->width;
1797 int pic_height =
sps->height;
1798 int mx0 = mv0->
x & 3;
1799 int my0 = mv0->
y & 3;
1800 int mx1 = mv1->
x & 3;
1801 int my1 = mv1->
y & 3;
1802 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
pps->weighted_pred_flag) ||
1804 int x_off0 = x_off + (mv0->
x >> 2);
1805 int y_off0 = y_off + (mv0->
y >> 2);
1806 int x_off1 = x_off + (mv1->
x >> 2);
1807 int y_off1 = y_off + (mv1->
y >> 2);
1810 const uint8_t *
src0 = ref0->
data[0] + y_off0 * src0stride + (int)((
unsigned)x_off0 <<
sps->pixel_shift);
1811 const uint8_t *
src1 = ref1->
data[0] + y_off1 * src1stride + (int)((
unsigned)x_off1 <<
sps->pixel_shift);
1821 edge_emu_stride, src0stride,
1825 pic_width, pic_height);
1827 src0stride = edge_emu_stride;
1838 edge_emu_stride, src1stride,
1842 pic_width, pic_height);
1844 src1stride = edge_emu_stride;
1847 s->hevcdsp.put_hevc_qpel[idx][!!my0][!!mx0](lc->
tmp,
src0, src0stride,
1848 block_h, mx0, my0, block_w);
1850 s->hevcdsp.put_hevc_qpel_bi[idx][!!my1][!!mx1](
dst, dststride,
src1, src1stride, lc->
tmp,
1851 block_h, mx1, my1, block_w);
1853 s->hevcdsp.put_hevc_qpel_bi_w[idx][!!my1][!!mx1](
dst, dststride,
src1, src1stride, lc->
tmp,
1854 block_h,
s->sh.luma_log2_weight_denom,
1855 s->sh.luma_weight_l0[current_mv->
ref_idx[0]],
1856 s->sh.luma_weight_l1[current_mv->
ref_idx[1]],
1857 s->sh.luma_offset_l0[current_mv->
ref_idx[0]] +
1858 s->sh.luma_offset_l1[current_mv->
ref_idx[1]],
1883 ptrdiff_t dststride,
const uint8_t *
src0, ptrdiff_t
srcstride,
int reflist,
1884 int x_off,
int y_off,
int block_w,
int block_h,
1885 const struct MvField *current_mv,
int chroma_weight,
int chroma_offset)
1888 int pic_width =
sps->width >>
sps->hshift[1];
1889 int pic_height =
sps->height >>
sps->vshift[1];
1890 const Mv *
mv = ¤t_mv->
mv[reflist];
1891 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
pps->weighted_pred_flag) ||
1894 int hshift =
sps->hshift[1];
1895 int vshift =
sps->vshift[1];
1898 intptr_t _mx =
mx << (1 - hshift);
1899 intptr_t _my =
my << (1 - vshift);
1900 int emu =
src0 ==
s->cur_frame->f->data[1] ||
src0 ==
s->cur_frame->f->data[2];
1902 x_off +=
mv->x >> (2 + hshift);
1903 y_off +=
mv->y >> (2 + vshift);
1913 (edge_emu_stride + (1 <<
sps->pixel_shift));
1919 pic_width, pic_height);
1926 block_h, _mx, _my, block_w);
1929 block_h,
s->sh.chroma_log2_weight_denom,
1930 chroma_weight, chroma_offset, _mx, _my, block_w);
1952 uint8_t *dst0, ptrdiff_t dststride,
1954 int x_off,
int y_off,
int block_w,
int block_h,
const MvField *current_mv,
int cidx)
1957 const uint8_t *
src1 = ref0->
data[cidx+1];
1958 const uint8_t *
src2 = ref1->
data[cidx+1];
1959 ptrdiff_t src1stride = ref0->
linesize[cidx+1];
1960 ptrdiff_t src2stride = ref1->
linesize[cidx+1];
1961 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
pps->weighted_pred_flag) ||
1963 int pic_width =
sps->width >>
sps->hshift[1];
1964 int pic_height =
sps->height >>
sps->vshift[1];
1965 const Mv *
const mv0 = ¤t_mv->
mv[0];
1966 const Mv *
const mv1 = ¤t_mv->
mv[1];
1967 int hshift =
sps->hshift[1];
1968 int vshift =
sps->vshift[1];
1974 intptr_t _mx0 = mx0 << (1 - hshift);
1975 intptr_t _my0 = my0 << (1 - vshift);
1976 intptr_t _mx1 = mx1 << (1 - hshift);
1977 intptr_t _my1 = my1 << (1 - vshift);
1979 int x_off0 = x_off + (mv0->
x >> (2 + hshift));
1980 int y_off0 = y_off + (mv0->
y >> (2 + vshift));
1981 int x_off1 = x_off + (mv1->
x >> (2 + hshift));
1982 int y_off1 = y_off + (mv1->
y >> (2 + vshift));
1984 src1 += y_off0 * src1stride + (int)((
unsigned)x_off0 <<
sps->pixel_shift);
1985 src2 += y_off1 * src2stride + (int)((
unsigned)x_off1 <<
sps->pixel_shift);
1993 (edge_emu_stride + (1 <<
sps->pixel_shift));
1996 edge_emu_stride, src1stride,
2000 pic_width, pic_height);
2003 src1stride = edge_emu_stride;
2012 (edge_emu_stride + (1 <<
sps->pixel_shift));
2015 edge_emu_stride, src2stride,
2019 pic_width, pic_height);
2022 src2stride = edge_emu_stride;
2025 s->hevcdsp.put_hevc_epel[idx][!!my0][!!mx0](lc->
tmp,
src1, src1stride,
2026 block_h, _mx0, _my0, block_w);
2028 s->hevcdsp.put_hevc_epel_bi[idx][!!my1][!!mx1](dst0,
s->cur_frame->f->linesize[cidx+1],
2030 block_h, _mx1, _my1, block_w);
2032 s->hevcdsp.put_hevc_epel_bi_w[idx][!!my1][!!mx1](dst0,
s->cur_frame->f->linesize[cidx+1],
2035 s->sh.chroma_log2_weight_denom,
2036 s->sh.chroma_weight_l0[current_mv->
ref_idx[0]][cidx],
2037 s->sh.chroma_weight_l1[current_mv->
ref_idx[1]][cidx],
2038 s->sh.chroma_offset_l0[current_mv->
ref_idx[0]][cidx] +
2039 s->sh.chroma_offset_l1[current_mv->
ref_idx[1]][cidx],
2040 _mx1, _my1, block_w);
2055 int x0,
int y0,
int nPbW,
2056 int nPbH,
int log2_cb_size,
int part_idx,
2068 if (inter_pred_idc !=
PRED_L1) {
2069 if (
s->sh.nb_refs[
L0])
2076 part_idx, merge_idx,
mv, mvp_flag, 0);
2081 if (inter_pred_idc !=
PRED_L0) {
2082 if (
s->sh.nb_refs[
L1])
2085 if (
s->sh.mvd_l1_zero_flag == 1 && inter_pred_idc ==
PRED_BI) {
2094 part_idx, merge_idx,
mv, mvp_flag, 1);
2103 int x0,
int y0,
int nPbW,
int nPbH,
2104 int log2_cb_size,
int partIdx,
int idx)
2106#define POS(c_idx, x, y) \
2107 s->cur_frame->f->data[c_idx] ? \
2108 &s->cur_frame->f->data[c_idx][((y) >> sps->vshift[c_idx]) * linesize[c_idx] + \
2109 (((x) >> sps->hshift[c_idx]) << sps->pixel_shift)] : NULL
2112 struct MvField current_mv = {{{ 0 }}};
2114 int min_pu_width =
sps->min_pu_width;
2116 MvField *tab_mvf =
s->cur_frame->tab_mvf;
2117 const RefPicList *refPicList =
s->cur_frame->refPicList;
2119 const int *linesize =
s->cur_frame->f->linesize;
2120 uint8_t *dst0 =
s->cur_frame->f->data[0] + y0 * linesize[0] + (x0 <<
sps->pixel_shift);
2121 uint8_t *dst1 =
POS(1, x0, y0);
2122 uint8_t *dst2 =
POS(2, x0, y0);
2123 int log2_min_cb_size =
sps->log2_min_cb_size;
2124 int min_cb_width =
sps->min_cb_width;
2125 int x_cb = x0 >> log2_min_cb_size;
2126 int y_cb = y0 >> log2_min_cb_size;
2136 if (
s->sh.max_num_merge_cand > 1)
2142 partIdx, merge_idx, ¤t_mv);
2145 partIdx, merge_idx, ¤t_mv);
2148 x_pu = x0 >>
sps->log2_min_pu_size;
2149 y_pu = y0 >>
sps->log2_min_pu_size;
2151 for (j = 0; j < nPbH >>
sps->log2_min_pu_size; j++)
2153 tab_mvf[(y_pu + j) * min_pu_width + x_pu +
i] = current_mv;
2156 ref0 = refPicList[0].
ref[current_mv.
ref_idx[0]];
2157 if (!ref0 || !ref0->
f)
2162 ref1 = refPicList[1].
ref[current_mv.
ref_idx[1]];
2163 if (!ref1 || !ref1->f)
2169 int x0_c = x0 >>
sps->hshift[1];
2170 int y0_c = y0 >>
sps->vshift[1];
2171 int nPbW_c = nPbW >>
sps->hshift[1];
2172 int nPbH_c = nPbH >>
sps->vshift[1];
2175 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
2176 s->sh.luma_weight_l0[current_mv.
ref_idx[0]],
2177 s->sh.luma_offset_l0[current_mv.
ref_idx[0]]);
2179 if (
sps->chroma_format_idc) {
2181 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2182 s->sh.chroma_weight_l0[current_mv.
ref_idx[0]][0],
s->sh.chroma_offset_l0[current_mv.
ref_idx[0]][0]);
2184 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2185 s->sh.chroma_weight_l0[current_mv.
ref_idx[0]][1],
s->sh.chroma_offset_l0[current_mv.
ref_idx[0]][1]);
2188 int x0_c = x0 >>
sps->hshift[1];
2189 int y0_c = y0 >>
sps->vshift[1];
2190 int nPbW_c = nPbW >>
sps->hshift[1];
2191 int nPbH_c = nPbH >>
sps->vshift[1];
2194 ¤t_mv.
mv[1], x0, y0, nPbW, nPbH,
2195 s->sh.luma_weight_l1[current_mv.
ref_idx[1]],
2196 s->sh.luma_offset_l1[current_mv.
ref_idx[1]]);
2198 if (
sps->chroma_format_idc) {
2200 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2201 s->sh.chroma_weight_l1[current_mv.
ref_idx[1]][0],
s->sh.chroma_offset_l1[current_mv.
ref_idx[1]][0]);
2204 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2205 s->sh.chroma_weight_l1[current_mv.
ref_idx[1]][1],
s->sh.chroma_offset_l1[current_mv.
ref_idx[1]][1]);
2208 int x0_c = x0 >>
sps->hshift[1];
2209 int y0_c = y0 >>
sps->vshift[1];
2210 int nPbW_c = nPbW >>
sps->hshift[1];
2211 int nPbH_c = nPbH >>
sps->vshift[1];
2214 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
2215 ref1->f, ¤t_mv.
mv[1], ¤t_mv);
2217 if (
sps->chroma_format_idc) {
2219 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0);
2222 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 1);
2232 int x0,
int y0,
int pu_size,
2233 int prev_intra_luma_pred_flag)
2236 int x_pu = x0 >>
sps->log2_min_pu_size;
2237 int y_pu = y0 >>
sps->log2_min_pu_size;
2238 int min_pu_width =
sps->min_pu_width;
2239 int size_in_pus = pu_size >>
sps->log2_min_pu_size;
2248 int y_ctb = (y0 >> (
sps->log2_ctb_size)) << (
sps->log2_ctb_size);
2250 MvField *tab_mvf =
s->cur_frame->tab_mvf;
2251 int intra_pred_mode;
2256 if ((y0 - 1) < y_ctb)
2259 if (cand_left == cand_up) {
2260 if (cand_left < 2) {
2265 candidate[0] = cand_left;
2266 candidate[1] = 2 + ((cand_left - 2 - 1 + 32) & 31);
2267 candidate[2] = 2 + ((cand_left - 2 + 1) & 31);
2270 candidate[0] = cand_left;
2271 candidate[1] = cand_up;
2281 if (prev_intra_luma_pred_flag) {
2282 intra_pred_mode = candidate[lc->
pu.
mpm_idx];
2284 if (candidate[0] > candidate[1])
2285 FFSWAP(uint8_t, candidate[0], candidate[1]);
2286 if (candidate[0] > candidate[2])
2287 FFSWAP(uint8_t, candidate[0], candidate[2]);
2288 if (candidate[1] > candidate[2])
2289 FFSWAP(uint8_t, candidate[1], candidate[2]);
2292 for (
i = 0;
i < 3;
i++)
2293 if (intra_pred_mode >= candidate[
i])
2300 for (
i = 0;
i < size_in_pus;
i++) {
2301 memset(&l->
tab_ipm[(y_pu +
i) * min_pu_width + x_pu],
2302 intra_pred_mode, size_in_pus);
2304 for (j = 0; j < size_in_pus; j++) {
2309 return intra_pred_mode;
2314 int log2_cb_size,
int ct_depth)
2316 int length = (1 << log2_cb_size) >>
sps->log2_min_cb_size;
2317 int x_cb = x0 >>
sps->log2_min_cb_size;
2318 int y_cb = y0 >>
sps->log2_min_cb_size;
2321 for (y = 0; y < length; y++)
2322 memset(&tab_ct_depth[(y_cb + y) *
sps->min_cb_width + x_cb],
2327 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20,
2328 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31};
2335 static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 };
2336 uint8_t prev_intra_luma_pred_flag[4];
2338 int pb_size = (1 << log2_cb_size) >>
split;
2339 int side =
split + 1;
2343 for (
i = 0;
i < side;
i++)
2344 for (j = 0; j < side; j++)
2347 for (
i = 0;
i < side;
i++) {
2348 for (j = 0; j < side; j++) {
2349 if (prev_intra_luma_pred_flag[2 *
i + j])
2356 x0 + pb_size * j, y0 + pb_size *
i, pb_size,
2357 prev_intra_luma_pred_flag[2 *
i + j]);
2361 if (
sps->chroma_format_idc == 3) {
2362 for (
i = 0;
i < side;
i++) {
2363 for (j = 0; j < side; j++) {
2365 if (chroma_mode != 4) {
2375 }
else if (
sps->chroma_format_idc == 2) {
2378 if (chroma_mode != 4) {
2382 mode_idx = intra_chroma_table[chroma_mode];
2387 }
else if (
sps->chroma_format_idc != 0) {
2389 if (chroma_mode != 4) {
2407 int pb_size = 1 << log2_cb_size;
2408 int size_in_pus = pb_size >>
sps->log2_min_pu_size;
2409 int min_pu_width =
sps->min_pu_width;
2410 MvField *tab_mvf =
s->cur_frame->tab_mvf;
2411 int x_pu = x0 >>
sps->log2_min_pu_size;
2412 int y_pu = y0 >>
sps->log2_min_pu_size;
2415 if (size_in_pus == 0)
2417 for (j = 0; j < size_in_pus; j++)
2418 memset(&l->
tab_ipm[(y_pu + j) * min_pu_width + x_pu],
INTRA_DC, size_in_pus);
2420 for (j = 0; j < size_in_pus; j++)
2421 for (k = 0; k < size_in_pus; k++)
2428 int x0,
int y0,
int log2_cb_size)
2430 int cb_size = 1 << log2_cb_size;
2431 int log2_min_cb_size =
sps->log2_min_cb_size;
2432 int length = cb_size >> log2_min_cb_size;
2433 int min_cb_width =
sps->min_cb_width;
2434 int x_cb = x0 >> log2_min_cb_size;
2435 int y_cb = y0 >> log2_min_cb_size;
2436 int idx = log2_cb_size - 2;
2437 int qp_block_mask = (1 << (
sps->log2_ctb_size -
pps->diff_cu_qp_delta_depth)) - 1;
2447 for (x = 0; x < 4; x++)
2449 if (
pps->transquant_bypass_enable_flag) {
2460 x0b, y0b, x_cb, y_cb,
2463 x = y_cb * min_cb_width + x_cb;
2464 for (y = 0; y < length; y++) {
2465 memset(&l->
skip_flag[x], skip_flag, length);
2470 x = y_cb * min_cb_width + x_cb;
2471 for (y = 0; y < length; y++) {
2479 x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
2482 if (!
s->sh.disable_deblocking_filter_flag)
2490 log2_cb_size ==
sps->log2_min_cb_size) {
2498 log2_cb_size >=
sps->pcm.log2_min_pcm_cb_size &&
2499 log2_cb_size <= sps->pcm.log2_max_pcm_cb_size) {
2505 if (
sps->pcm_loop_filter_disabled)
2518 x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
2522 x0, y0, cb_size, cb_size / 2, log2_cb_size, 0, idx);
2524 x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx);
2528 x0, y0, cb_size / 2, cb_size, log2_cb_size, 0, idx - 1);
2530 x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);
2534 x0, y0, cb_size, cb_size / 4, log2_cb_size, 0, idx);
2536 x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);
2540 x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0, idx);
2542 x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx);
2546 x0, y0, cb_size / 4, cb_size, log2_cb_size, 0, idx - 2);
2548 x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
2552 x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0, idx - 2);
2554 x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
2558 x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0, idx - 1);
2560 x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
2562 x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
2564 x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
2570 int rqt_root_cbf = 1;
2577 const static int cbf[2] = { 0 };
2580 sps->max_transform_hierarchy_depth_inter;
2581 ret =
hls_transform_tree(lc, l,
pps,
sps, x0, y0, x0, y0, x0, y0,
2583 log2_cb_size, 0, 0, cbf, cbf);
2587 if (!
s->sh.disable_deblocking_filter_flag)
2596 x = y_cb * min_cb_width + x_cb;
2597 for (y = 0; y < length; y++) {
2602 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2603 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0) {
2616 int log2_cb_size,
int cb_depth)
2619 const int cb_size = 1 << log2_cb_size;
2624 if (x0 + cb_size <= sps->
width &&
2625 y0 + cb_size <= sps->
height &&
2626 log2_cb_size >
sps->log2_min_cb_size) {
2628 sps, cb_depth, x0, y0);
2630 split_cu = (log2_cb_size >
sps->log2_min_cb_size);
2632 if (
pps->cu_qp_delta_enabled_flag &&
2633 log2_cb_size >=
sps->log2_ctb_size -
pps->diff_cu_qp_delta_depth) {
2638 if (
s->sh.cu_chroma_qp_offset_enabled_flag &&
2639 log2_cb_size >=
sps->log2_ctb_size -
pps->diff_cu_chroma_qp_offset_depth) {
2644 int qp_block_mask = (1 << (
sps->log2_ctb_size -
pps->diff_cu_qp_delta_depth)) - 1;
2645 const int cb_size_split = cb_size >> 1;
2646 const int x1 = x0 + cb_size_split;
2647 const int y1 = y0 + cb_size_split;
2652 x0, y0, log2_cb_size - 1, cb_depth + 1);
2656 if (more_data && x1 < sps->
width) {
2658 x1, y0, log2_cb_size - 1, cb_depth + 1);
2662 if (more_data && y1 < sps->
height) {
2664 x0, y1, log2_cb_size - 1, cb_depth + 1);
2668 if (more_data && x1 < sps->
width &&
2671 x1, y1, log2_cb_size - 1, cb_depth + 1);
2676 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2677 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0)
2681 return ((x1 + cb_size_split) <
sps->width ||
2682 (y1 + cb_size_split) <
sps->height);
2689 if ((!((x0 + cb_size) %
2690 (1 << (
sps->log2_ctb_size))) ||
2691 (x0 + cb_size >=
sps->width)) &&
2693 (1 << (
sps->log2_ctb_size))) ||
2694 (y0 + cb_size >=
sps->height))) {
2696 return !end_of_slice_flag;
2708 int x_ctb,
int y_ctb,
int ctb_addr_ts)
2711 int ctb_size = 1 <<
sps->log2_ctb_size;
2712 int ctb_addr_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2713 int ctb_addr_in_slice = ctb_addr_rs -
s->sh.slice_addr;
2717 if (
pps->entropy_coding_sync_enabled_flag) {
2718 if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
2721 }
else if (
pps->tiles_enabled_flag) {
2722 if (ctb_addr_ts &&
pps->tile_id[ctb_addr_ts] !=
pps->tile_id[ctb_addr_ts - 1]) {
2723 int idxX =
pps->col_idxX[x_ctb >>
sps->log2_ctb_size];
2734 if (
pps->tiles_enabled_flag) {
2735 if (x_ctb > 0 &&
pps->tile_id[ctb_addr_ts] !=
pps->tile_id[
pps->ctb_addr_rs_to_ts[ctb_addr_rs - 1]])
2739 if (y_ctb > 0 &&
pps->tile_id[ctb_addr_ts] !=
pps->tile_id[
pps->ctb_addr_rs_to_ts[ctb_addr_rs -
sps->ctb_width]])
2744 if (ctb_addr_in_slice <= 0)
2746 if (ctb_addr_in_slice < sps->ctb_width)
2752 lc->
ctb_up_right_flag = ((y_ctb > 0) && (ctb_addr_in_slice+1 >=
sps->ctb_width) && (
pps->tile_id[ctb_addr_ts] ==
pps->tile_id[
pps->ctb_addr_rs_to_ts[ctb_addr_rs+1 -
sps->ctb_width]]));
2753 lc->
ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0) && (ctb_addr_in_slice-1 >=
sps->ctb_width) && (
pps->tile_id[ctb_addr_ts] ==
pps->tile_id[
pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 -
sps->ctb_width]]));
2762 const uint8_t *slice_data = gb->
buffer +
s->sh.data_offset;
2764 int ctb_size = 1 <<
sps->log2_ctb_size;
2768 int ctb_addr_ts =
pps->ctb_addr_rs_to_ts[
s->sh.slice_ctb_addr_rs];
2771 while (more_data && ctb_addr_ts < sps->ctb_size) {
2772 int ctb_addr_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2774 x_ctb = (ctb_addr_rs % ((
sps->width + ctb_size - 1) >>
sps->log2_ctb_size)) <<
sps->log2_ctb_size;
2775 y_ctb = (ctb_addr_rs / ((
sps->width + ctb_size - 1) >>
sps->log2_ctb_size)) <<
sps->log2_ctb_size;
2785 x_ctb >>
sps->log2_ctb_size, y_ctb >>
sps->log2_ctb_size);
2792 if (more_data < 0) {
2803 if (x_ctb + ctb_size >=
sps->width &&
2804 y_ctb + ctb_size >=
sps->height)
2811 int job,
int thread)
2818 int ctb_size = 1 <<
sps->log2_ctb_size;
2821 int ctb_addr_rs =
s->sh.slice_ctb_addr_rs + ctb_row * ((
sps->width + ctb_size - 1) >>
sps->log2_ctb_size);
2822 int ctb_addr_ts =
pps->ctb_addr_rs_to_ts[ctb_addr_rs];
2824 const uint8_t *
data =
s->data +
s->sh.offset[ctb_row];
2825 const size_t data_size =
s->sh.size[ctb_row];
2834 while(more_data && ctb_addr_ts < sps->ctb_size) {
2835 int x_ctb = (ctb_addr_rs %
sps->ctb_width) <<
sps->log2_ctb_size;
2836 int y_ctb = (ctb_addr_rs /
sps->ctb_width) <<
sps->log2_ctb_size;
2856 x_ctb >>
sps->log2_ctb_size, y_ctb >>
sps->log2_ctb_size);
2864 if (more_data < 0) {
2875 if (!more_data && (x_ctb+ctb_size) <
sps->width && ctb_row !=
s->sh.num_entry_point_offsets) {
2882 if ((x_ctb+ctb_size) >=
sps->width && (y_ctb+ctb_size) >=
sps->height ) {
2887 ctb_addr_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2890 if(x_ctb >=
sps->width) {
2907 if (
s->nb_wpp_progress < count) {
2909 sizeof(*
s->wpp_progress));
2913 s->wpp_progress =
tmp;
2914 memset(
s->wpp_progress +
s->nb_wpp_progress, 0,
2915 (count -
s->nb_wpp_progress) *
sizeof(*
s->wpp_progress));
2917 for (
int i =
s->nb_wpp_progress;
i < count;
i++) {
2921 s->nb_wpp_progress =
i + 1;
2925 for (
int i = 0;
i < count;
i++)
2935 const uint8_t *
data =
nal->data;
2936 int length =
nal->size;
2939 int64_t startheader, cmpt = 0;
2942 if (
s->sh.slice_ctb_addr_rs +
s->sh.num_entry_point_offsets * (
int64_t)
sps->ctb_width >=
sps->ctb_width * (
int64_t)
sps->ctb_height) {
2944 s->sh.slice_ctb_addr_rs,
s->sh.num_entry_point_offsets,
2945 sps->ctb_width,
sps->ctb_height
2950 if (
s->avctx->thread_count >
s->nb_local_ctx) {
2956 memcpy(
tmp,
s->local_ctx,
sizeof(*
s->local_ctx) *
s->nb_local_ctx);
2960 for (
unsigned i =
s->nb_local_ctx;
i < s->avctx->thread_count;
i++) {
2961 tmp = &
s->local_ctx[
i];
2963 memset(
tmp, 0,
sizeof(*
tmp));
2965 tmp->logctx =
s->avctx;
2967 tmp->common_cabac_state = &
s->cabac;
2970 s->nb_local_ctx =
s->avctx->thread_count;
2975 for (j = 0, cmpt = 0, startheader =
offset +
s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) {
2976 if (
nal->skipped_bytes_pos[j] >=
offset &&
nal->skipped_bytes_pos[j] < startheader) {
2982 for (
int i = 1;
i <
s->sh.num_entry_point_offsets;
i++) {
2983 offset += (
s->sh.entry_point_offset[
i - 1] - cmpt);
2984 for (j = 0, cmpt = 0, startheader =
offset
2985 +
s->sh.entry_point_offset[
i]; j < nal->skipped_bytes; j++) {
2986 if (
nal->skipped_bytes_pos[j] >=
offset &&
nal->skipped_bytes_pos[j] < startheader) {
2991 s->sh.size[
i] =
s->sh.entry_point_offset[
i] - cmpt;
2996 offset +=
s->sh.entry_point_offset[
s->sh.num_entry_point_offsets - 1] - cmpt;
3001 s->sh.size [
s->sh.num_entry_point_offsets] = length -
offset;
3002 s->sh.offset[
s->sh.num_entry_point_offsets] =
offset;
3004 s->sh.offset[0] =
s->sh.data_offset;
3005 s->sh.size[0] =
s->sh.offset[1] -
s->sh.offset[0];
3009 for (
unsigned i = 1;
i <
s->nb_local_ctx;
i++) {
3010 s->local_ctx[
i].first_qp_group = 1;
3011 s->local_ctx[
i].qp_y =
s->local_ctx[0].qp_y;
3019 ret =
av_calloc(
s->sh.num_entry_point_offsets + 1,
sizeof(*ret));
3023 if (
pps->entropy_coding_sync_enabled_flag)
3026 for (
int i = 0;
i <=
s->sh.num_entry_point_offsets;
i++)
3039 if (!
s->sh.first_slice_in_pic_flag)
3040 s->slice_idx += !
s->sh.dependent_slice_segment_flag;
3042 if (!
s->sh.dependent_slice_segment_flag &&
s->sh.slice_type !=
HEVC_SLICE_I) {
3046 "Error constructing the reference lists for the current slice.\n");
3051 s->slice_initialized = 1;
3053 if (
s->avctx->hwaccel)
3058 "SCC profile is not yet implemented in hevc native decoder.\n");
3062 if (
s->sh.dependent_slice_segment_flag) {
3063 int ctb_addr_ts =
pps->ctb_addr_rs_to_ts[
s->sh.slice_ctb_addr_rs];
3064 int prev_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
3071 s->local_ctx[0].first_qp_group = !
s->sh.dependent_slice_segment_flag;
3073 if (!
pps->cu_qp_delta_enabled_flag)
3074 s->local_ctx[0].qp_y =
s->sh.slice_qp;
3076 s->local_ctx[0].tu.cu_qp_offset_cb = 0;
3077 s->local_ctx[0].tu.cu_qp_offset_cr = 0;
3080 s->sh.num_entry_point_offsets > 0 &&
3081 pps->num_tile_rows == 1 &&
pps->num_tile_columns == 1)
3096 if (
IS_IRAP(
s) &&
s->no_rasl_output_flag) {
3097 if (
s->sei.common.mastering_display.present > 0)
3098 s->sei.common.mastering_display.present--;
3100 if (
s->sei.common.content_light.present > 0)
3101 s->sei.common.content_light.present--;
3106 sps->bit_depth,
sps->bit_depth_chroma,
3107 s->cur_frame->poc );
3111 if (
s->sei.timecode.present) {
3116 sizeof(uint32_t) * 4, &tcside);
3121 tc_sd = (uint32_t*)tcside->
data;
3122 tc_sd[0] =
s->sei.timecode.num_clock_ts;
3124 for (
int i = 0;
i < tc_sd[0];
i++) {
3125 int drop =
s->sei.timecode.cnt_dropped_flag[
i];
3126 int hh =
s->sei.timecode.hours_value[
i];
3127 int mm =
s->sei.timecode.minutes_value[
i];
3128 int ss =
s->sei.timecode.seconds_value[
i];
3129 int ff =
s->sei.timecode.n_frames[
i];
3137 s->sei.timecode.num_clock_ts = 0;
3140 if (
s->sei.common.itut_t35.hdr_plus) {
3150 if (
s->sei.common.itut_t35.hdr_smpte2094_app5) {
3171 if (
s->sei.common.itut_t35.hdr_vivid) {
3174 &
s->sei.common.itut_t35.hdr_vivid,
3186 for (
int i = nal_idx;
i <
s->pkt.nb_nals;
i++) {
3188 const int layer_id =
nal->nuh_layer_id;
3192 !(
s->layers_active_decode & (1 <<
s->vps->layer_idx[layer_id])))
3195 switch (
nal->type) {
3229 const HEVCPPS *
const pps =
s->ps.pps_list[
s->sh.pps_id];
3231 int pic_size_in_ctb = ((
sps->width >>
sps->log2_min_cb_size) + 1) *
3232 ((
sps->height >>
sps->log2_min_cb_size) + 1);
3233 int new_sequence = (l == &
s->layers[0]) &&
3235 int prev_layers_active_decode =
s->layers_active_decode;
3236 int prev_layers_active_output =
s->layers_active_output;
3239 if (
sps->vps !=
s->vps && l != &
s->layers[0]) {
3247 const HEVCSPS *sps_base =
s->layers[0].sps;
3250 if (l != &
s->layers[0]) {
3253 "Access unit starts with a non-base layer frame\n");
3262 !
sps->vui.common.video_signal_type_present_flag)
3275 "Base/non-base layer SPS have unsupported parameter combination\n");
3286 if (l == &
s->layers[0]) {
3302 memset(l->
is_pcm, 0, (
sps->min_pu_width + 1) * (
sps->min_pu_height + 1));
3309 s->first_nal_type =
s->nal_unit_type;
3319 s->sei.recovery_point.has_recovery_poc) {
3321 s->recovery_poc =
s->poc +
s->sei.recovery_point.recovery_poc_cnt;
3322 else if (
s->poc >=
s->recovery_poc)
3327 if (
s->temporal_id == 0 &&
3335 s->poc_tid0 =
s->poc;
3337 if (
pps->tiles_enabled_flag)
3338 s->local_ctx[0].end_of_tiles_x =
pps->column_width[0] <<
sps->log2_ctb_size;
3342 0, 0,
s->sh.no_output_of_prior_pics_flag);
3366 s->cur_frame->needs_fg = ((
s->sei.common.film_grain_characteristics &&
3367 s->sei.common.film_grain_characteristics->present) ||
3368 s->sei.common.itut_t35.aom_film_grain.enable) &&
3376 if (
s->cur_frame->needs_fg &&
3377 (
s->sei.common.film_grain_characteristics &&
s->sei.common.film_grain_characteristics->present &&
3379 s->cur_frame->f->format) ||
3382 "Unsupported film grain parameters. Ignoring film grain.\n");
3383 s->cur_frame->needs_fg = 0;
3386 if (
s->cur_frame->needs_fg) {
3387 s->cur_frame->frame_grain->format =
s->cur_frame->f->format;
3388 s->cur_frame->frame_grain->width =
s->cur_frame->f->width;
3389 s->cur_frame->frame_grain->height =
s->cur_frame->f->height;
3398 s->cur_frame->f->pict_type = 3 -
s->sh.slice_type;
3401 sps->temporal_layer[
sps->max_sub_layers - 1].num_reorder_pics,
3402 sps->temporal_layer[
sps->max_sub_layers - 1].max_dec_pic_buffering, 0);
3406 if (
s->avctx->hwaccel) {
3418 if (l == &
s->layers[0])
3421 if (nal_idx >=
s->finish_setup_nal_idx)
3430 s->cur_frame =
s->collocated_ref =
NULL;
3437 char msg_buf[4 * (50 + 2 * 2 * 16 )];
3445 pixel_shift =
desc->comp[0].depth > 8;
3450 if (pixel_shift && !
s->checksum_buf) {
3453 frame->linesize[2]));
3454 if (!
s->checksum_buf)
3461 int width =
s->avctx->coded_width;
3462 int height =
s->avctx->coded_height;
3468 for (j = 0; j <
h; j++) {
3472 s->bdsp.bswap16_buf((uint16_t *)
s->checksum_buf,
3473 (
const uint16_t *)
src,
w);
3474 src =
s->checksum_buf;
3481#define MD5_PRI "%016" PRIx64 "%016" PRIx64
3482#define MD5_PRI_ARG(buf) AV_RB64(buf), AV_RB64((const uint8_t*)(buf) + 8)
3484 if (!memcmp(
md5,
s->sei.picture_hash.md5[
i], 16)) {
3486 "plane %d - correct " MD5_PRI "; ",
3490 "mismatching checksum of plane %d - " MD5_PRI " != " MD5_PRI "; ",
3497 "Verifying checksum for frame with POC %d: %s\n",
3509 if (
out->needs_fg) {
3512 switch (fgp->
type) {
3526 if (
s->avctx->hwaccel) {
3530 "hardware accelerator failed to decode picture\n");
3535 s->sei.picture_hash.is_md5) {
3541 s->sei.picture_hash.is_md5 = 0;
3544 l -
s->layers,
s->poc);
3551 const int layer_idx =
s->vps ?
s->vps->layer_idx[
s->nuh_layer_id] : 0;
3558 if (layer_idx < 0 ||
3559 (
s->nuh_layer_id > 0 && !(
s->layers_active_decode & (1 << layer_idx))))
3566 s->slice_initialized = 0;
3575 s->no_rasl_output_flag)) {
3580 if (
s->cur_layer != layer_idx &&
3581 s->layers[
s->cur_layer].cur_frame &&
3585 s->cur_layer = layer_idx;
3586 l = &
s->layers[
s->cur_layer];
3588 if (
s->sh.first_slice_in_pic_flag) {
3590 av_log(
s->avctx,
AV_LOG_ERROR,
"Two slices reporting being the first in the same frame.\n");
3602 if (
s->nal_unit_type !=
s->first_nal_type) {
3604 "Non-matching NAL types of the VCL NALUs: %d %d\n",
3605 s->first_nal_type,
s->nal_unit_type);
3622 s->nal_unit_type =
nal->type;
3623 s->nuh_layer_id =
nal->nuh_layer_id;
3624 s->temporal_id =
nal->temporal_id;
3633 nal->type,
nal->raw_data,
nal->raw_size);
3638 switch (
s->nal_unit_type) {
3646 nal->nuh_layer_id,
s->apply_defdispwin);
3690 "Skipping NAL unit %d\n",
s->nal_unit_type);
3698 "Skipping invalid undecodable NALU: %d\n",
s->nal_unit_type);
3707 s->sei.recovery_point.has_recovery_poc = 0;
3713 int eos_at_start = 1;
3716 s->cur_frame =
s->collocated_ref =
NULL;
3717 s->last_eos =
s->eos;
3719 s->slice_initialized = 0;
3731 s->nal_length_size,
s->avctx->codec_id,
flags);
3734 "Error splitting the input into NAL units.\n");
3738 for (
int i = 0;
i <
s->pkt.nb_nals;
i++) {
3761 for (
int i =
s->pkt.nb_nals - 1;
i > 0 ;
i--) {
3763 && !
s->pkt.nals[
i].nuh_layer_id && !
s->pkt.nals[
i].temporal_id) {
3764 rpu_nal = &
s->pkt.nals[
i];
3772 av_log(
s->avctx,
AV_LOG_WARNING,
"Multiple Dolby Vision RPUs found in one AU. Skipping previous.\n");
3783 s->avctx->err_recognition);
3792 for (
int i = 0;
i <
s->pkt.nb_nals;
i++) {
3802 "Error parsing NAL unit #%d.\n",
i);
3829 &
s->nal_length_size,
s->avctx->err_recognition,
3830 s->apply_defdispwin,
s->avctx);
3836 if (first &&
s->ps.sps_list[
i]) {
3875 s->layers_active_output, 0, 0, 0);
3882 s->pkt_dts = avpkt->
dts;
3885 if (sd && sd_size > 0) {
3892 if (sd && sd_size >=
sizeof(
s->dovi_ctx.cfg)) {
3893 int old =
s->dovi_ctx.cfg.dv_profile;
3897 "New DOVI configuration record from input packet (profile %d -> %u).\n",
3898 old,
s->dovi_ctx.cfg.dv_profile);
3922 if (
src->needs_fg) {
3935 dst->nb_rpl_elems =
src->nb_rpl_elems;
3938 dst->ctb_count =
src->ctb_count;
3941 dst->base_layer_frame =
src->base_layer_frame;
3944 src->hwaccel_picture_private);
3978 for (
int i = 0;
i <
s->nb_wpp_progress;
i++)
4004 s->nb_local_ctx = 1;
4006 s->local_ctx[0].parent =
s;
4007 s->local_ctx[0].logctx = avctx;
4008 s->local_ctx[0].common_cabac_state = &
s->cabac;
4011 if (!
s->output_fifo)
4029 s->dovi_ctx.logctx = avctx;
4088 memcmp(
s->view_ids, s0->
view_ids,
sizeof(*
s->view_ids) *
s->nb_view_ids)) {
4135 if (
sei->tdrdi.present) {
4153 for (
int i = 0;
i <
sei->tdrdi.num_ref_displays;
i++) {
4189 s->sei.picture_timing.picture_struct = 0;
4209 if (sd && sd->
size >=
sizeof(
s->dovi_ctx.cfg))
4229#define OFFSET(x) offsetof(HEVCContext, x)
4230#define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
4233 {
"apply_defdispwin",
"Apply default display window from VUI",
OFFSET(apply_defdispwin),
4235 {
"strict-displaywin",
"strictly apply default display window size",
OFFSET(apply_defdispwin),
4237 {
"view_ids",
"Array of view IDs that should be decoded and output; a single -1 to decode all views",
4239 .min = -1, .max = INT_MAX, .flags =
PAR },
4240 {
"view_ids_available",
"Array of available view IDs is exported here",
4243 {
"view_pos_available",
"Array of view positions for view_ids_available is exported here, as AVStereo3DView",
4254 .class_name =
"HEVC decoder",
4279#if CONFIG_HEVC_DXVA2_HWACCEL
4282#if CONFIG_HEVC_D3D11VA_HWACCEL
4285#if CONFIG_HEVC_D3D11VA2_HWACCEL
4288#if CONFIG_HEVC_D3D12VA_HWACCEL
4291#if CONFIG_HEVC_NVDEC_HWACCEL
4294#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
4297#if CONFIG_HEVC_VAAPI_HWACCEL
4300#if CONFIG_HEVC_VDPAU_HWACCEL
4303#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
4306#if CONFIG_HEVC_VULKAN_HWACCEL
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t const uint8_t ptrdiff_t srcstride
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t my
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t mx
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double val(void *priv, double ch)
static char * split(char *message, char delim)
const FFCodec ff_hevc_decoder
int ff_aom_apply_film_grain(AVFrame *out, const AVFrame *in, const AVFilmGrainParams *params)
AOM film grain synthesis.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define FF_THREAD_FRAME
Decode more than one frame at once.
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
int ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size)
Context Adaptive Binary Arithmetic Coder inline functions.
static av_unused const uint8_t * skip_bytes(CABACContext *c, int n)
Skip n bytes and reset the decoder.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int FUNC sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
static int FUNC sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
static int FUNC vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
static int FUNC nal(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawNAL *current, int nal_unit_type)
#define ss(width, name, subs,...)
#define UPDATE_THREAD_CONTEXT(func)
#define FF_CODEC_RECEIVE_FRAME_CB(func)
#define FF_CODEC_CAP_EXPORTS_CROPPING
The decoder sets the cropping fields in the output frames manually.
#define FF_CODEC_CAP_USES_PROGRESSFRAMES
The decoder might make use of the ProgressFrame API.
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
common internal and external API header
void av_container_fifo_free(AVContainerFifo **pcf)
Free a AVContainerFifo and everything in it.
int av_container_fifo_read(AVContainerFifo *cf, void *obj, unsigned flags)
Read the next available object from the FIFO into obj.
size_t av_container_fifo_can_read(const AVContainerFifo *cf)
AVContainerFifo * av_container_fifo_alloc_avframe(unsigned flags)
Allocate an AVContainerFifo instance for AVFrames.
void ff_progress_frame_ref(ProgressFrame *dst, const ProgressFrame *src)
Set dst->f to src->f and make dst a co-owner of src->f.
int ff_frame_new_side_data_from_buf(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef **buf)
Similar to ff_frame_new_side_data, but using an existing buffer ref.
void ff_progress_frame_await(const ProgressFrame *f, int n)
Wait for earlier decoding threads to finish reference frames.
void ff_progress_frame_report(ProgressFrame *f, int n)
Notify later decoding threads when part of their reference frame is ready.
int ff_frame_new_side_data_from_buf_ext(const AVCodecContext *avctx, AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, AVBufferRef **buf)
Same as ff_frame_new_side_data_from_buf, but taking a AVFrameSideData array directly instead of an AV...
const AVPacketSideData * ff_get_coded_side_data(const AVCodecContext *avctx, enum AVPacketSideDataType type)
Get side data of the given type from a decoding context.
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
int ff_frame_new_side_data(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, size_t size, AVFrameSideData **psd)
Wrapper around av_frame_new_side_data, which rejects side data overridden by the demuxer.
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data,...
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define AV_PROFILE_HEVC_SCC
static enum AVPixelFormat pix_fmt
void ff_dovi_ctx_replace(DOVIContext *s, const DOVIContext *s0)
av_cold void ff_dovi_ctx_flush(DOVIContext *s)
Partially reset the internal state.
void ff_dovi_ctx_unref(DOVIContext *s)
Completely reset a DOVIContext, preserving only logctx.
int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size, int err_recognition)
Parse the contents of a Dolby Vision RPU and update the parsed values in the DOVIContext struct.
int ff_dovi_attach_side_data(DOVIContext *s, AVFrame *frame)
Attach the decoded AVDOVIMetadata as side data to an AVFrame.
void(* flush)(AVBSFContext *ctx)
#define atomic_store(object, desired)
#define atomic_load(object)
#define atomic_init(obj, value)
static int decode_slice(AVCodecContext *c, void *arg)
const AVFilmGrainParams * av_film_grain_params_select(const AVFrame *frame)
Select the most appropriate film grain parameters set for the frame, taking into account the frame's ...
@ AV_FILM_GRAIN_PARAMS_H274
The union is valid when interpreted as AVFilmGrainH274Params (codec.h274)
@ AV_FILM_GRAIN_PARAMS_AV1
The union is valid when interpreted as AVFilmGrainAOMParams (codec.aom)
@ AV_FILM_GRAIN_PARAMS_NONE
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int get_bits_left(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static const uint8_t * align_get_bits(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
static int get_bits_bytesize(const GetBitContext *s, int round_up)
Get the size of the GetBitContext's buffer in bytes.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
#define AV_OPT_FLAG_READONLY
The option may not be set through the AVOptions API, only read.
#define AV_OPT_FLAG_EXPORT
The option is intended for exporting values to the caller.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_FLAG_ARRAY
May be combined with another regular option type to declare an array option.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_UINT
Underlying C type is unsigned int.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
#define AV_CODEC_EXPORT_DATA_FILM_GRAIN
Decoding only.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
@ AVDISCARD_ALL
discard all
@ AVDISCARD_NONKEY
discard all frames except keyframes
@ AVDISCARD_BIDIR
discard all bidirectional frames
@ AVDISCARD_NONINTRA
discard all non intra frames
@ AVDISCARD_NONREF
discard all non reference
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
@ AV_PKT_DATA_DOVI_CONF
DOVI configuration ref: dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2....
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
#define AV_FRAME_SIDE_DATA_FLAG_NEW_REF
Create a new reference to the passed in buffer instead of taking ownership of it.
AVFrameSideData * av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, AVBufferRef **buf, unsigned int flags)
Add a new side data entry to an array from an existing AVBufferRef.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrameSideData * av_frame_new_side_data_from_buf(AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf)
Add a new side data to a frame from an existing AVBufferRef.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
@ AV_FRAME_DATA_DYNAMIC_HDR_VIVID
HDR Vivid dynamic metadata associated with a video frame.
@ AV_FRAME_DATA_DYNAMIC_HDR_PLUS
HDR dynamic metadata associated with a video frame.
@ AV_FRAME_DATA_3D_REFERENCE_DISPLAYS
This side data contains information about the reference display width(s) and reference viewing distan...
@ AV_FRAME_DATA_DYNAMIC_HDR_SMPTE_2094_APP5
HDR dynamic metadata associated with a video frame.
@ AV_FRAME_DATA_FILM_GRAIN_PARAMS
Film grain parameters for a frame, described by AVFilmGrainParams.
@ AV_FRAME_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1.
@ AV_FRAME_DATA_DOVI_RPU_BUFFER
Dolby Vision RPU raw data, suitable for passing to x265 or other libraries.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
void av_md5_init(AVMD5 *ctx)
Initialize MD5 hashing.
void av_md5_final(AVMD5 *ctx, uint8_t *dst)
Finish hashing and output digest value.
struct AVMD5 * av_md5_alloc(void)
Allocate an AVMD5 context.
void av_md5_update(AVMD5 *ctx, const uint8_t *src, size_t len)
Update hash value.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define LIBAVUTIL_VERSION_INT
AV3DReferenceDisplaysInfo * av_tdrdi_alloc(unsigned int nb_displays, size_t *out_size)
Allocate a AV3DReferenceDisplaysInfo structure and initialize its fields to default values.
static av_always_inline AV3DReferenceDisplay * av_tdrdi_get_display(AV3DReferenceDisplaysInfo *tdrdi, unsigned int idx)
@ AV_STEREO3D_VIEW_RIGHT
Frame contains only the right view.
@ AV_STEREO3D_VIEW_LEFT
Frame contains only the left view.
@ AV_STEREO3D_VIEW_UNSPEC
Content is unspecified.
@ H2645_FLAG_SMALL_PADDING
int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei, enum AVCodecID codec_id, AVCodecContext *avctx, const H2645VUI *vui, unsigned bit_depth_luma, unsigned bit_depth_chroma, int seed)
int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src)
int ff_h2645_sei_to_context(AVCodecContext *avctx, H2645SEI *sei)
int ff_h274_apply_film_grain(AVFrame *out_frame, const AVFrame *in_frame, const AVFilmGrainParams *params)
H.274 film grain synthesis.
static int ff_h274_film_grain_params_supported(int model_id, enum AVPixelFormat pix_fmt)
Check whether ff_h274_apply_film_grain() supports the given parameter combination.
int ff_hevc_end_of_slice_flag_decode(HEVCLocalContext *lc)
int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc)
int ff_hevc_sao_type_idx_decode(HEVCLocalContext *lc)
int ff_hevc_no_residual_syntax_flag_decode(HEVCLocalContext *lc)
int ff_hevc_sao_merge_flag_decode(HEVCLocalContext *lc)
int ff_hevc_merge_flag_decode(HEVCLocalContext *lc)
int ff_hevc_cu_chroma_qp_offset_flag(HEVCLocalContext *lc)
int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc, int chroma_qp_offset_list_len_minus1)
int ff_hevc_sao_offset_abs_decode(HEVCLocalContext *lc, int bit_depth)
int ff_hevc_res_scale_sign_flag(HEVCLocalContext *lc, int idx)
int ff_hevc_cu_qp_delta_abs(HEVCLocalContext *lc)
int ff_hevc_mvp_lx_flag_decode(HEVCLocalContext *lc)
void ff_hevc_save_states(HEVCLocalContext *lc, const HEVCPPS *pps, int ctb_addr_ts)
int ff_hevc_split_transform_flag_decode(HEVCLocalContext *lc, int log2_trafo_size)
int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS *pps, int ctb_addr_ts, const uint8_t *data, size_t size, int is_wpp)
int ff_hevc_log2_res_scale_abs(HEVCLocalContext *lc, int idx)
int ff_hevc_sao_eo_class_decode(HEVCLocalContext *lc)
void ff_hevc_hls_mvd_coding(HEVCLocalContext *lc, int x0, int y0, int log2_cb_size)
int ff_hevc_mpm_idx_decode(HEVCLocalContext *lc)
int ff_hevc_sao_band_position_decode(HEVCLocalContext *lc)
int ff_hevc_inter_pred_idc_decode(HEVCLocalContext *lc, int nPbW, int nPbH)
int ff_hevc_cbf_cb_cr_decode(HEVCLocalContext *lc, int trafo_depth)
int ff_hevc_rem_intra_luma_pred_mode_decode(HEVCLocalContext *lc)
int ff_hevc_sao_offset_sign_decode(HEVCLocalContext *lc)
int ff_hevc_intra_chroma_pred_mode_decode(HEVCLocalContext *lc)
int ff_hevc_cbf_luma_decode(HEVCLocalContext *lc, int trafo_depth)
int ff_hevc_merge_idx_decode(HEVCLocalContext *lc)
void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, const HEVCPPS *pps, int x0, int y0, int log2_trafo_size, enum ScanType scan_idx, int c_idx)
int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, uint8_t *tab_ct_depth, const HEVCSPS *sps, int ct_depth, int x0, int y0)
int ff_hevc_pcm_flag_decode(HEVCLocalContext *lc)
int ff_hevc_part_mode_decode(HEVCLocalContext *lc, const HEVCSPS *sps, int log2_cb_size)
int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, uint8_t *skip_flag, int x0, int y0, int x_cb, int y_cb, int min_cb_width)
int ff_hevc_cu_qp_delta_sign_flag(HEVCLocalContext *lc)
int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCLocalContext *lc)
int ff_hevc_pred_mode_decode(HEVCLocalContext *lc)
int ff_hevc_ref_idx_lx_decode(HEVCLocalContext *lc, int num_ref_idx_lx)
void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
void ff_hevc_set_qPy(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int xBase, int yBase, int log2_cb_size)
void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x0, int y0, int log2_trafo_size)
void ff_hevc_hls_filters(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x_ctb, int y_ctb, int ctb_size)
void ff_hevc_hls_filter(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x, int y, int ctb_size)
int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps, HEVCSEI *sei, int *is_nalff, int *nal_length_size, int err_recognition, int apply_defdispwin, void *logctx)
int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
void ff_hevc_ps_uninit(HEVCParamSets *ps)
int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header)
int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps, unsigned nuh_layer_id, int apply_defdispwin)
static int ff_hevc_compute_poc(const HEVCSPS *sps, int pocTid0, int poc_lsb, int nal_unit_type)
int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s, const HEVCParamSets *ps, enum HEVCNALUnitType type)
static void ff_hevc_reset_sei(HEVCSEI *sei)
Reset SEI values that are stored on the Context.
#define BOUNDARY_UPPER_SLICE
int ff_hevc_output_frames(HEVCContext *s, unsigned layers_active_decode, unsigned layers_active_output, unsigned max_output, unsigned max_dpb, int discard)
Find frames in the DPB that are ready for output and either write them to the output FIFO or drop the...
#define BOUNDARY_LEFT_TILE
void ff_hevc_flush_dpb(HEVCContext *s)
Drop all frames currently in DPB.
int ff_hevc_frame_nb_refs(const SliceHeader *sh, const HEVCPPS *pps, unsigned layer_idx)
Get the number of candidate references for the current frame.
#define HEVC_RECOVERY_END
#define HEVC_RECOVERY_UNSPECIFIED
void ff_hevc_clear_refs(HEVCLayerContext *l)
Mark all frames in DPB as unused for reference.
int ff_hevc_set_new_ref(HEVCContext *s, HEVCLayerContext *l, int poc)
int ff_hevc_frame_rps(HEVCContext *s, HEVCLayerContext *l)
Construct the reference picture sets for the current frame.
void ff_hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, const HEVCPPS *pps, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv, int mvp_lx_flag, int LX)
#define QPEL_EXTRA_BEFORE
static av_always_inline int ff_hevc_nal_is_nonref(enum HEVCNALUnitType type)
void ff_hevc_set_neighbour_available(HEVCLocalContext *lc, int x0, int y0, int nPbW, int nPbH, int log2_ctb_size)
void ff_hevc_luma_mv_merge_mode(HEVCLocalContext *lc, const HEVCPPS *pps, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv)
#define EPEL_EXTRA_BEFORE
void ff_hevc_unref_frame(HEVCFrame *frame, int flags)
#define SAMPLE_CTB(tab, x, y)
int ff_hevc_slice_rpl(HEVCContext *s)
Construct the reference picture list(s) for the current slice.
#define BOUNDARY_UPPER_TILE
#define EDGE_EMU_BUFFER_STRIDE
#define BOUNDARY_LEFT_SLICE
#define FF_HW_HAS_CB(avctx, function)
#define FF_HW_SIMPLE_CALL(avctx, function)
#define FF_HW_CALL(avctx, function,...)
#define HWACCEL_NVDEC_CUARRAY(codec)
#define HWACCEL_DXVA2(codec)
#define HWACCEL_VDPAU(codec)
#define HWACCEL_D3D12VA(codec)
#define HWACCEL_VULKAN(codec)
#define HWACCEL_NVDEC(codec)
#define HWACCEL_VAAPI(codec)
#define HWACCEL_D3D11VA(codec)
#define HWACCEL_VIDEOTOOLBOX(codec)
#define HWACCEL_D3D11VA2(codec)
static const int8_t mv[256][2]
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, void *logctx, int nal_length_size, enum AVCodecID codec_id, int flags)
Split an input packet into NAL units.
@ HEVC_SCALABILITY_AUXILIARY
static av_cold int hevc_init_context(AVCodecContext *avctx)
static int set_sps(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *sps)
static void hls_prediction_unit(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int partIdx, int idx)
static int hevc_receive_frame(AVCodecContext *avctx, AVFrame *frame)
static int luma_intra_pred_mode(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCSPS *sps, int x0, int y0, int pu_size, int prev_intra_luma_pred_flag)
8.4.1
static int setup_multilayer(HEVCContext *s, const HEVCVPS *vps)
static int hls_transform_tree(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, int log2_cb_size, int log2_trafo_size, int trafo_depth, int blk_idx, const int *base_cbf_cb, const int *base_cbf_cr)
static void intra_prediction_unit(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCSPS *sps, int x0, int y0, int log2_cb_size)
static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
static av_cold int hevc_decode_init(AVCodecContext *avctx)
static void luma_mc_uni(HEVCLocalContext *lc, const HEVCPPS *pps, const HEVCSPS *sps, uint8_t *dst, ptrdiff_t dststride, const AVFrame *ref, const Mv *mv, int x_off, int y_off, int block_w, int block_h, int luma_weight, int luma_offset)
8.5.3.2.2.1 Luma sample unidirectional interpolation process
static int export_multilayer(HEVCContext *s, const HEVCVPS *vps)
static const AVClass hevc_decoder_class
static enum AVPixelFormat map_to_alpha_format(HEVCContext *s, enum AVPixelFormat pix_fmt)
static int hevc_sei_to_context(AVCodecContext *avctx, HEVCSEI *sei)
static av_cold int hevc_decode_free(AVCodecContext *avctx)
static int decode_slice_data(HEVCContext *s, const HEVCLayerContext *l, const H2645NAL *nal, GetBitContext *gb)
static void luma_mc_bi(HEVCLocalContext *lc, const HEVCPPS *pps, const HEVCSPS *sps, uint8_t *dst, ptrdiff_t dststride, const AVFrame *ref0, const Mv *mv0, int x_off, int y_off, int block_w, int block_h, const AVFrame *ref1, const Mv *mv1, struct MvField *current_mv)
8.5.3.2.2.1 Luma sample bidirectional interpolation process
static int hls_coding_quadtree(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int x0, int y0, int log2_cb_size, int cb_depth)
static void hls_decode_neighbour(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int x_ctb, int y_ctb, int ctb_addr_ts)
static int pred_weight_table(SliceHeader *sh, void *logctx, const HEVCSPS *sps, GetBitContext *gb)
static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length, int first)
static int export_stream_params_from_sei(HEVCContext *s)
static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, GetBitContext *gb)
static int hls_cross_component_pred(HEVCLocalContext *lc, int idx)
static void chroma_mc_bi(HEVCLocalContext *lc, const HEVCPPS *pps, const HEVCSPS *sps, uint8_t *dst0, ptrdiff_t dststride, const AVFrame *ref0, const AVFrame *ref1, int x_off, int y_off, int block_w, int block_h, const MvField *current_mv, int cidx)
8.5.3.2.2.2 Chroma sample bidirectional interpolation process
#define SET_SAO(elem, value)
int ff_hevc_is_alpha_video(const HEVCContext *s)
static int pic_arrays_init(HEVCLayerContext *l, const HEVCSPS *sps)
static int hls_decode_entry_wpp(AVCodecContext *avctx, void *hevc_lclist, int job, int thread)
static void intra_prediction_unit_default_value(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCSPS *sps, int x0, int y0, int log2_cb_size)
static int hevc_ref_frame(HEVCFrame *dst, const HEVCFrame *src)
static int hls_pcm_sample(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x0, int y0, int log2_cb_size)
static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
static int verify_md5(HEVCContext *s, AVFrame *frame)
static int decode_lt_rps(const HEVCSPS *sps, LongTermRPS *rps, GetBitContext *gb, int cur_poc, int poc_lsb)
static const uint8_t hevc_pel_weight[65]
static int set_side_data(HEVCContext *s)
static int find_finish_setup_nal(const HEVCContext *s)
static void decode_reset_recovery_point(HEVCContext *s)
#define SUBDIVIDE(x, y, idx)
static void pic_arrays_free(HEVCLayerContext *l)
NOTE: Each function hls_foo correspond to the function foo in the specification (HLS stands for High ...
static int hevc_frame_start(HEVCContext *s, HEVCLayerContext *l, unsigned nal_idx)
static void hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, const HEVCPPS *pps, const HEVCSPS *sps, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv)
static int wpp_progress_init(HEVCContext *s, unsigned count)
static int decode_nal_unit(HEVCContext *s, unsigned nal_idx)
static int decode_slice(HEVCContext *s, unsigned nal_idx, GetBitContext *gb)
static void chroma_mc_uni(HEVCLocalContext *lc, const HEVCPPS *pps, const HEVCSPS *sps, uint8_t *dst0, ptrdiff_t dststride, const uint8_t *src0, ptrdiff_t srcstride, int reflist, int x_off, int y_off, int block_w, int block_h, const struct MvField *current_mv, int chroma_weight, int chroma_offset)
8.5.3.2.2.2 Chroma sample uniprediction interpolation process
static const uint8_t tab_mode_idx[]
static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
static av_cold void hevc_decode_flush(AVCodecContext *avctx)
static void hevc_await_progress(const HEVCContext *s, const HEVCFrame *ref, const Mv *mv, int y0, int height)
static int hls_transform_unit(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, int log2_cb_size, int log2_trafo_size, int blk_idx, int cbf_luma, int *cbf_cb, int *cbf_cr)
static void set_deblocking_bypass(uint8_t *is_pcm, const HEVCSPS *sps, int x0, int y0, int log2_cb_size)
static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int x0, int y0, int log2_cb_size)
static int hevc_frame_end(HEVCContext *s, HEVCLayerContext *l)
static av_always_inline void set_ct_depth(const HEVCSPS *sps, uint8_t *tab_ct_depth, int x0, int y0, int log2_cb_size, int ct_depth)
static void export_stream_params(HEVCContext *s, const HEVCSPS *sps)
static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps)
static void hls_sao_param(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int rx, int ry)
common internal api header.
Multithreading API for decoders.
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
Macro definitions for various function/variable attributes.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
void av_log_once(void *avcl, int initial_level, int subsequent_level, int *state, const char *fmt,...)
#define FFSWAP(type, a, b)
Public header for MD5 hash function implementation.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
static int is_pcm(enum AVCodecID codec_id)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
#define AV_PIX_FMT_YUV444P12
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
@ AVCHROMA_LOC_UNSPECIFIED
#define AV_PIX_FMT_YUV420P10
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_JPEG
Full range content.
#define AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV422P12
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_D3D12
Hardware surfaces for Direct3D 12.
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_DXVA2_VLD
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer.
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ AV_PIX_FMT_YUVA422P10LE
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
@ AV_PIX_FMT_CUARRAY
hardware decoding through openharmony
@ AV_PIX_FMT_D3D11VA_VLD
HW decoding through Direct3D11 via old API, Picture.data[3] contains a ID3D11VideoDecoderOutputView p...
@ AV_PIX_FMT_YUV422P10LE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
@ AV_PIX_FMT_VDPAU
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
#define AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV444P10
void ff_hevc_pred_init(HEVCPredContext *hpc, int bit_depth)
const AVProfile ff_hevc_profiles[]
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
AVRefStructPool * av_refstruct_pool_alloc(size_t size, unsigned flags)
Equivalent to av_refstruct_pool_alloc(size, flags, NULL, NULL, NULL, NULL, NULL)
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
void av_refstruct_replace(void *dstp, const void *src)
Ensure *dstp refers to the same object as src.
const void * av_refstruct_ref_c(const void *obj)
Analog of av_refstruct_ref(), but for constant objects.
void * av_refstruct_ref(void *obj)
Create a new reference to an object managed via this API, i.e.
static void av_refstruct_pool_uninit(AVRefStructPool **poolp)
Mark the pool as being available for freeing.
#define FF_ARRAY_ELEMS(a)
Data structure for single deference display information.
uint8_t additional_shift_present_flag
An array of flags to indicates that the information about additional horizontal shift of the left and...
uint8_t mantissa_ref_viewing_distance
The mantissa part of the reference viewing distance of the n-th reference display.
uint16_t left_view_id
The ViewId of the left view of a stereo pair corresponding to the n-th reference display.
int16_t num_sample_shift
The recommended additional horizontal shift for a stereo pair corresponding to the n-th reference bas...
uint8_t mantissa_ref_display_width
The mantissa part of the reference display width of the n-th reference display.
uint8_t exponent_ref_display_width
The exponent part of the reference display width of the n-th reference display.
uint16_t right_view_id
The ViewId of the left view of a stereo pair corresponding to the n-th reference display.
uint8_t exponent_ref_viewing_distance
The exponent part of the reference viewing distance of the n-th reference display.
This structure describes information about the reference display width(s) and reference viewing dista...
uint8_t prec_ref_viewing_dist
The exponent of the maximum allowable truncation error for {exponent,mantissa}_ref_viewing_distance a...
uint8_t prec_ref_display_width
The exponent of the maximum allowable truncation error for {exponent,mantissa}_ref_display_width as g...
uint8_t ref_viewing_distance_flag
A flag to indicate the presence of reference viewing distance.
uint8_t num_ref_displays
The number of reference displays that are signalled in this struct.
A reference to a data buffer.
Describe the class of an AVClass context structure.
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
int has_b_frames
Size of the frame reordering buffer in the decoder.
int level
Encoding level descriptor.
int export_side_data
Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of metadata exported in frame,...
enum AVColorSpace colorspace
YUV colorspace type.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
AVFrameSideData ** decoded_side_data
Array containing static side data, such as HDR10 CLL / MDCV structures.
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
int coded_width
Bitstream width / height, may be different from width/height e.g.
struct AVCodecInternal * internal
Private context used for internal data.
int is_copy
When using frame-threaded decoding, this field is set for the first worker thread (e....
AVPacket * in_pkt
This packet is used to hold the packet given to decoders implementing the .decode API; it is unused b...
int draining
decoding: AVERROR_EOF has been returned from ff_decode_get_packet(); must not be used by decoders tha...
This structure describes how to handle film grain synthesis in video for specific codecs.
enum AVFilmGrainParamsType type
Specifies the codec for which this structure is valid.
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
This structure stores compressed data.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
enum PredMode pred_mode
PredMode.
uint8_t intra_split_flag
IntraSplitFlag.
uint8_t max_trafo_depth
MaxTrafoDepth.
enum PartMode part_mode
PartMode.
uint8_t cu_transquant_bypass_flag
H2645SEIFramePacking frame_packing
H2645SEIDisplayOrientation display_orientation
H2645SEIAlternativeTransfer alternative_transfer
int is_nalff
this flag is != 0 if bitstream is encapsulated as a format defined in 14496-15
int film_grain_warning_shown
AVBufferRef * rpu_buf
0 or 1 Dolby Vision RPUs.
int nal_length_size
Number of bytes used for nal length (1, 2 or 4)
HEVCLayerContext layers[HEVC_VPS_MAX_LAYERS]
int eos
current packet contains an EOS/EOB NAL
unsigned layers_active_output
DOVIContext dovi_ctx
Dolby Vision decoding context.
unsigned layers_active_decode
uint8_t * filter_slice_edges
struct AVRefStructPool * rpl_tab_pool
int32_t * tab_slice_address
uint8_t * sao_pixel_buffer_h[3]
struct AVRefStructPool * tab_mvf_pool
uint8_t * sao_pixel_buffer_v[3]
uint8_t edge_emu_buffer[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
const struct HEVCContext * parent
int16_t tmp[MAX_PB_SIZE *MAX_PB_SIZE]
uint8_t ctb_up_right_flag
uint8_t edge_emu_buffer2[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
const HEVCVPS * vps_list[HEVC_MAX_VPS_COUNT]
RefStruct references.
const HEVCPPS * pps_list[HEVC_MAX_PPS_COUNT]
RefStruct references.
const HEVCSPS * sps_list[HEVC_MAX_SPS_COUNT]
RefStruct references.
uint16_t left_view_id[32]
uint16_t right_view_id[32]
HEVCSEIRecoveryPoint recovery_point
int width
coded frame dimension in various units
enum AVPixelFormat pix_fmt
unsigned int right_offset
unsigned int bottom_offset
uint8_t poc_msb_present[32]
int8_t ref_idx[2]
refIdxL0, refIdxL1
int16_t x
horizontal component of motion vector
int16_t y
vertical component of motion vector
uint8_t intra_pred_mode_c[4]
uint8_t intra_pred_mode[4]
int rem_intra_luma_pred_mode
struct HEVCFrame * ref[HEVC_MAX_REFS]
int offset_sign[3][4]
sao_offset_sign
int16_t offset_val[3][5]
SaoOffsetVal.
int eo_class[3]
sao_eo_class
int offset_abs[3][4]
sao_offset_abs
uint8_t type_idx[3]
sao_type_idx
#define av_malloc_array(a, b)
static void error(const char *err)
static int ref[MAX_W *MAX_W]
static struct AVMD5 * md5
av_cold void ff_thread_progress_destroy(ThreadProgress *pro)
Destroy a ThreadProgress.
av_cold int ff_thread_progress_init(ThreadProgress *pro, int init_mode)
Initialize a ThreadProgress.
void ff_thread_progress_report(ThreadProgress *pro, int n)
This function is a no-op in no-op mode; otherwise it notifies other threads that a certain level of p...
void ff_thread_progress_await(const ThreadProgress *pro_c, int n)
This function is a no-op in no-op mode; otherwise it waits until other threads have reached a certain...
static void ff_thread_progress_reset(ThreadProgress *pro)
Reset the ThreadProgress.progress counter; must only be called if the ThreadProgress is not in use in...
uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int ss, int ff)
Convert sei info to SMPTE 12M binary representation.
char * av_timecode_make_smpte_tc_string2(char *buf, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field)
Get the timecode string from the SMPTE timecode format.
#define AV_TIMECODE_STR_SIZE
static void do_output(BM3DContext *s, uint8_t *dst, int dst_linesize, int plane, int nb_jobs)