static int inter_recon(AVCodecContext *avctx)
{
    static const uint8_t bwlog_tab[2][N_BS_SIZES] = {
        { 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 },
        { 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4 },
    };
    VP9Context *s = avctx->priv_data;
    VP9Block *const b = &s->b;
    int row = b->row, col = b->col;
    AVFrame *ref1 = s->refs[s->refidx[b->ref[0]]];
    AVFrame *ref2 = b->comp ? s->refs[s->refidx[b->ref[1]]] : NULL;
    int w = avctx->width, h = avctx->height;
    ptrdiff_t ls_y = b->y_stride, ls_uv = b->uv_stride;
    if (!ref1->data[0] || (b->comp && !ref2->data[0]))
        return AVERROR_INVALIDDATA;
    if (b->bs > BS_8x8) {
        if (b->bs == BS_8x4) {
            mc_luma_dir(s, s->dsp.mc[3][b->filter][0], b->dst[0], ls_y,
                        ref1->data[0], ref1->linesize[0],
                        row << 3, col << 3, &b->mv[0][0], 8, 4, w, h);
            mc_luma_dir(s, s->dsp.mc[3][b->filter][0],
                        b->dst[0] + 4 * ls_y, ls_y,
                        ref1->data[0], ref1->linesize[0],
                        (row << 3) + 4, col << 3, &b->mv[2][0], 8, 4, w, h);
            if (b->comp) {
                mc_luma_dir(s, s->dsp.mc[3][b->filter][1], b->dst[0], ls_y,
                            ref2->data[0], ref2->linesize[0],
                            row << 3, col << 3, &b->mv[0][1], 8, 4, w, h);
                mc_luma_dir(s, s->dsp.mc[3][b->filter][1],
                            b->dst[0] + 4 * ls_y, ls_y,
                            ref2->data[0], ref2->linesize[0],
                            (row << 3) + 4, col << 3, &b->mv[2][1], 8, 4, w, h);
            }
        } else if (b->bs == BS_4x8) {
            mc_luma_dir(s, s->dsp.mc[4][b->filter][0], b->dst[0], ls_y,
                        ref1->data[0], ref1->linesize[0],
                        row << 3, col << 3, &b->mv[0][0], 4, 8, w, h);
            mc_luma_dir(s, s->dsp.mc[4][b->filter][0], b->dst[0] + 4, ls_y,
                        ref1->data[0], ref1->linesize[0],
                        row << 3, (col << 3) + 4, &b->mv[1][0], 4, 8, w, h);
            if (b->comp) {
                mc_luma_dir(s, s->dsp.mc[4][b->filter][1], b->dst[0], ls_y,
                            ref2->data[0], ref2->linesize[0],
                            row << 3, col << 3, &b->mv[0][1], 4, 8, w, h);
                mc_luma_dir(s, s->dsp.mc[4][b->filter][1], b->dst[0] + 4, ls_y,
                            ref2->data[0], ref2->linesize[0],
                            row << 3, (col << 3) + 4, &b->mv[1][1], 4, 8, w, h);
            }
        } else {
            av_assert2(b->bs == BS_4x4);
            mc_luma_dir(s, s->dsp.mc[4][b->filter][0], b->dst[0], ls_y,
                        ref1->data[0], ref1->linesize[0],
                        row << 3, col << 3, &b->mv[0][0], 4, 4, w, h);
            mc_luma_dir(s, s->dsp.mc[4][b->filter][0], b->dst[0] + 4, ls_y,
                        ref1->data[0], ref1->linesize[0],
                        row << 3, (col << 3) + 4, &b->mv[1][0], 4, 4, w, h);
            mc_luma_dir(s, s->dsp.mc[4][b->filter][0],
                        b->dst[0] + 4 * ls_y, ls_y,
                        ref1->data[0], ref1->linesize[0],
                        (row << 3) + 4, col << 3, &b->mv[2][0], 4, 4, w, h);
            mc_luma_dir(s, s->dsp.mc[4][b->filter][0],
                        b->dst[0] + 4 * ls_y + 4, ls_y,
                        ref1->data[0], ref1->linesize[0],
                        (row << 3) + 4, (col << 3) + 4, &b->mv[3][0], 4, 4, w, h);
            if (b->comp) {
                mc_luma_dir(s, s->dsp.mc[4][b->filter][1], b->dst[0], ls_y,
                            ref2->data[0], ref2->linesize[0],
                            row << 3, col << 3, &b->mv[0][1], 4, 4, w, h);
                mc_luma_dir(s, s->dsp.mc[4][b->filter][1], b->dst[0] + 4, ls_y,
                            ref2->data[0], ref2->linesize[0],
                            row << 3, (col << 3) + 4, &b->mv[1][1], 4, 4, w, h);
                mc_luma_dir(s, s->dsp.mc[4][b->filter][1],
                            b->dst[0] + 4 * ls_y, ls_y,
                            ref2->data[0], ref2->linesize[0],
                            (row << 3) + 4, col << 3, &b->mv[2][1], 4, 4, w, h);
                mc_luma_dir(s, s->dsp.mc[4][b->filter][1],
                            b->dst[0] + 4 * ls_y + 4, ls_y,
                            ref2->data[0], ref2->linesize[0],
                            (row << 3) + 4, (col << 3) + 4, &b->mv[3][1], 4, 4, w, h);
            }
        }
    } else {
        int bwl = bwlog_tab[0][b->bs];
        int bw  = bwh_tab[0][b->bs][0] * 4;
        int bh  = bwh_tab[0][b->bs][1] * 4;
        mc_luma_dir(s, s->dsp.mc[bwl][b->filter][0], b->dst[0], ls_y,
                    ref1->data[0], ref1->linesize[0],
                    row << 3, col << 3, &b->mv[0][0], bw, bh, w, h);
        if (b->comp)
            mc_luma_dir(s, s->dsp.mc[bwl][b->filter][1], b->dst[0], ls_y,
                        ref2->data[0], ref2->linesize[0],
                        row << 3, col << 3, &b->mv[0][1], bw, bh, w, h);
    }
    {
        int bwl = bwlog_tab[1][b->bs];
        int bw  = bwh_tab[1][b->bs][0] * 4, bh = bwh_tab[1][b->bs][1] * 4;
        VP56mv mvuv;
        w = (w + 1) >> 1;
        h = (h + 1) >> 1;
        if (b->bs > BS_8x8) {
            mvuv.x = ROUNDED_DIV(b->mv[0][0].x + b->mv[1][0].x +
                                 b->mv[2][0].x + b->mv[3][0].x, 4);
            mvuv.y = ROUNDED_DIV(b->mv[0][0].y + b->mv[1][0].y +
                                 b->mv[2][0].y + b->mv[3][0].y, 4);
        } else {
            mvuv = b->mv[0][0];
        }
        mc_chroma_dir(s, s->dsp.mc[bwl][b->filter][0],
                      b->dst[1], b->dst[2], ls_uv,
                      ref1->data[1], ref1->linesize[1],
                      ref1->data[2], ref1->linesize[2],
                      row << 2, col << 2, &mvuv, bw, bh, w, h);
        if (b->comp) {
            if (b->bs > BS_8x8) {
                mvuv.x = ROUNDED_DIV(b->mv[0][1].x + b->mv[1][1].x +
                                     b->mv[2][1].x + b->mv[3][1].x, 4);
                mvuv.y = ROUNDED_DIV(b->mv[0][1].y + b->mv[1][1].y +
                                     b->mv[2][1].y + b->mv[3][1].y, 4);
            } else {
                mvuv = b->mv[0][1];
            }
            mc_chroma_dir(s, s->dsp.mc[bwl][b->filter][1],
                          b->dst[1], b->dst[2], ls_uv,
                          ref2->data[1], ref2->linesize[1],
                          ref2->data[2], ref2->linesize[2],
                          row << 2, col << 2, &mvuv, bw, bh, w, h);
        }
    }
    if (!b->skip) {
        int w4 = bwh_tab[1][b->bs][0] << 1, step1d = 1 << b->tx, n;
        int h4 = bwh_tab[1][b->bs][1] << 1, x, y, step = 1 << (b->tx * 2);
        int end_x = FFMIN(2 * (s->cols - col), w4);
        int end_y = FFMIN(2 * (s->rows - row), h4);
        int tx = 4 * s->lossless + b->tx, uvtx = b->uvtx + 4 * s->lossless;
        int uvstep1d = 1 << b->uvtx, p;
        uint8_t *dst = b->dst[0];
        for (n = 0, y = 0; y < end_y; y += step1d) {
            uint8_t *ptr = dst;
            for (x = 0; x < end_x; x += step1d, ptr += 4 * step1d, n += step) {
                int eob = b->tx > TX_8X8 ? AV_RN16A(&s->eob[n]) : s->eob[n];
                if (eob)
                    s->dsp.itxfm_add[tx][DCT_DCT](ptr, b->y_stride,
                                                  s->block + 16 * n, eob);
            }
            dst += 4 * b->y_stride * step1d;
        }
        h4    >>= 1;
        w4    >>= 1;
        end_x >>= 1;
        end_y >>= 1;
        step    = 1 << (b->uvtx * 2);
        for (p = 0; p < 2; p++) {
            dst = b->dst[p + 1];
            for (n = 0, y = 0; y < end_y; y += uvstep1d) {
                uint8_t *ptr = dst;
                for (x = 0; x < end_x; x += uvstep1d, ptr += 4 * uvstep1d, n += step) {
                    int eob = b->uvtx > TX_8X8 ? AV_RN16A(&s->uveob[p][n])
                                               : s->uveob[p][n];
                    if (eob)
                        s->dsp.itxfm_add[uvtx][DCT_DCT](ptr, b->uv_stride,
                                                        s->uvblock[p] + 16 * n, eob);
                }
                dst += 4 * uvstep1d * b->uv_stride;
            }
        }
    }
    return 0;
}
['static int inter_recon(AVCodecContext *avctx)\n{\n    static const uint8_t bwlog_tab[2][N_BS_SIZES] = {\n        { 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 },\n        { 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4 },\n    };\n    VP9Context *s = avctx->priv_data;\n    VP9Block *const b = &s->b;\n    int row = b->row, col = b->col;\n    AVFrame *ref1 = s->refs[s->refidx[b->ref[0]]];\n    AVFrame *ref2 = b->comp ? s->refs[s->refidx[b->ref[1]]] : NULL;\n    int w = avctx->width, h = avctx->height;\n    ptrdiff_t ls_y = b->y_stride, ls_uv = b->uv_stride;\n    if (!ref1->data[0] || (b->comp && !ref2->data[0]))\n        return AVERROR_INVALIDDATA;\n    if (b->bs > BS_8x8) {\n        if (b->bs == BS_8x4) {\n            mc_luma_dir(s, s->dsp.mc[3][b->filter][0], b->dst[0], ls_y,\n                        ref1->data[0], ref1->linesize[0],\n                        row << 3, col << 3, &b->mv[0][0], 8, 4, w, h);\n            mc_luma_dir(s, s->dsp.mc[3][b->filter][0],\n                        b->dst[0] + 4 * ls_y, ls_y,\n                        ref1->data[0], ref1->linesize[0],\n                        (row << 3) + 4, col << 3, &b->mv[2][0], 8, 4, w, h);\n            if (b->comp) {\n                mc_luma_dir(s, s->dsp.mc[3][b->filter][1], b->dst[0], ls_y,\n                            ref2->data[0], ref2->linesize[0],\n                            row << 3, col << 3, &b->mv[0][1], 8, 4, w, h);\n                mc_luma_dir(s, s->dsp.mc[3][b->filter][1],\n                            b->dst[0] + 4 * ls_y, ls_y,\n                            ref2->data[0], ref2->linesize[0],\n                            (row << 3) + 4, col << 3, &b->mv[2][1], 8, 4, w, h);\n            }\n        } else if (b->bs == BS_4x8) {\n            mc_luma_dir(s, s->dsp.mc[4][b->filter][0], b->dst[0], ls_y,\n                        ref1->data[0], ref1->linesize[0],\n                        row << 3, col << 3, &b->mv[0][0], 4, 8, w, h);\n            mc_luma_dir(s, s->dsp.mc[4][b->filter][0], b->dst[0] + 4, ls_y,\n                        ref1->data[0], ref1->linesize[0],\n                        row << 3, (col << 3) + 4, &b->mv[1][0], 4, 8, w, h);\n            if (b->comp) {\n                mc_luma_dir(s, s->dsp.mc[4][b->filter][1], b->dst[0], ls_y,\n                            ref2->data[0], ref2->linesize[0],\n                            row << 3, col << 3, &b->mv[0][1], 4, 8, w, h);\n                mc_luma_dir(s, s->dsp.mc[4][b->filter][1], b->dst[0] + 4, ls_y,\n                            ref2->data[0], ref2->linesize[0],\n                            row << 3, (col << 3) + 4, &b->mv[1][1], 4, 8, w, h);\n            }\n        } else {\n            av_assert2(b->bs == BS_4x4);\n            mc_luma_dir(s, s->dsp.mc[4][b->filter][0], b->dst[0], ls_y,\n                        ref1->data[0], ref1->linesize[0],\n                        row << 3, col << 3, &b->mv[0][0], 4, 4, w, h);\n            mc_luma_dir(s, s->dsp.mc[4][b->filter][0], b->dst[0] + 4, ls_y,\n                        ref1->data[0], ref1->linesize[0],\n                        row << 3, (col << 3) + 4, &b->mv[1][0], 4, 4, w, h);\n            mc_luma_dir(s, s->dsp.mc[4][b->filter][0],\n                        b->dst[0] + 4 * ls_y, ls_y,\n                        ref1->data[0], ref1->linesize[0],\n                        (row << 3) + 4, col << 3, &b->mv[2][0], 4, 4, w, h);\n            mc_luma_dir(s, s->dsp.mc[4][b->filter][0],\n                        b->dst[0] + 4 * ls_y + 4, ls_y,\n                        ref1->data[0], ref1->linesize[0],\n                        (row << 3) + 4, (col << 3) + 4, &b->mv[3][0], 4, 4, w, h);\n            if (b->comp) {\n                mc_luma_dir(s, s->dsp.mc[4][b->filter][1], b->dst[0], ls_y,\n                            ref2->data[0], ref2->linesize[0],\n                            row << 3, col << 3, &b->mv[0][1], 4, 4, w, h);\n                mc_luma_dir(s, s->dsp.mc[4][b->filter][1], b->dst[0] + 4, ls_y,\n                            ref2->data[0], ref2->linesize[0],\n                            row << 3, (col << 3) + 4, &b->mv[1][1], 4, 4, w, h);\n                mc_luma_dir(s, s->dsp.mc[4][b->filter][1],\n                            b->dst[0] + 4 * ls_y, ls_y,\n                            ref2->data[0], ref2->linesize[0],\n                            (row << 3) + 4, col << 3, &b->mv[2][1], 4, 4, w, h);\n                mc_luma_dir(s, s->dsp.mc[4][b->filter][1],\n                            b->dst[0] + 4 * ls_y + 4, ls_y,\n                            ref2->data[0], ref2->linesize[0],\n                            (row << 3) + 4, (col << 3) + 4, &b->mv[3][1], 4, 4, w, h);\n            }\n        }\n    } else {\n        int bwl = bwlog_tab[0][b->bs];\n        int bw  = bwh_tab[0][b->bs][0] * 4;\n        int bh  = bwh_tab[0][b->bs][1] * 4;\n        mc_luma_dir(s, s->dsp.mc[bwl][b->filter][0], b->dst[0], ls_y,\n                    ref1->data[0], ref1->linesize[0],\n                    row << 3, col << 3, &b->mv[0][0], bw, bh, w, h);\n        if (b->comp)\n            mc_luma_dir(s, s->dsp.mc[bwl][b->filter][1], b->dst[0], ls_y,\n                        ref2->data[0], ref2->linesize[0],\n                        row << 3, col << 3, &b->mv[0][1], bw, bh, w, h);\n    }\n    {\n        int bwl = bwlog_tab[1][b->bs];\n        int bw  = bwh_tab[1][b->bs][0] * 4, bh = bwh_tab[1][b->bs][1] * 4;\n        VP56mv mvuv;\n        w = (w + 1) >> 1;\n        h = (h + 1) >> 1;\n        if (b->bs > BS_8x8) {\n            mvuv.x = ROUNDED_DIV(b->mv[0][0].x + b->mv[1][0].x +\n                                 b->mv[2][0].x + b->mv[3][0].x, 4);\n            mvuv.y = ROUNDED_DIV(b->mv[0][0].y + b->mv[1][0].y +\n                                 b->mv[2][0].y + b->mv[3][0].y, 4);\n        } else {\n            mvuv = b->mv[0][0];\n        }\n        mc_chroma_dir(s, s->dsp.mc[bwl][b->filter][0],\n                      b->dst[1], b->dst[2], ls_uv,\n                      ref1->data[1], ref1->linesize[1],\n                      ref1->data[2], ref1->linesize[2],\n                      row << 2, col << 2, &mvuv, bw, bh, w, h);\n        if (b->comp) {\n            if (b->bs > BS_8x8) {\n                mvuv.x = ROUNDED_DIV(b->mv[0][1].x + b->mv[1][1].x +\n                                     b->mv[2][1].x + b->mv[3][1].x, 4);\n                mvuv.y = ROUNDED_DIV(b->mv[0][1].y + b->mv[1][1].y +\n                                     b->mv[2][1].y + b->mv[3][1].y, 4);\n            } else {\n                mvuv = b->mv[0][1];\n            }\n            mc_chroma_dir(s, s->dsp.mc[bwl][b->filter][1],\n                          b->dst[1], b->dst[2], ls_uv,\n                          ref2->data[1], ref2->linesize[1],\n                          ref2->data[2], ref2->linesize[2],\n                          row << 2, col << 2, &mvuv, bw, bh, w, h);\n        }\n    }\n    if (!b->skip) {\n        int w4 = bwh_tab[1][b->bs][0] << 1, step1d = 1 << b->tx, n;\n        int h4 = bwh_tab[1][b->bs][1] << 1, x, y, step = 1 << (b->tx * 2);\n        int end_x = FFMIN(2 * (s->cols - col), w4);\n        int end_y = FFMIN(2 * (s->rows - row), h4);\n        int tx = 4 * s->lossless + b->tx, uvtx = b->uvtx + 4 * s->lossless;\n        int uvstep1d = 1 << b->uvtx, p;\n        uint8_t *dst = b->dst[0];\n        for (n = 0, y = 0; y < end_y; y += step1d) {\n            uint8_t *ptr = dst;\n            for (x = 0; x < end_x; x += step1d, ptr += 4 * step1d, n += step) {\n                int eob = b->tx > TX_8X8 ? AV_RN16A(&s->eob[n]) : s->eob[n];\n                if (eob)\n                    s->dsp.itxfm_add[tx][DCT_DCT](ptr, b->y_stride,\n                                                  s->block + 16 * n, eob);\n            }\n            dst += 4 * b->y_stride * step1d;\n        }\n        h4    >>= 1;\n        w4    >>= 1;\n        end_x >>= 1;\n        end_y >>= 1;\n        step    = 1 << (b->uvtx * 2);\n        for (p = 0; p < 2; p++) {\n            dst = b->dst[p + 1];\n            for (n = 0, y = 0; y < end_y; y += uvstep1d) {\n                uint8_t *ptr = dst;\n                for (x = 0; x < end_x; x += uvstep1d, ptr += 4 * uvstep1d, n += step) {\n                    int eob = b->uvtx > TX_8X8 ? AV_RN16A(&s->uveob[p][n])\n                                               : s->uveob[p][n];\n                    if (eob)\n                        s->dsp.itxfm_add[uvtx][DCT_DCT](ptr, b->uv_stride,\n                                                        s->uvblock[p] + 16 * n, eob);\n                }\n                dst += 4 * uvstep1d * b->uv_stride;\n            }\n        }\n    }\n    return 0;\n}']