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;
796 unsigned pps_id, layer_idx;
817 pps =
s->ps.pps_list[pps_id];
820 layer_idx =
vps->layer_idx[
s->nuh_layer_id];
827 int slice_address_length;
829 if (
pps->dependent_slice_segments_enabled_flag)
841 "Invalid slice segment address: %u.\n",
854 for (
i = 0;
i <
pps->num_extra_slice_header_bits;
i++)
866 !
pps->pps_curr_pic_ref_enabled_flag &&
867 s->nuh_layer_id == 0) {
874 if (
pps->output_flag_present_flag)
877 if (
sps->separate_colour_plane)
881 (
s->nuh_layer_id > 0 &&
882 !(
vps->poc_lsb_not_present & (1 << layer_idx)))) {
889 "Ignoring POC change between slices: %d -> %d\n", poc, sh->
poc);
909 int numbits, rps_idx;
911 if (!
sps->nb_st_rps) {
917 rps_idx = numbits > 0 ?
get_bits(gb, numbits) : 0;
931 if (
sps->temporal_mvp_enabled)
947 if (
s->nuh_layer_id > 0) {
948 int num_direct_ref_layers =
vps->num_direct_ref_layers[layer_idx];
950 if (
vps->default_ref_layers_active)
952 else if (num_direct_ref_layers) {
957 "NumDirectRefLayers>1 not supported\n");
963 if (
sps->sao_enabled) {
965 if (
sps->chroma_format_idc) {
1002 if (
pps->lists_modification_present_flag && nb_refs > 1) {
1020 if (
pps->cabac_init_present_flag)
1035 "Invalid collocated_ref_idx: %d.\n",
1052 "Invalid number of merging MVP candidates: %d.\n",
1058 if (
sps->motion_vector_resolution_control_idc == 2)
1068 if (
pps->pic_slice_level_chroma_qp_offsets_present_flag) {
1081 if (
pps->pps_slice_act_qp_offsets_present_flag) {
1087 if (
pps->chroma_qp_offset_list_enabled_flag)
1092 if (
pps->deblocking_filter_control_present_flag) {
1093 int deblocking_filter_override_flag = 0;
1095 if (
pps->deblocking_filter_override_enabled_flag)
1096 deblocking_filter_override_flag =
get_bits1(gb);
1098 if (deblocking_filter_override_flag) {
1103 if (beta_offset_div2 < -6 || beta_offset_div2 > 6 ||
1104 tc_offset_div2 < -6 || tc_offset_div2 > 6) {
1106 "Invalid deblock filter offsets: %d, %d\n",
1107 beta_offset_div2, tc_offset_div2);
1124 if (
pps->seq_loop_filter_across_slices_enabled_flag &&
1135 if (
pps->tiles_enabled_flag ||
pps->entropy_coding_sync_enabled_flag) {
1138 if (num_entry_point_offsets >
get_bits_left(gb) || num_entry_point_offsets > UINT16_MAX) {
1139 av_log(
s->avctx,
AV_LOG_ERROR,
"num_entry_point_offsets %d is invalid\n", num_entry_point_offsets);
1147 if (offset_len < 1 || offset_len > 32) {
1171 if (
pps->slice_header_extension_present_flag) {
1177 for (
i = 0;
i < length;
i++)
1199 "The slice_qp %d is outside the valid range "
1202 -
sps->qp_bd_offset);
1217#define CTB(tab, x, y) ((tab)[(y) * sps->ctb_width + (x)])
1219#define SET_SAO(elem, value) \
1221 if (!sao_merge_up_flag && !sao_merge_left_flag) \
1222 sao->elem = value; \
1223 else if (sao_merge_left_flag) \
1224 sao->elem = CTB(l->sao, rx-1, ry).elem; \
1225 else if (sao_merge_up_flag) \
1226 sao->elem = CTB(l->sao, rx, ry-1).elem; \
1236 int sao_merge_left_flag = 0;
1237 int sao_merge_up_flag = 0;
1241 if (
s->sh.slice_sample_adaptive_offset_flag[0] ||
1242 s->sh.slice_sample_adaptive_offset_flag[1]) {
1247 if (ry > 0 && !sao_merge_left_flag) {
1253 for (c_idx = 0; c_idx < (
sps->chroma_format_idc ? 3 : 1); c_idx++) {
1254 int log2_sao_offset_scale = c_idx == 0 ?
pps->log2_sao_offset_scale_luma :
1255 pps->log2_sao_offset_scale_chroma;
1257 if (!
s->sh.slice_sample_adaptive_offset_flag[c_idx]) {
1272 for (
i = 0;
i < 4;
i++)
1276 for (
i = 0;
i < 4;
i++) {
1285 }
else if (c_idx != 2) {
1291 for (
i = 0;
i < 4;
i++) {
1299 sao->
offset_val[c_idx][
i + 1] *= 1 << log2_sao_offset_scale;
1311 if (log2_res_scale_abs_plus1 != 0) {
1314 (1 - 2 * res_scale_sign_flag);
1327 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1328 int log2_cb_size,
int log2_trafo_size,
1329 int blk_idx,
int cbf_luma,
int *cbf_cb,
int *cbf_cr)
1332 const int log2_trafo_size_c = log2_trafo_size -
sps->hshift[1];
1336 int trafo_size = 1 << log2_trafo_size;
1339 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, x0, y0, 0);
1342 if (cbf_luma || cbf_cb[0] || cbf_cr[0] ||
1343 (
sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
1346 int cbf_chroma = cbf_cb[0] || cbf_cr[0] ||
1347 (
sps->chroma_format_idc == 2 &&
1348 (cbf_cb[1] || cbf_cr[1]));
1360 "The cu_qp_delta %d is outside the valid range "
1363 -(26 +
sps->qp_bd_offset / 2),
1364 (25 +
sps->qp_bd_offset / 2));
1371 if (
s->sh.cu_chroma_qp_offset_enabled_flag && cbf_chroma &&
1374 if (cu_chroma_qp_offset_flag) {
1375 int cu_chroma_qp_offset_idx = 0;
1376 if (
pps->chroma_qp_offset_list_len_minus1 > 0) {
1379 "cu_chroma_qp_offset_idx not yet tested.\n");
1412 if (
sps->chroma_format_idc && (log2_trafo_size > 2 ||
sps->chroma_format_idc == 3)) {
1413 int trafo_size_h = 1 << (log2_trafo_size_c +
sps->hshift[1]);
1414 int trafo_size_v = 1 << (log2_trafo_size_c +
sps->vshift[1]);
1415 lc->
tu.
cross_pf = (
pps->cross_component_prediction_enabled_flag && cbf_luma &&
1422 for (
i = 0;
i < (
sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1425 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1426 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0 + (
i << log2_trafo_size_c), 1);
1430 log2_trafo_size_c, scan_idx_c, 1);
1433 ptrdiff_t
stride =
s->cur_frame->f->linesize[1];
1434 int hshift =
sps->hshift[1];
1435 int vshift =
sps->vshift[1];
1438 int size = 1 << log2_trafo_size_c;
1440 uint8_t *
dst = &
s->cur_frame->f->data[1][(y0 >> vshift) *
stride +
1441 ((x0 >> hshift) <<
sps->pixel_shift)];
1445 s->hevcdsp.add_residual[log2_trafo_size_c-2](
dst, coeffs,
stride);
1452 for (
i = 0;
i < (
sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1455 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1456 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0 + (
i << log2_trafo_size_c), 2);
1460 log2_trafo_size_c, scan_idx_c, 2);
1463 ptrdiff_t
stride =
s->cur_frame->f->linesize[2];
1464 int hshift =
sps->hshift[2];
1465 int vshift =
sps->vshift[2];
1468 int size = 1 << log2_trafo_size_c;
1470 uint8_t *
dst = &
s->cur_frame->f->data[2][(y0 >> vshift) *
stride +
1471 ((x0 >> hshift) <<
sps->pixel_shift)];
1475 s->hevcdsp.add_residual[log2_trafo_size_c-2](
dst, coeffs,
stride);
1478 }
else if (
sps->chroma_format_idc && blk_idx == 3) {
1479 int trafo_size_h = 1 << (log2_trafo_size + 1);
1480 int trafo_size_v = 1 << (log2_trafo_size +
sps->vshift[1]);
1481 for (
i = 0;
i < (
sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1484 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1485 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase + (
i << log2_trafo_size), 1);
1489 log2_trafo_size, scan_idx_c, 1);
1491 for (
i = 0;
i < (
sps->chroma_format_idc == 2 ? 2 : 1);
i++) {
1494 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1495 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase + (
i << log2_trafo_size), 2);
1499 log2_trafo_size, scan_idx_c, 2);
1503 if (log2_trafo_size > 2 ||
sps->chroma_format_idc == 3) {
1504 int trafo_size_h = 1 << (log2_trafo_size_c +
sps->hshift[1]);
1505 int trafo_size_v = 1 << (log2_trafo_size_c +
sps->vshift[1]);
1507 sps->log2_ctb_size);
1508 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0, 1);
1509 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0, 2);
1510 if (
sps->chroma_format_idc == 2) {
1512 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1513 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0 + (1 << log2_trafo_size_c), 1);
1514 s->hpc.intra_pred[log2_trafo_size_c - 2](lc,
pps, x0, y0 + (1 << log2_trafo_size_c), 2);
1516 }
else if (blk_idx == 3) {
1517 int trafo_size_h = 1 << (log2_trafo_size + 1);
1518 int trafo_size_v = 1 << (log2_trafo_size +
sps->vshift[1]);
1520 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1521 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase, 1);
1522 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase, 2);
1523 if (
sps->chroma_format_idc == 2) {
1525 trafo_size_h, trafo_size_v,
sps->log2_ctb_size);
1526 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase + (1 << log2_trafo_size), 1);
1527 s->hpc.intra_pred[log2_trafo_size - 2](lc,
pps, xBase, yBase + (1 << log2_trafo_size), 2);
1536 int x0,
int y0,
int log2_cb_size)
1538 int cb_size = 1 << log2_cb_size;
1539 int log2_min_pu_size =
sps->log2_min_pu_size;
1541 int min_pu_width =
sps->min_pu_width;
1542 int x_end =
FFMIN(x0 + cb_size,
sps->width);
1543 int y_end =
FFMIN(y0 + cb_size,
sps->height);
1546 for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
1547 for (
i = (x0 >> log2_min_pu_size);
i < (x_end >> log2_min_pu_size);
i++)
1548 is_pcm[
i + j * min_pu_width] = 2;
1555 int xBase,
int yBase,
int cb_xBase,
int cb_yBase,
1556 int log2_cb_size,
int log2_trafo_size,
1557 int trafo_depth,
int blk_idx,
1558 const int *base_cbf_cb,
const int *base_cbf_cr)
1561 uint8_t split_transform_flag;
1566 cbf_cb[0] = base_cbf_cb[0];
1567 cbf_cb[1] = base_cbf_cb[1];
1568 cbf_cr[0] = base_cbf_cr[0];
1569 cbf_cr[1] = base_cbf_cr[1];
1572 if (trafo_depth == 1) {
1574 if (
sps->chroma_format_idc == 3) {
1588 if (log2_trafo_size <= sps->log2_max_trafo_size &&
1589 log2_trafo_size >
sps->log2_min_tb_size &&
1590 trafo_depth < lc->cu.max_trafo_depth &&
1594 int inter_split =
sps->max_transform_hierarchy_depth_inter == 0 &&
1599 split_transform_flag = log2_trafo_size >
sps->log2_max_trafo_size ||
1604 if (
sps->chroma_format_idc && (log2_trafo_size > 2 ||
sps->chroma_format_idc == 3)) {
1605 if (trafo_depth == 0 || cbf_cb[0]) {
1607 if (
sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
1612 if (trafo_depth == 0 || cbf_cr[0]) {
1614 if (
sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) {
1620 if (split_transform_flag) {
1621 const int trafo_size_split = 1 << (log2_trafo_size - 1);
1622 const int x1 = x0 + trafo_size_split;
1623 const int y1 = y0 + trafo_size_split;
1625#define SUBDIVIDE(x, y, idx) \
1627 ret = hls_transform_tree(lc, l, pps, sps, \
1628 x, y, x0, y0, cb_xBase, cb_yBase, log2_cb_size, \
1629 log2_trafo_size - 1, trafo_depth + 1, idx, \
1642 int min_tu_size = 1 <<
sps->log2_min_tb_size;
1643 int log2_min_tu_size =
sps->log2_min_tb_size;
1644 int min_tu_width =
sps->min_tb_width;
1648 cbf_cb[0] || cbf_cr[0] ||
1649 (
sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) {
1654 x0, y0, xBase, yBase, cb_xBase, cb_yBase,
1655 log2_cb_size, log2_trafo_size,
1656 blk_idx, cbf_luma, cbf_cb, cbf_cr);
1662 for (
i = 0;
i < (1 << log2_trafo_size);
i += min_tu_size)
1663 for (j = 0; j < (1 << log2_trafo_size); j += min_tu_size) {
1664 int x_tu = (x0 + j) >> log2_min_tu_size;
1665 int y_tu = (y0 +
i) >> log2_min_tu_size;
1666 l->
cbf_luma[y_tu * min_tu_width + x_tu] = 1;
1669 if (!
s->sh.disable_deblocking_filter_flag) {
1671 if (
pps->transquant_bypass_enable_flag &&
1680 const HEVCPPS *
pps,
int x0,
int y0,
int log2_cb_size)
1685 int cb_size = 1 << log2_cb_size;
1686 ptrdiff_t stride0 =
s->cur_frame->f->linesize[0];
1687 uint8_t *dst0 = &
s->cur_frame->f->data[0][y0 * stride0 + (x0 <<
sps->pixel_shift)];
1689 int length = cb_size * cb_size *
sps->pcm.bit_depth + (
sps->chroma_format_idc != 0 ?
1690 (((cb_size >>
sps->hshift[1]) * (cb_size >>
sps->vshift[1])) +
1691 ((cb_size >>
sps->hshift[2]) * (cb_size >>
sps->vshift[2]))) *
1692 sps->pcm.bit_depth_chroma : 0);
1693 const uint8_t *pcm =
skip_bytes(&lc->
cc, (length + 7) >> 3);
1696 if (!
s->sh.disable_deblocking_filter_flag)
1703 s->hevcdsp.put_pcm(dst0, stride0, cb_size, cb_size, &gb,
sps->pcm.bit_depth);
1704 if (
sps->chroma_format_idc) {
1705 ptrdiff_t stride1 =
s->cur_frame->f->linesize[1];
1706 ptrdiff_t stride2 =
s->cur_frame->f->linesize[2];
1707 uint8_t *dst1 = &
s->cur_frame->f->data[1][(y0 >>
sps->vshift[1]) * stride1 + ((x0 >>
sps->hshift[1]) <<
sps->pixel_shift)];
1708 uint8_t *dst2 = &
s->cur_frame->f->data[2][(y0 >>
sps->vshift[2]) * stride2 + ((x0 >>
sps->hshift[2]) <<
sps->pixel_shift)];
1710 s->hevcdsp.put_pcm(dst1, stride1,
1711 cb_size >>
sps->hshift[1],
1712 cb_size >>
sps->vshift[1],
1713 &gb,
sps->pcm.bit_depth_chroma);
1714 s->hevcdsp.put_pcm(dst2, stride2,
1715 cb_size >>
sps->hshift[2],
1716 cb_size >>
sps->vshift[2],
1717 &gb,
sps->pcm.bit_depth_chroma);
1741 uint8_t *
dst, ptrdiff_t dststride,
1743 int block_w,
int block_h,
int luma_weight,
int luma_offset)
1746 const uint8_t *
src =
ref->data[0];
1748 int pic_width =
sps->width;
1749 int pic_height =
sps->height;
1752 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
pps->weighted_pred_flag) ||
1756 x_off +=
mv->x >> 2;
1757 y_off +=
mv->y >> 2;
1763 ref ==
s->cur_frame->f) {
1773 pic_width, pic_height);
1780 block_h,
mx,
my, block_w);
1783 block_h,
s->sh.luma_log2_weight_denom,
1784 luma_weight, luma_offset,
mx,
my, block_w);
1805 uint8_t *
dst, ptrdiff_t dststride,
1806 const AVFrame *ref0,
const Mv *mv0,
int x_off,
int y_off,
1807 int block_w,
int block_h,
const AVFrame *ref1,
1808 const Mv *mv1,
struct MvField *current_mv)
1811 ptrdiff_t src0stride = ref0->
linesize[0];
1812 ptrdiff_t src1stride = ref1->
linesize[0];
1813 int pic_width =
sps->width;
1814 int pic_height =
sps->height;
1815 int mx0 = mv0->
x & 3;
1816 int my0 = mv0->
y & 3;
1817 int mx1 = mv1->
x & 3;
1818 int my1 = mv1->
y & 3;
1819 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
pps->weighted_pred_flag) ||
1821 int x_off0 = x_off + (mv0->
x >> 2);
1822 int y_off0 = y_off + (mv0->
y >> 2);
1823 int x_off1 = x_off + (mv1->
x >> 2);
1824 int y_off1 = y_off + (mv1->
y >> 2);
1827 const uint8_t *
src0 = ref0->
data[0] + y_off0 * src0stride + (int)((
unsigned)x_off0 <<
sps->pixel_shift);
1828 const uint8_t *
src1 = ref1->
data[0] + y_off1 * src1stride + (int)((
unsigned)x_off1 <<
sps->pixel_shift);
1838 edge_emu_stride, src0stride,
1842 pic_width, pic_height);
1844 src0stride = edge_emu_stride;
1855 edge_emu_stride, src1stride,
1859 pic_width, pic_height);
1861 src1stride = edge_emu_stride;
1864 s->hevcdsp.put_hevc_qpel[idx][!!my0][!!mx0](lc->
tmp,
src0, src0stride,
1865 block_h, mx0, my0, block_w);
1867 s->hevcdsp.put_hevc_qpel_bi[idx][!!my1][!!mx1](
dst, dststride,
src1, src1stride, lc->
tmp,
1868 block_h, mx1, my1, block_w);
1870 s->hevcdsp.put_hevc_qpel_bi_w[idx][!!my1][!!mx1](
dst, dststride,
src1, src1stride, lc->
tmp,
1871 block_h,
s->sh.luma_log2_weight_denom,
1872 s->sh.luma_weight_l0[current_mv->
ref_idx[0]],
1873 s->sh.luma_weight_l1[current_mv->
ref_idx[1]],
1874 s->sh.luma_offset_l0[current_mv->
ref_idx[0]] +
1875 s->sh.luma_offset_l1[current_mv->
ref_idx[1]],
1900 ptrdiff_t dststride,
const uint8_t *
src0, ptrdiff_t
srcstride,
int reflist,
1901 int x_off,
int y_off,
int block_w,
int block_h,
1902 const struct MvField *current_mv,
int chroma_weight,
int chroma_offset)
1905 int pic_width =
sps->width >>
sps->hshift[1];
1906 int pic_height =
sps->height >>
sps->vshift[1];
1907 const Mv *
mv = ¤t_mv->
mv[reflist];
1908 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
pps->weighted_pred_flag) ||
1911 int hshift =
sps->hshift[1];
1912 int vshift =
sps->vshift[1];
1915 intptr_t _mx =
mx << (1 - hshift);
1916 intptr_t _my =
my << (1 - vshift);
1917 int emu =
src0 ==
s->cur_frame->f->data[1] ||
src0 ==
s->cur_frame->f->data[2];
1919 x_off +=
mv->x >> (2 + hshift);
1920 y_off +=
mv->y >> (2 + vshift);
1930 (edge_emu_stride + (1 <<
sps->pixel_shift));
1936 pic_width, pic_height);
1943 block_h, _mx, _my, block_w);
1946 block_h,
s->sh.chroma_log2_weight_denom,
1947 chroma_weight, chroma_offset, _mx, _my, block_w);
1969 uint8_t *dst0, ptrdiff_t dststride,
1971 int x_off,
int y_off,
int block_w,
int block_h,
const MvField *current_mv,
int cidx)
1974 const uint8_t *
src1 = ref0->
data[cidx+1];
1975 const uint8_t *
src2 = ref1->
data[cidx+1];
1976 ptrdiff_t src1stride = ref0->
linesize[cidx+1];
1977 ptrdiff_t src2stride = ref1->
linesize[cidx+1];
1978 int weight_flag = (
s->sh.slice_type ==
HEVC_SLICE_P &&
pps->weighted_pred_flag) ||
1980 int pic_width =
sps->width >>
sps->hshift[1];
1981 int pic_height =
sps->height >>
sps->vshift[1];
1982 const Mv *
const mv0 = ¤t_mv->
mv[0];
1983 const Mv *
const mv1 = ¤t_mv->
mv[1];
1984 int hshift =
sps->hshift[1];
1985 int vshift =
sps->vshift[1];
1991 intptr_t _mx0 = mx0 << (1 - hshift);
1992 intptr_t _my0 = my0 << (1 - vshift);
1993 intptr_t _mx1 = mx1 << (1 - hshift);
1994 intptr_t _my1 = my1 << (1 - vshift);
1996 int x_off0 = x_off + (mv0->
x >> (2 + hshift));
1997 int y_off0 = y_off + (mv0->
y >> (2 + vshift));
1998 int x_off1 = x_off + (mv1->
x >> (2 + hshift));
1999 int y_off1 = y_off + (mv1->
y >> (2 + vshift));
2001 src1 += y_off0 * src1stride + (int)((
unsigned)x_off0 <<
sps->pixel_shift);
2002 src2 += y_off1 * src2stride + (int)((
unsigned)x_off1 <<
sps->pixel_shift);
2010 (edge_emu_stride + (1 <<
sps->pixel_shift));
2013 edge_emu_stride, src1stride,
2017 pic_width, pic_height);
2020 src1stride = edge_emu_stride;
2029 (edge_emu_stride + (1 <<
sps->pixel_shift));
2032 edge_emu_stride, src2stride,
2036 pic_width, pic_height);
2039 src2stride = edge_emu_stride;
2042 s->hevcdsp.put_hevc_epel[idx][!!my0][!!mx0](lc->
tmp,
src1, src1stride,
2043 block_h, _mx0, _my0, block_w);
2045 s->hevcdsp.put_hevc_epel_bi[idx][!!my1][!!mx1](dst0,
s->cur_frame->f->linesize[cidx+1],
2047 block_h, _mx1, _my1, block_w);
2049 s->hevcdsp.put_hevc_epel_bi_w[idx][!!my1][!!mx1](dst0,
s->cur_frame->f->linesize[cidx+1],
2052 s->sh.chroma_log2_weight_denom,
2053 s->sh.chroma_weight_l0[current_mv->
ref_idx[0]][cidx],
2054 s->sh.chroma_weight_l1[current_mv->
ref_idx[1]][cidx],
2055 s->sh.chroma_offset_l0[current_mv->
ref_idx[0]][cidx] +
2056 s->sh.chroma_offset_l1[current_mv->
ref_idx[1]][cidx],
2057 _mx1, _my1, block_w);
2072 int x0,
int y0,
int nPbW,
2073 int nPbH,
int log2_cb_size,
int part_idx,
2085 if (inter_pred_idc !=
PRED_L1) {
2086 if (
s->sh.nb_refs[
L0])
2093 part_idx, merge_idx,
mv, mvp_flag, 0);
2098 if (inter_pred_idc !=
PRED_L0) {
2099 if (
s->sh.nb_refs[
L1])
2102 if (
s->sh.mvd_l1_zero_flag == 1 && inter_pred_idc ==
PRED_BI) {
2111 part_idx, merge_idx,
mv, mvp_flag, 1);
2120 int x0,
int y0,
int nPbW,
int nPbH,
2121 int log2_cb_size,
int partIdx,
int idx)
2123#define POS(c_idx, x, y) \
2124 s->cur_frame->f->data[c_idx] ? \
2125 &s->cur_frame->f->data[c_idx][((y) >> sps->vshift[c_idx]) * linesize[c_idx] + \
2126 (((x) >> sps->hshift[c_idx]) << sps->pixel_shift)] : NULL
2129 struct MvField current_mv = {{{ 0 }}};
2131 int min_pu_width =
sps->min_pu_width;
2133 MvField *tab_mvf =
s->cur_frame->tab_mvf;
2134 const RefPicList *refPicList =
s->cur_frame->refPicList;
2136 const int *linesize =
s->cur_frame->f->linesize;
2137 uint8_t *dst0 =
s->cur_frame->f->data[0] + y0 * linesize[0] + (x0 <<
sps->pixel_shift);
2138 uint8_t *dst1 =
POS(1, x0, y0);
2139 uint8_t *dst2 =
POS(2, x0, y0);
2140 int log2_min_cb_size =
sps->log2_min_cb_size;
2141 int min_cb_width =
sps->min_cb_width;
2142 int x_cb = x0 >> log2_min_cb_size;
2143 int y_cb = y0 >> log2_min_cb_size;
2153 if (
s->sh.max_num_merge_cand > 1)
2159 partIdx, merge_idx, ¤t_mv);
2162 partIdx, merge_idx, ¤t_mv);
2165 x_pu = x0 >>
sps->log2_min_pu_size;
2166 y_pu = y0 >>
sps->log2_min_pu_size;
2168 for (j = 0; j < nPbH >>
sps->log2_min_pu_size; j++)
2170 tab_mvf[(y_pu + j) * min_pu_width + x_pu +
i] = current_mv;
2173 ref0 = refPicList[0].
ref[current_mv.
ref_idx[0]];
2174 if (!ref0 || !ref0->
f)
2179 ref1 = refPicList[1].
ref[current_mv.
ref_idx[1]];
2180 if (!ref1 || !ref1->f)
2186 int x0_c = x0 >>
sps->hshift[1];
2187 int y0_c = y0 >>
sps->vshift[1];
2188 int nPbW_c = nPbW >>
sps->hshift[1];
2189 int nPbH_c = nPbH >>
sps->vshift[1];
2192 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
2193 s->sh.luma_weight_l0[current_mv.
ref_idx[0]],
2194 s->sh.luma_offset_l0[current_mv.
ref_idx[0]]);
2196 if (
sps->chroma_format_idc) {
2198 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2199 s->sh.chroma_weight_l0[current_mv.
ref_idx[0]][0],
s->sh.chroma_offset_l0[current_mv.
ref_idx[0]][0]);
2201 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2202 s->sh.chroma_weight_l0[current_mv.
ref_idx[0]][1],
s->sh.chroma_offset_l0[current_mv.
ref_idx[0]][1]);
2205 int x0_c = x0 >>
sps->hshift[1];
2206 int y0_c = y0 >>
sps->vshift[1];
2207 int nPbW_c = nPbW >>
sps->hshift[1];
2208 int nPbH_c = nPbH >>
sps->vshift[1];
2211 ¤t_mv.
mv[1], x0, y0, nPbW, nPbH,
2212 s->sh.luma_weight_l1[current_mv.
ref_idx[1]],
2213 s->sh.luma_offset_l1[current_mv.
ref_idx[1]]);
2215 if (
sps->chroma_format_idc) {
2217 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2218 s->sh.chroma_weight_l1[current_mv.
ref_idx[1]][0],
s->sh.chroma_offset_l1[current_mv.
ref_idx[1]][0]);
2221 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv,
2222 s->sh.chroma_weight_l1[current_mv.
ref_idx[1]][1],
s->sh.chroma_offset_l1[current_mv.
ref_idx[1]][1]);
2225 int x0_c = x0 >>
sps->hshift[1];
2226 int y0_c = y0 >>
sps->vshift[1];
2227 int nPbW_c = nPbW >>
sps->hshift[1];
2228 int nPbH_c = nPbH >>
sps->vshift[1];
2231 ¤t_mv.
mv[0], x0, y0, nPbW, nPbH,
2232 ref1->f, ¤t_mv.
mv[1], ¤t_mv);
2234 if (
sps->chroma_format_idc) {
2236 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0);
2239 x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 1);
2249 int x0,
int y0,
int pu_size,
2250 int prev_intra_luma_pred_flag)
2253 int x_pu = x0 >>
sps->log2_min_pu_size;
2254 int y_pu = y0 >>
sps->log2_min_pu_size;
2255 int min_pu_width =
sps->min_pu_width;
2256 int size_in_pus = pu_size >>
sps->log2_min_pu_size;
2265 int y_ctb = (y0 >> (
sps->log2_ctb_size)) << (
sps->log2_ctb_size);
2267 MvField *tab_mvf =
s->cur_frame->tab_mvf;
2268 int intra_pred_mode;
2273 if ((y0 - 1) < y_ctb)
2276 if (cand_left == cand_up) {
2277 if (cand_left < 2) {
2282 candidate[0] = cand_left;
2283 candidate[1] = 2 + ((cand_left - 2 - 1 + 32) & 31);
2284 candidate[2] = 2 + ((cand_left - 2 + 1) & 31);
2287 candidate[0] = cand_left;
2288 candidate[1] = cand_up;
2298 if (prev_intra_luma_pred_flag) {
2299 intra_pred_mode = candidate[lc->
pu.
mpm_idx];
2301 if (candidate[0] > candidate[1])
2302 FFSWAP(uint8_t, candidate[0], candidate[1]);
2303 if (candidate[0] > candidate[2])
2304 FFSWAP(uint8_t, candidate[0], candidate[2]);
2305 if (candidate[1] > candidate[2])
2306 FFSWAP(uint8_t, candidate[1], candidate[2]);
2309 for (
i = 0;
i < 3;
i++)
2310 if (intra_pred_mode >= candidate[
i])
2317 for (
i = 0;
i < size_in_pus;
i++) {
2318 memset(&l->
tab_ipm[(y_pu +
i) * min_pu_width + x_pu],
2319 intra_pred_mode, size_in_pus);
2321 for (j = 0; j < size_in_pus; j++) {
2326 return intra_pred_mode;
2331 int log2_cb_size,
int ct_depth)
2333 int length = (1 << log2_cb_size) >>
sps->log2_min_cb_size;
2334 int x_cb = x0 >>
sps->log2_min_cb_size;
2335 int y_cb = y0 >>
sps->log2_min_cb_size;
2338 for (y = 0; y < length; y++)
2339 memset(&tab_ct_depth[(y_cb + y) *
sps->min_cb_width + x_cb],
2344 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20,
2345 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31};
2352 static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 };
2353 uint8_t prev_intra_luma_pred_flag[4];
2355 int pb_size = (1 << log2_cb_size) >>
split;
2356 int side =
split + 1;
2360 for (
i = 0;
i < side;
i++)
2361 for (j = 0; j < side; j++)
2364 for (
i = 0;
i < side;
i++) {
2365 for (j = 0; j < side; j++) {
2366 if (prev_intra_luma_pred_flag[2 *
i + j])
2373 x0 + pb_size * j, y0 + pb_size *
i, pb_size,
2374 prev_intra_luma_pred_flag[2 *
i + j]);
2378 if (
sps->chroma_format_idc == 3) {
2379 for (
i = 0;
i < side;
i++) {
2380 for (j = 0; j < side; j++) {
2382 if (chroma_mode != 4) {
2392 }
else if (
sps->chroma_format_idc == 2) {
2395 if (chroma_mode != 4) {
2399 mode_idx = intra_chroma_table[chroma_mode];
2404 }
else if (
sps->chroma_format_idc != 0) {
2406 if (chroma_mode != 4) {
2424 int pb_size = 1 << log2_cb_size;
2425 int size_in_pus = pb_size >>
sps->log2_min_pu_size;
2426 int min_pu_width =
sps->min_pu_width;
2427 MvField *tab_mvf =
s->cur_frame->tab_mvf;
2428 int x_pu = x0 >>
sps->log2_min_pu_size;
2429 int y_pu = y0 >>
sps->log2_min_pu_size;
2432 if (size_in_pus == 0)
2434 for (j = 0; j < size_in_pus; j++)
2435 memset(&l->
tab_ipm[(y_pu + j) * min_pu_width + x_pu],
INTRA_DC, size_in_pus);
2437 for (j = 0; j < size_in_pus; j++)
2438 for (k = 0; k < size_in_pus; k++)
2445 int x0,
int y0,
int log2_cb_size)
2447 int cb_size = 1 << log2_cb_size;
2448 int log2_min_cb_size =
sps->log2_min_cb_size;
2449 int length = cb_size >> log2_min_cb_size;
2450 int min_cb_width =
sps->min_cb_width;
2451 int x_cb = x0 >> log2_min_cb_size;
2452 int y_cb = y0 >> log2_min_cb_size;
2453 int idx = log2_cb_size - 2;
2454 int qp_block_mask = (1 << (
sps->log2_ctb_size -
pps->diff_cu_qp_delta_depth)) - 1;
2464 for (x = 0; x < 4; x++)
2466 if (
pps->transquant_bypass_enable_flag) {
2477 x0b, y0b, x_cb, y_cb,
2480 x = y_cb * min_cb_width + x_cb;
2481 for (y = 0; y < length; y++) {
2482 memset(&l->
skip_flag[x], skip_flag, length);
2487 x = y_cb * min_cb_width + x_cb;
2488 for (y = 0; y < length; y++) {
2496 x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
2499 if (!
s->sh.disable_deblocking_filter_flag)
2507 log2_cb_size ==
sps->log2_min_cb_size) {
2515 log2_cb_size >=
sps->pcm.log2_min_pcm_cb_size &&
2516 log2_cb_size <= sps->pcm.log2_max_pcm_cb_size) {
2522 if (
sps->pcm_loop_filter_disabled)
2535 x0, y0, cb_size, cb_size, log2_cb_size, 0, idx);
2539 x0, y0, cb_size, cb_size / 2, log2_cb_size, 0, idx);
2541 x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx);
2545 x0, y0, cb_size / 2, cb_size, log2_cb_size, 0, idx - 1);
2547 x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1);
2551 x0, y0, cb_size, cb_size / 4, log2_cb_size, 0, idx);
2553 x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx);
2557 x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0, idx);
2559 x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx);
2563 x0, y0, cb_size / 4, cb_size, log2_cb_size, 0, idx - 2);
2565 x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2);
2569 x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0, idx - 2);
2571 x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2);
2575 x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0, idx - 1);
2577 x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1);
2579 x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1);
2581 x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1);
2587 int rqt_root_cbf = 1;
2594 const static int cbf[2] = { 0 };
2597 sps->max_transform_hierarchy_depth_inter;
2598 ret =
hls_transform_tree(lc, l,
pps,
sps, x0, y0, x0, y0, x0, y0,
2600 log2_cb_size, 0, 0, cbf, cbf);
2604 if (!
s->sh.disable_deblocking_filter_flag)
2613 x = y_cb * min_cb_width + x_cb;
2614 for (y = 0; y < length; y++) {
2619 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2620 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0) {
2633 int log2_cb_size,
int cb_depth)
2636 const int cb_size = 1 << log2_cb_size;
2641 if (x0 + cb_size <= sps->
width &&
2642 y0 + cb_size <= sps->
height &&
2643 log2_cb_size >
sps->log2_min_cb_size) {
2645 sps, cb_depth, x0, y0);
2647 split_cu = (log2_cb_size >
sps->log2_min_cb_size);
2649 if (
pps->cu_qp_delta_enabled_flag &&
2650 log2_cb_size >=
sps->log2_ctb_size -
pps->diff_cu_qp_delta_depth) {
2655 if (
s->sh.cu_chroma_qp_offset_enabled_flag &&
2656 log2_cb_size >=
sps->log2_ctb_size -
pps->diff_cu_chroma_qp_offset_depth) {
2661 int qp_block_mask = (1 << (
sps->log2_ctb_size -
pps->diff_cu_qp_delta_depth)) - 1;
2662 const int cb_size_split = cb_size >> 1;
2663 const int x1 = x0 + cb_size_split;
2664 const int y1 = y0 + cb_size_split;
2669 x0, y0, log2_cb_size - 1, cb_depth + 1);
2673 if (more_data && x1 < sps->
width) {
2675 x1, y0, log2_cb_size - 1, cb_depth + 1);
2679 if (more_data && y1 < sps->
height) {
2681 x0, y1, log2_cb_size - 1, cb_depth + 1);
2685 if (more_data && x1 < sps->
width &&
2688 x1, y1, log2_cb_size - 1, cb_depth + 1);
2693 if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
2694 ((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0)
2698 return ((x1 + cb_size_split) <
sps->width ||
2699 (y1 + cb_size_split) <
sps->height);
2706 if ((!((x0 + cb_size) %
2707 (1 << (
sps->log2_ctb_size))) ||
2708 (x0 + cb_size >=
sps->width)) &&
2710 (1 << (
sps->log2_ctb_size))) ||
2711 (y0 + cb_size >=
sps->height))) {
2713 return !end_of_slice_flag;
2725 int x_ctb,
int y_ctb,
int ctb_addr_ts)
2728 int ctb_size = 1 <<
sps->log2_ctb_size;
2729 int ctb_addr_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2730 int ctb_addr_in_slice = ctb_addr_rs -
s->sh.slice_addr;
2734 if (
pps->entropy_coding_sync_enabled_flag) {
2735 if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
2738 }
else if (
pps->tiles_enabled_flag) {
2739 if (ctb_addr_ts &&
pps->tile_id[ctb_addr_ts] !=
pps->tile_id[ctb_addr_ts - 1]) {
2740 int idxX =
pps->col_idxX[x_ctb >>
sps->log2_ctb_size];
2751 if (
pps->tiles_enabled_flag) {
2752 if (x_ctb > 0 &&
pps->tile_id[ctb_addr_ts] !=
pps->tile_id[
pps->ctb_addr_rs_to_ts[ctb_addr_rs - 1]])
2756 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]])
2761 if (ctb_addr_in_slice <= 0)
2763 if (ctb_addr_in_slice < sps->ctb_width)
2769 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]]));
2770 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]]));
2779 const uint8_t *slice_data = gb->
buffer +
s->sh.data_offset;
2781 int ctb_size = 1 <<
sps->log2_ctb_size;
2785 int ctb_addr_ts =
pps->ctb_addr_rs_to_ts[
s->sh.slice_ctb_addr_rs];
2788 while (more_data && ctb_addr_ts < sps->ctb_size) {
2789 int ctb_addr_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2791 x_ctb = (ctb_addr_rs % ((
sps->width + ctb_size - 1) >>
sps->log2_ctb_size)) <<
sps->log2_ctb_size;
2792 y_ctb = (ctb_addr_rs / ((
sps->width + ctb_size - 1) >>
sps->log2_ctb_size)) <<
sps->log2_ctb_size;
2802 x_ctb >>
sps->log2_ctb_size, y_ctb >>
sps->log2_ctb_size);
2809 if (more_data < 0) {
2820 if (x_ctb + ctb_size >=
sps->width &&
2821 y_ctb + ctb_size >=
sps->height)
2828 int job,
int thread)
2835 int ctb_size = 1 <<
sps->log2_ctb_size;
2838 int ctb_addr_rs =
s->sh.slice_ctb_addr_rs + ctb_row * ((
sps->width + ctb_size - 1) >>
sps->log2_ctb_size);
2839 int ctb_addr_ts =
pps->ctb_addr_rs_to_ts[ctb_addr_rs];
2841 const uint8_t *
data =
s->data +
s->sh.offset[ctb_row];
2842 const size_t data_size =
s->sh.size[ctb_row];
2851 while(more_data && ctb_addr_ts < sps->ctb_size) {
2852 int x_ctb = (ctb_addr_rs %
sps->ctb_width) <<
sps->log2_ctb_size;
2853 int y_ctb = (ctb_addr_rs /
sps->ctb_width) <<
sps->log2_ctb_size;
2873 x_ctb >>
sps->log2_ctb_size, y_ctb >>
sps->log2_ctb_size);
2881 if (more_data < 0) {
2892 if (!more_data && (x_ctb+ctb_size) <
sps->width && ctb_row !=
s->sh.num_entry_point_offsets) {
2899 if ((x_ctb+ctb_size) >=
sps->width && (y_ctb+ctb_size) >=
sps->height ) {
2904 ctb_addr_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts];
2907 if(x_ctb >=
sps->width) {
2924 if (
s->nb_wpp_progress < count) {
2926 sizeof(*
s->wpp_progress));
2930 s->wpp_progress =
tmp;
2931 memset(
s->wpp_progress +
s->nb_wpp_progress, 0,
2932 (count -
s->nb_wpp_progress) *
sizeof(*
s->wpp_progress));
2934 for (
int i =
s->nb_wpp_progress;
i < count;
i++) {
2938 s->nb_wpp_progress =
i + 1;
2942 for (
int i = 0;
i < count;
i++)
2952 const uint8_t *
data =
nal->data;
2953 int length =
nal->size;
2956 int64_t startheader, cmpt = 0;
2959 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) {
2961 s->sh.slice_ctb_addr_rs,
s->sh.num_entry_point_offsets,
2962 sps->ctb_width,
sps->ctb_height
2967 if (
s->avctx->thread_count >
s->nb_local_ctx) {
2973 memcpy(
tmp,
s->local_ctx,
sizeof(*
s->local_ctx) *
s->nb_local_ctx);
2977 for (
unsigned i =
s->nb_local_ctx;
i < s->avctx->thread_count;
i++) {
2978 tmp = &
s->local_ctx[
i];
2980 memset(
tmp, 0,
sizeof(*
tmp));
2982 tmp->logctx =
s->avctx;
2984 tmp->common_cabac_state = &
s->cabac;
2987 s->nb_local_ctx =
s->avctx->thread_count;
2992 for (j = 0, cmpt = 0, startheader =
offset +
s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) {
2993 if (
nal->skipped_bytes_pos[j] >=
offset &&
nal->skipped_bytes_pos[j] < startheader) {
2999 for (
int i = 1;
i <
s->sh.num_entry_point_offsets;
i++) {
3000 offset += (
s->sh.entry_point_offset[
i - 1] - cmpt);
3001 for (j = 0, cmpt = 0, startheader =
offset
3002 +
s->sh.entry_point_offset[
i]; j < nal->skipped_bytes; j++) {
3003 if (
nal->skipped_bytes_pos[j] >=
offset &&
nal->skipped_bytes_pos[j] < startheader) {
3008 s->sh.size[
i] =
s->sh.entry_point_offset[
i] - cmpt;
3013 offset +=
s->sh.entry_point_offset[
s->sh.num_entry_point_offsets - 1] - cmpt;
3018 s->sh.size [
s->sh.num_entry_point_offsets] = length -
offset;
3019 s->sh.offset[
s->sh.num_entry_point_offsets] =
offset;
3021 s->sh.offset[0] =
s->sh.data_offset;
3022 s->sh.size[0] =
s->sh.offset[1] -
s->sh.offset[0];
3026 for (
unsigned i = 1;
i <
s->nb_local_ctx;
i++) {
3027 s->local_ctx[
i].first_qp_group = 1;
3028 s->local_ctx[
i].qp_y =
s->local_ctx[0].qp_y;
3036 ret =
av_calloc(
s->sh.num_entry_point_offsets + 1,
sizeof(*ret));
3040 if (
pps->entropy_coding_sync_enabled_flag)
3043 for (
int i = 0;
i <=
s->sh.num_entry_point_offsets;
i++)
3056 if (!
s->sh.first_slice_in_pic_flag)
3057 s->slice_idx += !
s->sh.dependent_slice_segment_flag;
3059 if (!
s->sh.dependent_slice_segment_flag &&
s->sh.slice_type !=
HEVC_SLICE_I) {
3063 "Error constructing the reference lists for the current slice.\n");
3068 s->slice_initialized = 1;
3070 if (
s->avctx->hwaccel)
3075 "SCC profile is not yet implemented in hevc native decoder.\n");
3079 if (
s->sh.dependent_slice_segment_flag) {
3080 int ctb_addr_ts =
pps->ctb_addr_rs_to_ts[
s->sh.slice_ctb_addr_rs];
3081 int prev_rs =
pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
3088 s->local_ctx[0].first_qp_group = !
s->sh.dependent_slice_segment_flag;
3090 if (!
pps->cu_qp_delta_enabled_flag)
3091 s->local_ctx[0].qp_y =
s->sh.slice_qp;
3093 s->local_ctx[0].tu.cu_qp_offset_cb = 0;
3094 s->local_ctx[0].tu.cu_qp_offset_cr = 0;
3097 s->sh.num_entry_point_offsets > 0 &&
3098 pps->num_tile_rows == 1 &&
pps->num_tile_columns == 1)
3113 if (
IS_IRAP(
s) &&
s->no_rasl_output_flag) {
3114 if (
s->sei.common.mastering_display.present > 0)
3115 s->sei.common.mastering_display.present--;
3117 if (
s->sei.common.content_light.present > 0)
3118 s->sei.common.content_light.present--;
3123 sps->bit_depth,
sps->bit_depth_chroma,
3124 s->cur_frame->poc );
3128 if (
s->sei.timecode.present) {
3133 sizeof(uint32_t) * 4, &tcside);
3138 tc_sd = (uint32_t*)tcside->
data;
3139 tc_sd[0] =
s->sei.timecode.num_clock_ts;
3141 for (
int i = 0;
i < tc_sd[0];
i++) {
3142 int drop =
s->sei.timecode.cnt_dropped_flag[
i];
3143 int hh =
s->sei.timecode.hours_value[
i];
3144 int mm =
s->sei.timecode.minutes_value[
i];
3145 int ss =
s->sei.timecode.seconds_value[
i];
3146 int ff =
s->sei.timecode.n_frames[
i];
3154 s->sei.timecode.num_clock_ts = 0;
3157 if (
s->sei.common.itut_t35.hdr_plus) {
3167 if (
s->sei.common.itut_t35.hdr_smpte2094_app5) {
3188 if (
s->sei.common.itut_t35.hdr_vivid) {
3191 &
s->sei.common.itut_t35.hdr_vivid,
3203 for (
int i = nal_idx;
i <
s->pkt.nb_nals;
i++) {
3205 const int layer_id =
nal->nuh_layer_id;
3209 !(
s->layers_active_decode & (1 <<
s->vps->layer_idx[layer_id])))
3212 switch (
nal->type) {
3246 const HEVCPPS *
const pps =
s->ps.pps_list[
s->sh.pps_id];
3248 int pic_size_in_ctb = ((
sps->width >>
sps->log2_min_cb_size) + 1) *
3249 ((
sps->height >>
sps->log2_min_cb_size) + 1);
3250 int new_sequence = (l == &
s->layers[0]) &&
3252 int prev_layers_active_decode =
s->layers_active_decode;
3253 int prev_layers_active_output =
s->layers_active_output;
3256 if (
sps->vps !=
s->vps && l != &
s->layers[0]) {
3264 const HEVCSPS *sps_base =
s->layers[0].sps;
3267 if (l != &
s->layers[0]) {
3270 "Access unit starts with a non-base layer frame\n");
3279 !
sps->vui.common.video_signal_type_present_flag)
3292 "Base/non-base layer SPS have unsupported parameter combination\n");
3303 if (l == &
s->layers[0]) {
3319 memset(l->
is_pcm, 0, (
sps->min_pu_width + 1) * (
sps->min_pu_height + 1));
3326 s->first_nal_type =
s->nal_unit_type;
3336 s->sei.recovery_point.has_recovery_poc) {
3338 s->recovery_poc =
s->poc +
s->sei.recovery_point.recovery_poc_cnt;
3339 else if (
s->poc >=
s->recovery_poc)
3344 if (
s->temporal_id == 0 &&
3352 s->poc_tid0 =
s->poc;
3354 if (
pps->tiles_enabled_flag)
3355 s->local_ctx[0].end_of_tiles_x =
pps->column_width[0] <<
sps->log2_ctb_size;
3359 0, 0,
s->sh.no_output_of_prior_pics_flag);
3383 s->cur_frame->needs_fg = ((
s->sei.common.film_grain_characteristics &&
3384 s->sei.common.film_grain_characteristics->present) ||
3385 s->sei.common.itut_t35.aom_film_grain.enable) &&
3393 if (
s->cur_frame->needs_fg &&
3394 (
s->sei.common.film_grain_characteristics &&
s->sei.common.film_grain_characteristics->present &&
3396 s->cur_frame->f->format) ||
3399 "Unsupported film grain parameters. Ignoring film grain.\n");
3400 s->cur_frame->needs_fg = 0;
3403 if (
s->cur_frame->needs_fg) {
3404 s->cur_frame->frame_grain->format =
s->cur_frame->f->format;
3405 s->cur_frame->frame_grain->width =
s->cur_frame->f->width;
3406 s->cur_frame->frame_grain->height =
s->cur_frame->f->height;
3415 s->cur_frame->f->pict_type = 3 -
s->sh.slice_type;
3418 sps->temporal_layer[
sps->max_sub_layers - 1].num_reorder_pics,
3419 sps->temporal_layer[
sps->max_sub_layers - 1].max_dec_pic_buffering, 0);
3423 if (
s->avctx->hwaccel) {
3435 if (l == &
s->layers[0])
3438 if (nal_idx >=
s->finish_setup_nal_idx)
3447 s->cur_frame =
s->collocated_ref =
NULL;
3454 char msg_buf[4 * (50 + 2 * 2 * 16 )];
3462 pixel_shift =
desc->comp[0].depth > 8;
3467 if (pixel_shift && !
s->checksum_buf) {
3470 frame->linesize[2]));
3471 if (!
s->checksum_buf)
3478 int width =
s->avctx->coded_width;
3479 int height =
s->avctx->coded_height;
3485 for (j = 0; j <
h; j++) {
3489 s->bdsp.bswap16_buf((uint16_t *)
s->checksum_buf,
3490 (
const uint16_t *)
src,
w);
3491 src =
s->checksum_buf;
3498#define MD5_PRI "%016" PRIx64 "%016" PRIx64
3499#define MD5_PRI_ARG(buf) AV_RB64(buf), AV_RB64((const uint8_t*)(buf) + 8)
3501 if (!memcmp(
md5,
s->sei.picture_hash.md5[
i], 16)) {
3503 "plane %d - correct " MD5_PRI "; ",
3507 "mismatching checksum of plane %d - " MD5_PRI " != " MD5_PRI "; ",
3514 "Verifying checksum for frame with POC %d: %s\n",
3526 if (
out->needs_fg) {
3529 switch (fgp->
type) {
3543 if (
s->avctx->hwaccel) {
3547 "hardware accelerator failed to decode picture\n");
3552 s->sei.picture_hash.is_md5) {
3558 s->sei.picture_hash.is_md5 = 0;
3561 l -
s->layers,
s->poc);
3568 const int layer_idx =
s->vps ?
s->vps->layer_idx[
s->nuh_layer_id] : 0;
3575 if (layer_idx < 0 ||
3576 (
s->nuh_layer_id > 0 && !(
s->layers_active_decode & (1 << layer_idx))))
3588 s->slice_initialized = 0;
3597 s->no_rasl_output_flag)) {
3598 if (
s->sh.first_slice_in_pic_flag)
3599 s->skipping_frame = 1;
3602 if (
s->sh.first_slice_in_pic_flag)
3603 s->skipping_frame = 0;
3606 if (
s->cur_layer != layer_idx &&
3607 s->layers[
s->cur_layer].cur_frame &&
3611 s->cur_layer = layer_idx;
3612 l = &
s->layers[
s->cur_layer];
3614 if (
s->sh.first_slice_in_pic_flag) {
3616 av_log(
s->avctx,
AV_LOG_ERROR,
"Two slices reporting being the first in the same frame.\n");
3628 if (
s->nal_unit_type !=
s->first_nal_type) {
3630 "Non-matching NAL types of the VCL NALUs: %d %d\n",
3631 s->first_nal_type,
s->nal_unit_type);
3648 s->nal_unit_type =
nal->type;
3649 s->nuh_layer_id =
nal->nuh_layer_id;
3650 s->temporal_id =
nal->temporal_id;
3659 nal->type,
nal->raw_data,
nal->raw_size);
3664 switch (
s->nal_unit_type) {
3672 nal->nuh_layer_id,
s->apply_defdispwin);
3716 "Skipping NAL unit %d\n",
s->nal_unit_type);
3724 "Skipping invalid undecodable NALU: %d\n",
s->nal_unit_type);
3733 s->sei.recovery_point.has_recovery_poc = 0;
3739 int eos_at_start = 1;
3742 s->cur_frame =
s->collocated_ref =
NULL;
3743 s->last_eos =
s->eos;
3745 s->slice_initialized = 0;
3757 s->nal_length_size,
s->avctx->codec_id,
flags);
3760 "Error splitting the input into NAL units.\n");
3764 for (
int i = 0;
i <
s->pkt.nb_nals;
i++) {
3787 for (
int i =
s->pkt.nb_nals - 1;
i > 0 ;
i--) {
3789 && !
s->pkt.nals[
i].nuh_layer_id && !
s->pkt.nals[
i].temporal_id) {
3790 rpu_nal = &
s->pkt.nals[
i];
3798 av_log(
s->avctx,
AV_LOG_WARNING,
"Multiple Dolby Vision RPUs found in one AU. Skipping previous.\n");
3809 s->avctx->err_recognition);
3818 for (
int i = 0;
i <
s->pkt.nb_nals;
i++) {
3828 "Error parsing NAL unit #%d.\n",
i);
3855 &
s->nal_length_size,
s->avctx->err_recognition,
3856 s->apply_defdispwin,
s->avctx);
3862 if (first &&
s->ps.sps_list[
i]) {
3901 s->layers_active_output, 0, 0, 0);
3908 s->pkt_dts = avpkt->
dts;
3911 if (sd && sd_size > 0) {
3918 if (sd && sd_size >=
sizeof(
s->dovi_ctx.cfg)) {
3919 int old =
s->dovi_ctx.cfg.dv_profile;
3923 "New DOVI configuration record from input packet (profile %d -> %u).\n",
3924 old,
s->dovi_ctx.cfg.dv_profile);
3948 if (
src->needs_fg) {
3961 dst->nb_rpl_elems =
src->nb_rpl_elems;
3964 dst->ctb_count =
src->ctb_count;
3967 dst->base_layer_frame =
src->base_layer_frame;
3970 src->hwaccel_picture_private);
4004 for (
int i = 0;
i <
s->nb_wpp_progress;
i++)
4030 s->nb_local_ctx = 1;
4032 s->local_ctx[0].parent =
s;
4033 s->local_ctx[0].logctx = avctx;
4034 s->local_ctx[0].common_cabac_state = &
s->cabac;
4037 if (!
s->output_fifo)
4055 s->dovi_ctx.logctx = avctx;
4115 memcmp(
s->view_ids, s0->
view_ids,
sizeof(*
s->view_ids) *
s->nb_view_ids)) {
4162 if (
sei->tdrdi.present) {
4180 for (
int i = 0;
i <
sei->tdrdi.num_ref_displays;
i++) {
4216 s->sei.picture_timing.picture_struct = 0;
4236 if (sd && sd->
size >=
sizeof(
s->dovi_ctx.cfg))
4251 s->skipping_frame = 0;
4257#define OFFSET(x) offsetof(HEVCContext, x)
4258#define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
4261 {
"apply_defdispwin",
"Apply default display window from VUI",
OFFSET(apply_defdispwin),
4263 {
"strict-displaywin",
"strictly apply default display window size",
OFFSET(apply_defdispwin),
4265 {
"view_ids",
"Array of view IDs that should be decoded and output; a single -1 to decode all views",
4267 .min = -1, .max = INT_MAX, .flags =
PAR },
4268 {
"view_ids_available",
"Array of available view IDs is exported here",
4271 {
"view_pos_available",
"Array of view positions for view_ids_available is exported here, as AVStereo3DView",
4282 .class_name =
"HEVC decoder",
4307#if CONFIG_HEVC_DXVA2_HWACCEL
4310#if CONFIG_HEVC_D3D11VA_HWACCEL
4313#if CONFIG_HEVC_D3D11VA2_HWACCEL
4316#if CONFIG_HEVC_D3D12VA_HWACCEL
4319#if CONFIG_HEVC_NVDEC_HWACCEL
4322#if CONFIG_HEVC_NVDEC_CUARRAY_HWACCEL
4325#if CONFIG_HEVC_VAAPI_HWACCEL
4328#if CONFIG_HEVC_VDPAU_HWACCEL
4331#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
4334#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_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define FF_THREAD_FRAME
Decode more than one frame at once.
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
int ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size)
Context Adaptive Binary Arithmetic Coder inline functions.
static av_unused const uint8_t * skip_bytes(CABACContext *c, int n)
Skip n bytes and reset the decoder.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int FUNC sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
static int FUNC sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
static int FUNC vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
static int FUNC nal(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawNAL *current, int nal_unit_type)
#define ss(width, name, subs,...)
#define UPDATE_THREAD_CONTEXT(func)
#define FF_CODEC_RECEIVE_FRAME_CB(func)
#define FF_CODEC_CAP_EXPORTS_CROPPING
The decoder sets the cropping fields in the output frames manually.
#define FF_CODEC_CAP_USES_PROGRESSFRAMES
The decoder might make use of the ProgressFrame API.
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
common internal and external API header
void av_container_fifo_free(AVContainerFifo **pcf)
Free a AVContainerFifo and everything in it.
int av_container_fifo_read(AVContainerFifo *cf, void *obj, unsigned flags)
Read the next available object from the FIFO into obj.
size_t av_container_fifo_can_read(const AVContainerFifo *cf)
AVContainerFifo * av_container_fifo_alloc_avframe(unsigned flags)
Allocate an AVContainerFifo instance for AVFrames.
void ff_progress_frame_ref(ProgressFrame *dst, const ProgressFrame *src)
Set dst->f to src->f and make dst a co-owner of src->f.
int ff_frame_new_side_data_from_buf(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef **buf)
Similar to ff_frame_new_side_data, but using an existing buffer ref.
void ff_progress_frame_await(const ProgressFrame *f, int n)
Wait for earlier decoding threads to finish reference frames.
void ff_progress_frame_report(ProgressFrame *f, int n)
Notify later decoding threads when part of their reference frame is ready.
int ff_frame_new_side_data_from_buf_ext(const AVCodecContext *avctx, AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, AVBufferRef **buf)
Same as ff_frame_new_side_data_from_buf, but taking a AVFrameSideData array directly instead of an AV...
const AVPacketSideData * ff_get_coded_side_data(const AVCodecContext *avctx, enum AVPacketSideDataType type)
Get side data of the given type from a decoding context.
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
int ff_frame_new_side_data(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, size_t size, AVFrameSideData **psd)
Wrapper around av_frame_new_side_data, which rejects side data overridden by the demuxer.
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data,...
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define AV_PROFILE_HEVC_SCC
static enum AVPixelFormat pix_fmt
void ff_dovi_ctx_replace(DOVIContext *s, const DOVIContext *s0)
av_cold void ff_dovi_ctx_flush(DOVIContext *s)
Partially reset the internal state.
void ff_dovi_ctx_unref(DOVIContext *s)
Completely reset a DOVIContext, preserving only logctx.
int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size, int err_recognition)
Parse the contents of a Dolby Vision RPU and update the parsed values in the DOVIContext struct.
int ff_dovi_attach_side_data(DOVIContext *s, AVFrame *frame)
Attach the decoded AVDOVIMetadata as side data to an AVFrame.
void(* flush)(AVBSFContext *ctx)
static int decode_slice(AVCodecContext *c, void *arg)
const AVFilmGrainParams * av_film_grain_params_select(const AVFrame *frame)
Select the most appropriate film grain parameters set for the frame, taking into account the frame's ...
@ AV_FILM_GRAIN_PARAMS_H274
The union is valid when interpreted as AVFilmGrainH274Params (codec.h274)
@ AV_FILM_GRAIN_PARAMS_AV1
The union is valid when interpreted as AVFilmGrainAOMParams (codec.aom)
@ AV_FILM_GRAIN_PARAMS_NONE
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int get_bits_left(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static const uint8_t * align_get_bits(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
static int get_bits_bytesize(const GetBitContext *s, int round_up)
Get the size of the GetBitContext's buffer in bytes.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static 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_split_transform_flag_decode(HEVCLocalContext *lc, int log2_trafo_size)
int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS *pps, int ctb_addr_ts, const uint8_t *data, size_t size, int is_wpp)
int ff_hevc_log2_res_scale_abs(HEVCLocalContext *lc, int idx)
int ff_hevc_sao_eo_class_decode(HEVCLocalContext *lc)
void ff_hevc_hls_mvd_coding(HEVCLocalContext *lc, int x0, int y0, int log2_cb_size)
int ff_hevc_mpm_idx_decode(HEVCLocalContext *lc)
int ff_hevc_sao_band_position_decode(HEVCLocalContext *lc)
int ff_hevc_inter_pred_idc_decode(HEVCLocalContext *lc, int nPbW, int nPbH)
int ff_hevc_cbf_cb_cr_decode(HEVCLocalContext *lc, int trafo_depth)
int ff_hevc_rem_intra_luma_pred_mode_decode(HEVCLocalContext *lc)
int ff_hevc_sao_offset_sign_decode(HEVCLocalContext *lc)
int ff_hevc_intra_chroma_pred_mode_decode(HEVCLocalContext *lc)
int ff_hevc_cbf_luma_decode(HEVCLocalContext *lc, int trafo_depth)
int ff_hevc_merge_idx_decode(HEVCLocalContext *lc)
void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, const HEVCPPS *pps, int x0, int y0, int log2_trafo_size, enum ScanType scan_idx, int c_idx)
int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, uint8_t *tab_ct_depth, const HEVCSPS *sps, int ct_depth, int x0, int y0)
int ff_hevc_pcm_flag_decode(HEVCLocalContext *lc)
int ff_hevc_part_mode_decode(HEVCLocalContext *lc, const HEVCSPS *sps, int log2_cb_size)
int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, uint8_t *skip_flag, int x0, int y0, int x_cb, int y_cb, int min_cb_width)
int ff_hevc_cu_qp_delta_sign_flag(HEVCLocalContext *lc)
int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCLocalContext *lc)
int ff_hevc_pred_mode_decode(HEVCLocalContext *lc)
int ff_hevc_ref_idx_lx_decode(HEVCLocalContext *lc, int num_ref_idx_lx)
void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
void ff_hevc_set_qPy(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int xBase, int yBase, int log2_cb_size)
void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x0, int y0, int log2_trafo_size)
void ff_hevc_hls_filters(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x_ctb, int y_ctb, int ctb_size)
void ff_hevc_hls_filter(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x, int y, int ctb_size)
int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps, HEVCSEI *sei, int *is_nalff, int *nal_length_size, int err_recognition, int apply_defdispwin, void *logctx)
int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
void ff_hevc_ps_uninit(HEVCParamSets *ps)
int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header)
int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps, unsigned nuh_layer_id, int apply_defdispwin)
static int ff_hevc_compute_poc(const HEVCSPS *sps, int pocTid0, int poc_lsb, int nal_unit_type)
int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s, const HEVCParamSets *ps, enum HEVCNALUnitType type)
static void ff_hevc_reset_sei(HEVCSEI *sei)
Reset SEI values that are stored on the Context.
#define BOUNDARY_UPPER_SLICE
int ff_hevc_output_frames(HEVCContext *s, unsigned layers_active_decode, unsigned layers_active_output, unsigned max_output, unsigned max_dpb, int discard)
Find frames in the DPB that are ready for output and either write them to the output FIFO or drop the...
#define BOUNDARY_LEFT_TILE
void ff_hevc_flush_dpb(HEVCContext *s)
Drop all frames currently in DPB.
int ff_hevc_frame_nb_refs(const SliceHeader *sh, const HEVCPPS *pps, unsigned layer_idx)
Get the number of candidate references for the current frame.
#define HEVC_RECOVERY_END
#define HEVC_RECOVERY_UNSPECIFIED
void ff_hevc_clear_refs(HEVCLayerContext *l)
Mark all frames in DPB as unused for reference.
int ff_hevc_set_new_ref(HEVCContext *s, HEVCLayerContext *l, int poc)
int ff_hevc_frame_rps(HEVCContext *s, HEVCLayerContext *l)
Construct the reference picture sets for the current frame.
void ff_hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, const HEVCPPS *pps, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv, int mvp_lx_flag, int LX)
#define QPEL_EXTRA_BEFORE
static av_always_inline int ff_hevc_nal_is_nonref(enum HEVCNALUnitType type)
void ff_hevc_set_neighbour_available(HEVCLocalContext *lc, int x0, int y0, int nPbW, int nPbH, int log2_ctb_size)
void ff_hevc_luma_mv_merge_mode(HEVCLocalContext *lc, const HEVCPPS *pps, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv)
#define EPEL_EXTRA_BEFORE
void ff_hevc_unref_frame(HEVCFrame *frame, int flags)
#define SAMPLE_CTB(tab, x, y)
int ff_hevc_slice_rpl(HEVCContext *s)
Construct the reference picture list(s) for the current slice.
#define BOUNDARY_UPPER_TILE
#define EDGE_EMU_BUFFER_STRIDE
#define BOUNDARY_LEFT_SLICE
#define FF_HW_HAS_CB(avctx, function)
#define FF_HW_SIMPLE_CALL(avctx, function)
#define FF_HW_CALL(avctx, function,...)
#define HWACCEL_NVDEC_CUARRAY(codec)
#define HWACCEL_DXVA2(codec)
#define HWACCEL_VDPAU(codec)
#define HWACCEL_D3D12VA(codec)
#define HWACCEL_VULKAN(codec)
#define HWACCEL_NVDEC(codec)
#define HWACCEL_VAAPI(codec)
#define HWACCEL_D3D11VA(codec)
#define HWACCEL_VIDEOTOOLBOX(codec)
#define HWACCEL_D3D11VA2(codec)
static const int8_t mv[256][2]
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, void *logctx, int nal_length_size, enum AVCodecID codec_id, int flags)
Split an input packet into NAL units.
@ HEVC_SCALABILITY_AUXILIARY
static av_cold int hevc_init_context(AVCodecContext *avctx)
static int set_sps(HEVCContext *s, HEVCLayerContext *l, const HEVCSPS *sps)
static void hls_prediction_unit(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int partIdx, int idx)
static int hevc_receive_frame(AVCodecContext *avctx, AVFrame *frame)
static int luma_intra_pred_mode(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCSPS *sps, int x0, int y0, int pu_size, int prev_intra_luma_pred_flag)
8.4.1
static int setup_multilayer(HEVCContext *s, const HEVCVPS *vps)
static int hls_transform_tree(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, int log2_cb_size, int log2_trafo_size, int trafo_depth, int blk_idx, const int *base_cbf_cb, const int *base_cbf_cr)
static void intra_prediction_unit(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCSPS *sps, int x0, int y0, int log2_cb_size)
static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
static av_cold int hevc_decode_init(AVCodecContext *avctx)
static void luma_mc_uni(HEVCLocalContext *lc, const HEVCPPS *pps, const HEVCSPS *sps, uint8_t *dst, ptrdiff_t dststride, const AVFrame *ref, const Mv *mv, int x_off, int y_off, int block_w, int block_h, int luma_weight, int luma_offset)
8.5.3.2.2.1 Luma sample unidirectional interpolation process
static int export_multilayer(HEVCContext *s, const HEVCVPS *vps)
static const AVClass hevc_decoder_class
static enum AVPixelFormat map_to_alpha_format(HEVCContext *s, enum AVPixelFormat pix_fmt)
static int hevc_sei_to_context(AVCodecContext *avctx, HEVCSEI *sei)
static av_cold int hevc_decode_free(AVCodecContext *avctx)
static int decode_slice_data(HEVCContext *s, const HEVCLayerContext *l, const H2645NAL *nal, GetBitContext *gb)
static void luma_mc_bi(HEVCLocalContext *lc, const HEVCPPS *pps, const HEVCSPS *sps, uint8_t *dst, ptrdiff_t dststride, const AVFrame *ref0, const Mv *mv0, int x_off, int y_off, int block_w, int block_h, const AVFrame *ref1, const Mv *mv1, struct MvField *current_mv)
8.5.3.2.2.1 Luma sample bidirectional interpolation process
static int hls_coding_quadtree(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int x0, int y0, int log2_cb_size, int cb_depth)
static void hls_decode_neighbour(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int x_ctb, int y_ctb, int ctb_addr_ts)
static int pred_weight_table(SliceHeader *sh, void *logctx, const HEVCSPS *sps, GetBitContext *gb)
static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length, int first)
static int export_stream_params_from_sei(HEVCContext *s)
static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, GetBitContext *gb)
static int hls_cross_component_pred(HEVCLocalContext *lc, int idx)
static void chroma_mc_bi(HEVCLocalContext *lc, const HEVCPPS *pps, const HEVCSPS *sps, uint8_t *dst0, ptrdiff_t dststride, const AVFrame *ref0, const AVFrame *ref1, int x_off, int y_off, int block_w, int block_h, const MvField *current_mv, int cidx)
8.5.3.2.2.2 Chroma sample bidirectional interpolation process
#define SET_SAO(elem, value)
int ff_hevc_is_alpha_video(const HEVCContext *s)
static int pic_arrays_init(HEVCLayerContext *l, const HEVCSPS *sps)
static int hls_decode_entry_wpp(AVCodecContext *avctx, void *hevc_lclist, int job, int thread)
static void intra_prediction_unit_default_value(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCSPS *sps, int x0, int y0, int log2_cb_size)
static int hevc_ref_frame(HEVCFrame *dst, const HEVCFrame *src)
static int hls_pcm_sample(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x0, int y0, int log2_cb_size)
static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
static int verify_md5(HEVCContext *s, AVFrame *frame)
int ff_hevc_requested_layers(const HEVCContext *s, const HEVCVPS *vps, unsigned *active_output)
Resolve the caller's view selection into layers.
static int decode_lt_rps(const HEVCSPS *sps, LongTermRPS *rps, GetBitContext *gb, int cur_poc, int poc_lsb)
static const uint8_t hevc_pel_weight[65]
static int set_side_data(HEVCContext *s)
static int find_finish_setup_nal(const HEVCContext *s)
static void decode_reset_recovery_point(HEVCContext *s)
#define SUBDIVIDE(x, y, idx)
static void pic_arrays_free(HEVCLayerContext *l)
NOTE: Each function hls_foo correspond to the function foo in the specification (HLS stands for High ...
static int hevc_frame_start(HEVCContext *s, HEVCLayerContext *l, unsigned nal_idx)
static void hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, const HEVCPPS *pps, const HEVCSPS *sps, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv)
static int wpp_progress_init(HEVCContext *s, unsigned count)
static int decode_nal_unit(HEVCContext *s, unsigned nal_idx)
static int decode_slice(HEVCContext *s, unsigned nal_idx, GetBitContext *gb)
static void chroma_mc_uni(HEVCLocalContext *lc, const HEVCPPS *pps, const HEVCSPS *sps, uint8_t *dst0, ptrdiff_t dststride, const uint8_t *src0, ptrdiff_t srcstride, int reflist, int x_off, int y_off, int block_w, int block_h, const struct MvField *current_mv, int chroma_weight, int chroma_offset)
8.5.3.2.2.2 Chroma sample uniprediction interpolation process
static const uint8_t tab_mode_idx[]
static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
static av_cold void hevc_decode_flush(AVCodecContext *avctx)
static void hevc_await_progress(const HEVCContext *s, const HEVCFrame *ref, const Mv *mv, int y0, int height)
static int hls_transform_unit(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase, int log2_cb_size, int log2_trafo_size, int blk_idx, int cbf_luma, int *cbf_cb, int *cbf_cr)
static void set_deblocking_bypass(uint8_t *is_pcm, const HEVCSPS *sps, int x0, int y0, int log2_cb_size)
static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int x0, int y0, int log2_cb_size)
static int hevc_frame_end(HEVCContext *s, HEVCLayerContext *l)
static av_always_inline void set_ct_depth(const HEVCSPS *sps, uint8_t *tab_ct_depth, int x0, int y0, int log2_cb_size, int ct_depth)
static void export_stream_params(HEVCContext *s, const HEVCSPS *sps)
static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps)
static void hls_sao_param(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, const HEVCSPS *sps, int rx, int ry)
common internal api header.
Multithreading API for decoders.
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
Macro definitions for various function/variable attributes.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
void av_log_once(void *avcl, int initial_level, int subsequent_level, int *state, const char *fmt,...)
#define FFSWAP(type, a, b)
Public header for MD5 hash function implementation.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
static int is_pcm(enum AVCodecID codec_id)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
#define AV_PIX_FMT_YUV444P12
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
@ AVCHROMA_LOC_UNSPECIFIED
#define AV_PIX_FMT_YUV420P10
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_JPEG
Full range content.
#define AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV422P12
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_D3D12
Hardware surfaces for Direct3D 12.
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_DXVA2_VLD
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer.
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ AV_PIX_FMT_YUVA422P10LE
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
@ AV_PIX_FMT_CUARRAY
hardware decoding through openharmony
@ AV_PIX_FMT_D3D11VA_VLD
HW decoding through Direct3D11 via old API, Picture.data[3] contains a ID3D11VideoDecoderOutputView p...
@ AV_PIX_FMT_YUV422P10LE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
@ AV_PIX_FMT_VDPAU
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
#define AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV444P10
void ff_hevc_pred_init(HEVCPredContext *hpc, int bit_depth)
const AVProfile ff_hevc_profiles[]
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
AVRefStructPool * av_refstruct_pool_alloc(size_t size, unsigned flags)
Equivalent to av_refstruct_pool_alloc(size, flags, NULL, NULL, NULL, NULL, NULL)
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
void av_refstruct_replace(void *dstp, const void *src)
Ensure *dstp refers to the same object as src.
const void * av_refstruct_ref_c(const void *obj)
Analog of av_refstruct_ref(), but for constant objects.
void * av_refstruct_ref(void *obj)
Create a new reference to an object managed via this API, i.e.
static void av_refstruct_pool_uninit(AVRefStructPool **poolp)
Mark the pool as being available for freeing.
#define FF_ARRAY_ELEMS(a)
#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
H2645SEIAlternativeTransfer alternative_transfer
int is_nalff
this flag is != 0 if bitstream is encapsulated as a format defined in 14496-15
int film_grain_warning_shown
AVBufferRef * rpu_buf
0 or 1 Dolby Vision RPUs.
int nal_length_size
Number of bytes used for nal length (1, 2 or 4)
HEVCLayerContext layers[HEVC_VPS_MAX_LAYERS]
int eos
current packet contains an EOS/EOB NAL
unsigned layers_active_output
DOVIContext dovi_ctx
Dolby Vision decoding context.
unsigned layers_active_decode
uint8_t * filter_slice_edges
struct AVRefStructPool * rpl_tab_pool
int32_t * tab_slice_address
uint8_t * sao_pixel_buffer_h[3]
struct AVRefStructPool * tab_mvf_pool
uint8_t * sao_pixel_buffer_v[3]
uint8_t edge_emu_buffer[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
const struct HEVCContext * parent
int16_t tmp[MAX_PB_SIZE *MAX_PB_SIZE]
uint8_t ctb_up_right_flag
uint8_t edge_emu_buffer2[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
const HEVCVPS * vps_list[HEVC_MAX_VPS_COUNT]
RefStruct references.
const HEVCPPS * pps_list[HEVC_MAX_PPS_COUNT]
RefStruct references.
const HEVCSPS * sps_list[HEVC_MAX_SPS_COUNT]
RefStruct references.
uint16_t left_view_id[32]
uint16_t right_view_id[32]
HEVCSEIRecoveryPoint recovery_point
int width
coded frame dimension in various units
enum AVPixelFormat pix_fmt
unsigned int right_offset
unsigned int bottom_offset
uint8_t poc_msb_present[32]
int8_t ref_idx[2]
refIdxL0, refIdxL1
int16_t x
horizontal component of motion vector
int16_t y
vertical component of motion vector
uint8_t intra_pred_mode_c[4]
uint8_t intra_pred_mode[4]
int rem_intra_luma_pred_mode
struct HEVCFrame * ref[HEVC_MAX_REFS]
int offset_sign[3][4]
sao_offset_sign
int16_t offset_val[3][5]
SaoOffsetVal.
int eo_class[3]
sao_eo_class
int offset_abs[3][4]
sao_offset_abs
uint8_t type_idx[3]
sao_type_idx
#define av_malloc_array(a, b)
static void error(const char *err)
static int ref[MAX_W *MAX_W]
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)