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)
 
   39     int have_top = row > 0 || y > 0;
 
   41     int have_right = x < w - 1;
 
   43     static const uint8_t mode_conv[10][2 ][2 ] = {
 
   74         [
DC_PRED]              = { .needs_top  = 1, .needs_left = 1 },
 
   83         [
HOR_UP_PRED]          = { .needs_left = 1, .invert_left = 1 },
 
   94     mode = mode_conv[
mode][have_left][have_top];
 
   95     if (edges[mode].needs_top) {
 
   97         int n_px_need = 4 << tx, n_px_have = (((s->
cols - col) << !ss_h) - x) * 4;
 
  100         if (tx == 
TX_4X4 && edges[mode].needs_topright && have_right)
 
  107             top = !(row & 7) && !y ?
 
  109                 y == 0 ? &dst_edge[-stride_edge] : &dst_inner[-stride_inner];
 
  111                 topleft = !(row & 7) && !y ?
 
  113                     y == 0 || x == 0 ? &dst_edge[-stride_edge] :
 
  114                     &dst_inner[-stride_inner];
 
  118             (!edges[mode].needs_topleft || (have_left && top == topleft)) &&
 
  119             (tx != 
TX_4X4 || !edges[mode].needs_topright || have_right) &&
 
  120             n_px_need + n_px_need_tr <= n_px_have) {
 
  124                 if (n_px_need <= n_px_have) {
 
  125                     memcpy(*a, top, n_px_need * bytesperpixel);
 
  127 #define memset_bpp(c, i1, v, i2, num) do { \ 
  128     if (bytesperpixel == 1) { \ 
  129         memset(&(c)[(i1)], (v)[(i2)], (num)); \ 
  131         int n, val = AV_RN16A(&(v)[(i2) * 2]); \ 
  132         for (n = 0; n < (num); n++) { \ 
  133             AV_WN16A(&(c)[((i1) + n) * 2], val); \ 
  137                     memcpy(*a, top, n_px_have * bytesperpixel);
 
  138                     memset_bpp(*a, n_px_have, (*a), n_px_have - 1, n_px_need - n_px_have);
 
  141 #define memset_val(c, val, num) do { \ 
  142     if (bytesperpixel == 1) { \ 
  143         memset((c), (val), (num)); \ 
  146         for (n = 0; n < (num); n++) { \ 
  147             AV_WN16A(&(c)[n * 2], (val)); \ 
  151                 memset_val(*a, (128 << (bpp - 8)) - 1, n_px_need);
 
  153             if (edges[mode].needs_topleft) {
 
  154                 if (have_left && have_top) {
 
  155 #define assign_bpp(c, i1, v, i2) do { \ 
  156     if (bytesperpixel == 1) { \ 
  157         (c)[(i1)] = (v)[(i2)]; \ 
  159         AV_COPY16(&(c)[(i1) * 2], &(v)[(i2) * 2]); \ 
  164 #define assign_val(c, i, v) do { \ 
  165     if (bytesperpixel == 1) { \ 
  168         AV_WN16A(&(c)[(i) * 2], (v)); \ 
  171                     assign_val((*a), -1, (128 << (bpp - 8)) + (have_top ? +1 : -1));
 
  174             if (tx == 
TX_4X4 && edges[mode].needs_topright) {
 
  175                 if (have_top && have_right &&
 
  176                     n_px_need + n_px_need_tr <= n_px_have) {
 
  177                     memcpy(&(*a)[4 * bytesperpixel], &top[4 * bytesperpixel], 4 * bytesperpixel);
 
  184     if (edges[mode].needs_left) {
 
  186             int n_px_need = 4 << tx, i, n_px_have = (((s->
rows - row) << !ss_v) - y) * 4;
 
  187             uint8_t *dst = x == 0 ? dst_edge : dst_inner;
 
  188             ptrdiff_t 
stride = x == 0 ? stride_edge : stride_inner;
 
  190             if (edges[mode].invert_left) {
 
  191                 if (n_px_need <= n_px_have) {
 
  192                     for (i = 0; i < n_px_need; i++)
 
  195                     for (i = 0; i < n_px_have; i++)
 
  197                     memset_bpp(l, n_px_have, l, n_px_have - 1, n_px_need - n_px_have);
 
  200                 if (n_px_need <= n_px_have) {
 
  201                     for (i = 0; i < n_px_need; i++)
 
  202                         assign_bpp(l, n_px_need - 1 - i, &dst[i * stride], -1);
 
  204                     for (i = 0; i < n_px_have; i++)
 
  205                         assign_bpp(l, n_px_need - 1 - i, &dst[i * stride], -1);
 
  206                     memset_bpp(l, 0, l, n_px_need - n_px_have, n_px_need - n_px_have);
 
  210             memset_val(l, (128 << (bpp - 8)) + 1, 4 << tx);
 
  218                                          ptrdiff_t uv_off, 
int bytesperpixel)
 
  222     int row = s->
row, col = s->
col;
 
  225     int end_x = 
FFMIN(2 * (s->
cols - col), w4);
 
  226     int end_y = 
FFMIN(2 * (s->
rows - row), h4);
 
  228     int uvstep1d = 1 << b->
uvtx, p;
 
  233     for (
n = 0, y = 0; y < end_y; y += step1d) {
 
  234         uint8_t *ptr = dst, *ptr_r = dst_r;
 
  235         for (x = 0; x < end_x; x += step1d, ptr += 4 * step1d * bytesperpixel,
 
  236                                ptr_r += 4 * step1d * bytesperpixel, 
n += step) {
 
  246                                     col, x, w4, row, y, b->tx, 0, 0, 0, bytesperpixel);
 
  250                                            s->
block + 16 * n * bytesperpixel, eob);
 
  260     step = 1 << (b->
uvtx * 2);
 
  261     for (p = 0; p < 2; p++) {
 
  264         for (
n = 0, y = 0; y < end_y; y += uvstep1d) {
 
  265             uint8_t *ptr = dst, *ptr_r = dst_r;
 
  266             for (x = 0; x < end_x; x += uvstep1d, ptr += 4 * uvstep1d * bytesperpixel,
 
  267                                    ptr_r += 4 * uvstep1d * bytesperpixel, 
n += step) {
 
  274                                         ptr, s->
uv_stride, l, col, x, w4, row, y,
 
  279                                                     s->
uvblock[p] + 16 * n * bytesperpixel, eob);
 
  298                                               uint8_t *dst, ptrdiff_t dst_stride,
 
  301                                               ptrdiff_t y, ptrdiff_t x, 
const VP56mv *
mv,
 
  302                                               int bw, 
int bh, 
int w, 
int h, 
int bytesperpixel)
 
  304     int mx = mv->
x, my = mv->
y, 
th;
 
  308     ref += y * ref_stride + x * bytesperpixel;
 
  314     th = (y + bh + 4 * !!my + 7) >> 6;
 
  319     if (x < !!mx * 3 || y < !!my * 3 ||
 
  320         x + !!mx * 4 > w - bw || y + !!my * 5 > h - bh) {
 
  322                                  ref - !!my * 3 * ref_stride - !!mx * 3 * bytesperpixel,
 
  324                                  bw + !!mx * 7, bh + !!my * 7,
 
  325                                  x - !!mx * 3, y - !!my * 3, w, h);
 
  329     mc[!!mx][!!my](dst, dst_stride, 
ref, ref_stride, bh, mx << 1, my << 1);
 
  334                                                 ptrdiff_t dst_stride,
 
  335                                                 const uint8_t *ref_u, ptrdiff_t src_stride_u,
 
  336                                                 const uint8_t *ref_v, ptrdiff_t src_stride_v,
 
  338                                                 ptrdiff_t y, ptrdiff_t x, 
const VP56mv *
mv,
 
  339                                                 int bw, 
int bh, 
int w, 
int h, 
int bytesperpixel)
 
  341     int mx = mv->
x * (1 << !s->
ss_h), my = mv->
y * (1 << !s->
ss_v), 
th;
 
  345     ref_u += y * src_stride_u + x * bytesperpixel;
 
  346     ref_v += y * src_stride_v + x * bytesperpixel;
 
  352     th = (y + bh + 4 * !!my + 7) >> (6 - s->
ss_v);
 
  357     if (x < !!mx * 3 || y < !!my * 3 ||
 
  358         x + !!mx * 4 > w - bw || y + !!my * 5 > h - bh) {
 
  360                                  ref_u - !!my * 3 * src_stride_u - !!mx * 3 * bytesperpixel,
 
  362                                  bw + !!mx * 7, bh + !!my * 7,
 
  363                                  x - !!mx * 3, y - !!my * 3, w, h);
 
  364         ref_u = s->
edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
 
  365         mc[!!mx][!!my](dst_u, dst_stride, ref_u, 160, bh, mx, my);
 
  368                                  ref_v - !!my * 3 * src_stride_v - !!mx * 3 * bytesperpixel,
 
  370                                  bw + !!mx * 7, bh + !!my * 7,
 
  371                                  x - !!mx * 3, y - !!my * 3, w, h);
 
  372         ref_v = s->
edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
 
  373         mc[!!mx][!!my](dst_v, dst_stride, ref_v, 160, bh, mx, my);
 
  375         mc[!!mx][!!my](dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my);
 
  376         mc[!!mx][!!my](dst_v, dst_stride, ref_v, src_stride_v, bh, mx, my);
 
  380 #define mc_luma_dir(s, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, \ 
  381                     px, py, pw, ph, bw, bh, w, h, i) \ 
  382     mc_luma_unscaled(s, s->dsp.mc, dst, dst_ls, src, src_ls, tref, row, col, \ 
  383                      mv, bw, bh, w, h, bytesperpixel) 
  384 #define mc_chroma_dir(s, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \ 
  385                       row, col, mv, px, py, pw, ph, bw, bh, w, h, i) \ 
  386     mc_chroma_unscaled(s, s->dsp.mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \ 
  387                        row, col, mv, bw, bh, w, h, bytesperpixel) 
  389 #define FN(x) x##_8bpp 
  390 #define BYTES_PER_PIXEL 1 
  393 #undef BYTES_PER_PIXEL 
  394 #define FN(x) x##_16bpp 
  395 #define BYTES_PER_PIXEL 2 
  400 #undef BYTES_PER_PIXEL 
  405                                             uint8_t *dst, ptrdiff_t dst_stride,
 
  408                                             ptrdiff_t y, ptrdiff_t x, 
const VP56mv *in_mv,
 
  409                                             int px, 
int py, 
int pw, 
int ph,
 
  410                                             int bw, 
int bh, 
int w, 
int h, 
int bytesperpixel,
 
  411                                             const uint16_t *scale, 
const uint8_t *step)
 
  416                          y, x, in_mv, bw, bh, w, h, bytesperpixel);
 
  418 #define scale_mv(n, dim) (((int64_t)(n) * scale[dim]) >> 14) 
  420     int refbw_m1, refbh_m1;
 
  424     mv.
x = av_clip(in_mv->
x, -(x + pw - px + 4) * 8, (s->
cols * 8 - x + px + 3) * 8);
 
  425     mv.
y = av_clip(in_mv->
y, -(y + ph - py + 4) * 8, (s->
rows * 8 - y + py + 3) * 8);
 
  434     ref += y * ref_stride + x * bytesperpixel;
 
  437     refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
 
  438     refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
 
  442     th = (y + refbh_m1 + 4 + 7) >> 6;
 
  447     if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 5 >= h - refbh_m1) {
 
  449                                  ref - 3 * ref_stride - 3 * bytesperpixel,
 
  451                                  refbw_m1 + 8, refbh_m1 + 8,
 
  456     smc(dst, dst_stride, ref, ref_stride, bh, mx, my, step[0], step[1]);
 
  463                                               ptrdiff_t dst_stride,
 
  464                                               const uint8_t *ref_u, ptrdiff_t src_stride_u,
 
  465                                               const uint8_t *ref_v, ptrdiff_t src_stride_v,
 
  467                                               ptrdiff_t y, ptrdiff_t x, 
const VP56mv *in_mv,
 
  468                                               int px, 
int py, 
int pw, 
int ph,
 
  469                                               int bw, 
int bh, 
int w, 
int h, 
int bytesperpixel,
 
  470                                               const uint16_t *scale, 
const uint8_t *step)
 
  475                            ref_v, src_stride_v, ref_frame,
 
  476                            y, x, in_mv, bw, bh, w, h, bytesperpixel);
 
  479     int refbw_m1, refbh_m1;
 
  485         mv.
x = av_clip(in_mv->
x, -(x + pw - px + 4) * 16, (s->
cols * 4 - x + px + 3) * 16);
 
  488         mv.
x = av_clip(in_mv->
x, -(x + pw - px + 4) * 8, (s->
cols * 8 - x + px + 3) * 8);
 
  493         mv.
y = av_clip(in_mv->
y, -(y + ph - py + 4) * 16, (s->
rows * 4 - y + py + 3) * 16);
 
  496         mv.
y = av_clip(in_mv->
y, -(y + ph - py + 4) * 8, (s->
rows * 8 - y + py + 3) * 8);
 
  502     ref_u += y * src_stride_u + x * bytesperpixel;
 
  503     ref_v += y * src_stride_v + x * bytesperpixel;
 
  506     refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
 
  507     refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
 
  511     th = (y + refbh_m1 + 4 + 7) >> (6 - s->
ss_v);
 
  516     if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 5 >= h - refbh_m1) {
 
  518                                  ref_u - 3 * src_stride_u - 3 * bytesperpixel,
 
  520                                  refbw_m1 + 8, refbh_m1 + 8,
 
  523         smc(dst_u, dst_stride, ref_u, 288, bh, mx, my, step[0], step[1]);
 
  526                                  ref_v - 3 * src_stride_v - 3 * bytesperpixel,
 
  528                                  refbw_m1 + 8, refbh_m1 + 8,
 
  531         smc(dst_v, dst_stride, ref_v, 288, bh, mx, my, step[0], step[1]);
 
  533         smc(dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my, step[0], step[1]);
 
  534         smc(dst_v, dst_stride, ref_v, src_stride_v, bh, mx, my, step[0], step[1]);
 
  539 #define mc_luma_dir(s, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, \ 
  540                     px, py, pw, ph, bw, bh, w, h, i) \ 
  541     mc_luma_scaled(s, s->dsp.s##mc, s->dsp.mc, dst, dst_ls, src, src_ls, tref, row, col, \ 
  542                    mv, px, py, pw, ph, bw, bh, w, h, bytesperpixel, \ 
  543                    s->mvscale[b->ref[i]], s->mvstep[b->ref[i]]) 
  544 #define mc_chroma_dir(s, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \ 
  545                       row, col, mv, px, py, pw, ph, bw, bh, w, h, i) \ 
  546     mc_chroma_scaled(s, s->dsp.s##mc, s->dsp.mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \ 
  547                      row, col, mv, px, py, pw, ph, bw, bh, w, h, bytesperpixel, \ 
  548                      s->mvscale[b->ref[i]], s->mvstep[b->ref[i]]) 
  550 #define FN(x) x##_scaled_8bpp 
  551 #define BYTES_PER_PIXEL 1 
  554 #undef BYTES_PER_PIXEL 
  555 #define FN(x) x##_scaled_16bpp 
  556 #define BYTES_PER_PIXEL 2 
  561 #undef BYTES_PER_PIXEL 
  568     int row = s->
row, col = s->
col;
 
  571         if (bytesperpixel == 1) {
 
  572             inter_pred_scaled_8bpp(avctx);
 
  574             inter_pred_scaled_16bpp(avctx);
 
  577         if (bytesperpixel == 1) {
 
  578             inter_pred_8bpp(avctx);
 
  580             inter_pred_16bpp(avctx);
 
  589         int end_x = 
FFMIN(2 * (s->
cols - col), w4);
 
  590         int end_y = 
FFMIN(2 * (s->
rows - row), h4);
 
  592         int uvstep1d = 1 << b->
uvtx, p;
 
  596         for (
n = 0, y = 0; y < end_y; y += step1d) {
 
  598             for (x = 0; x < end_x; x += step1d,
 
  599                  ptr += 4 * step1d * bytesperpixel, 
n += step) {
 
  604                                                   s->
block + 16 * n * bytesperpixel, eob);
 
  612         step = 1 << (b->
uvtx * 2);
 
  613         for (p = 0; p < 2; p++) {
 
  615             for (
n = 0, y = 0; y < end_y; y += uvstep1d) {
 
  617                 for (x = 0; x < end_x; x += uvstep1d,
 
  618                      ptr += 4 * uvstep1d * bytesperpixel, 
n += step) {
 
  623                                                         s->
uvblock[p] + 16 * n * bytesperpixel, eob);
 
#define assign_val(c, i, v)
 
static av_always_inline void inter_recon(AVCodecContext *avctx, int bytesperpixel)
 
void ff_vp9_inter_recon_16bpp(AVCodecContext *avctx)
 
static av_always_inline void mc_luma_scaled(VP9Context *s, 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)
 
void(* intra_pred[N_TXFM_SIZES][N_INTRA_PRED_MODES])(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, const uint8_t *top)
 
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...
 
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code. 
 
static av_always_inline void mc_luma_unscaled(VP9Context *s, 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)
 
int width
width and height of the video frame 
 
simple assert() macros that are a bit more flexible than ISO C assert(). 
 
#define memset_bpp(c, i1, v, i2, num)
 
void ff_vp9_intra_recon_16bpp(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off)
 
void ff_vp9_inter_recon_8bpp(AVCodecContext *avctx)
 
unsigned eob[4][2][2][6][6][2]
 
static av_always_inline void mc_chroma_unscaled(VP9Context *s, 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 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. 
 
main external API structure. 
 
enum TxfmType ff_vp9_intra_txfm_type[14]
 
const uint8_t ff_vp9_bwh_tab[2][N_BS_SIZES][2]
 
static av_always_inline int check_intra_mode(VP9Context *s, 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)
 
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes. 
 
#define LOCAL_ALIGNED_32(t, v,...)
 
static av_always_inline void intra_recon(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off, int bytesperpixel)
 
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 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 mc_chroma_scaled(VP9Context *s, 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)
 
uint8_t edge_emu_buffer[135 *144 *2]
 
void ff_vp9_intra_recon_8bpp(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off)
 
mode
Use these values in ebur128_init (or'ed).