33 uint8_t *dst_edge, ptrdiff_t stride_edge,
34 uint8_t *dst_inner, ptrdiff_t stride_inner,
35 uint8_t *l,
int col,
int x,
int w,
37 int p,
int ss_h,
int ss_v,
int bytesperpixel)
40 int have_top = row > 0 || y > 0;
42 int have_right = x < w - 1;
44 static const uint8_t mode_conv[10][2 ][2 ] = {
75 [
DC_PRED] = { .needs_top = 1, .needs_left = 1 },
84 [
HOR_UP_PRED] = { .needs_left = 1, .invert_left = 1 },
95 mode = mode_conv[
mode][have_left][have_top];
96 if (edges[mode].needs_top) {
98 int n_px_need = 4 << tx, n_px_have = (((s->
cols - col) << !ss_h) - x) * 4;
101 if (tx ==
TX_4X4 && edges[mode].needs_topright && have_right)
108 top = !(row & 7) && !y ?
110 y == 0 ? &dst_edge[-stride_edge] : &dst_inner[-stride_inner];
112 topleft = !(row & 7) && !y ?
114 y == 0 || x == 0 ? &dst_edge[-stride_edge] :
115 &dst_inner[-stride_inner];
119 (!edges[mode].needs_topleft || (have_left && top == topleft)) &&
120 (tx !=
TX_4X4 || !edges[mode].needs_topright || have_right) &&
121 n_px_need + n_px_need_tr <= n_px_have) {
125 if (n_px_need <= n_px_have) {
126 memcpy(*a, top, n_px_need * bytesperpixel);
128 #define memset_bpp(c, i1, v, i2, num) do { \
129 if (bytesperpixel == 1) { \
130 memset(&(c)[(i1)], (v)[(i2)], (num)); \
132 int n, val = AV_RN16A(&(v)[(i2) * 2]); \
133 for (n = 0; n < (num); n++) { \
134 AV_WN16A(&(c)[((i1) + n) * 2], val); \
138 memcpy(*a, top, n_px_have * bytesperpixel);
139 memset_bpp(*a, n_px_have, (*a), n_px_have - 1, n_px_need - n_px_have);
142 #define memset_val(c, val, num) do { \
143 if (bytesperpixel == 1) { \
144 memset((c), (val), (num)); \
147 for (n = 0; n < (num); n++) { \
148 AV_WN16A(&(c)[n * 2], (val)); \
152 memset_val(*a, (128 << (bpp - 8)) - 1, n_px_need);
154 if (edges[mode].needs_topleft) {
155 if (have_left && have_top) {
156 #define assign_bpp(c, i1, v, i2) do { \
157 if (bytesperpixel == 1) { \
158 (c)[(i1)] = (v)[(i2)]; \
160 AV_COPY16(&(c)[(i1) * 2], &(v)[(i2) * 2]); \
165 #define assign_val(c, i, v) do { \
166 if (bytesperpixel == 1) { \
169 AV_WN16A(&(c)[(i) * 2], (v)); \
172 assign_val((*a), -1, (128 << (bpp - 8)) + (have_top ? +1 : -1));
175 if (tx ==
TX_4X4 && edges[mode].needs_topright) {
176 if (have_top && have_right &&
177 n_px_need + n_px_need_tr <= n_px_have) {
178 memcpy(&(*a)[4 * bytesperpixel], &top[4 * bytesperpixel], 4 * bytesperpixel);
185 if (edges[mode].needs_left) {
187 int n_px_need = 4 << tx, i, n_px_have = (((s->
rows - row) << !ss_v) - y) * 4;
188 uint8_t *dst = x == 0 ? dst_edge : dst_inner;
189 ptrdiff_t
stride = x == 0 ? stride_edge : stride_inner;
191 if (edges[mode].invert_left) {
192 if (n_px_need <= n_px_have) {
193 for (i = 0; i < n_px_need; i++)
196 for (i = 0; i < n_px_have; i++)
198 memset_bpp(l, n_px_have, l, n_px_have - 1, n_px_need - n_px_have);
201 if (n_px_need <= n_px_have) {
202 for (i = 0; i < n_px_need; i++)
203 assign_bpp(l, n_px_need - 1 - i, &dst[i * stride], -1);
205 for (i = 0; i < n_px_have; i++)
206 assign_bpp(l, n_px_need - 1 - i, &dst[i * stride], -1);
207 memset_bpp(l, 0, l, n_px_need - n_px_have, n_px_need - n_px_have);
211 memset_val(l, (128 << (bpp - 8)) + 1, 4 << tx);
219 ptrdiff_t uv_off,
int bytesperpixel)
223 int row = td->
row, col = td->
col;
226 int end_x =
FFMIN(2 * (s->
cols - col), w4);
227 int end_y =
FFMIN(2 * (s->
rows - row), h4);
229 int uvstep1d = 1 << b->
uvtx, p;
234 for (
n = 0, y = 0; y < end_y; y += step1d) {
235 uint8_t *ptr = dst, *ptr_r = dst_r;
236 for (x = 0; x < end_x; x += step1d, ptr += 4 * step1d * bytesperpixel,
237 ptr_r += 4 * step1d * bytesperpixel,
n += step) {
247 col, x, w4, row, y, b->tx, 0, 0, 0, bytesperpixel);
251 td->
block + 16 * n * bytesperpixel, eob);
261 step = 1 << (b->
uvtx * 2);
262 for (p = 0; p < 2; p++) {
263 dst = td->
dst[1 + p];
265 for (
n = 0, y = 0; y < end_y; y += uvstep1d) {
266 uint8_t *ptr = dst, *ptr_r = dst_r;
267 for (x = 0; x < end_x; x += uvstep1d, ptr += 4 * uvstep1d * bytesperpixel,
268 ptr_r += 4 * uvstep1d * bytesperpixel,
n += step) {
275 ptr, td->
uv_stride, l, col, x, w4, row, y,
280 td->
uvblock[p] + 16 * n * bytesperpixel, eob);
299 uint8_t *dst, ptrdiff_t dst_stride,
302 ptrdiff_t y, ptrdiff_t x,
const VP56mv *
mv,
303 int bw,
int bh,
int w,
int h,
int bytesperpixel)
306 int mx = mv->
x, my = mv->
y,
th;
310 ref += y * ref_stride + x * bytesperpixel;
316 th = (y + bh + 4 * !!my + 7) >> 6;
321 if (x < !!mx * 3 || y < !!my * 3 ||
322 x + !!mx * 4 > w - bw || y + !!my * 5 > h - bh) {
324 ref - !!my * 3 * ref_stride - !!mx * 3 * bytesperpixel,
326 bw + !!mx * 7, bh + !!my * 7,
327 x - !!mx * 3, y - !!my * 3, w, h);
331 mc[!!mx][!!my](dst, dst_stride,
ref, ref_stride, bh, mx << 1, my << 1);
336 ptrdiff_t dst_stride,
337 const uint8_t *ref_u, ptrdiff_t src_stride_u,
338 const uint8_t *ref_v, ptrdiff_t src_stride_v,
340 ptrdiff_t y, ptrdiff_t x,
const VP56mv *
mv,
341 int bw,
int bh,
int w,
int h,
int bytesperpixel)
344 int mx = mv->
x * (1 << !s->
ss_h), my = mv->
y * (1 << !s->
ss_v),
th;
348 ref_u += y * src_stride_u + x * bytesperpixel;
349 ref_v += y * src_stride_v + x * bytesperpixel;
355 th = (y + bh + 4 * !!my + 7) >> (6 - s->
ss_v);
360 if (x < !!mx * 3 || y < !!my * 3 ||
361 x + !!mx * 4 > w - bw || y + !!my * 5 > h - bh) {
363 ref_u - !!my * 3 * src_stride_u - !!mx * 3 * bytesperpixel,
365 bw + !!mx * 7, bh + !!my * 7,
366 x - !!mx * 3, y - !!my * 3, w, h);
367 ref_u = td->
edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
368 mc[!!mx][!!my](dst_u, dst_stride, ref_u, 160, bh, mx, my);
371 ref_v - !!my * 3 * src_stride_v - !!mx * 3 * bytesperpixel,
373 bw + !!mx * 7, bh + !!my * 7,
374 x - !!mx * 3, y - !!my * 3, w, h);
375 ref_v = td->
edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
376 mc[!!mx][!!my](dst_v, dst_stride, ref_v, 160, bh, mx, my);
378 mc[!!mx][!!my](dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my);
379 mc[!!mx][!!my](dst_v, dst_stride, ref_v, src_stride_v, bh, mx, my);
383 #define mc_luma_dir(td, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, \
384 px, py, pw, ph, bw, bh, w, h, i) \
385 mc_luma_unscaled(td, s->dsp.mc, dst, dst_ls, src, src_ls, tref, row, col, \
386 mv, bw, bh, w, h, bytesperpixel)
387 #define mc_chroma_dir(td, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
388 row, col, mv, px, py, pw, ph, bw, bh, w, h, i) \
389 mc_chroma_unscaled(td, s->dsp.mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
390 row, col, mv, bw, bh, w, h, bytesperpixel)
392 #define FN(x) x##_8bpp
393 #define BYTES_PER_PIXEL 1
396 #undef BYTES_PER_PIXEL
397 #define FN(x) x##_16bpp
398 #define BYTES_PER_PIXEL 2
403 #undef BYTES_PER_PIXEL
408 uint8_t *dst, ptrdiff_t dst_stride,
411 ptrdiff_t y, ptrdiff_t x,
const VP56mv *in_mv,
412 int px,
int py,
int pw,
int ph,
413 int bw,
int bh,
int w,
int h,
int bytesperpixel,
414 const uint16_t *scale,
const uint8_t *step)
420 y, x, in_mv, bw, bh, w, h, bytesperpixel);
422 #define scale_mv(n, dim) (((int64_t)(n) * scale[dim]) >> 14)
424 int refbw_m1, refbh_m1;
428 mv.
x = av_clip(in_mv->
x, -(x + pw - px + 4) * 8, (s->
cols * 8 - x + px + 3) * 8);
429 mv.
y = av_clip(in_mv->
y, -(y + ph - py + 4) * 8, (s->
rows * 8 - y + py + 3) * 8);
438 ref += y * ref_stride + x * bytesperpixel;
441 refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
442 refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
446 th = (y + refbh_m1 + 4 + 7) >> 6;
451 if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 5 >= h - refbh_m1) {
453 ref - 3 * ref_stride - 3 * bytesperpixel,
455 refbw_m1 + 8, refbh_m1 + 8,
460 smc(dst, dst_stride, ref, ref_stride, bh, mx, my, step[0], step[1]);
467 ptrdiff_t dst_stride,
468 const uint8_t *ref_u, ptrdiff_t src_stride_u,
469 const uint8_t *ref_v, ptrdiff_t src_stride_v,
471 ptrdiff_t y, ptrdiff_t x,
const VP56mv *in_mv,
472 int px,
int py,
int pw,
int ph,
473 int bw,
int bh,
int w,
int h,
int bytesperpixel,
474 const uint16_t *scale,
const uint8_t *step)
480 ref_v, src_stride_v, ref_frame,
481 y, x, in_mv, bw, bh, w, h, bytesperpixel);
484 int refbw_m1, refbh_m1;
490 mv.
x = av_clip(in_mv->
x, -(x + pw - px + 4) * 16, (s->
cols * 4 - x + px + 3) * 16);
493 mv.
x = av_clip(in_mv->
x, -(x + pw - px + 4) * 8, (s->
cols * 8 - x + px + 3) * 8);
498 mv.
y = av_clip(in_mv->
y, -(y + ph - py + 4) * 16, (s->
rows * 4 - y + py + 3) * 16);
501 mv.
y = av_clip(in_mv->
y, -(y + ph - py + 4) * 8, (s->
rows * 8 - y + py + 3) * 8);
507 ref_u += y * src_stride_u + x * bytesperpixel;
508 ref_v += y * src_stride_v + x * bytesperpixel;
511 refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
512 refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
516 th = (y + refbh_m1 + 4 + 7) >> (6 - s->
ss_v);
521 if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 5 >= h - refbh_m1) {
523 ref_u - 3 * src_stride_u - 3 * bytesperpixel,
525 refbw_m1 + 8, refbh_m1 + 8,
528 smc(dst_u, dst_stride, ref_u, 288, bh, mx, my, step[0], step[1]);
531 ref_v - 3 * src_stride_v - 3 * bytesperpixel,
533 refbw_m1 + 8, refbh_m1 + 8,
536 smc(dst_v, dst_stride, ref_v, 288, bh, mx, my, step[0], step[1]);
538 smc(dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my, step[0], step[1]);
539 smc(dst_v, dst_stride, ref_v, src_stride_v, bh, mx, my, step[0], step[1]);
544 #define mc_luma_dir(td, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, \
545 px, py, pw, ph, bw, bh, w, h, i) \
546 mc_luma_scaled(td, s->dsp.s##mc, s->dsp.mc, dst, dst_ls, src, src_ls, tref, row, col, \
547 mv, px, py, pw, ph, bw, bh, w, h, bytesperpixel, \
548 s->mvscale[b->ref[i]], s->mvstep[b->ref[i]])
549 #define mc_chroma_dir(td, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
550 row, col, mv, px, py, pw, ph, bw, bh, w, h, i) \
551 mc_chroma_scaled(td, s->dsp.s##mc, s->dsp.mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
552 row, col, mv, px, py, pw, ph, bw, bh, w, h, bytesperpixel, \
553 s->mvscale[b->ref[i]], s->mvstep[b->ref[i]])
555 #define FN(x) x##_scaled_8bpp
556 #define BYTES_PER_PIXEL 1
559 #undef BYTES_PER_PIXEL
560 #define FN(x) x##_scaled_16bpp
561 #define BYTES_PER_PIXEL 2
566 #undef BYTES_PER_PIXEL
573 int row = td->
row, col = td->
col;
576 if (bytesperpixel == 1) {
577 inter_pred_scaled_8bpp(td);
579 inter_pred_scaled_16bpp(td);
582 if (bytesperpixel == 1) {
585 inter_pred_16bpp(td);
594 int end_x =
FFMIN(2 * (s->
cols - col), w4);
595 int end_y =
FFMIN(2 * (s->
rows - row), h4);
597 int uvstep1d = 1 << b->
uvtx, p;
601 for (
n = 0, y = 0; y < end_y; y += step1d) {
603 for (x = 0; x < end_x; x += step1d,
604 ptr += 4 * step1d * bytesperpixel,
n += step) {
609 td->
block + 16 * n * bytesperpixel, eob);
617 step = 1 << (b->
uvtx * 2);
618 for (p = 0; p < 2; p++) {
619 dst = td->
dst[p + 1];
620 for (
n = 0, y = 0; y < end_y; y += uvstep1d) {
622 for (x = 0; x < end_x; x += uvstep1d,
623 ptr += 4 * uvstep1d * bytesperpixel,
n += step) {
628 td->
uvblock[p] + 16 * n * bytesperpixel, eob);
#define assign_val(c, i, v)
void ff_vp9_intra_recon_16bpp(VP9TileData *td, ptrdiff_t y_off, ptrdiff_t uv_off)
static av_always_inline void inter_recon(VP9TileData *td, int bytesperpixel)
void(* intra_pred[N_TXFM_SIZES][N_INTRA_PRED_MODES])(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, const uint8_t *top)
static av_always_inline int check_intra_mode(VP9TileData *td, int mode, uint8_t **a, uint8_t *dst_edge, ptrdiff_t stride_edge, uint8_t *dst_inner, ptrdiff_t stride_inner, uint8_t *l, int col, int x, int w, int row, int y, enum TxfmMode tx, int p, int ss_h, int ss_v, int bytesperpixel)
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
uint8_t * intra_pred_data[3]
void(* emulated_edge_mc)(uint8_t *dst, const uint8_t *src, ptrdiff_t dst_linesize, ptrdiff_t src_linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
void ff_vp9_inter_recon_8bpp(VP9TileData *td)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static av_always_inline void mc_luma_unscaled(VP9TileData *td, vp9_mc_func(*mc)[2], uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *ref, ptrdiff_t ref_stride, ThreadFrame *ref_frame, ptrdiff_t y, ptrdiff_t x, const VP56mv *mv, int bw, int bh, int w, int h, int bytesperpixel)
#define assign_bpp(c, i1, v, i2)
#define memset_val(c, val, num)
simple assert() macros that are a bit more flexible than ISO C assert().
#define memset_bpp(c, i1, v, i2, num)
static av_always_inline void mc_luma_scaled(VP9TileData *td, vp9_scaled_mc_func smc, vp9_mc_func(*mc)[2], uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *ref, ptrdiff_t ref_stride, ThreadFrame *ref_frame, ptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv, int px, int py, int pw, int ph, int bw, int bh, int w, int h, int bytesperpixel, const uint16_t *scale, const uint8_t *step)
static av_always_inline void mc_chroma_scaled(VP9TileData *td, vp9_scaled_mc_func smc, vp9_mc_func(*mc)[2], uint8_t *dst_u, uint8_t *dst_v, ptrdiff_t dst_stride, const uint8_t *ref_u, ptrdiff_t src_stride_u, const uint8_t *ref_v, ptrdiff_t src_stride_v, ThreadFrame *ref_frame, ptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv, int px, int py, int pw, int ph, int bw, int bh, int w, int h, int bytesperpixel, const uint16_t *scale, const uint8_t *step)
static const int8_t mv[256][2]
void(* vp9_scaled_mc_func)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *ref, ptrdiff_t ref_stride, int h, int mx, int my, int dx, int dy)
Libavcodec external API header.
void(* vp9_mc_func)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *ref, ptrdiff_t ref_stride, int h, int mx, int my)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
enum TxfmType ff_vp9_intra_txfm_type[14]
void ff_vp9_inter_recon_16bpp(VP9TileData *td)
const uint8_t ff_vp9_bwh_tab[2][N_BS_SIZES][2]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
unsigned eob[4][2][2][6][6][2]
#define LOCAL_ALIGNED_32(t, v,...)
GLint GLenum GLboolean GLsizei stride
void(* itxfm_add[N_TXFM_SIZES+1][N_TXFM_TYPES])(uint8_t *dst, ptrdiff_t stride, int16_t *block, int eob)
common internal api header.
static av_always_inline void mc_chroma_unscaled(VP9TileData *td, vp9_mc_func(*mc)[2], uint8_t *dst_u, uint8_t *dst_v, ptrdiff_t dst_stride, const uint8_t *ref_u, ptrdiff_t src_stride_u, const uint8_t *ref_v, ptrdiff_t src_stride_v, ThreadFrame *ref_frame, ptrdiff_t y, ptrdiff_t x, const VP56mv *mv, int bw, int bh, int w, int h, int bytesperpixel)
static int ref[MAX_W *MAX_W]
static int ref_frame(Vp3DecodeContext *s, ThreadFrame *dst, ThreadFrame *src)
Core video DSP helper functions.
static av_always_inline void intra_recon(VP9TileData *td, ptrdiff_t y_off, ptrdiff_t uv_off, int bytesperpixel)
uint8_t edge_emu_buffer[135 *144 *2]
void ff_vp9_intra_recon_8bpp(VP9TileData *td, ptrdiff_t y_off, ptrdiff_t uv_off)
mode
Use these values in ebur128_init (or'ed).