Go to the documentation of this file.
26 #define TMP_STRIDE EDGE_EMU_BUFFER_STRIDE
28 const uint8_t *
const _src, ptrdiff_t _src_stride,
const int src_height,
29 const int _x,
const int _y,
const int dx,
const int dy,
30 const int height,
const int8_t *
hf,
const int8_t *
vf,
const int width,
const int is_uni,
const int is_chroma)
33 int16_t *
tmp = tmp_array;
35 int16_t *dst16 = (int16_t*)
_dst;
36 const ptrdiff_t dst_stride = _dst_stride /
sizeof(
pixel);
37 const ptrdiff_t src_stride = _src_stride /
sizeof(
pixel);
43 const int shift1 = 6 - is_chroma;
44 const int shift2 = 4 + is_chroma;
49 const int tx = _x + dx *
i;
55 for (
int j = 0; j < src_height + extra; j++) {
63 const int ty = _y + dy *
i;
68 tmp = tmp_array + extra_before;
69 for (
int j = 0; j <
width; j++) {
85 const uint8_t *
_src, ptrdiff_t _src_stride,
const int src_height,
86 const int x,
const int y,
const int dx,
const int dy,
89 FUNC(
put_scaled)((uint8_t *)
_dst,
MAX_PB_SIZE *
sizeof(
pixel),
_src, _src_stride, src_height, x, y, dx, dy,
height,
hf,
vf,
width, 0, 0);
93 const uint8_t *
_src, ptrdiff_t _src_stride,
const int src_height,
94 const int x,
const int y,
const int dx,
const int dy,
97 FUNC(
put_scaled)((uint8_t *)
_dst,
MAX_PB_SIZE *
sizeof(
pixel),
_src, _src_stride, src_height, x, y, dx, dy,
height,
hf,
vf,
width, 0, 1);
101 const uint8_t *
_src, ptrdiff_t _src_stride,
const int src_height,
102 const int x,
const int y,
const int dx,
const int dy,
105 FUNC(
put_scaled)(
_dst, _dst_stride,
_src, _src_stride, src_height, x, y, dx, dy,
height,
hf,
vf,
width, 1, 0);
109 const uint8_t *
_src, ptrdiff_t _src_stride,
const int src_height,
110 const int x,
const int y,
const int dx,
const int dy,
113 FUNC(
put_scaled)(
_dst, _dst_stride,
_src, _src_stride, src_height, x, y, dx, dy,
height,
hf,
vf,
width, 1, 1);
117 const uint8_t *
const _src, ptrdiff_t _src_stride,
const int src_height,
118 const int _x,
const int _y,
const int dx,
const int dy,
const int denom,
const int wx,
const int _ox,
119 const int height,
const int8_t *
hf,
const int8_t *
vf,
const int width,
const int is_chroma)
122 int16_t *
tmp = tmp_array;
124 const ptrdiff_t dst_stride = _dst_stride /
sizeof(
pixel);
125 const ptrdiff_t src_stride = _src_stride /
sizeof(
pixel);
128 const int ox = _ox * (1 << (
BIT_DEPTH - 8));
132 const int shift1 = 6 - is_chroma;
133 const int shift2 = 4 + is_chroma;
138 const int tx = _x + dx *
i;
144 for (
int j = 0; j < src_height + extra; j++) {
152 const int ty = _y + dy *
i;
157 tmp = tmp_array + extra_before;
158 for (
int j = 0; j <
width; j++) {
168 const uint8_t *
_src, ptrdiff_t _src_stride,
const int src_height,
169 const int x,
const int y,
const int dx,
const int dy,
const int denom,
const int wx,
const int ox,
172 FUNC(
put_uni_w_scaled)(
_dst, _dst_stride,
_src, _src_stride, src_height, x, y, dx, dy, denom, wx, ox,
height,
hf,
vf,
width, 0);
176 const uint8_t *
_src, ptrdiff_t _src_stride,
const int src_height,
177 const int x,
const int y,
const int dx,
const int dy,
const int denom,
const int wx,
const int ox,
180 FUNC(
put_uni_w_scaled)(
_dst, _dst_stride,
_src, _src_stride, src_height, x, y, dx, dy, denom, wx, ox,
height,
hf,
vf,
width, 1);
189 const ptrdiff_t dst_stride = _dst_stride /
sizeof(
pixel);
193 for (
int y = 0; y <
height; y++) {
194 for (
int x = 0; x <
width; x++)
204 const int denom,
const int w0,
const int w1,
const int o0,
const int o1)
207 const ptrdiff_t dst_stride = _dst_stride /
sizeof(
pixel);
211 for (
int y = 0; y <
height; y++) {
212 for (
int x = 0; x <
width; x++)
222 const uint8_t *_inter,
const ptrdiff_t _inter_stride,
const int intra_weight)
226 const size_t dst_stride = _dst_stride /
sizeof(
pixel);
227 const size_t inter_stride = _inter_stride /
sizeof(
pixel);
228 const int inter_weight = 4 - intra_weight;
230 for (
int y = 0; y <
height; y++) {
231 for (
int x = 0; x <
width; x++)
232 dst[x] = (
dst[x] * intra_weight + inter[x] * inter_weight + 2) >> 2;
234 inter += inter_stride;
240 const int16_t *
src0,
const int16_t *
src1,
241 const uint8_t *
weights,
const int step_x,
const int step_y)
247 dst_stride /=
sizeof(
pixel);
248 for (
int y = 0; y <
height; y++) {
249 for (
int x = 0; x <
width; x++) {
250 const uint8_t
w =
weights[x * step_x];
262 const int x_frac,
const int y_frac,
const int width,
const int height)
264 const int x_off = (x_frac >> 3) - 1;
265 const int y_off = (y_frac >> 3) - 1;
266 const ptrdiff_t src_stride = _src_stride /
sizeof(
pixel);
273 for (
int i = 0;
i < bdof_width;
i++)
285 for (
int i = 0;
i < bdof_width;
i++)
296 const int16_t *
_src,
const ptrdiff_t src_stride,
const int width,
const int height)
301 for (
int y = 0; y <
height; y++) {
302 const int16_t *p =
src;
303 for (
int x = 0; x <
width; x++) {
304 gradient_h[x] = (p[1] >>
shift) - (p[-1] >>
shift);
305 gradient_v[x] = (p[src_stride] >>
shift) - (p[-src_stride] >>
shift);
308 gradient_h += gradient_stride;
309 gradient_v += gradient_stride;
314 static void FUNC(
apply_prof)(int16_t *
dst,
const int16_t *
src,
const int16_t *diff_mv_x,
const int16_t *diff_mv_y)
325 const int di = gradient_h[o] * diff_mv_x[o] + gradient_v[o] * diff_mv_y[o];
335 static void FUNC(
apply_prof_uni)(uint8_t *
_dst,
const ptrdiff_t _dst_stride,
const int16_t *
src,
const int16_t *diff_mv_x,
const int16_t *diff_mv_y)
339 const ptrdiff_t dst_stride = _dst_stride /
sizeof(
pixel);
354 const int di = gradient_h[o] * diff_mv_x[o] + gradient_v[o] * diff_mv_y[o];
365 const int16_t *
src,
const int16_t *diff_mv_x,
const int16_t *diff_mv_y,
366 const int denom,
const int wx,
const int _ox)
370 const ptrdiff_t dst_stride = _dst_stride /
sizeof(
pixel);
373 const int ox = _ox * (1 << (
BIT_DEPTH - 8));
382 const int di = gradient_h[o] * diff_mv_x[o] + gradient_v[o] * diff_mv_y[o];
392 const int pad_left,
const int pad_top,
const int pad_right,
const int pad_bottom,
393 const int16_t **gradient_h,
const int16_t **gradient_v,
397 const int shift3 = 1;
398 const int thres = 1 << 4;
399 int sgx2 = 0, sgy2 = 0, sgxgy = 0, sgxdi = 0, sgydi = 0;
410 const int temph = (gradient_h[0][idx] + gradient_h[1][idx]) >> shift3;
411 const int tempv = (gradient_v[0][idx] + gradient_v[1][idx]) >> shift3;
413 sgx2 +=
FFABS(temph);
414 sgy2 +=
FFABS(tempv);
420 *vx = sgx2 > 0 ?
av_clip((sgxdi * (1 << 2)) >>
av_log2(sgx2) , -thres + 1, thres - 1) : 0;
421 *vy = sgy2 > 0 ?
av_clip(((sgydi * (1 << 2)) - ((*vx * sgxgy) >> 1)) >>
av_log2(sgy2), -thres + 1, thres - 1) : 0;
425 const int16_t **gh,
const int16_t **gv,
const int vx,
const int vy)
428 const int offset4 = 1 << (shift4 - 1);
433 const int bdof_offset = vx * (gh[0][idx] - gh[1][idx]) + vy * (gv[0][idx] - gv[1][idx]);
442 static void FUNC(
apply_bdof)(uint8_t *
_dst,
const ptrdiff_t _dst_stride,
const int16_t *_src0,
const int16_t *_src1,
443 const int block_w,
const int block_h)
448 const ptrdiff_t dst_stride = _dst_stride /
sizeof(
pixel);
462 const int16_t* gh[] = { gradient_h[0] + idx, gradient_h[1] + idx };
463 const int16_t* gv[] = { gradient_v[0] + idx, gradient_v[1] + idx };
471 #define DMVR_FILTER(src, stride) \
472 (filter[0] * src[x] + \
473 filter[1] * src[x + stride])
475 #define DMVR_FILTER2(filter, src0, src1) \
476 (filter[0] * src0 + filter[1] * src1)
479 static void FUNC(
dmvr)(int16_t *
dst,
const uint8_t *
_src,
const ptrdiff_t _src_stride,
480 const int height,
const intptr_t
mx,
const intptr_t
my,
const int width)
484 const ptrdiff_t src_stride = _src_stride /
sizeof(
pixel);
487 const int offset4 = 1 << (shift4 - 1);
488 #define DMVR_SHIFT(s) (((s) + offset4) >> shift4)
490 #define DMVR_SHIFT(s) ((s) << (10 - BIT_DEPTH))
491 #endif // BIT_DEPTH > 10
493 for (
int y = 0; y <
height; y++) {
494 for (
int x = 0; x <
width; x++)
503 #endif // BIT_DEPTH != 10
508 const int height,
const intptr_t
mx,
const intptr_t
my,
const int width)
511 const ptrdiff_t src_stride = _src_stride /
sizeof(
pixel);
514 const int offset1 = 1 << (
shift1 - 1);
516 for (
int y = 0; y <
height; y++) {
517 for (
int x = 0; x <
width; x++)
526 const int height,
const intptr_t
mx,
const intptr_t
my,
const int width)
529 const ptrdiff_t src_stride = _src_stride /
sizeof(
pixel);
532 const int offset1 = 1 << (
shift1 - 1);
534 for (
int y = 0; y <
height; y++) {
535 for (
int x = 0; x <
width; x++)
545 const int height,
const intptr_t
mx,
const intptr_t
my,
const int width)
548 int16_t *tmp0 = tmp_array;
551 const ptrdiff_t src_stride = _src_stride /
sizeof(
pixel);
555 const int offset1 = 1 << (
shift1 - 1);
557 const int offset2 = 1 << (
shift2 - 1);
560 for (
int x = 0; x <
width; x++)
565 for (
int x = 0; x <
width; x++) {
571 FFSWAP(int16_t *, tmp0, tmp1);
575 #define PEL_FUNC(dst, C, idx1, idx2, a) \
577 for (int w = 0; w < 7; w++) \
578 inter->dst[C][w][idx1][idx2] = FUNC(a); \
581 #define DIR_FUNCS(d, C, c) \
582 PEL_FUNC(put_##d, C, 0, 0, put_##d##_pixels); \
583 PEL_FUNC(put_##d, C, 0, 1, put_##d##_##c##_h); \
584 PEL_FUNC(put_##d, C, 1, 0, put_##d##_##c##_v); \
585 PEL_FUNC(put_##d, C, 1, 1, put_##d##_##c##_hv); \
586 PEL_FUNC(put_##d##_w, C, 0, 0, put_##d##_w_pixels); \
587 PEL_FUNC(put_##d##_w, C, 0, 1, put_##d##_##c##_w_h); \
588 PEL_FUNC(put_##d##_w, C, 1, 0, put_##d##_##c##_w_v); \
589 PEL_FUNC(put_##d##_w, C, 1, 1, put_##d##_##c##_w_hv);
591 #define FUNCS(C, c) \
592 PEL_FUNC(put, C, 0, 0, put_pixels); \
593 PEL_FUNC(put, C, 0, 1, put_##c##_h); \
594 PEL_FUNC(put, C, 1, 0, put_##c##_v); \
595 PEL_FUNC(put, C, 1, 1, put_##c##_hv); \
596 DIR_FUNCS(uni, C, c); \
static void FUNC() dmvr_hv(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const intptr_t mx, const intptr_t my, const int width)
#define VVC_INTER_LUMA_TAPS
const int8_t ff_vvc_inter_luma_dmvr_filters[VVC_INTER_LUMA_DMVR_FACTS][VVC_INTER_LUMA_DMVR_TAPS]
#define CHROMA_FILTER(src, stride)
static void FUNC() ff_vvc_inter_dsp_init(VVCInterDSPContext *const inter)
#define CHROMA_EXTRA_BEFORE
static void FUNC() apply_bdof(uint8_t *_dst, const ptrdiff_t _dst_stride, const int16_t *_src0, const int16_t *_src1, const int block_w, const int block_h)
static void FUNC() bdof_fetch_samples(int16_t *_dst, const uint8_t *_src, const ptrdiff_t _src_stride, const int x_frac, const int y_frac, const int width, const int height)
static void FUNC() prof_grad_filter(int16_t *gradient_h, int16_t *gradient_v, const ptrdiff_t gradient_stride, const int16_t *_src, const ptrdiff_t src_stride, const int width, const int height)
void(* filter)(uint8_t *src, int stride, int qscale)
static int vvc_sad(const int16_t *src0, const int16_t *src1, int dx, int dy, const int block_w, const int block_h)
static void FUNC() dmvr(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const intptr_t mx, const intptr_t my, const int width)
static void av_always_inline FUNC() put_scaled(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *const _src, ptrdiff_t _src_stride, const int src_height, const int _x, const int _y, const int dx, const int dy, const int height, const int8_t *hf, const int8_t *vf, const int width, const int is_uni, const int is_chroma)
uint8_t ptrdiff_t const uint8_t * _src
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.
static void FUNC() apply_bdof_min_block(pixel *dst, const ptrdiff_t dst_stride, const int16_t *src0, const int16_t *src1, const int16_t **gh, const int16_t **gv, const int vx, const int vy)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t mx
static void FUNC() put_uni_chroma_scaled(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, ptrdiff_t _src_stride, const int src_height, const int x, const int y, const int dx, const int dy, const int height, const int8_t *hf, const int8_t *vf, const int width)
static double val(void *priv, double ch)
#define FF_ARRAY_ELEMS(a)
#define VVC_INTER_CHROMA_TAPS
static void FUNC() apply_prof(int16_t *dst, const int16_t *src, const int16_t *diff_mv_x, const int16_t *diff_mv_y)
static void FUNC() put_ciip(uint8_t *_dst, const ptrdiff_t _dst_stride, const int width, const int height, const uint8_t *_inter, const ptrdiff_t _inter_stride, const int intra_weight)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t my
static void av_always_inline FUNC() put_uni_w_scaled(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *const _src, ptrdiff_t _src_stride, const int src_height, const int _x, const int _y, const int dx, const int dy, const int denom, const int wx, const int _ox, const int height, const int8_t *hf, const int8_t *vf, const int width, const int is_chroma)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static void FUNC() put_uni_luma_w_scaled(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, ptrdiff_t _src_stride, const int src_height, const int x, const int y, const int dx, const int dy, const int denom, const int wx, const int ox, const int height, const int8_t *hf, const int8_t *vf, const int width)
#define LUMA_EXTRA_BEFORE
static void FUNC() dmvr_v(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const intptr_t mx, const intptr_t my, const int width)
static void FUNC() apply_prof_uni(uint8_t *_dst, const ptrdiff_t _dst_stride, const int16_t *src, const int16_t *diff_mv_x, const int16_t *diff_mv_y)
static int shift(int a, int b)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
#define AFFINE_MIN_BLOCK_SIZE
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
static void FUNC() put_uni_luma_scaled(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, ptrdiff_t _src_stride, const int src_height, const int x, const int y, const int dx, const int dy, const int height, const int8_t *hf, const int8_t *vf, const int width)
#define DMVR_FILTER(src, stride)
#define i(width, name, range_min, range_max)
#define BDOF_MIN_BLOCK_SIZE
static const int weights[]
static void FUNC() derive_bdof_vx_vy(const int16_t *_src0, const int16_t *_src1, const int pad_left, const int pad_top, const int pad_right, const int pad_bottom, const int16_t **gradient_h, const int16_t **gradient_v, int *vx, int *vy)
static void FUNC() put_gpm(uint8_t *_dst, ptrdiff_t dst_stride, const int width, const int height, const int16_t *src0, const int16_t *src1, const uint8_t *weights, const int step_x, const int step_y)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int const int8_t * hf
static void FUNC() avg(uint8_t *_dst, const ptrdiff_t _dst_stride, const int16_t *src0, const int16_t *src1, const int width, const int height)
static const uint8_t shift2[6]
static double limit(double x)
static void FUNC() dmvr_h(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const intptr_t mx, const intptr_t my, const int width)
#define FFSWAP(type, a, b)
#define DMVR_FILTER2(filter, src0, src1)
static void FUNC() w_avg(uint8_t *_dst, const ptrdiff_t _dst_stride, const int16_t *src0, const int16_t *src1, const int width, const int height, const int denom, const int w0, const int w1, const int o0, const int o1)
#define BILINEAR_EXTRA_BEFORE
static void FUNC() put_luma_scaled(int16_t *_dst, const uint8_t *_src, ptrdiff_t _src_stride, const int src_height, const int x, const int y, const int dx, const int dy, const int height, const int8_t *hf, const int8_t *vf, const int width)
static void FUNC() put_chroma_scaled(int16_t *_dst, const uint8_t *_src, ptrdiff_t _src_stride, const int src_height, const int x, const int y, const int dx, const int dy, const int height, const int8_t *hf, const int8_t *vf, const int width)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int const int8_t const int8_t * vf
static void FUNC() put_uni_chroma_w_scaled(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, ptrdiff_t _src_stride, const int src_height, const int x, const int y, const int dx, const int dy, const int denom, const int wx, const int ox, const int height, const int8_t *hf, const int8_t *vf, const int width)
static const uint8_t shift1[6]
static void FUNC() apply_prof_uni_w(uint8_t *_dst, const ptrdiff_t _dst_stride, const int16_t *src, const int16_t *diff_mv_x, const int16_t *diff_mv_y, const int denom, const int wx, const int _ox)
#define LUMA_FILTER(src, stride)
static void FUNC() fetch_samples(int16_t *_dst, const uint8_t *_src, const ptrdiff_t _src_stride, const int x_frac, const int y_frac)