30#define POS(c_idx, x, y) \
31 &fc->frame->data[c_idx][((y) >> fc->ps.sps->vshift[c_idx]) * fc->frame->linesize[c_idx] + \
32 (((x) >> fc->ps.sps->hshift[c_idx]) << fc->ps.sps->pixel_shift)]
44 const int x_tb = tb->
x0 >>
fc->ps.sps->min_cb_log2_size_y;
45 const int y_tb = tb->
y0 >>
fc->ps.sps->min_cb_log2_size_y;
46 const int x_c = (tb->
x0 + (tb->
tb_width <<
sps->hshift[1] >> 1) ) >>
fc->ps.sps->min_cb_log2_size_y;
47 const int y_c = (tb->
y0 + (tb->
tb_height <<
sps->vshift[1] >> 1)) >>
fc->ps.sps->min_cb_log2_size_y;
48 const int min_cb_width =
fc->ps.pps->min_cb_width;
49 const int intra_mip_flag =
SAMPLE_CTB(
fc->tab.imf, x_tb, y_tb);
51 if (intra_mip_flag && !tb->
c_idx) {
53 }
else if (
is_cclm(pred_mode_intra)) {
54 int intra_mip_flag_c =
SAMPLE_CTB(
fc->tab.imf, x_c, y_c);
56 if (intra_mip_flag_c) {
66 return pred_mode_intra;
76 const int n_lfnst_out_size = (
w >= 8 &&
h >= 8) ? 48 : 16;
77 const int log2_lfnst_size = (
w >= 8 &&
h >= 8) ? 3 : 2;
78 const int n_lfnst_size = 1 << log2_lfnst_size;
79 const int non_zero_size = ((
w == 8 &&
h == 8) || (
w == 4 &&
h == 4)) ? 8 : 16;
81 const int transpose = pred_mode_intra > 34;
84 for (
int x = 0; x < non_zero_size; x++) {
94 if (n_lfnst_size == 4) {
95 for (
int y = 0; y < 4; y++) {
104 for (
int y = 0; y < 8; y++) {
123 for (
int y = 0; y < n_lfnst_size; y++) {
124 int size = (y < 4) ? n_lfnst_size : 4;
141 int implicit_mts_enabled = 0;
147 if (
sps->r->sps_mts_enabled_flag) {
152 implicit_mts_enabled = 1;
155 if (implicit_mts_enabled) {
167 *trh = mts_to_trh[cu->
mts_idx];
168 *trv = mts_to_trv[cu->
mts_idx];
174 const int hs =
sps->hshift[ch_type];
175 const int vs =
sps->vshift[ch_type];
199#define MIN_ISP_PRED_WIDTH 4
233 int x0, y0,
w,
h, ret;
241 fc->vvcdsp.intra.intra_pred(lc, x0, y0,
w,
h, 0);
251 fc->vvcdsp.intra.intra_cclm_pred(lc, x0, y0,
w,
h);
253 fc->vvcdsp.intra.intra_pred(lc, x0, y0,
w,
h, 1);
254 fc->vvcdsp.intra.intra_pred(lc, x0, y0,
w,
h, 2);
265 const int shift,
const int log2_transform_range)
267 const int add = 1 << (
shift - 1);
268 for (
int y = 0; y <
h; y++) {
270 for (
int x = 0; x < nzw; x++) {
274 memset(p, 0,
sizeof(*p) * (
w - nzw));
280 const int add = 1 << (
shift - 1);
281 for (
int y = 0; y <
h; y++) {
282 for (
int x = 0; x <
w; x++) {
283 int *o =
out + y *
w + x;
284 const int *
i = in + y *
w + x;
298 const int qp = cu->
qp[idx] + (idx ? 0 :
sps->qp_bd_offset);
299 const int act_offset[] = { -5, 1, 3, 1 };
303 const int qp_prime_ts_min = 4 + 6 *
sps->r->sps_min_qp_prime_ts;
305 tb->
qp =
av_clip(qp + qp_act_offset, qp_prime_ts_min, 63 +
sps->qp_bd_offset);
310 const int rect_non_ts_flag = log_sum & 1;
312 tb->
qp =
av_clip(qp + qp_act_offset, 0, 63 +
sps->qp_bd_offset);
314 tb->
bd_shift =
sps->bit_depth + rect_non_ts_flag + (log_sum / 2)
320static const uint8_t
rem6[63 + 8 * 6 + 1] = {
321 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
322 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
323 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
324 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
325 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3,
328static const uint8_t
div6[63 + 8 * 6 + 1] = {
329 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
330 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7,
331 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11,
332 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15,
333 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18,
337 { 40, 45, 51, 57, 64, 72 },
338 { 57, 64, 72, 80, 90, 102 }
344 const int addin = sh_dep_quant_used_flag && !tb->
ts;
345 const int qp = tb->
qp + addin;
354 const int ids[2][3][6] = {
356 { 0, 2, 8, 14, 20, 26 },
357 { 0, 3, 9, 15, 21, 21 },
358 { 0, 4, 10, 16, 22, 22 }
361 { 0, 5, 11, 17, 23, 27 },
362 { 0, 6, 12, 18, 24, 24 },
363 { 1, 7, 13, 19, 25, 25 },
372 const int log2_matrix_size = (
id < 2) ? 1 : (
id < 8) ? 2 : 3;
373 uint8_t *p = scale_m;
377 (
sps->r->sps_scaling_matrix_for_alternative_colour_space_disabled_flag &&
386 for (
int y = tb->
min_scan_y; y <= tb->max_scan_y; y++) {
387 const int off = y << log2_matrix_size >> tb->
log2_tb_height << log2_matrix_size;
390 for (
int x = tb->
min_scan_x; x <= tb->max_scan_x; x++)
401 const int scale,
const int scale_m,
const int log2_transform_range)
419 for (
int y = tb->
min_scan_y; y <= tb->max_scan_y; y++) {
420 for (
int x = tb->
min_scan_x; x <= tb->max_scan_x; x++) {
439 const int shift[] = { 7, 5 +
sps->log2_transform_range -
sps->bit_depth };
442 const int add[] = { 1 << (
shift[0] - 1), 1 << (
shift[1] - 1) };
444 const int dc = (t *
DCT_A + add[1]) >>
shift[1];
446 for (
int i = 0;
i <
w *
h;
i++)
452 for (
int x = 0; x < nzw; x++)
456 for (
int y = 0; y <
h; y++)
469 if ((
w > 1 && nzw == 1 && trh ==
VVC_DCT2) || (
h > 1 && nzh == 1 && trv ==
VVC_DCT2)) {
470 const int shift = 6 +
sps->log2_transform_range -
sps->bit_depth;
471 const int add = 1 << (
shift - 1);
474 for (
int i = 0;
i <
w *
h;
i++)
493 vertical,
sps->log2_transform_range);
505 const int c_idx = tb->
c_idx;
506 const int ch_type = c_idx > 0;
509 const int chroma_scale = ch_type && sh->
r->
sh_lmcs_used_flag &&
fc->ps.ph.r->ph_chroma_residual_scale_flag && (
w *
h > 4);
512 for (
int j = 0; j < 1 + has_jcbcr; j++) {
513 const bool is_jcbcr = j > 0;
518 if (!j && has_jcbcr) {
519 const int c_sign = 1 - 2 *
fc->ps.ph.r->ph_joint_cbcr_sign_flag;
524 fc->vvcdsp.intra.lmcs_scale_chroma(lc, coeffs,
w,
h, cu->
x0, cu->
y0);
535 const int c_idx = tb->
c_idx;
536 const int ch_type = c_idx > 0;
537 const ptrdiff_t
stride =
fc->frame->linesize[c_idx];
542 if (ch_type == target_ch_type && has_residual)
556 const int c_idx = tb->
c_idx;
557 const int ch_type = c_idx > 0;
558 const bool do_itx = is_act_luma || !cu->
act_enabled_flag && ch_type == target_ch_type;
580 fc->vvcdsp.itx.adaptive_color_transform(
581 tbs[
LUMA].coeffs, tbs[
CB].coeffs, tbs[
CR].coeffs,
582 tbs[
LUMA].tb_width, tbs[
LUMA].tb_height);
596 for (
int ch_type = start; ch_type <= end; ch_type++) {
598 for (
int i = 0; tu;
i++) {
609#define IBC_POS(c_idx, x, y) \
610 (fc->tab.ibc_vir_buf[c_idx] + \
611 (x << ps) + (y + ((cu->y0 & ~(sps->ctb_size_y - 1)) >> vs)) * ibc_stride)
612#define IBC_X(x) ((x) & ((fc->tab.sz.ibc_buffer_width >> hs) - 1))
613#define IBC_Y(y) ((y) & ((1 << sps->ctb_log2_size_y >> vs) - 1))
622 const int hs =
sps->hshift[c_idx];
623 const int vs =
sps->vshift[c_idx];
624 const int ps =
sps->pixel_shift;
625 const int ref_x =
IBC_X((cu->
x0 >> hs) + (bv->
x >> (4 + hs)));
626 const int ref_y =
IBC_Y((cu->
y0 >> vs) + (bv->
y >> (4 + vs)));
629 const int ibc_buf_width =
fc->tab.sz.ibc_buffer_width >> hs;
630 const int rw =
FFMIN(
w, ibc_buf_width - ref_x);
631 const int ibc_stride = ibc_buf_width << ps;
632 const int dst_stride =
fc->frame->linesize[c_idx];
633 const uint8_t *ibc_buf =
IBC_POS(c_idx, ref_x, ref_y);
640 ibc_buf =
IBC_POS(c_idx, 0, ref_y);
665 for (
int c_idx = start; c_idx < end; c_idx++) {
666 const int hs =
sps->hshift[c_idx];
667 const int vs =
sps->vshift[c_idx];
668 const int ps =
sps->pixel_shift;
669 const int x =
IBC_X(cu->
x0 >> hs);
670 const int y =
IBC_Y(cu->
y0 >> vs);
671 const int src_stride =
fc->frame->linesize[c_idx];
672 const int ibc_stride =
fc->tab.sz.ibc_buffer_width >> hs << ps;
673 const uint8_t *
src =
POS(c_idx, cu->
x0, cu->
y0);
674 uint8_t *ibc_buf =
IBC_POS(c_idx, x, y);
683 const int qp_prime_ts_min = 4 + 6 *
sps->r->sps_min_qp_prime_ts;
687 qp =
FFMAX(qp_prime_ts_min, tb->
qp);
698 const int ps =
sps->pixel_shift;
702 const int c_idx = tb->
c_idx;
705 const ptrdiff_t
stride =
fc->frame->linesize[c_idx];
716 const int x_ctb = rx <<
sps->ctb_log2_size_y;
717 const int y_ctb = ry <<
sps->ctb_log2_size_y;
748 if (
sps->r->sps_ibc_enabled_flag)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define i(width, name, range_min, range_max)
static int FUNC sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
void ff_vvc_channel_range(int *start, int *end, const VVCTreeType tree_type, const uint8_t chroma_format_idc)
void ff_vvc_set_neighbour_available(VVCLocalContext *lc, const int x0, const int y0, const int w, const int h)
void ff_vvc_ctu_free_cus(CodingUnit **cus)
void ff_vvc_decode_neighbour(VVCLocalContext *lc, const int x_ctb, const int y_ctb, const int rx, const int ry, const int rs)
static const uint16_t fc[]
reference-counted frame API
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
#define SAMPLE_CTB(tab, x, y)
void ff_vvc_predict_ciip(VVCLocalContext *lc)
CIIP(Combined Inter-Intra Prediction) for a coding block.
static int add_reconstructed_area(VVCLocalContext *lc, const int ch_type, const int x0, const int y0, const int w, const int h)
static void itx_1d(const VVCFrameContext *fc, TransformBlock *tb, const enum VVCTxType trh, const enum VVCTxType trv)
static int get_chroma_predict_unit(const CodingUnit *cu, const TransformUnit *tu, const int idx, int *x0, int *y0, int *w, int *h)
int ff_vvc_palette_derive_scale(VVCLocalContext *lc, const TransformUnit *tu, TransformBlock *tb)
static int derive_ilfnst_pred_mode_intra(const VVCLocalContext *lc, const TransformBlock *tb)
static int is_cclm(enum IntraPredMode mode)
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static void transform_bdpcm(TransformBlock *tb, const VVCLocalContext *lc, const CodingUnit *cu)
static void intra_block_copy(const VVCLocalContext *lc, const int c_idx)
static void ibc_fill_vir_buf(const VVCLocalContext *lc, const CodingUnit *cu)
static void add_residual(const VVCLocalContext *lc, TransformUnit *tu, const int target_ch_type)
#define IBC_POS(c_idx, x, y)
static void itransform(VVCLocalContext *lc, TransformUnit *tu, const int target_ch_type)
static av_always_inline int scale_coeff(const TransformBlock *tb, int coeff, const int scale, const int scale_m, const int log2_transform_range)
static void scale_clip(int *coeff, const int nzw, const int w, const int h, const int shift, const int log2_transform_range)
static const uint8_t div6[63+8 *6+1]
static int get_luma_predict_unit(const CodingUnit *cu, const TransformUnit *tu, const int idx, int *x0, int *y0, int *w, int *h)
static void itx_2d(const VVCFrameContext *fc, TransformBlock *tb, const enum VVCTxType trh, const enum VVCTxType trv)
static void derive_qp(const VVCLocalContext *lc, const TransformUnit *tu, TransformBlock *tb)
static int predict_intra(VVCLocalContext *lc, const TransformUnit *tu, const int idx, const int target_ch_type)
static void add_tu_area(const TransformUnit *tu, int *x0, int *y0, int *w, int *h)
static const uint8_t rem6[63+8 *6+1]
#define MIN_ISP_PRED_WIDTH
static int reconstruct(VVCLocalContext *lc)
static void dequant(const VVCLocalContext *lc, const TransformUnit *tu, TransformBlock *tb)
static const uint8_t * derive_scale_m(const VVCLocalContext *lc, const TransformBlock *tb, uint8_t *scale_m)
static void ilfnst_transform(const VVCLocalContext *lc, TransformBlock *tb)
static void lmcs_scale_chroma(VVCLocalContext *lc, TransformUnit *tu, TransformBlock *tb, const int target_ch_type)
static void derive_transform_type(const VVCFrameContext *fc, const VVCLocalContext *lc, const TransformBlock *tb, enum VVCTxType *trh, enum VVCTxType *trv)
static av_always_inline int derive_scale(const TransformBlock *tb, const int sh_dep_quant_used_flag)
static void vvc_predict_palette(VVCLocalContext *lc)
static void vvc_predict_ibc(const VVCLocalContext *lc)
int ff_vvc_reconstruct(VVCLocalContext *lc, const int rs, const int rx, const int ry)
reconstruct a CTU
static const int level_scale[2][6]
int ff_vvc_wide_angle_mode_mapping(const CodingUnit *cu, int tb_width, int tb_height, int c_idx, int pred_mode_intra)
void ff_vvc_inv_lfnst_1d(int *v, const int *u, int no_zero_size, int n_tr_s, int pred_mode_intra, int lfnst_idx, int log2_transform_range)
static int shift(int a, int b)
#define u(width, name, range_min, range_max)
#define FF_ARRAY_ELEMS(a)
int apply_lfnst_flag[VVC_MAX_SAMPLE_ARRAYS]
ApplyLfnstFlag[].
TransformUnit * head
RefStruct reference.
enum PredMode pred_mode
PredMode.
int bdpcm_flag[VVC_MAX_SAMPLE_ARRAYS]
BdpcmFlag.
uint8_t sbt_horizontal_flag
enum IspType isp_split_type
IntraSubPartitionsSplitType.
struct CodingUnit * next
RefStruct reference.
IntraPredMode intra_pred_mode_y
IntraPredModeY.
IntraPredMode intra_pred_mode_c
IntraPredModeC.
int num_intra_subpartitions
struct CodingUnit::@377377256006074143206227277326325371142325360110 tus
uint8_t intra_mip_flag
intra_mip_flag
int8_t qp[4]
QpY, Qp′Cb, Qp′Cr, Qp′CbCr.
uint8_t sps_chroma_format_idc
Mv mv[2][MAX_CONTROL_POINTS]
int16_t x
horizontal component of motion vector
int16_t y
vertical component of motion vector
const VVCScalingList * sl
RefStruct reference.
const VVCSPS * sps
RefStruct reference.
void(* transform_bdpcm)(int *coeffs, int width, int height, int vertical, int log2_transform_range)
struct VVCLocalContext::@021361013100205372061325107241166327104062156055 lmcs
ReconstructedArea ras[2][MAX_PARTS_IN_CTU]
const H266RawPictureHeader * r
const H266RawSliceHeader * r
RefStruct reference.
const H266RawSPS * r
RefStruct reference.
uint8_t scaling_matrix_rec[SL_MAX_ID][SL_MAX_MATRIX_SIZE *SL_MAX_MATRIX_SIZE]
ScalingMatrixRec.
uint8_t scaling_matrix_dc_rec[SL_MAX_ID - SL_START_16x16]
ScalingMatrixDcRec[refId − 14].
static const double coeff[2][5]
uint8_t ff_vvc_default_scale_m[64 *64]
const uint8_t ff_vvc_diag_scan_y[5][5][16 *16]
const uint8_t ff_vvc_diag_scan_x[5][5][16 *16]