static int update_dimensions(VP8Context *s, int width, int height)
{
    int i;
    if (avcodec_check_dimensions(s->avctx, width, height))
        return AVERROR_INVALIDDATA;
    vp8_decode_flush(s->avctx);
    avcodec_set_dimensions(s->avctx, width, height);
    s->mb_width  = (s->avctx->coded_width +15) / 16;
    s->mb_height = (s->avctx->coded_height+15) / 16;
    s->mb_stride = s->mb_width+1;
    s->b4_stride = 4*s->mb_stride;
    s->macroblocks_base        = av_mallocz(s->mb_stride*(s->mb_height+1)*sizeof(*s->macroblocks));
    s->intra4x4_pred_mode_base = av_mallocz(s->b4_stride*(4*s->mb_height+1));
    s->top_nnz                 = av_mallocz(s->mb_width*sizeof(*s->top_nnz));
    s->macroblocks        = s->macroblocks_base        + 1 + s->mb_stride;
    s->intra4x4_pred_mode = s->intra4x4_pred_mode_base + 4 + s->b4_stride;
    memset(s->intra4x4_pred_mode_base, DC_PRED, s->b4_stride);
    for (i = 0; i < 4*s->mb_height; i++)
        s->intra4x4_pred_mode[i*s->b4_stride-1] = DC_PRED;
    return 0;
}
['static int update_dimensions(VP8Context *s, int width, int height)\n{\n    int i;\n    if (avcodec_check_dimensions(s->avctx, width, height))\n        return AVERROR_INVALIDDATA;\n    vp8_decode_flush(s->avctx);\n    avcodec_set_dimensions(s->avctx, width, height);\n    s->mb_width  = (s->avctx->coded_width +15) / 16;\n    s->mb_height = (s->avctx->coded_height+15) / 16;\n    s->mb_stride = s->mb_width+1;\n    s->b4_stride = 4*s->mb_stride;\n    s->macroblocks_base        = av_mallocz(s->mb_stride*(s->mb_height+1)*sizeof(*s->macroblocks));\n    s->intra4x4_pred_mode_base = av_mallocz(s->b4_stride*(4*s->mb_height+1));\n    s->top_nnz                 = av_mallocz(s->mb_width*sizeof(*s->top_nnz));\n    s->macroblocks        = s->macroblocks_base        + 1 + s->mb_stride;\n    s->intra4x4_pred_mode = s->intra4x4_pred_mode_base + 4 + s->b4_stride;\n    memset(s->intra4x4_pred_mode_base, DC_PRED, s->b4_stride);\n    for (i = 0; i < 4*s->mb_height; i++)\n        s->intra4x4_pred_mode[i*s->b4_stride-1] = DC_PRED;\n    return 0;\n}', 'int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){\n    if((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)\n        return 0;\n    av_log(av_log_ctx, AV_LOG_ERROR, "picture size invalid (%ux%u)\\n", w, h);\n    return AVERROR(EINVAL);\n}', 'void avcodec_set_dimensions(AVCodecContext *s, int width, int height){\n    s->coded_width = width;\n    s->coded_height= height;\n    s->width = -((-width )>>s->lowres);\n    s->height= -((-height)>>s->lowres);\n}', 'void *av_mallocz(unsigned int size)\n{\n    void *ptr = av_malloc(size);\n    if (ptr)\n        memset(ptr, 0, size);\n    return ptr;\n}', 'void *av_malloc(unsigned int size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    ptr = malloc(size+16);\n    if(!ptr)\n        return ptr;\n    diff= ((-(long)ptr - 1)&15) + 1;\n    ptr = (char*)ptr + diff;\n    ((char*)ptr)[-1]= diff;\n#elif HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr,16,size))\n        ptr = NULL;\n#elif HAVE_MEMALIGN\n    ptr = memalign(16,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}']