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])
460 unsigned *active_output)
462 unsigned layers_active_output = 0, highest_layer;
465 if (!
s->nb_view_ids) {
470 if (
s->nb_view_ids == 1 &&
s->view_ids[0] == -1) {
471 layers_active_output = (1 <<
vps->nb_layers) - 1;
473 for (
int i = 0;
i <
s->nb_view_ids;
i++) {
474 int view_id =
s->view_ids[
i];
479 "Invalid view ID requested: %d\n", view_id);
483 for (
int j = 0; j <
vps->nb_layers; j++) {
484 if (
vps->view_id[j] == view_id) {
491 "View ID %d not present in VPS\n", view_id);
494 layers_active_output |= 1 << layer_idx;
498 if (!layers_active_output) {
503 highest_layer =
ff_log2(layers_active_output);
506 "Too many layers requested: %u\n", layers_active_output);
510 *active_output = layers_active_output;
516 return highest_layer + 1;
521 unsigned layers_active_output;
522 int nb_decode_layers;
524 s->layers_active_output = 1;
525 s->layers_active_decode = 1;
533 s->layers_active_decode = (1 <<
vps->nb_layers) - 1;
534 s->layers_active_output = 1;
540 if (nb_decode_layers < 0)
541 return nb_decode_layers;
543 s->layers_active_decode = (1 << nb_decode_layers) - 1;
544 s->layers_active_output = layers_active_output;
547 s->layers_active_decode,
s->layers_active_output);
582#define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + \
583 CONFIG_HEVC_D3D11VA_HWACCEL * 2 + \
584 CONFIG_HEVC_D3D12VA_HWACCEL + \
585 CONFIG_HEVC_NVDEC_HWACCEL + \
586 CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL + \
587 CONFIG_HEVC_VAAPI_HWACCEL + \
588 CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL + \
589 CONFIG_HEVC_VDPAU_HWACCEL + \
590 CONFIG_HEVC_VULKAN_HWACCEL)
598 switch (
sps->pix_fmt) {
601#if CONFIG_HEVC_DXVA2_HWACCEL
604#if CONFIG_HEVC_D3D11VA_HWACCEL
608#if CONFIG_HEVC_D3D12VA_HWACCEL
611#if CONFIG_HEVC_VAAPI_HWACCEL
614#if CONFIG_HEVC_VDPAU_HWACCEL
617#if CONFIG_HEVC_NVDEC_HWACCEL
620#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
623#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
626#if CONFIG_HEVC_VULKAN_HWACCEL
631#if CONFIG_HEVC_DXVA2_HWACCEL
634#if CONFIG_HEVC_D3D11VA_HWACCEL
638#if CONFIG_HEVC_D3D12VA_HWACCEL
641#if CONFIG_HEVC_VAAPI_HWACCEL
644#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
647#if CONFIG_HEVC_VULKAN_HWACCEL
650#if CONFIG_HEVC_VDPAU_HWACCEL
653#if CONFIG_HEVC_NVDEC_HWACCEL
656#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
661#if CONFIG_HEVC_VAAPI_HWACCEL
664#if CONFIG_HEVC_VDPAU_HWACCEL
667#if CONFIG_HEVC_NVDEC_HWACCEL
670#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
673#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
676#if CONFIG_HEVC_VULKAN_HWACCEL
682#if CONFIG_HEVC_VAAPI_HWACCEL
685#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
688#if CONFIG_HEVC_VULKAN_HWACCEL
691#if CONFIG_HEVC_NVDEC_HWACCEL
694#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
699#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
705#if CONFIG_HEVC_VAAPI_HWACCEL
708#if CONFIG_HEVC_VDPAU_HWACCEL
711#if CONFIG_HEVC_VULKAN_HWACCEL
714#if CONFIG_HEVC_NVDEC_HWACCEL
717#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
722#if CONFIG_HEVC_VAAPI_HWACCEL
725#if CONFIG_HEVC_VULKAN_HWACCEL
728#if CONFIG_HEVC_NVDEC_HWACCEL
731#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
739 *fmt++ =
sps->pix_fmt;
751 s->avctx->pix_fmt =
ret;
798 int i,
ret, layer_idx;
818 pps =
s->ps.pps_list[pps_id];
821 layer_idx =
vps->layer_idx[
s->nuh_layer_id];
832 int slice_address_length;
834 if (
pps->dependent_slice_segments_enabled_flag)
846 "Invalid slice segment address: %u.\n",
859 for (
i = 0;
i <
pps->num_extra_slice_header_bits;
i++)
871 !
pps->pps_curr_pic_ref_enabled_flag &&
872 s->nuh_layer_id == 0) {
879 if (
pps->output_flag_present_flag)
882 if (
sps->separate_colour_plane)
886 (
s->nuh_layer_id > 0 &&
887 !(
vps->poc_lsb_not_present & (1 << layer_idx)))) {
894 "Ignoring POC change between slices: %d -> %d\n", poc, sh->
poc);
914 int numbits, rps_idx;
916 if (!
sps->nb_st_rps) {
922 rps_idx = numbits > 0 ?
get_bits(gb, numbits) : 0;
936 if (
sps->temporal_mvp_enabled)
952 if (
s->nuh_layer_id > 0) {
953 int num_direct_ref_layers =
vps->num_direct_ref_layers[layer_idx];
955 if (
vps->default_ref_layers_active)
957 else if (num_direct_ref_layers) {
962 "NumDirectRefLayers>1 not supported\n");
968 if (
sps->sao_enabled) {
970 if (
sps->chroma_format_idc) {
1007 if (
pps->lists_modification_present_flag && nb_refs > 1) {
1025 if (
pps->cabac_init_present_flag)
1040 "Invalid collocated_ref_idx: %d.\n",
1057 "Invalid number of merging MVP candidates: %d.\n",
1063 if (
sps->motion_vector_resolution_control_idc == 2)
1073 if (
pps->pic_slice_level_chroma_qp_offsets_present_flag) {
1086 if (
pps->pps_slice_act_qp_offsets_present_flag) {
1092 if (
pps->chroma_qp_offset_list_enabled_flag)
1097 if (
pps->deblocking_filter_control_present_flag) {
1098 int deblocking_filter_override_flag = 0;
1100 if (
pps->deblocking_filter_override_enabled_flag)
1101 deblocking_filter_override_flag =
get_bits1(gb);
1103 if (deblocking_filter_override_flag) {
1108 if (beta_offset_div2 < -6 || beta_offset_div2 > 6 ||
1109 tc_offset_div2 < -6 || tc_offset_div2 > 6) {
1111 "Invalid deblock filter offsets: %d, %d\n",
1112 beta_offset_div2, tc_offset_div2);
1129 if (
pps->seq_loop_filter_across_slices_enabled_flag &&
1140 if (
pps->tiles_enabled_flag ||
pps->entropy_coding_sync_enabled_flag) {
1143 if (num_entry_point_offsets >
get_bits_left(gb) || num_entry_point_offsets > UINT16_MAX) {
1144 av_log(
s->avctx,
AV_LOG_ERROR,
"num_entry_point_offsets %d is invalid\n", num_entry_point_offsets);
1152 if (offset_len < 1 || offset_len > 32) {
1176 if (
pps->slice_header_extension_present_flag) {
1182 for (
i = 0;
i < length;
i++)
1204 "The slice_qp %d is outside the valid range "
1207 -
sps->qp_bd_offset);
1222#define CTB(tab, x, y) ((tab)[(y) * sps->ctb_width + (x)])
1224#define SET_SAO(elem, value) \
1226 if (!sao_merge_up_flag && !sao_merge_left_flag) \
1227 sao->elem = value; \
1228 else if (sao_merge_left_flag) \
1229 sao->elem = CTB(l->sao, rx-1, ry).elem; \
1230 else if (sao_merge_up_flag) \
1231 sao->elem = CTB(l->sao, rx, ry-1).elem; \
1240 int sao_merge_left_flag = 0;
1241 int sao_merge_up_flag = 0;
1251 if (ry > 0 && !sao_merge_left_flag) {
1257 for (c_idx = 0; c_idx < (
sps->chroma_format_idc ? 3 : 1); c_idx++) {
1258 int log2_sao_offset_scale = c_idx == 0 ?
pps->log2_sao_offset_scale_luma :
1259 pps->log2_sao_offset_scale_chroma;
1276 for (
i = 0;
i < 4;
i++)
1280 for (
i = 0;
i < 4;
i++) {
1289 }
else if (c_idx != 2) {
1295 for (
i = 0;
i < 4;
i++) {
1303 sao->
offset_val[c_idx][
i + 1] *= 1 << log2_sao_offset_scale;
1315 if (log2_res_scale_abs_plus1 != 0) {
1318 (1 - 2 * res_scale_sign_flag);
1331 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1332 int log2_cb_size,
int log2_trafo_size,
1333 int blk_idx,
int cbf_luma,
int *cbf_cb,
int *cbf_cr)
1336 const int log2_trafo_size_c = log2_trafo_size -
sps->hshift[1];
1340 int trafo_size = 1 << log2_trafo_size;
1343 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, x0, y0, 0);
1346 if (cbf_luma || cbf_cb[0] || cbf_cr[0] ||
1347 (
sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
1350 int cbf_chroma = cbf_cb[0] || cbf_cr[0] ||
1351 (
sps->chroma_format_idc == 2 &&
1352 (cbf_cb[1] || cbf_cr[1]));
1364 "The cu_qp_delta %d is outside the valid range "
1367 -(26 +
sps->qp_bd_offset / 2),
1368 (25 +
sps->qp_bd_offset / 2));
1378 if (cu_chroma_qp_offset_flag) {
1379 int cu_chroma_qp_offset_idx = 0;
1380 if (
pps->chroma_qp_offset_list_len_minus1 > 0) {
1383 "cu_chroma_qp_offset_idx not yet tested.\n");
1416 if (
sps->chroma_format_idc && (log2_trafo_size > 2 ||
sps->chroma_format_idc == 3)) {
1417 int trafo_size_h = 1 << (log2_trafo_size_c +
sps->hshift[1]);
1418 int trafo_size_v = 1 << (log2_trafo_size_c +
sps->vshift[1]);
1419 lc->
tu.
cross_pf = (
pps->cross_component_prediction_enabled_flag && cbf_luma &&
1426 for (
i = 0;
i < (
sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1429 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1430 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0 + (
i << log2_trafo_size_c), 1);
1434 log2_trafo_size_c, scan_idx_c, 1);
1437 ptrdiff_t
stride =
s->cur_frame->f->linesize[1];
1438 int hshift =
sps->hshift[1];
1439 int vshift =
sps->vshift[1];
1442 int size = 1 << log2_trafo_size_c;
1444 uint8_t *
dst = &
s->cur_frame->f->data[1][(y0 >> vshift) *
stride +
1445 ((x0 >> hshift) <<
sps->pixel_shift)];
1449 s->hevcdsp.add_residual[log2_trafo_size_c-2](
dst, coeffs,
stride);
1456 for (
i = 0;
i < (
sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1459 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1460 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0 + (
i << log2_trafo_size_c), 2);
1464 log2_trafo_size_c, scan_idx_c, 2);
1467 ptrdiff_t
stride =
s->cur_frame->f->linesize[2];
1468 int hshift =
sps->hshift[2];
1469 int vshift =
sps->vshift[2];
1472 int size = 1 << log2_trafo_size_c;
1474 uint8_t *
dst = &
s->cur_frame->f->data[2][(y0 >> vshift) *
stride +
1475 ((x0 >> hshift) <<
sps->pixel_shift)];
1479 s->hevcdsp.add_residual[log2_trafo_size_c-2](
dst, coeffs,
stride);
1482 }
else if (
sps->chroma_format_idc && blk_idx == 3) {
1483 int trafo_size_h = 1 << (log2_trafo_size + 1);
1484 int trafo_size_v = 1 << (log2_trafo_size +
sps->vshift[1]);
1485 for (
i = 0;
i < (
sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1488 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1489 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase + (
i << log2_trafo_size), 1);
1493 log2_trafo_size, scan_idx_c, 1);
1495 for (
i = 0;
i < (
sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1498 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1499 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase + (
i << log2_trafo_size), 2);
1503 log2_trafo_size, scan_idx_c, 2);
1507 if (log2_trafo_size > 2 ||
sps->chroma_format_idc == 3) {
1508 int trafo_size_h = 1 << (log2_trafo_size_c +
sps->hshift[1]);
1509 int trafo_size_v = 1 << (log2_trafo_size_c +
sps->vshift[1]);
1511 sps->log2_ctb_size);
1512 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0, 1);
1513 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0, 2);
1514 if (
sps->chroma_format_idc == 2) {
1516 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1517 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0 + (1 << log2_trafo_size_c), 1);
1518 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0 + (1 << log2_trafo_size_c), 2);
1520 }
else if (blk_idx == 3) {
1521 int trafo_size_h = 1 << (log2_trafo_size + 1);
1522 int trafo_size_v = 1 << (log2_trafo_size +
sps->vshift[1]);
1524 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1525 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase, 1);
1526 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase, 2);
1527 if (
sps->chroma_format_idc == 2) {
1529 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1530 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase + (1 << log2_trafo_size), 1);
1531 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase + (1 << log2_trafo_size), 2);
1540 int x0,
int y0,
int log2_cb_size)
1542 int cb_size = 1 << log2_cb_size;
1543 int log2_min_pu_size =
sps->log2_min_pu_size;
1545 int min_pu_width =
sps->min_pu_width;
1546 int x_end =
FFMIN(x0 + cb_size,
sps->width);
1547 int y_end =
FFMIN(y0 + cb_size,
sps->height);
1550 for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
1551 for (
i = (x0 >> log2_min_pu_size);
i < (x_end >> log2_min_pu_size);
i++)
1552 is_pcm[
i + j * min_pu_width] = 2;
1559 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1560 int log2_cb_size,
int log2_trafo_size,
1561 int trafo_depth,
int blk_idx,
1562 const int *base_cbf_cb,
const int *base_cbf_cr)
1564 uint8_t split_transform_flag;
1569 cbf_cb[0] = base_cbf_cb[0];
1570 cbf_cb[1] = base_cbf_cb[1];
1571 cbf_cr[0] = base_cbf_cr[0];
1572 cbf_cr[1] = base_cbf_cr[1];
1575 if (trafo_depth == 1) {
1577 if (
sps->chroma_format_idc == 3) {
1591 if (log2_trafo_size <= sps->log2_max_trafo_size &&
1592 log2_trafo_size >
sps->log2_min_tb_size &&
1593 trafo_depth < lc->cu.max_trafo_depth &&
1597 int inter_split =
sps->max_transform_hierarchy_depth_inter == 0 &&
1602 split_transform_flag = log2_trafo_size >
sps->log2_max_trafo_size ||
1607 if (
sps->chroma_format_idc && (log2_trafo_size > 2 ||
sps->chroma_format_idc == 3)) {
1608 if (trafo_depth == 0 || cbf_cb[0]) {
1610 if (
sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
1615 if (trafo_depth == 0 || cbf_cr[0]) {
1617 if (
sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
1623 if (split_transform_flag) {
1624 const int trafo_size_split = 1 << (log2_trafo_size - 1);
1625 const int x1 = x0 + trafo_size_split;
1626 const int y1 = y0 + trafo_size_split;
1628#define SUBDIVIDE(x, y, idx) \
1630 ret = hls_transform_tree(lc, l, pps, sps, \
1631 x, y, x0, y0, cb_xBase, cb_yBase, log2_cb_size, \
1632 log2_trafo_size - 1, trafo_depth + 1, idx, \
1645 int min_tu_size = 1 <<
sps->log2_min_tb_size;
1646 int log2_min_tu_size =
sps->log2_min_tb_size;
1647 int min_tu_width =
sps->min_tb_width;
1651 cbf_cb[0] || cbf_cr[0] ||
1652 (
sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
1657 x0, y0, xBase, yBase, cb_xBase, cb_yBase,
1658 log2_cb_size, log2_trafo_size,
1659 blk_idx, cbf_luma, cbf_cb, cbf_cr);
1665 for (
i = 0;
i < (1 << log2_trafo_size);
i += min_tu_size)
1666 for (j = 0; j < (1 << log2_trafo_size); j += min_tu_size) {
1667 int x_tu = (x0 + j) >> log2_min_tu_size;
1668 int y_tu = (y0 +
i) >> log2_min_tu_size;
1669 l->
cbf_luma[y_tu * min_tu_width + x_tu] = 1;
1674 if (
pps->transquant_bypass_enable_flag &&
1683 const HEVCPPS *
pps,
int x0,
int y0,
int log2_cb_size)
1688 int cb_size = 1 << log2_cb_size;
1689 ptrdiff_t stride0 =
s->cur_frame->f->linesize[0];
1690 uint8_t *dst0 = &
s->cur_frame->f->data[0][y0 * stride0 + (x0 <<
sps->pixel_shift)];
1692 int length = cb_size * cb_size *
sps->pcm.bit_depth + (
sps->chroma_format_idc != 0 ?
1693 (((cb_size >>
sps->hshift[1]) * (cb_size >>
sps->vshift[1])) +
1694 ((cb_size >>
sps->hshift[2]) * (cb_size >>
sps->vshift[2]))) *
1695 sps->pcm.bit_depth_chroma : 0);
1706 s->hevcdsp.put_pcm(dst0, stride0, cb_size, cb_size, &gb,
sps->pcm.bit_depth);
1707 if (
sps->chroma_format_idc) {
1708 ptrdiff_t stride1 =
s->cur_frame->f->linesize[1];
1709 ptrdiff_t stride2 =
s->cur_frame->f->linesize[2];
1710 uint8_t *dst1 = &
s->cur_frame->f->data[1][(y0 >>
sps->vshift[1]) * stride1 + ((x0 >>
sps->hshift[1]) <<
sps->pixel_shift)];
1711 uint8_t *dst2 = &
s->cur_frame->f->data[2][(y0 >>
sps->vshift[2]) * stride2 + ((x0 >>
sps->hshift[2]) <<
sps->pixel_shift)];
1713 s->hevcdsp.put_pcm(dst1, stride1,
1714 cb_size >>
sps->hshift[1],
1715 cb_size >>
sps->vshift[1],
1716 &gb,
sps->pcm.bit_depth_chroma);
1717 s->hevcdsp.put_pcm(dst2, stride2,
1718 cb_size >>
sps->hshift[2],
1719 cb_size >>
sps->vshift[2],
1720 &gb,
sps->pcm.bit_depth_chroma);
1744 uint8_t *
dst, ptrdiff_t dststride,
1746 int block_w,
int block_h,
int luma_weight,
int luma_offset)
1749 const uint8_t *
src =
ref->data[0];
1751 int pic_width =
sps->width;
1752 int pic_height =
sps->height;
1759 x_off +=
mv->x >> 2;
1760 y_off +=
mv->y >> 2;
1766 ref ==
s->cur_frame->f) {
1776 pic_width, pic_height);
1783 block_h,
mx,
my, block_w);
1787 luma_weight, luma_offset,
mx,
my, block_w);
1808 uint8_t *
dst, ptrdiff_t dststride,
1809 const AVFrame *ref0,
const Mv *mv0,
int x_off,
int y_off,
1810 int block_w,
int block_h,
const AVFrame *ref1,
1811 const Mv *mv1,
struct MvField *current_mv)
1814 ptrdiff_t src0stride = ref0->
linesize[0];
1815 ptrdiff_t src1stride = ref1->
linesize[0];
1816 int pic_width =
sps->width;
1817 int pic_height =
sps->height;
1818 int mx0 = mv0->
x & 3;
1819 int my0 = mv0->
y & 3;
1820 int mx1 = mv1->
x & 3;
1821 int my1 = mv1->
y & 3;
1824 int x_off0 = x_off + (mv0->
x >> 2);
1825 int y_off0 = y_off + (mv0->
y >> 2);
1826 int x_off1 = x_off + (mv1->
x >> 2);
1827 int y_off1 = y_off + (mv1->
y >> 2);
1830 const uint8_t *
src0 = ref0->
data[0] + y_off0 * src0stride + (int)((
unsigned)x_off0 <<
sps->pixel_shift);
1831 const uint8_t *
src1 = ref1->
data[0] + y_off1 * src1stride + (int)((
unsigned)x_off1 <<
sps->pixel_shift);
1841 edge_emu_stride, src0stride,
1845 pic_width, pic_height);
1847 src0stride = edge_emu_stride;
1858 edge_emu_stride, src1stride,
1862 pic_width, pic_height);
1864 src1stride = edge_emu_stride;
1867 s->hevcdsp.put_hevc_qpel[idx][!!my0][!!mx0](lc->
tmp,
src0, src0stride,
1868 block_h, mx0, my0, block_w);
1870 s->hevcdsp.put_hevc_qpel_bi[idx][!!my1][!!mx1](
dst, dststride,
src1, src1stride, lc->
tmp,
1871 block_h, mx1, my1, block_w);
1873 s->hevcdsp.put_hevc_qpel_bi_w[idx][!!my1][!!mx1](
dst, dststride,
src1, src1stride, lc->
tmp,
1903 ptrdiff_t dststride,
const uint8_t *
src0, ptrdiff_t
srcstride,
int reflist,
1904 int x_off,
int y_off,
int block_w,
int block_h,
1905 const struct MvField *current_mv,
int chroma_weight,
int chroma_offset)
1908 int pic_width =
sps->width >>
sps->hshift[1];
1909 int pic_height =
sps->height >>
sps->vshift[1];
1910 const Mv *
mv = ¤t_mv->
mv[reflist];
1914 int hshift =
sps->hshift[1];
1915 int vshift =
sps->vshift[1];
1918 intptr_t _mx =
mx << (1 - hshift);
1919 intptr_t _my =
my << (1 - vshift);
1920 int emu =
src0 ==
s->cur_frame->f->data[1] ||
src0 ==
s->cur_frame->f->data[2];
1922 x_off +=
mv->x >> (2 + hshift);
1923 y_off +=
mv->y >> (2 + vshift);
1933 (edge_emu_stride + (1 <<
sps->pixel_shift));
1939 pic_width, pic_height);
1946 block_h, _mx, _my, block_w);
1950 chroma_weight, chroma_offset, _mx, _my, block_w);
1972 uint8_t *dst0, ptrdiff_t dststride,
1974 int x_off,
int y_off,
int block_w,
int block_h,
const MvField *current_mv,
int cidx)
1977 const uint8_t *
src1 = ref0->
data[cidx+1];
1978 const uint8_t *
src2 = ref1->
data[cidx+1];
1979 ptrdiff_t src1stride = ref0->
linesize[cidx+1];
1980 ptrdiff_t src2stride = ref1->
linesize[cidx+1];
1983 int pic_width =
sps->width >>
sps->hshift[1];
1984 int pic_height =
sps->height >>
sps->vshift[1];
1985 const Mv *
const mv0 = ¤t_mv->
mv[0];
1986 const Mv *
const mv1 = ¤t_mv->
mv[1];
1987 int hshift =
sps->hshift[1];
1988 int vshift =
sps->vshift[1];
1994 intptr_t _mx0 = mx0 << (1 - hshift);
1995 intptr_t _my0 = my0 << (1 - vshift);
1996 intptr_t _mx1 = mx1 << (1 - hshift);
1997 intptr_t _my1 = my1 << (1 - vshift);
1999 int x_off0 = x_off + (mv0->
x >> (2 + hshift));
2000 int y_off0 = y_off + (mv0->
y >> (2 + vshift));
2001 int x_off1 = x_off + (mv1->
x >> (2 + hshift));
2002 int y_off1 = y_off + (mv1->
y >> (2 + vshift));
2004 src1 += y_off0 * src1stride + (int)((
unsigned)x_off0 <<
sps->pixel_shift);
2005 src2 += y_off1 * src2stride + (int)((
unsigned)x_off1 <<
sps->pixel_shift);
2013 (edge_emu_stride + (1 <<
sps->pixel_shift));
2016 edge_emu_stride, src1stride,
2020 pic_width, pic_height);
2023 src1stride = edge_emu_stride;
2032 (edge_emu_stride + (1 <<
sps->pixel_shift));
2035 edge_emu_stride, src2stride,
2039 pic_width, pic_height);
2042 src2stride = edge_emu_stride;
2045 s->hevcdsp.put_hevc_epel[idx][!!my0][!!mx0](lc->
tmp,
src1, src1stride,
2046 block_h, _mx0, _my0, block_w);
2048 s->hevcdsp.put_hevc_epel_bi[idx][!!my1][!!mx1](dst0,
s->cur_frame->f->linesize[cidx+1],
2050 block_h, _mx1, _my1, block_w);
2052 s->hevcdsp.put_hevc_epel_bi_w[idx][!!my1][!!mx1](dst0,
s->cur_frame->f->linesize[cidx+1],
2060 _mx1, _my1, block_w);
2075 int x0,
int y0,
int nPbW,
2076 int nPbH,
int log2_cb_size,
int part_idx,
2087 if (inter_pred_idc !=
PRED_L1) {
2095 part_idx, merge_idx,
mv, mvp_flag, 0);
2100 if (inter_pred_idc !=
PRED_L0) {
2113 part_idx, merge_idx,
mv, mvp_flag, 1);
2122 int x0,
int y0,
int nPbW,
int nPbH,
2123 int log2_cb_size,
int partIdx,
int idx)
2125#define POS(c_idx, x, y) \
2126 s->cur_frame->f->data[c_idx] ? \
2127 &s->cur_frame->f->data[c_idx][((y) >> sps->vshift[c_idx]) * linesize[c_idx] + \
2128 (((x) >> sps->hshift[c_idx]) << sps->pixel_shift)] : NULL
2131 struct MvField current_mv = {{{ 0 }}};
2133 int min_pu_width =
sps->min_pu_width;
2135 MvField *tab_mvf =
s->cur_frame->tab_mvf;
2138 const int *linesize =
s->cur_frame->f->linesize;
2139 uint8_t *dst0 =
s->cur_frame->f->data[0] + y0 * linesize[0] + (x0 <<
sps->pixel_shift);
2140 uint8_t *dst1 =
POS(1, x0, y0);
2141 uint8_t *dst2 =
POS(2, x0, y0);
2142 int log2_min_cb_size =
sps->log2_min_cb_size;
2143 int min_cb_width =
sps->min_cb_width;
2144 int x_cb = x0 >> log2_min_cb_size;
2145 int y_cb = y0 >> log2_min_cb_size;
2161 partIdx, merge_idx, ¤t_mv);
2164 partIdx, merge_idx, ¤t_mv);
2167 x_pu = x0 >>
sps->log2_min_pu_size;
2168 y_pu = y0 >>
sps->log2_min_pu_size;
2170 for (j = 0; j < nPbH >>
sps->log2_min_pu_size; j++)
2172 tab_mvf[(y_pu + j) * min_pu_width + x_pu +
i] = current_mv;
2175 ref0 = refPicList[0].
ref[current_mv.
ref_idx[0]];
2176 if (!ref0 || !ref0->
f)
2181 ref1 = refPicList[1].
ref[current_mv.
ref_idx[1]];
2182 if (!ref1 || !ref1->f)
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[0], x0, y0, nPbW, nPbH,
2198 if (
sps->chroma_format_idc) {
2200 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2203 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2207 int x0_c = x0 >>
sps->hshift[1];
2208 int y0_c = y0 >>
sps->vshift[1];
2209 int nPbW_c = nPbW >>
sps->hshift[1];
2210 int nPbH_c = nPbH >>
sps->vshift[1];
2213 ¤t_mv.
mv[1], x0, y0, nPbW, nPbH,
2217 if (
sps->chroma_format_idc) {
2219 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2223 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2227 int x0_c = x0 >>
sps->hshift[1];
2228 int y0_c = y0 >>
sps->vshift[1];
2229 int nPbW_c = nPbW >>
sps->hshift[1];
2230 int nPbH_c = nPbH >>
sps->vshift[1];
2233 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
2234 ref1->f, ¤t_mv.
mv[1], ¤t_mv);
2236 if (
sps->chroma_format_idc) {
2238 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0);
2241 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 1);
2251 int x0,
int y0,
int pu_size,
2252 int prev_intra_luma_pred_flag)
2255 int x_pu = x0 >>
sps->log2_min_pu_size;
2256 int y_pu = y0 >>
sps->log2_min_pu_size;
2257 int min_pu_width =
sps->min_pu_width;
2258 int size_in_pus = pu_size >>
sps->log2_min_pu_size;
2267 int y_ctb = (y0 >> (
sps->log2_ctb_size)) << (
sps->log2_ctb_size);
2269 MvField *tab_mvf =
s->cur_frame->tab_mvf;
2270 int intra_pred_mode;
2275 if ((y0 - 1) < y_ctb)
2278 if (cand_left == cand_up) {
2279 if (cand_left < 2) {
2284 candidate[0] = cand_left;
2285 candidate[1] = 2 + ((cand_left - 2 - 1 + 32) & 31);
2286 candidate[2] = 2 + ((cand_left - 2 + 1) & 31);
2289 candidate[0] = cand_left;
2290 candidate[1] = cand_up;
2300 if (prev_intra_luma_pred_flag) {
2301 intra_pred_mode = candidate[lc->
pu.
mpm_idx];
2303 if (candidate[0] > candidate[1])
2304 FFSWAP(uint8_t, candidate[0], candidate[1]);
2305 if (candidate[0] > candidate[2])
2306 FFSWAP(uint8_t, candidate[0], candidate[2]);
2307 if (candidate[1] > candidate[2])
2308 FFSWAP(uint8_t, candidate[1], candidate[2]);
2311 for (
i = 0;
i < 3;
i++)
2312 if (intra_pred_mode >= candidate[
i])
2319 for (
i = 0;
i < size_in_pus;
i++) {
2320 memset(&l->
tab_ipm[(y_pu +
i) * min_pu_width + x_pu],
2321 intra_pred_mode, size_in_pus);
2323 for (j = 0; j < size_in_pus; j++) {
2328 return intra_pred_mode;
2333 int log2_cb_size,
int ct_depth)
2335 int length = (1 << log2_cb_size) >>
sps->log2_min_cb_size;
2336 int x_cb = x0 >>
sps->log2_min_cb_size;
2337 int y_cb = y0 >>
sps->log2_min_cb_size;
2340 for (y = 0; y < length; y++)
2341 memset(&tab_ct_depth[(y_cb + y) *
sps->min_cb_width + x_cb],
2346 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20,
2347 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31};
2354 static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 };
2355 uint8_t prev_intra_luma_pred_flag[4];
2357 int pb_size = (1 << log2_cb_size) >>
split;
2358 int side =
split + 1;
2362 for (
i = 0;
i < side;
i++)
2363 for (j = 0; j < side; j++)
2366 for (
i = 0;
i < side;
i++) {
2367 for (j = 0; j < side; j++) {
2368 if (prev_intra_luma_pred_flag[2 *
i + j])
2375 x0 + pb_size * j, y0 + pb_size *
i, pb_size,
2376 prev_intra_luma_pred_flag[2 *
i + j]);
2380 if (
sps->chroma_format_idc == 3) {
2381 for (
i = 0;
i < side;
i++) {
2382 for (j = 0; j < side; j++) {
2384 if (chroma_mode != 4) {
2394 }
else if (
sps->chroma_format_idc == 2) {
2397 if (chroma_mode != 4) {
2401 mode_idx = intra_chroma_table[chroma_mode];
2406 }
else if (
sps->chroma_format_idc != 0) {
2408 if (chroma_mode != 4) {
2426 int pb_size = 1 << log2_cb_size;
2427 int size_in_pus = pb_size >>
sps->log2_min_pu_size;
2428 int min_pu_width =
sps->min_pu_width;
2429 MvField *tab_mvf =
s->cur_frame->tab_mvf;
2430 int x_pu = x0 >>
sps->log2_min_pu_size;
2431 int y_pu = y0 >>
sps->log2_min_pu_size;
2434 if (size_in_pus == 0)
2436 for (j = 0; j < size_in_pus; j++)
2437 memset(&l->
tab_ipm[(y_pu + j) * min_pu_width + x_pu],
INTRA_DC, size_in_pus);
2439 for (j = 0; j < size_in_pus; j++)
2440 for (k = 0; k < size_in_pus; k++)
2447 int x0,
int y0,
int log2_cb_size)
2449 int cb_size = 1 << log2_cb_size;
2450 int log2_min_cb_size =
sps->log2_min_cb_size;
2451 int length = cb_size >> log2_min_cb_size;
2452 int min_cb_width =
sps->min_cb_width;
2453 int x_cb = x0 >> log2_min_cb_size;
2454 int y_cb = y0 >> log2_min_cb_size;
2455 int idx = log2_cb_size - 2;
2456 int qp_block_mask = (1 << (
sps->log2_ctb_size -
pps->diff_cu_qp_delta_depth)) - 1;
2466 for (x = 0; x < 4; x++)
2468 if (
pps->transquant_bypass_enable_flag) {
2479 x0b, y0b, x_cb, y_cb,
2482 x = y_cb * min_cb_width + x_cb;
2483 for (y = 0; y < length; y++) {
2484 memset(&l->
skip_flag[x], skip_flag, length);
2489 x = y_cb * min_cb_width + x_cb;
2490 for (y = 0; y < length; y++) {
2498 x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
2509 log2_cb_size ==
sps->log2_min_cb_size) {
2517 log2_cb_size >=
sps->pcm.log2_min_pcm_cb_size &&
2518 log2_cb_size <= sps->pcm.log2_max_pcm_cb_size) {
2524 if (
sps->pcm_loop_filter_disabled)
2537 x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
2541 x0, y0, cb_size, cb_size / 2, log2_cb_size, 0, idx);
2543 x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx);
2547 x0, y0, cb_size / 2, cb_size, log2_cb_size, 0, idx - 1);
2549 x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);
2553 x0, y0, cb_size, cb_size / 4, log2_cb_size, 0, idx);
2555 x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);
2559 x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0, idx);
2561 x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx);
2565 x0, y0, cb_size / 4, cb_size, log2_cb_size, 0, idx - 2);
2567 x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
2571 x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0, idx - 2);
2573 x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
2577 x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0, idx - 1);
2579 x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
2581 x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
2583 x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
2589 int rqt_root_cbf = 1;
2596 const static int cbf[2] = { 0 };
2599 sps->max_transform_hierarchy_depth_inter;
2600 ret =
hls_transform_tree(lc, l,
pps,
sps, x0, y0, x0, y0, x0, y0,
2602 log2_cb_size, 0, 0, cbf, cbf);
2615 x = y_cb * min_cb_width + x_cb;
2616 for (y = 0; y < length; y++) {
2621 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2622 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0) {
2635 int log2_cb_size,
int cb_depth)
2638 const int cb_size = 1 << log2_cb_size;
2643 if (x0 + cb_size <= sps->
width &&
2644 y0 + cb_size <= sps->
height &&
2645 log2_cb_size >
sps->log2_min_cb_size) {
2647 sps, cb_depth, x0, y0);
2649 split_cu = (log2_cb_size >
sps->log2_min_cb_size);
2651 if (
pps->cu_qp_delta_enabled_flag &&
2652 log2_cb_size >=
sps->log2_ctb_size -
pps->diff_cu_qp_delta_depth) {
2658 log2_cb_size >=
sps->log2_ctb_size -
pps->diff_cu_chroma_qp_offset_depth) {
2663 int qp_block_mask = (1 << (
sps->log2_ctb_size -
pps->diff_cu_qp_delta_depth)) - 1;
2664 const int cb_size_split = cb_size >> 1;
2665 const int x1 = x0 + cb_size_split;
2666 const int y1 = y0 + cb_size_split;
2671 x0, y0, log2_cb_size - 1, cb_depth + 1);
2675 if (more_data && x1 < sps->
width) {
2677 x1, y0, log2_cb_size - 1, cb_depth + 1);
2681 if (more_data && y1 < sps->
height) {
2683 x0, y1, log2_cb_size - 1, cb_depth + 1);
2687 if (more_data && x1 < sps->
width &&
2690 x1, y1, log2_cb_size - 1, cb_depth + 1);
2695 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2696 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0)
2700 return ((x1 + cb_size_split) <
sps->width ||
2701 (y1 + cb_size_split) <
sps->height);
2708 if ((!((x0 + cb_size) %
2709 (1 << (
sps->log2_ctb_size))) ||
2710 (x0 + cb_size >=
sps->width)) &&
2712 (1 << (
sps->log2_ctb_size))) ||
2713 (y0 + cb_size >=
sps->height))) {
2715 return !end_of_slice_flag;
2727 int x_ctb,
int y_ctb,
int ctb_addr_ts)
2729 int ctb_size = 1 <<
sps->log2_ctb_size;
2730 int ctb_addr_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2731 int ctb_addr_in_slice = ctb_addr_rs - lc->
sh->
slice_addr;
2737 if (
pps->entropy_coding_sync_enabled_flag) {
2738 if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
2741 }
else if (
pps->tiles_enabled_flag) {
2742 if (ctb_addr_ts &&
pps->tile_id[ctb_addr_ts] !=
pps->tile_id[ctb_addr_ts - 1]) {
2743 int idxX =
pps->col_idxX[x_ctb >>
sps->log2_ctb_size];
2754 if (
pps->tiles_enabled_flag) {
2755 if (x_ctb > 0 &&
pps->tile_id[ctb_addr_ts] !=
pps->tile_id[
pps->ctb_addr_rs_to_ts[ctb_addr_rs - 1]])
2759 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]])
2764 if (ctb_addr_in_slice <= 0)
2766 if (ctb_addr_in_slice < sps->ctb_width)
2772 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]]));
2773 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]]));
2782 const int ctb_addr_ts =
pps->ctb_addr_rs_to_ts[ctb_addr_rs];
2783 const int x_ctb = (ctb_addr_rs %
sps->ctb_width) <<
sps->log2_ctb_size;
2784 const int y_ctb = (ctb_addr_rs /
sps->ctb_width) <<
sps->log2_ctb_size;
2794 ctb_addr_rs %
sps->ctb_width, ctb_addr_rs /
sps->ctb_width);
2818 const int ctb_size = 1 <<
sps->log2_ctb_size;
2819 const int x_ctb = (ctb_addr_rs %
sps->ctb_width) <<
sps->log2_ctb_size;
2820 const int y_ctb = (ctb_addr_rs /
sps->ctb_width) <<
sps->log2_ctb_size;
2835 int ctb_size = 1 <<
sps->log2_ctb_size;
2847 while (more_data && ctb_addr_ts < sps->ctb_size) {
2848 int ctb_addr_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2850 x_ctb = (ctb_addr_rs % ((
sps->width + ctb_size - 1) >>
sps->log2_ctb_size)) <<
sps->log2_ctb_size;
2851 y_ctb = (ctb_addr_rs / ((
sps->width + ctb_size - 1) >>
sps->log2_ctb_size)) <<
sps->log2_ctb_size;
2861 if (x_ctb + ctb_size >=
sps->width &&
2862 y_ctb + ctb_size >=
sps->height)
2885 int job,
int thread)
2892 int ctb_size = 1 <<
sps->log2_ctb_size;
2896 int ctb_addr_ts =
pps->ctb_addr_rs_to_ts[ctb_addr_rs];
2911 while(more_data && ctb_addr_ts < sps->ctb_size) {
2912 int x_ctb = (ctb_addr_rs %
sps->ctb_width) <<
sps->log2_ctb_size;
2913 int y_ctb = (ctb_addr_rs /
sps->ctb_width) <<
sps->log2_ctb_size;
2933 x_ctb >>
sps->log2_ctb_size, y_ctb >>
sps->log2_ctb_size);
2941 if (more_data < 0) {
2959 if ((x_ctb+ctb_size) >=
sps->width && (y_ctb+ctb_size) >=
sps->height ) {
2964 ctb_addr_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2967 if(x_ctb >=
sps->width) {
2984 if (
s->nb_wpp_progress < count) {
2986 sizeof(*
s->wpp_progress));
2990 s->wpp_progress =
tmp;
2991 memset(
s->wpp_progress +
s->nb_wpp_progress, 0,
2992 (count -
s->nb_wpp_progress) *
sizeof(*
s->wpp_progress));
2994 for (
int i =
s->nb_wpp_progress;
i < count;
i++) {
2998 s->nb_wpp_progress =
i + 1;
3002 for (
int i = 0;
i < count;
i++)
3012 if (
s->avctx->thread_count <=
s->nb_local_ctx)
3019 memcpy(
tmp,
s->local_ctx,
sizeof(*
s->local_ctx) *
s->nb_local_ctx);
3023 for (
unsigned i =
s->nb_local_ctx;
i < s->avctx->thread_count;
i++) {
3024 tmp = &
s->local_ctx[
i];
3026 memset(
tmp, 0,
sizeof(*
tmp));
3028 tmp->logctx =
s->avctx;
3030 tmp->common_cabac_state = &
s->cabac;
3033 s->nb_local_ctx =
s->avctx->thread_count;
3045 for (j = 0, cmpt = 0, startheader =
offset +
s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) {
3046 if (
nal->skipped_bytes_pos[j] >=
offset &&
nal->skipped_bytes_pos[j] < startheader) {
3052 for (
int i = 1;
i <
s->sh.num_entry_point_offsets;
i++) {
3053 offset += (
s->sh.entry_point_offset[
i - 1] - cmpt);
3054 for (j = 0, cmpt = 0, startheader =
offset
3055 +
s->sh.entry_point_offset[
i]; j < nal->skipped_bytes; j++) {
3056 if (
nal->skipped_bytes_pos[j] >=
offset &&
nal->skipped_bytes_pos[j] < startheader) {
3061 s->sh.size[
i] =
s->sh.entry_point_offset[
i] - cmpt;
3066 offset +=
s->sh.entry_point_offset[
s->sh.num_entry_point_offsets - 1] - cmpt;
3071 s->sh.size [
s->sh.num_entry_point_offsets] =
nal->size -
offset;
3072 s->sh.offset[
s->sh.num_entry_point_offsets] =
offset;
3074 s->sh.offset[0] =
s->sh.data_offset;
3075 s->sh.size[0] =
s->sh.offset[1] -
s->sh.offset[0];
3077 s->data =
nal->data;
3095 sub->
qp_y = qp_y_seed;
3106 const int ctb_size = 1 <<
sps->log2_ctb_size;
3108 if (x_ctb + ctb_size >=
sps->width && y_ctb + ctb_size >=
sps->height)
3114 if (!
s->tile_interleave || !
pps || !
pps->tiles_enabled_flag ||
3115 pps->entropy_coding_sync_enabled_flag ||
pps->num_tile_columns <= 1)
3118 if (
s->tile_interleave < 0 && !(
s->avctx->active_thread_type &
FF_THREAD_FRAME))
3121 return pps->num_tile_columns *
pps->num_tile_rows > 1;
3128 !
pps->tiles_enabled_flag &&
3129 !
pps->entropy_coding_sync_enabled_flag &&
3130 !
pps->constrained_intra_pred_flag &&
3131 !
pps->pps_scc_extension_flag;
3136 if (n >
s->tile_streams_alloc) {
3142 s->tile_streams =
tmp;
3143 s->tile_streams_alloc = n;
3146 memset(
s->tile_streams, 0, n *
sizeof(*
s->tile_streams));
3153 if (n >
s->tile_segments_alloc) {
3159 s->tile_segments =
tmp;
3160 s->tile_segments_alloc = n;
3168 if (n >
s->nb_substreams) {
3174 memset(
tmp +
s->nb_substreams, 0,
3175 (n -
s->nb_substreams) *
sizeof(*
tmp));
3177 s->substreams =
tmp;
3178 s->nb_substreams = n;
3196 int last_ctb_decoded = 0;
3199 for (
int rs = 0; rs <
sps->ctb_size; rs++) {
3200 const int ts =
pps->ctb_addr_rs_to_ts[rs];
3201 const int tile =
pps->tile_id[ts];
3205 s->tile_segments[t->
next_seg].start_ts == ts;
3233 if (rs ==
sps->ctb_size - 1)
3234 last_ctb_decoded = 1;
3241 if (last_ctb_decoded)
3243 (
sps->ctb_width - 1) <<
sps->log2_ctb_size,
3244 (
sps->ctb_height - 1) <<
sps->log2_ctb_size);
3255 const int nb_tiles =
pps->num_tile_columns *
pps->num_tile_rows;
3274 for (
int i = 0;
i < nb_tiles;
i++) {
3276 const int start_ts =
pps->ctb_addr_rs_to_ts[
pps->tile_pos_rs[
i]];
3278 if (
s->sh.size[
i] <= 0 ||
pps->tile_id[start_ts] !=
i)
3282 seg->
rpl =
s->cur_frame->refPicList;
3284 seg->
data =
s->data +
s->sh.offset[
i];
3285 seg->
size =
s->sh.size[
i];
3291 s->tile_streams[
i].next_seg =
i;
3292 s->tile_streams[
i].end_seg =
i + 1;
3299 return sps->ctb_size;
3304 const uint8_t **
data,
size_t *
size)
3324 if (
s->sh.num_entry_point_offsets != 0 ||
3325 s->sh.dependent_slice_segment_flag ||
3326 s->cur_layer != 0 ||
3331 if (
s->nb_tile_slices &&
s->cur_frame !=
s->tile_slices_frame)
3340 start_ts =
pps->ctb_addr_rs_to_ts[
s->sh.slice_ctb_addr_rs];
3342 if (start_ts < 0 || start_ts >=
pps->sps->ctb_size)
3359 start_ts =
pps->ctb_addr_rs_to_ts[
s->sh.slice_ctb_addr_rs];
3361 if (
s->nb_tile_slices >=
s->tile_slices_alloc) {
3362 unsigned n =
s->tile_slices_alloc ?
s->tile_slices_alloc * 2 : 8;
3368 s->tile_slices =
tmp;
3369 s->tile_slices_alloc = n;
3372 if (!
s->nb_tile_slices) {
3373 s->tile_slices_frame =
s->cur_frame;
3374 s->tile_slices_layer =
s->cur_layer;
3377 sl = &
s->tile_slices[
s->nb_tile_slices++];
3386 sl->
rpl =
s->cur_frame->refPicList;
3407 const unsigned nb_tiles =
pps->num_tile_columns *
pps->num_tile_rows;
3421 for (
unsigned i = 0;
i < nb;
i++) {
3425 const uint8_t *
data;
3437 t = &
s->tile_streams[
tile];
3455 for (
unsigned i = 0;
i < nb_tiles;
i++)
3456 if (!
s->tile_streams[
i].end_seg)
3463 int job,
int thread)
3470 const uint8_t *
data;
3472 int more_data = 1, ts = sl->
start_ts;
3480 while (more_data && ts < sl->end_ts) {
3496 const int ctb_size = 1 <<
sps->log2_ctb_size;
3501 for (
unsigned i = 0;
i < nb;
i++) {
3503 const uint8_t *
data;
3511 if (sl->
start_ts <=
s->tile_slices[
i - 1].start_ts)
3516 s->tile_slices[nb - 1].end_ts =
sps->ctb_size;
3521 lc = &
s->local_ctx[0];
3523 end_ts =
av_calloc(nb,
sizeof(*end_ts));
3529 for (
unsigned i = 0;
i <
s->nb_local_ctx;
i++)
3530 s->local_ctx[
i].slice_bs_defer = 0;
3532 for (
unsigned i = 0;
i < nb;
i++) {
3535 if (end_ts[
i] < 0) {
3542 "Skipping invalid undecodable slice %u\n",
i);
3546 for (
int ts = end_ts[
i]; ts < sl->
end_ts; ts++)
3550 for (
unsigned i = 0;
i < nb;
i++) {
3559 for (
int ts = sl->
start_ts; ts < end_ts[
i]; ts++) {
3560 const int rs =
pps->ctb_addr_ts_to_rs[ts];
3561 const int x_ctb = (rs %
sps->ctb_width) <<
sps->log2_ctb_size;
3562 const int y_ctb = (rs /
sps->ctb_width) <<
sps->log2_ctb_size;
3575 for (
unsigned i = 0;
i < nb;
i++) {
3580 for (
int ts = sl->
start_ts; ts < end_ts[
i]; ts++) {
3581 const int rs =
pps->ctb_addr_ts_to_rs[ts];
3582 const int x_ctb = (rs %
sps->ctb_width) <<
sps->log2_ctb_size;
3583 const int y_ctb = (rs /
sps->ctb_width) <<
sps->log2_ctb_size;
3589 if (end_ts[nb - 1] ==
sps->ctb_size)
3591 (
sps->ctb_width - 1) <<
sps->log2_ctb_size,
3592 (
sps->ctb_height - 1) <<
sps->log2_ctb_size);
3610 const unsigned nb =
s->nb_tile_slices;
3613 s->nb_tile_slices = 0;
3619 if (!
pps || !
sps || !
s->cur_frame ||
s->cur_frame !=
s->tile_slices_frame) {
3621 "Dropping %u deferred tile slice(s) of a stale picture\n", nb);
3628 return ret < 0 ?
ret : 0;
3631 if (picture_complete) {
3645 for (
unsigned i = 0;
i < nb;
i++) {
3648 const uint8_t *
data;
3651 int x_ctb = 0, y_ctb = 0;
3659 for (
int ts = sl->
start_ts; more_data > 0 && ts < sps->ctb_size; ts++) {
3660 int rs =
pps->ctb_addr_ts_to_rs[ts];
3662 x_ctb = (rs %
sps->ctb_width) <<
sps->log2_ctb_size;
3663 y_ctb = (rs /
sps->ctb_width) <<
sps->log2_ctb_size;
3683 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) {
3685 s->sh.slice_ctb_addr_rs,
s->sh.num_entry_point_offsets,
3686 sps->ctb_width,
sps->ctb_height
3699 for (
unsigned i = 1;
i <
s->nb_local_ctx;
i++) {
3700 s->local_ctx[
i].sub.first_qp_group = 1;
3701 s->local_ctx[
i].sub.qp_y =
s->local_ctx[0].sub.qp_y;
3714 if (
pps->entropy_coding_sync_enabled_flag)
3717 for (
int i = 0;
i <=
s->sh.num_entry_point_offsets;
i++)
3725 int job,
int thread)
3733 int ctb_addr_ts =
pps->ctb_addr_rs_to_ts[
pps->row_bd[job /
pps->num_tile_columns] *
sps->ctb_width +
3734 pps->col_bd[job %
pps->num_tile_columns]];
3735 int more_data = 1,
ret;
3748 while (more_data && ctb_addr_ts < sps->ctb_size &&
3749 pps->tile_id[ctb_addr_ts] == job) {
3750 int ctb_addr_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts];
3751 int x_ctb = (ctb_addr_rs %
sps->ctb_width) <<
sps->log2_ctb_size;
3752 int y_ctb = (ctb_addr_rs /
sps->ctb_width) <<
sps->log2_ctb_size;
3761 x_ctb >>
sps->log2_ctb_size, y_ctb >>
sps->log2_ctb_size);
3780 const int ctb_size = 1 <<
sps->log2_ctb_size;
3781 const int nb_tiles =
s->sh.num_entry_point_offsets + 1;
3782 const int start_ts =
pps->ctb_addr_rs_to_ts[
s->sh.slice_ctb_addr_rs];
3783 int res = 0, ctb_addr_ts, x_ctb = 0, y_ctb = 0;
3794 for (
unsigned i = 1;
i <
s->nb_local_ctx;
i++) {
3795 s->local_ctx[
i].sub.first_qp_group = 1;
3796 s->local_ctx[
i].sub.qp_y =
s->local_ctx[0].sub.qp_y;
3800 for (ctb_addr_ts = start_ts; ctb_addr_ts <
sps->ctb_size; ctb_addr_ts++)
3807 for (
int i = 0;
i < nb_tiles;
i++)
3812 for (
unsigned i = 0;
i <
s->nb_local_ctx;
i++)
3813 s->local_ctx[
i].tile_bs_defer = 0;
3818 if (
pps->loop_filter_across_tiles_enabled_flag &&
3819 !
s->sh.disable_deblocking_filter_flag) {
3820 for (ctb_addr_ts = start_ts; ctb_addr_ts <
sps->ctb_size; ctb_addr_ts++) {
3821 int ctb_addr_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts];
3822 x_ctb = (ctb_addr_rs %
sps->ctb_width) <<
sps->log2_ctb_size;
3823 y_ctb = (ctb_addr_rs /
sps->ctb_width) <<
sps->log2_ctb_size;
3831 for (ctb_addr_ts = start_ts; ctb_addr_ts <
sps->ctb_size; ctb_addr_ts++) {
3832 int ctb_addr_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts];
3833 x_ctb = (ctb_addr_rs %
sps->ctb_width) <<
sps->log2_ctb_size;
3834 y_ctb = (ctb_addr_rs /
sps->ctb_width) <<
sps->log2_ctb_size;
3838 if (x_ctb + ctb_size >=
sps->width && y_ctb + ctb_size >=
sps->height)
3841 return sps->ctb_size;
3858 if (!
s->sh.first_slice_in_pic_flag)
3859 s->slice_idx += !
s->sh.dependent_slice_segment_flag;
3861 if (!
s->sh.dependent_slice_segment_flag &&
s->sh.slice_type !=
HEVC_SLICE_I) {
3865 "Error constructing the reference lists for the current slice.\n");
3870 s->slice_initialized = 1;
3872 if (
s->avctx->hwaccel)
3880 "SCC profile is not yet implemented in hevc native decoder.\n");
3884 if (
s->sh.dependent_slice_segment_flag) {
3885 int ctb_addr_ts =
pps->ctb_addr_rs_to_ts[
s->sh.slice_ctb_addr_rs];
3886 int prev_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
3896 s->local_ctx[0].sub.first_qp_group = !
s->sh.dependent_slice_segment_flag;
3898 if (!
pps->cu_qp_delta_enabled_flag)
3899 s->local_ctx[0].sub.qp_y =
s->sh.slice_qp;
3901 s->local_ctx[0].sub.cu_qp_offset_cb = 0;
3902 s->local_ctx[0].sub.cu_qp_offset_cr = 0;
3905 s->sh.num_entry_point_offsets > 0 &&
3906 pps->num_tile_rows == 1 &&
pps->num_tile_columns == 1)
3910 s->sh.num_entry_point_offsets > 0 &&
3911 pps->tiles_enabled_flag &&
3912 !
pps->entropy_coding_sync_enabled_flag &&
3913 !
pps->constrained_intra_pred_flag &&
3914 s->sh.first_slice_in_pic_flag &&
3915 s->sh.num_entry_point_offsets + 1 ==
pps->num_tile_rows *
pps->num_tile_columns)
3920 return ret < 0 ?
ret : 0;
3923 s->sh.first_slice_in_pic_flag &&
3924 !
s->sh.dependent_slice_segment_flag &&
3925 s->sh.num_entry_point_offsets ==
3926 pps->num_tile_columns *
pps->num_tile_rows - 1)
3941 if (
IS_IRAP(
s) &&
s->no_rasl_output_flag) {
3942 if (
s->sei.common.mastering_display.present > 0)
3943 s->sei.common.mastering_display.present--;
3945 if (
s->sei.common.content_light.present > 0)
3946 s->sei.common.content_light.present--;
3951 sps->bit_depth,
sps->bit_depth_chroma,
3952 s->cur_frame->poc );
3956 if (
s->sei.timecode.present) {
3961 sizeof(uint32_t) * 4, &tcside);
3966 tc_sd = (uint32_t*)tcside->
data;
3967 tc_sd[0] =
s->sei.timecode.num_clock_ts;
3969 for (
int i = 0;
i < tc_sd[0];
i++) {
3970 int drop =
s->sei.timecode.cnt_dropped_flag[
i];
3971 int hh =
s->sei.timecode.hours_value[
i];
3972 int mm =
s->sei.timecode.minutes_value[
i];
3973 int ss =
s->sei.timecode.seconds_value[
i];
3974 int ff =
s->sei.timecode.n_frames[
i];
3982 s->sei.timecode.num_clock_ts = 0;
3985 if (
s->sei.common.itut_t35.hdr_plus) {
3995 if (
s->sei.common.itut_t35.hdr_smpte2094_app5) {
4016 if (
s->sei.common.itut_t35.hdr_vivid) {
4019 &
s->sei.common.itut_t35.hdr_vivid,
4031 for (
int i = nal_idx;
i <
s->pkt.nb_nals;
i++) {
4033 const int layer_id =
nal->nuh_layer_id;
4037 !(
s->layers_active_decode & (1 <<
s->vps->layer_idx[layer_id])))
4040 switch (
nal->type) {
4074 return s->temporal_id == 0 &&
4087 const HEVCPPS *
const pps =
s->ps.pps_list[
s->sh.pps_id];
4089 int pic_size_in_ctb = ((
sps->width >>
sps->log2_min_cb_size) + 1) *
4090 ((
sps->height >>
sps->log2_min_cb_size) + 1);
4091 int new_sequence = (l == &
s->layers[0]) &&
4093 int prev_layers_active_decode =
s->layers_active_decode;
4094 int prev_layers_active_output =
s->layers_active_output;
4097 if (
sps->vps !=
s->vps && l != &
s->layers[0]) {
4110 const HEVCSPS *sps_base =
s->layers[0].sps;
4113 if (l != &
s->layers[0]) {
4116 "Access unit starts with a non-base layer frame\n");
4125 !
sps->vui.common.video_signal_type_present_flag)
4138 "Base/non-base layer SPS have unsupported parameter combination\n");
4152 if (l == &
s->layers[0]) {
4168 memset(l->
is_pcm, 0, (
sps->min_pu_width + 1) * (
sps->min_pu_height + 1));
4175 s->first_nal_type =
s->nal_unit_type;
4185 s->sei.recovery_point.has_recovery_poc) {
4187 s->recovery_poc =
s->poc +
s->sei.recovery_point.recovery_poc_cnt;
4188 else if (
s->poc >=
s->recovery_poc)
4194 s->poc_tid0 =
s->poc;
4196 if (
pps->tiles_enabled_flag)
4197 s->local_ctx[0].end_of_tiles_x =
pps->column_width[0] <<
sps->log2_ctb_size;
4201 0, 0,
s->sh.no_output_of_prior_pics_flag);
4209 s->sei.common.alternative_transfer.present = 0;
4226 s->cur_frame->needs_fg = ((
s->sei.common.film_grain_characteristics &&
4227 s->sei.common.film_grain_characteristics->present) ||
4228 s->sei.common.itut_t35.aom_film_grain.enable) &&
4237 if (
s->cur_frame->needs_fg &&
4238 (
s->sei.common.film_grain_characteristics &&
s->sei.common.film_grain_characteristics->present &&
4240 s->cur_frame->f->format) ||
4243 "Unsupported film grain parameters. Ignoring film grain.\n");
4244 s->cur_frame->needs_fg = 0;
4247 if (
s->cur_frame->needs_fg) {
4248 s->cur_frame->frame_grain->format =
s->cur_frame->f->format;
4249 s->cur_frame->frame_grain->width =
s->cur_frame->f->width;
4250 s->cur_frame->frame_grain->height =
s->cur_frame->f->height;
4259 s->cur_frame->f->pict_type = 3 -
s->sh.slice_type;
4262 sps->temporal_layer[
sps->max_sub_layers - 1].num_reorder_pics,
4263 sps->temporal_layer[
sps->max_sub_layers - 1].max_dec_pic_buffering, 0);
4267 if (
s->avctx->hwaccel) {
4279 if (l == &
s->layers[0])
4282 if (nal_idx >=
s->finish_setup_nal_idx)
4291 s->cur_frame =
s->collocated_ref =
NULL;
4298 char msg_buf[4 * (50 + 2 * 2 * 16 )];
4306 pixel_shift =
desc->comp[0].depth > 8;
4311 if (pixel_shift && !
s->checksum_buf) {
4314 frame->linesize[2]));
4315 if (!
s->checksum_buf)
4322 int width =
s->avctx->coded_width;
4323 int height =
s->avctx->coded_height;
4329 for (j = 0; j <
h; j++) {
4333 s->bdsp.bswap16_buf((uint16_t *)
s->checksum_buf,
4334 (
const uint16_t *)
src,
w);
4335 src =
s->checksum_buf;
4342#define MD5_PRI "%016" PRIx64 "%016" PRIx64
4343#define MD5_PRI_ARG(buf) AV_RB64(buf), AV_RB64((const uint8_t*)(buf) + 8)
4345 if (!memcmp(
md5,
s->sei.picture_hash.md5[
i], 16)) {
4347 "plane %d - correct " MD5_PRI "; ",
4351 "mismatching checksum of plane %d - " MD5_PRI " != " MD5_PRI "; ",
4358 "Verifying checksum for frame with POC %d: %s\n",
4370 if (
out->needs_fg) {
4373 switch (fgp->
type) {
4390 if (
s->avctx->hwaccel) {
4394 "hardware accelerator failed to decode picture\n");
4399 s->sei.picture_hash.is_md5) {
4405 s->sei.picture_hash.is_md5 = 0;
4408 l -
s->layers,
s->poc);
4415 const int layer_idx =
s->vps ?
s->vps->layer_idx[
s->nuh_layer_id] : 0;
4422 if (layer_idx < 0 ||
4423 (
s->nuh_layer_id > 0 && !(
s->layers_active_decode & (1 << layer_idx))))
4435 s->slice_initialized = 0;
4444 s->no_rasl_output_flag)) {
4445 if (
s->sh.first_slice_in_pic_flag) {
4446 s->skipping_frame = 1;
4449 s->poc_tid0 =
s->sh.poc;
4453 if (
s->sh.first_slice_in_pic_flag)
4454 s->skipping_frame = 0;
4459 if (
s->nb_tile_slices &&
s->sh.first_slice_in_pic_flag) {
4466 if (
s->cur_layer != layer_idx &&
4467 s->layers[
s->cur_layer].cur_frame &&
4471 s->cur_layer = layer_idx;
4472 l = &
s->layers[
s->cur_layer];
4474 if (
s->sh.first_slice_in_pic_flag) {
4476 av_log(
s->avctx,
AV_LOG_ERROR,
"Two slices reporting being the first in the same frame.\n");
4488 if (
s->nal_unit_type !=
s->first_nal_type) {
4490 "Non-matching NAL types of the VCL NALUs: %d %d\n",
4491 s->first_nal_type,
s->nal_unit_type);
4508 s->nal_unit_type =
nal->type;
4509 s->nuh_layer_id =
nal->nuh_layer_id;
4510 s->temporal_id =
nal->temporal_id;
4519 nal->type,
nal->raw_data,
nal->raw_size);
4524 switch (
s->nal_unit_type) {
4532 nal->nuh_layer_id,
s->apply_defdispwin);
4576 "Skipping NAL unit %d\n",
s->nal_unit_type);
4584 "Skipping invalid undecodable NALU: %d\n",
s->nal_unit_type);
4593 s->sei.recovery_point.has_recovery_poc = 0;
4607 if (!is_slice ||
nal->nuh_layer_id)
4616 sps =
s->ps.pps_list[pps_id]->sps;
4621 if (
vps->nb_layers == 2 &&
vps->layer_id_in_nuh[1] &&
4626 s->avctx->pix_fmt = alpha_fmt;
4635 int eos_at_start = 1;
4636 int params_exported = 0;
4639 s->cur_frame =
s->collocated_ref =
NULL;
4640 s->last_eos =
s->eos;
4642 s->slice_initialized = 0;
4653 if (
s->nb_tile_slices) {
4655 "Discarding %u deferred tile slice(s) left from the previous packet\n",
4657 s->nb_tile_slices = 0;
4663 s->nal_length_size,
s->avctx->codec_id,
flags);
4666 "Error splitting the input into NAL units.\n");
4670 for (
int i = 0;
i <
s->pkt.nb_nals;
i++) {
4693 for (
int i =
s->pkt.nb_nals - 1;
i > 0 ;
i--) {
4695 && !
s->pkt.nals[
i].nuh_layer_id && !
s->pkt.nals[
i].temporal_id) {
4696 rpu_nal = &
s->pkt.nals[
i];
4704 av_log(
s->avctx,
AV_LOG_WARNING,
"Multiple Dolby Vision RPUs found in one AU. Skipping previous.\n");
4715 s->avctx->err_recognition);
4724 for (
int i = 0;
i <
s->pkt.nb_nals;
i++) {
4728 switch (
nal->type) {
4736 if (!
s->layers[0].sps && !params_exported)
4747 "Error parsing NAL unit #%d.\n",
i);
4752 if (params_exported) {
4760 if (
s->nb_tile_slices) {
4788 &
s->nal_length_size,
s->avctx->err_recognition,
4789 s->apply_defdispwin,
s->avctx);
4795 if (first &&
s->ps.sps_list[
i]) {
4834 s->layers_active_output, 0, 0, 0);
4841 s->pkt_dts = avpkt->
dts;
4844 if (sd && sd_size > 0) {
4851 if (sd && sd_size >=
sizeof(
s->dovi_ctx.cfg)) {
4852 int old =
s->dovi_ctx.cfg.dv_profile;
4856 "New DOVI configuration record from input packet (profile %d -> %u).\n",
4857 old,
s->dovi_ctx.cfg.dv_profile);
4881 if (
src->needs_fg) {
4894 dst->nb_rpl_elems =
src->nb_rpl_elems;
4897 dst->ctb_count =
src->ctb_count;
4900 dst->base_layer_frame =
src->base_layer_frame;
4903 src->hwaccel_picture_private);
4937 for (
int i = 0;
i <
s->nb_wpp_progress;
i++)
4967 s->nb_local_ctx = 1;
4969 s->local_ctx[0].parent =
s;
4970 s->local_ctx[0].logctx = avctx;
4971 s->local_ctx[0].common_cabac_state = &
s->cabac;
4974 if (!
s->output_fifo)
4992 s->dovi_ctx.logctx = avctx;
5052 memcmp(
s->view_ids, s0->
view_ids,
sizeof(*
s->view_ids) *
s->nb_view_ids)) {
5098 if (
sei->tdrdi.present) {
5116 for (
int i = 0;
i <
sei->tdrdi.num_ref_displays;
i++) {
5152 s->sei.picture_timing.picture_struct = 0;
5172 if (sd && sd->
size >=
sizeof(
s->dovi_ctx.cfg))
5187 s->nb_tile_slices = 0;
5188 s->tile_slices_frame =
NULL;
5190 s->skipping_frame = 0;
5196#define OFFSET(x) offsetof(HEVCContext, x)
5197#define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
5200 {
"apply_defdispwin",
"Apply default display window from VUI",
OFFSET(apply_defdispwin),
5202 {
"tile_interleave",
"Decode tiled pictures in CTB row order to keep frame threading overlapped "
5203 "(-1: auto, 0: off, 1: force)",
OFFSET(tile_interleave),
5205 {
"strict-displaywin",
"strictly apply default display window size",
OFFSET(apply_defdispwin),
5207 {
"view_ids",
"Array of view IDs that should be decoded and output; a single -1 to decode all views",
5209 .min = -1, .max = INT_MAX, .flags =
PAR },
5210 {
"view_ids_available",
"Array of available view IDs is exported here",
5213 {
"view_pos_available",
"Array of view positions for view_ids_available is exported here, as AVStereo3DView",
5224 .class_name =
"HEVC decoder",
5250#if CONFIG_HEVC_DXVA2_HWACCEL
5253#if CONFIG_HEVC_D3D11VA_HWACCEL
5256#if CONFIG_HEVC_D3D11VA2_HWACCEL
5259#if CONFIG_HEVC_D3D12VA_HWACCEL
5262#if CONFIG_HEVC_NVDEC_HWACCEL
5265#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
5268#if CONFIG_HEVC_VAAPI_HWACCEL
5271#if CONFIG_HEVC_VDPAU_HWACCEL
5274#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
5277#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.
static struct AVMD5 * md5
#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.
static int FUNC tile(CodedBitstreamContext *ctx, RWContext *rw, APVRawTile *current, int tile_idx, uint32_t tile_size)
#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 FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters if all frames are skipped due to the skip_frame setting...
#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_drain(AVContainerFifo *cf, size_t nb_elems)
Discard the specified number of elements from the FIFO.
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.
static int ff_decode_skip_all_pixels(const AVCodecContext *avctx)
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)
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 void skip_bits1(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 unsigned int show_bits1(GetBitContext *s)
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_cabac_init(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_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_ctb_edge_bs(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x0, int y0, unsigned edges)
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 alloc_substreams(HEVCContext *s, unsigned n)
static int setup_multilayer(HEVCContext *s, const HEVCVPS *vps)
static void substream_load(HEVCSubstream *sub, const uint8_t *data, size_t size, int qp_y_seed)
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_ctb_data(const HEVCContext *s, const HEVCLayerContext *l, HEVCLocalContext *lc, int ctb_addr_rs)
static int decode_tiles_row_major(HEVCContext *s, const HEVCLayerContext *l, HEVCTileStream *tiles)
static void finish_last_ctb_filter(HEVCContext *s, const HEVCLayerContext *l, HEVCLocalContext *lc, int x_ctb, int y_ctb)
static int export_stream_params_from_slice(HEVCContext *s, const H2645NAL *nal)
static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
static av_cold int hevc_decode_init(AVCodecContext *avctx)
static void bind_slice_ctx(HEVCLocalContext *lc, const SliceHeader *sh, const RefPicList *rpl, const HEVCFrame *collocated_ref)
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 int slice_threads_wanted(const HEVCContext *s, const HEVCPPS *pps)
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 decode_ctb(HEVCContext *s, const HEVCLayerContext *l, HEVCLocalContext *lc, int ctb_addr_rs)
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 slice_is_deferrable(const 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 int alloc_tile_segments(HEVCContext *s, unsigned n)
static int alloc_tile_streams(HEVCContext *s, unsigned n)
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
static int alloc_local_ctxs(HEVCContext *s)
#define SET_SAO(elem, value)
static int tile_interleave_wanted(const HEVCContext *s, const HEVCPPS *pps)
static int tile_slice_payload(const HEVCTileSlice *sl, const uint8_t **data, size_t *size)
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 slice_substreams_init(HEVCContext *s, const H2645NAL *nal)
static int hevc_ref_frame(HEVCFrame *dst, const HEVCFrame *src)
static int is_prev_tid0_pic(const HEVCContext *s)
static int hls_decode_entry_slice(AVCodecContext *avctx, void *hevc_lclist, int job, int thread)
static int build_tile_streams(HEVCContext *s, unsigned nb)
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)
int ff_hevc_requested_layers(const HEVCContext *s, const HEVCVPS *vps, unsigned *active_output)
Resolve the caller's view selection into layers.
static int defer_tile_slice(HEVCContext *s, const H2645NAL *nal)
static int decode_lt_rps(const HEVCSPS *sps, LongTermRPS *rps, GetBitContext *gb, int cur_poc, int poc_lsb)
static int hls_decode_entry_tiles(HEVCContext *s, const H2645NAL *nal)
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 bind_current_slice(HEVCContext *s, HEVCLocalContext *lc)
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 int decode_slices_parallel(HEVCContext *s, const HEVCLayerContext *l, unsigned nb)
static int hls_slice_data_tiles(HEVCContext *s, const H2645NAL *nal)
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 int hls_decode_entry_tile(AVCodecContext *avctx, void *hevc_lclist, int job, int thread)
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 int decode_deferred_tile_slices(HEVCContext *s, int picture_complete)
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)
#define atomic_store(object, desired)
#define atomic_load(object)
#define atomic_init(obj, value)
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
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]
const RefPicList * rpl
reference lists of that slice, NULL for I slices
const HEVCFrame * collocated_ref
picture read by the temporal MVP, NULL if none
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
const uint8_t * data
CABAC bytes of this substream.
int start_ts
first CTB of the segment, in tile scan order
const RefPicList * rpl
reference lists of that slice, NULL for I slices
const SliceHeader * sh
header of the slice this segment belongs to
const HEVCFrame * collocated_ref
temporal MVP target of that slice
const uint8_t * data
start of the CABAC substream
const HEVCFrame * collocated_ref
temporal MVP target of this slice
const RefPicList * rpl
reference lists of this slice
int qp_y_seed
lc[0].qp_y before deferring, the initial QP predictor
const HEVCTileSegment * seg
segment being decoded, NULL if none
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 const char * err(int ret)
static int ref[MAX_W *MAX_W]
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)
static void interleave(uint8_t *dst, uint8_t *src, int w, int h, int dst_linesize, int src_linesize, enum FilterMode mode, int swap)