34 uint8_t *dst_edge, ptrdiff_t stride_edge,
35 uint8_t *dst_inner, ptrdiff_t stride_inner,
38 int p,
int ss_h,
int ss_v,
int bytesperpixel)
41 int have_top = row > 0 || y > 0;
43 int have_right = x < w - 1;
45 static const uint8_t mode_conv[10][2 ][2 ] = {
76 [
DC_PRED] = { .needs_top = 1, .needs_left = 1 },
85 [
HOR_UP_PRED] = { .needs_left = 1, .invert_left = 1 },
96 mode = mode_conv[
mode][have_left][have_top];
97 if (edges[mode].needs_top) {
99 int n_px_need = 4 << tx, n_px_have = (((s->
cols - col) << !ss_h) - x) * 4;
100 int n_px_need_tr = 0;
102 if (tx ==
TX_4X4 && edges[mode].needs_topright && have_right)
109 top = !(row & 7) && !y ?
111 y == 0 ? &dst_edge[-stride_edge] : &dst_inner[-stride_inner];
113 topleft = !(row & 7) && !y ?
115 y == 0 || x == 0 ? &dst_edge[-stride_edge] :
116 &dst_inner[-stride_inner];
120 (!edges[mode].needs_topleft || (have_left && top == topleft)) &&
121 (tx !=
TX_4X4 || !edges[mode].needs_topright || have_right) &&
122 n_px_need + n_px_need_tr <= n_px_have) {
126 if (n_px_need <= n_px_have) {
127 memcpy(*a, top, n_px_need * bytesperpixel);
129 #define memset_bpp(c, i1, v, i2, num) do { \ 130 if (bytesperpixel == 1) { \ 131 memset(&(c)[(i1)], (v)[(i2)], (num)); \ 133 int n, val = AV_RN16A(&(v)[(i2) * 2]); \ 134 for (n = 0; n < (num); n++) { \ 135 AV_WN16A(&(c)[((i1) + n) * 2], val); \ 139 memcpy(*a, top, n_px_have * bytesperpixel);
140 memset_bpp(*a, n_px_have, (*a), n_px_have - 1, n_px_need - n_px_have);
143 #define memset_val(c, val, num) do { \ 144 if (bytesperpixel == 1) { \ 145 memset((c), (val), (num)); \ 148 for (n = 0; n < (num); n++) { \ 149 AV_WN16A(&(c)[n * 2], (val)); \ 153 memset_val(*a, (128 << (bpp - 8)) - 1, n_px_need);
155 if (edges[mode].needs_topleft) {
156 if (have_left && have_top) {
157 #define assign_bpp(c, i1, v, i2) do { \ 158 if (bytesperpixel == 1) { \ 159 (c)[(i1)] = (v)[(i2)]; \ 161 AV_COPY16(&(c)[(i1) * 2], &(v)[(i2) * 2]); \ 166 #define assign_val(c, i, v) do { \ 167 if (bytesperpixel == 1) { \ 170 AV_WN16A(&(c)[(i) * 2], (v)); \ 173 assign_val((*a), -1, (128 << (bpp - 8)) + (have_top ? +1 : -1));
176 if (tx ==
TX_4X4 && edges[mode].needs_topright) {
177 if (have_top && have_right &&
178 n_px_need + n_px_need_tr <= n_px_have) {
179 memcpy(&(*a)[4 * bytesperpixel], &top[4 * bytesperpixel], 4 * bytesperpixel);
186 if (edges[mode].needs_left) {
188 int n_px_need = 4 << tx,
i, n_px_have = (((s->
rows - row) << !ss_v) - y) * 4;
189 uint8_t *dst = x == 0 ? dst_edge : dst_inner;
190 ptrdiff_t
stride = x == 0 ? stride_edge : stride_inner;
192 if (edges[mode].invert_left) {
193 if (n_px_need <= n_px_have) {
194 for (i = 0; i < n_px_need; i++)
197 for (i = 0; i < n_px_have; i++)
199 memset_bpp(l, n_px_have, l, n_px_have - 1, n_px_need - n_px_have);
202 if (n_px_need <= n_px_have) {
203 for (i = 0; i < n_px_need; i++)
204 assign_bpp(l, n_px_need - 1 - i, &dst[i * stride], -1);
206 for (i = 0; i < n_px_have; i++)
207 assign_bpp(l, n_px_need - 1 - i, &dst[i * stride], -1);
208 memset_bpp(l, 0, l, n_px_need - n_px_have, n_px_need - n_px_have);
212 memset_val(l, (128 << (bpp - 8)) + 1, 4 << tx);
220 ptrdiff_t uv_off,
int bytesperpixel)
224 int row = td->
row, col = td->
col;
227 int end_x =
FFMIN(2 * (s->
cols - col), w4);
228 int end_y =
FFMIN(2 * (s->
rows - row), h4);
230 int uvstep1d = 1 << b->
uvtx, p;
235 for (n = 0, y = 0; y < end_y; y += step1d) {
236 uint8_t *ptr = dst, *ptr_r = dst_r;
237 for (x = 0; x < end_x; x += step1d, ptr += 4 * step1d * bytesperpixel,
238 ptr_r += 4 * step1d * bytesperpixel, n +=
step) {
248 col, x, w4, row, y, b->tx, 0, 0, 0, bytesperpixel);
252 td->
block + 16 * n * bytesperpixel, eob);
262 step = 1 << (b->
uvtx * 2);
263 for (p = 0; p < 2; p++) {
264 dst = td->
dst[1 + p];
266 for (n = 0, y = 0; y < end_y; y += uvstep1d) {
267 uint8_t *ptr = dst, *ptr_r = dst_r;
268 for (x = 0; x < end_x; x += uvstep1d, ptr += 4 * uvstep1d * bytesperpixel,
269 ptr_r += 4 * uvstep1d * bytesperpixel, n +=
step) {
276 ptr, td->
uv_stride, l, col, x, w4, row, y,
281 td->
uvblock[p] + 16 * n * bytesperpixel, eob);
300 uint8_t *dst, ptrdiff_t dst_stride,
303 ptrdiff_t y, ptrdiff_t x,
const VP56mv *
mv,
304 int bw,
int bh,
int w,
int h,
int bytesperpixel)
307 int mx = mv->
x, my = mv->
y,
th;
311 ref += y * ref_stride + x * bytesperpixel;
317 th = (y + bh + 4 * !!my + 7) >> 6;
322 if (x < !!mx * 3 || y < !!my * 3 ||
323 x + !!mx * 4 > w - bw || y + !!my * 5 > h - bh) {
325 ref - !!my * 3 * ref_stride - !!mx * 3 * bytesperpixel,
327 bw + !!mx * 7, bh + !!my * 7,
328 x - !!mx * 3, y - !!my * 3, w, h);
332 mc[!!mx][!!my](dst, dst_stride,
ref, ref_stride, bh, mx << 1, my << 1);
337 ptrdiff_t dst_stride,
338 const uint8_t *ref_u, ptrdiff_t src_stride_u,
339 const uint8_t *ref_v, ptrdiff_t src_stride_v,
341 ptrdiff_t y, ptrdiff_t x,
const VP56mv *
mv,
342 int bw,
int bh,
int w,
int h,
int bytesperpixel)
345 int mx = mv->
x * (1 << !s->
ss_h), my = mv->
y * (1 << !s->
ss_v),
th;
349 ref_u += y * src_stride_u + x * bytesperpixel;
350 ref_v += y * src_stride_v + x * bytesperpixel;
356 th = (y + bh + 4 * !!my + 7) >> (6 - s->
ss_v);
361 if (x < !!mx * 3 || y < !!my * 3 ||
362 x + !!mx * 4 > w - bw || y + !!my * 5 > h - bh) {
364 ref_u - !!my * 3 * src_stride_u - !!mx * 3 * bytesperpixel,
366 bw + !!mx * 7, bh + !!my * 7,
367 x - !!mx * 3, y - !!my * 3, w, h);
368 ref_u = td->
edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
369 mc[!!mx][!!my](dst_u, dst_stride, ref_u, 160, bh, mx, my);
372 ref_v - !!my * 3 * src_stride_v - !!mx * 3 * bytesperpixel,
374 bw + !!mx * 7, bh + !!my * 7,
375 x - !!mx * 3, y - !!my * 3, w, h);
376 ref_v = td->
edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
377 mc[!!mx][!!my](dst_v, dst_stride, ref_v, 160, bh, mx, my);
379 mc[!!mx][!!my](dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my);
380 mc[!!mx][!!my](dst_v, dst_stride, ref_v, src_stride_v, bh, mx, my);
384 #define mc_luma_dir(td, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, \ 385 px, py, pw, ph, bw, bh, w, h, i) \ 386 mc_luma_unscaled(td, s->dsp.mc, dst, dst_ls, src, src_ls, tref, row, col, \ 387 mv, bw, bh, w, h, bytesperpixel) 388 #define mc_chroma_dir(td, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \ 389 row, col, mv, px, py, pw, ph, bw, bh, w, h, i) \ 390 mc_chroma_unscaled(td, s->dsp.mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \ 391 row, col, mv, bw, bh, w, h, bytesperpixel) 393 #define FN(x) x##_8bpp 394 #define BYTES_PER_PIXEL 1 397 #undef BYTES_PER_PIXEL 398 #define FN(x) x##_16bpp 399 #define BYTES_PER_PIXEL 2 404 #undef BYTES_PER_PIXEL 409 uint8_t *dst, ptrdiff_t dst_stride,
412 ptrdiff_t y, ptrdiff_t x,
const VP56mv *in_mv,
413 int px,
int py,
int pw,
int ph,
414 int bw,
int bh,
int w,
int h,
int bytesperpixel,
421 y, x, in_mv, bw, bh, w, h, bytesperpixel);
423 #define scale_mv(n, dim) (((int64_t)(n) * scale[dim]) >> 14) 425 int refbw_m1, refbh_m1;
429 mv.
x =
av_clip(in_mv->
x, -(x + pw - px + 4) * 8, (s->
cols * 8 - x + px + 3) * 8);
430 mv.
y =
av_clip(in_mv->
y, -(y + ph - py + 4) * 8, (s->
rows * 8 - y + py + 3) * 8);
439 ref += y * ref_stride + x * bytesperpixel;
442 refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
443 refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
447 th = (y + refbh_m1 + 4 + 7) >> 6;
452 if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 5 >= h - refbh_m1) {
454 ref - 3 * ref_stride - 3 * bytesperpixel,
456 refbw_m1 + 8, refbh_m1 + 8,
461 smc(dst, dst_stride, ref, ref_stride, bh, mx, my, step[0], step[1]);
468 ptrdiff_t dst_stride,
469 const uint8_t *ref_u, ptrdiff_t src_stride_u,
470 const uint8_t *ref_v, ptrdiff_t src_stride_v,
472 ptrdiff_t y, ptrdiff_t x,
const VP56mv *in_mv,
473 int px,
int py,
int pw,
int ph,
474 int bw,
int bh,
int w,
int h,
int bytesperpixel,
481 ref_v, src_stride_v, ref_frame,
482 y, x, in_mv, bw, bh, w, h, bytesperpixel);
485 int refbw_m1, refbh_m1;
491 mv.
x =
av_clip(in_mv->
x, -(x + pw - px + 4) * 16, (s->
cols * 4 - x + px + 3) * 16);
494 mv.
x =
av_clip(in_mv->
x, -(x + pw - px + 4) * 8, (s->
cols * 8 - x + px + 3) * 8);
499 mv.
y =
av_clip(in_mv->
y, -(y + ph - py + 4) * 16, (s->
rows * 4 - y + py + 3) * 16);
502 mv.
y =
av_clip(in_mv->
y, -(y + ph - py + 4) * 8, (s->
rows * 8 - y + py + 3) * 8);
508 ref_u += y * src_stride_u + x * bytesperpixel;
509 ref_v += y * src_stride_v + x * bytesperpixel;
512 refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
513 refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
517 th = (y + refbh_m1 + 4 + 7) >> (6 - s->
ss_v);
522 if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 5 >= h - refbh_m1) {
524 ref_u - 3 * src_stride_u - 3 * bytesperpixel,
526 refbw_m1 + 8, refbh_m1 + 8,
529 smc(dst_u, dst_stride, ref_u, 288, bh, mx, my, step[0], step[1]);
532 ref_v - 3 * src_stride_v - 3 * bytesperpixel,
534 refbw_m1 + 8, refbh_m1 + 8,
537 smc(dst_v, dst_stride, ref_v, 288, bh, mx, my, step[0], step[1]);
539 smc(dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my, step[0], step[1]);
540 smc(dst_v, dst_stride, ref_v, src_stride_v, bh, mx, my, step[0], step[1]);
545 #define mc_luma_dir(td, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, \ 546 px, py, pw, ph, bw, bh, w, h, i) \ 547 mc_luma_scaled(td, s->dsp.s##mc, s->dsp.mc, dst, dst_ls, src, src_ls, tref, row, col, \ 548 mv, px, py, pw, ph, bw, bh, w, h, bytesperpixel, \ 549 s->mvscale[b->ref[i]], s->mvstep[b->ref[i]]) 550 #define mc_chroma_dir(td, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \ 551 row, col, mv, px, py, pw, ph, bw, bh, w, h, i) \ 552 mc_chroma_scaled(td, s->dsp.s##mc, s->dsp.mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \ 553 row, col, mv, px, py, pw, ph, bw, bh, w, h, bytesperpixel, \ 554 s->mvscale[b->ref[i]], s->mvstep[b->ref[i]]) 556 #define FN(x) x##_scaled_8bpp 557 #define BYTES_PER_PIXEL 1 560 #undef BYTES_PER_PIXEL 561 #define FN(x) x##_scaled_16bpp 562 #define BYTES_PER_PIXEL 2 567 #undef BYTES_PER_PIXEL 574 int row = td->
row, col = td->
col;
581 "reference frame has invalid dimensions\n");
587 if (bytesperpixel == 1) {
588 inter_pred_scaled_8bpp(td);
590 inter_pred_scaled_16bpp(td);
593 if (bytesperpixel == 1) {
596 inter_pred_16bpp(td);
605 int end_x =
FFMIN(2 * (s->
cols - col), w4);
606 int end_y =
FFMIN(2 * (s->
rows - row), h4);
608 int uvstep1d = 1 << b->
uvtx, p;
612 for (n = 0, y = 0; y < end_y; y += step1d) {
614 for (x = 0; x < end_x; x += step1d,
615 ptr += 4 * step1d * bytesperpixel, n +=
step) {
620 td->
block + 16 * n * bytesperpixel, eob);
628 step = 1 << (b->
uvtx * 2);
629 for (p = 0; p < 2; p++) {
630 dst = td->
dst[p + 1];
631 for (n = 0, y = 0; y < end_y; y += uvstep1d) {
633 for (x = 0; x < end_x; x += uvstep1d,
634 ptr += 4 * uvstep1d * bytesperpixel, n +=
step) {
639 td->
uvblock[p] + 16 * n * bytesperpixel, eob);
#define assign_val(c, i, v)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
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(* vp9_mc_func)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *ref, ptrdiff_t ref_stride, int h, int mx, int my)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
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)
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before ff_thread_await_progress() has been called on them.reget_buffer() and buffer age optimizations no longer work.*The contents of buffers must not be written to after ff_thread_report_progress() has been called on them.This includes draw_edges().Porting codecs to frame threading
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.
#define LOCAL_ALIGNED_32(t, v,...)
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)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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]
Libavcodec external API header.
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]
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]
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)
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)
#define REF_INVALID_SCALE
mode
Use these values in ebur128_init (or'ed).
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step