static int update_size(AVCodecContext *ctx, int w, int h, enum AVPixelFormat fmt)

{

    VP9Context *s = ctx->priv_data;

    uint8_t *p;

    int bytesperpixel = s->bytesperpixel;



    av_assert0(w > 0 && h > 0);



    if (s->intra_pred_data[0] && w == ctx->width && h == ctx->height && ctx->pix_fmt == fmt)

        return 0;



    ctx->width   = w;

    ctx->height  = h;

    ctx->pix_fmt = fmt;

    s->sb_cols   = (w + 63) >> 6;

    s->sb_rows   = (h + 63) >> 6;

    s->cols      = (w + 7) >> 3;

    s->rows      = (h + 7) >> 3;



#define assign(var, type, n) var = (type) p; p += s->sb_cols * (n) * sizeof(*var)

    av_freep(&s->intra_pred_data[0]);

    // FIXME we slightly over-allocate here for subsampled chroma, but a little

    // bit of padding shouldn't affect performance...

    p = av_malloc(s->sb_cols * (128 + 192 * bytesperpixel +

                                sizeof(*s->lflvl) + 16 * sizeof(*s->above_mv_ctx)));

    if (!p)

        return AVERROR(ENOMEM);

    assign(s->intra_pred_data[0],  uint8_t *,             64 * bytesperpixel);

    assign(s->intra_pred_data[1],  uint8_t *,             64 * bytesperpixel);

    assign(s->intra_pred_data[2],  uint8_t *,             64 * bytesperpixel);

    assign(s->above_y_nnz_ctx,     uint8_t *,             16);

    assign(s->above_mode_ctx,      uint8_t *,             16);

    assign(s->above_mv_ctx,        VP56mv(*)[2],          16);

    assign(s->above_uv_nnz_ctx[0], uint8_t *,             16);

    assign(s->above_uv_nnz_ctx[1], uint8_t *,             16);

    assign(s->above_partition_ctx, uint8_t *,              8);

    assign(s->above_skip_ctx,      uint8_t *,              8);

    assign(s->above_txfm_ctx,      uint8_t *,              8);

    assign(s->above_segpred_ctx,   uint8_t *,              8);

    assign(s->above_intra_ctx,     uint8_t *,              8);

    assign(s->above_comp_ctx,      uint8_t *,              8);

    assign(s->above_ref_ctx,       uint8_t *,              8);

    assign(s->above_filter_ctx,    uint8_t *,              8);

    assign(s->lflvl,               struct VP9Filter *,     1);

#undef assign



    // these will be re-allocated a little later

    av_freep(&s->b_base);

    av_freep(&s->block_base);



    if (s->bpp != s->last_bpp) {

        ff_vp9dsp_init(&s->dsp, s->bpp);

        ff_videodsp_init(&s->vdsp, s->bpp);

        s->last_bpp = s->bpp;

    }



    return 0;

}

static int update_size(AVCodecContext *ctx, int w, int h, enum AVPixelFormat fmt)

{

    VP9Context *s = ctx->priv_data;

    uint8_t *p;

    int bytesperpixel = s->bytesperpixel;



    av_assert0(w > 0 && h > 0);



    if (s->intra_pred_data[0] && w == ctx->width && h == ctx->height && ctx->pix_fmt == fmt)

        return 0;



    ctx->width   = w;

    ctx->height  = h;

    ctx->pix_fmt = fmt;

    s->sb_cols   = (w + 63) >> 6;

    s->sb_rows   = (h + 63) >> 6;

    s->cols      = (w + 7) >> 3;

    s->rows      = (h + 7) >> 3;



#define assign(var, type, n) var = (type) p; p += s->sb_cols * (n) * sizeof(*var)

    av_freep(&s->intra_pred_data[0]);

    

    

    p = av_malloc(s->sb_cols * (128 + 192 * bytesperpixel +

                                sizeof(*s->lflvl) + 16 * sizeof(*s->above_mv_ctx)));

    if (!p)

        return AVERROR(ENOMEM);

    assign(s->intra_pred_data[0],  uint8_t *,             64 * bytesperpixel);

    assign(s->intra_pred_data[1],  uint8_t *,             64 * bytesperpixel);

    assign(s->intra_pred_data[2],  uint8_t *,             64 * bytesperpixel);

    assign(s->above_y_nnz_ctx,     uint8_t *,             16);

    assign(s->above_mode_ctx,      uint8_t *,             16);

    assign(s->above_mv_ctx,        VP56mv(*)[2],          16);

    assign(s->above_uv_nnz_ctx[0], uint8_t *,             16);

    assign(s->above_uv_nnz_ctx[1], uint8_t *,             16);

    assign(s->above_partition_ctx, uint8_t *,              8);

    assign(s->above_skip_ctx,      uint8_t *,              8);

    assign(s->above_txfm_ctx,      uint8_t *,              8);

    assign(s->above_segpred_ctx,   uint8_t *,              8);

    assign(s->above_intra_ctx,     uint8_t *,              8);

    assign(s->above_comp_ctx,      uint8_t *,              8);

    assign(s->above_ref_ctx,       uint8_t *,              8);

    assign(s->above_filter_ctx,    uint8_t *,              8);

    assign(s->lflvl,               struct VP9Filter *,     1);

#undef assign



    

    av_freep(&s->b_base);

    av_freep(&s->block_base);



    if (s->bpp != s->last_bpp) {

        ff_vp9dsp_init(&s->dsp, s->bpp);

        ff_videodsp_init(&s->vdsp, s->bpp);

        s->last_bpp = s->bpp;

    }



    return 0;

}

        ff_vp9dsp_init(&s->dsp, s->bpp);
static int FUNC_0(AVCodecContext *VAR_0, int VAR_1, int VAR_2, enum AVPixelFormat VAR_3)

{

    VP9Context *s = VAR_0->priv_data;

    uint8_t *p;

    int VAR_4 = s->VAR_4;



    av_assert0(VAR_1 > 0 && VAR_2 > 0);



    if (s->intra_pred_data[0] && VAR_1 == VAR_0->width && VAR_2 == VAR_0->height && VAR_0->pix_fmt == VAR_3)

        return 0;



    VAR_0->width   = VAR_1;

    VAR_0->height  = VAR_2;

    VAR_0->pix_fmt = VAR_3;

    s->sb_cols   = (VAR_1 + 63) >> 6;

    s->sb_rows   = (VAR_2 + 63) >> 6;

    s->cols      = (VAR_1 + 7) >> 3;

    s->rows      = (VAR_2 + 7) >> 3;



#define assign(var, type, n) var = (type) p; p += s->sb_cols * (n) * sizeof(*var)

    av_freep(&s->intra_pred_data[0]);

    

    

    p = av_malloc(s->sb_cols * (128 + 192 * VAR_4 +

                                sizeof(*s->lflvl) + 16 * sizeof(*s->above_mv_ctx)));

    if (!p)

        return AVERROR(ENOMEM);

    assign(s->intra_pred_data[0],  uint8_t *,             64 * VAR_4);

    assign(s->intra_pred_data[1],  uint8_t *,             64 * VAR_4);

    assign(s->intra_pred_data[2],  uint8_t *,             64 * VAR_4);

    assign(s->above_y_nnz_ctx,     uint8_t *,             16);

    assign(s->above_mode_ctx,      uint8_t *,             16);

    assign(s->above_mv_ctx,        VP56mv(*)[2],          16);

    assign(s->above_uv_nnz_ctx[0], uint8_t *,             16);

    assign(s->above_uv_nnz_ctx[1], uint8_t *,             16);

    assign(s->above_partition_ctx, uint8_t *,              8);

    assign(s->above_skip_ctx,      uint8_t *,              8);

    assign(s->above_txfm_ctx,      uint8_t *,              8);

    assign(s->above_segpred_ctx,   uint8_t *,              8);

    assign(s->above_intra_ctx,     uint8_t *,              8);

    assign(s->above_comp_ctx,      uint8_t *,              8);

    assign(s->above_ref_ctx,       uint8_t *,              8);

    assign(s->above_filter_ctx,    uint8_t *,              8);

    assign(s->lflvl,               struct VP9Filter *,     1);

#undef assign



    

    av_freep(&s->b_base);

    av_freep(&s->block_base);



    if (s->bpp != s->last_bpp) {

        ff_vp9dsp_init(&s->dsp, s->bpp);

        ff_videodsp_init(&s->vdsp, s->bpp);

        s->last_bpp = s->bpp;

    }



    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0, int VAR_1, int VAR_2, enum AVPixelFormat VAR_3)
{ VP9Context *s = VAR_0->priv_data; uint8_t *p; int VAR_4 = s->VAR_4; av_assert0(VAR_1 > 0 && VAR_2 > 0); if (s->intra_pred_data[0] && VAR_1 == VAR_0->width && VAR_2 == VAR_0->height && VAR_0->pix_fmt == VAR_3)
return 0; VAR_0->width   = VAR_1; VAR_0->height  = VAR_2; VAR_0->pix_fmt = VAR_3; s->sb_cols   = (VAR_1 + 63) >> 6; s->sb_rows   = (VAR_2 + 63) >> 6; s->cols      = (VAR_1 + 7) >> 3; s->rows      = (VAR_2 + 7) >> 3; #define assign(var, type, n) var = (type) p; p += s->sb_cols * (n) * sizeof(*var) av_freep(&s->intra_pred_data[0]); p = av_malloc(s->sb_cols * (128 + 192 * VAR_4 +
sizeof(*s->lflvl) + 16 * sizeof(*s->above_mv_ctx))); if (!p)
return AVERROR(ENOMEM); assign(s->intra_pred_data[0],  uint8_t *,             64 * VAR_4); assign(s->intra_pred_data[1],  uint8_t *,             64 * VAR_4); assign(s->intra_pred_data[2],  uint8_t *,             64 * VAR_4); assign(s->above_y_nnz_ctx,     uint8_t *,             16); assign(s->above_mode_ctx,      uint8_t *,             16); assign(s->above_mv_ctx,        VP56mv(*)[2],          16); assign(s->above_uv_nnz_ctx[0], uint8_t *,             16); assign(s->above_uv_nnz_ctx[1], uint8_t *,             16); assign(s->above_partition_ctx, uint8_t *,              8); assign(s->above_skip_ctx,      uint8_t *,              8); assign(s->above_txfm_ctx,      uint8_t *,              8); assign(s->above_segpred_ctx,   uint8_t *,              8); assign(s->above_intra_ctx,     uint8_t *,              8); assign(s->above_comp_ctx,      uint8_t *,              8); assign(s->above_ref_ctx,       uint8_t *,              8); assign(s->above_filter_ctx,    uint8_t *,              8); assign(s->lflvl,               struct VP9Filter *,     1); #undef assign
av_freep(&s->b_base); av_freep(&s->block_base); if (s->bpp != s->last_bpp) { ff_vp9dsp_init(&s->dsp, s->bpp); ff_videodsp_init(&s->vdsp, s->bpp); s->last_bpp = s->bpp; } return 0; }