static av_cold int vp3_decode_init(AVCodecContext *avctx)
{
    Vp3DecodeContext *s = avctx->priv_data;
    int i, inter, plane;
    int c_width;
    int c_height;
    int y_superblock_count;
    int c_superblock_count;
    if (avctx->codec_tag == MKTAG('V','P','3','0'))
        s->version = 0;
    else
        s->version = 1;
    s->avctx = avctx;
    s->width = (avctx->width + 15) & 0xFFFFFFF0;
    s->height = (avctx->height + 15) & 0xFFFFFFF0;
    avctx->pix_fmt = PIX_FMT_YUV420P;
    if(avctx->idct_algo==FF_IDCT_AUTO)
        avctx->idct_algo=FF_IDCT_VP3;
    dsputil_init(&s->dsp, avctx);
    ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
    s->quality_index = -1;
    s->y_superblock_width = (s->width + 31) / 32;
    s->y_superblock_height = (s->height + 31) / 32;
    y_superblock_count = s->y_superblock_width * s->y_superblock_height;
    c_width = s->width / 2;
    c_height = s->height / 2;
    s->c_superblock_width = (c_width + 31) / 32;
    s->c_superblock_height = (c_height + 31) / 32;
    c_superblock_count = s->c_superblock_width * s->c_superblock_height;
    s->superblock_count = y_superblock_count + (c_superblock_count * 2);
    s->u_superblock_start = y_superblock_count;
    s->v_superblock_start = s->u_superblock_start + c_superblock_count;
    s->superblock_coding = av_malloc(s->superblock_count);
    s->macroblock_width = (s->width + 15) / 16;
    s->macroblock_height = (s->height + 15) / 16;
    s->macroblock_count = s->macroblock_width * s->macroblock_height;
    s->fragment_width = s->width / FRAGMENT_PIXELS;
    s->fragment_height = s->height / FRAGMENT_PIXELS;
    s->fragment_count = s->fragment_width * s->fragment_height * 3 / 2;
    s->fragment_start[1] = s->fragment_width * s->fragment_height;
    s->fragment_start[2] = s->fragment_width * s->fragment_height * 5 / 4;
    debug_init("  Y plane: %d x %d\n", s->width, s->height);
    debug_init("  C plane: %d x %d\n", c_width, c_height);
    debug_init("  Y superblocks: %d x %d, %d total\n",
        s->y_superblock_width, s->y_superblock_height, y_superblock_count);
    debug_init("  C superblocks: %d x %d, %d total\n",
        s->c_superblock_width, s->c_superblock_height, c_superblock_count);
    debug_init("  total superblocks = %d, U starts @ %d, V starts @ %d\n",
        s->superblock_count, s->u_superblock_start, s->v_superblock_start);
    debug_init("  macroblocks: %d x %d, %d total\n",
        s->macroblock_width, s->macroblock_height, s->macroblock_count);
    debug_init("  %d fragments, %d x %d, u starts @ %d, v starts @ %d\n",
        s->fragment_count,
        s->fragment_width,
        s->fragment_height,
        s->fragment_start[1],
        s->fragment_start[2]);
    s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
    s->coeffs = av_malloc(s->fragment_count * sizeof(Coeff) * 65);
    s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int));
    s->pixel_addresses_initialized = 0;
    if (!s->theora_tables)
    {
        for (i = 0; i < 64; i++) {
            s->coded_dc_scale_factor[i] = vp31_dc_scale_factor[i];
            s->coded_ac_scale_factor[i] = vp31_ac_scale_factor[i];
            s->base_matrix[0][i] = vp31_intra_y_dequant[i];
            s->base_matrix[1][i] = vp31_intra_c_dequant[i];
            s->base_matrix[2][i] = vp31_inter_dequant[i];
            s->filter_limit_values[i] = vp31_filter_limit_values[i];
        }
        for(inter=0; inter<2; inter++){
            for(plane=0; plane<3; plane++){
                s->qr_count[inter][plane]= 1;
                s->qr_size [inter][plane][0]= 63;
                s->qr_base [inter][plane][0]=
                s->qr_base [inter][plane][1]= 2*inter + (!!plane)*!inter;
            }
        }
        for (i = 0; i < 16; i++) {
            init_vlc(&s->dc_vlc[i], 5, 32,
                &dc_bias[i][0][1], 4, 2,
                &dc_bias[i][0][0], 4, 2, 0);
            init_vlc(&s->ac_vlc_1[i], 5, 32,
                &ac_bias_0[i][0][1], 4, 2,
                &ac_bias_0[i][0][0], 4, 2, 0);
            init_vlc(&s->ac_vlc_2[i], 5, 32,
                &ac_bias_1[i][0][1], 4, 2,
                &ac_bias_1[i][0][0], 4, 2, 0);
            init_vlc(&s->ac_vlc_3[i], 5, 32,
                &ac_bias_2[i][0][1], 4, 2,
                &ac_bias_2[i][0][0], 4, 2, 0);
            init_vlc(&s->ac_vlc_4[i], 5, 32,
                &ac_bias_3[i][0][1], 4, 2,
                &ac_bias_3[i][0][0], 4, 2, 0);
        }
    } else {
        for (i = 0; i < 16; i++) {
            init_vlc(&s->dc_vlc[i], 5, 32,
                &s->huffman_table[i][0][1], 4, 2,
                &s->huffman_table[i][0][0], 4, 2, 0);
            init_vlc(&s->ac_vlc_1[i], 5, 32,
                &s->huffman_table[i+16][0][1], 4, 2,
                &s->huffman_table[i+16][0][0], 4, 2, 0);
            init_vlc(&s->ac_vlc_2[i], 5, 32,
                &s->huffman_table[i+16*2][0][1], 4, 2,
                &s->huffman_table[i+16*2][0][0], 4, 2, 0);
            init_vlc(&s->ac_vlc_3[i], 5, 32,
                &s->huffman_table[i+16*3][0][1], 4, 2,
                &s->huffman_table[i+16*3][0][0], 4, 2, 0);
            init_vlc(&s->ac_vlc_4[i], 5, 32,
                &s->huffman_table[i+16*4][0][1], 4, 2,
                &s->huffman_table[i+16*4][0][0], 4, 2, 0);
        }
    }
    init_vlc(&s->superblock_run_length_vlc, 6, 34,
        &superblock_run_length_vlc_table[0][1], 4, 2,
        &superblock_run_length_vlc_table[0][0], 4, 2, 0);
    init_vlc(&s->fragment_run_length_vlc, 5, 30,
        &fragment_run_length_vlc_table[0][1], 4, 2,
        &fragment_run_length_vlc_table[0][0], 4, 2, 0);
    init_vlc(&s->mode_code_vlc, 3, 8,
        &mode_code_vlc_table[0][1], 2, 1,
        &mode_code_vlc_table[0][0], 2, 1, 0);
    init_vlc(&s->motion_vector_vlc, 6, 63,
        &motion_vector_vlc_table[0][1], 2, 1,
        &motion_vector_vlc_table[0][0], 2, 1, 0);
    s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));
    s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int));
    s->macroblock_fragments = av_malloc(s->macroblock_count * 6 * sizeof(int));
    s->macroblock_coding = av_malloc(s->macroblock_count + 1);
    init_block_mapping(s);
    for (i = 0; i < 3; i++) {
        s->current_frame.data[i] = NULL;
        s->last_frame.data[i] = NULL;
        s->golden_frame.data[i] = NULL;
    }
    return 0;
}
['static av_cold int vp3_decode_init(AVCodecContext *avctx)\n{\n    Vp3DecodeContext *s = avctx->priv_data;\n    int i, inter, plane;\n    int c_width;\n    int c_height;\n    int y_superblock_count;\n    int c_superblock_count;\n    if (avctx->codec_tag == MKTAG(\'V\',\'P\',\'3\',\'0\'))\n        s->version = 0;\n    else\n        s->version = 1;\n    s->avctx = avctx;\n    s->width = (avctx->width + 15) & 0xFFFFFFF0;\n    s->height = (avctx->height + 15) & 0xFFFFFFF0;\n    avctx->pix_fmt = PIX_FMT_YUV420P;\n    if(avctx->idct_algo==FF_IDCT_AUTO)\n        avctx->idct_algo=FF_IDCT_VP3;\n    dsputil_init(&s->dsp, avctx);\n    ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);\n    s->quality_index = -1;\n    s->y_superblock_width = (s->width + 31) / 32;\n    s->y_superblock_height = (s->height + 31) / 32;\n    y_superblock_count = s->y_superblock_width * s->y_superblock_height;\n    c_width = s->width / 2;\n    c_height = s->height / 2;\n    s->c_superblock_width = (c_width + 31) / 32;\n    s->c_superblock_height = (c_height + 31) / 32;\n    c_superblock_count = s->c_superblock_width * s->c_superblock_height;\n    s->superblock_count = y_superblock_count + (c_superblock_count * 2);\n    s->u_superblock_start = y_superblock_count;\n    s->v_superblock_start = s->u_superblock_start + c_superblock_count;\n    s->superblock_coding = av_malloc(s->superblock_count);\n    s->macroblock_width = (s->width + 15) / 16;\n    s->macroblock_height = (s->height + 15) / 16;\n    s->macroblock_count = s->macroblock_width * s->macroblock_height;\n    s->fragment_width = s->width / FRAGMENT_PIXELS;\n    s->fragment_height = s->height / FRAGMENT_PIXELS;\n    s->fragment_count = s->fragment_width * s->fragment_height * 3 / 2;\n    s->fragment_start[1] = s->fragment_width * s->fragment_height;\n    s->fragment_start[2] = s->fragment_width * s->fragment_height * 5 / 4;\n    debug_init("  Y plane: %d x %d\\n", s->width, s->height);\n    debug_init("  C plane: %d x %d\\n", c_width, c_height);\n    debug_init("  Y superblocks: %d x %d, %d total\\n",\n        s->y_superblock_width, s->y_superblock_height, y_superblock_count);\n    debug_init("  C superblocks: %d x %d, %d total\\n",\n        s->c_superblock_width, s->c_superblock_height, c_superblock_count);\n    debug_init("  total superblocks = %d, U starts @ %d, V starts @ %d\\n",\n        s->superblock_count, s->u_superblock_start, s->v_superblock_start);\n    debug_init("  macroblocks: %d x %d, %d total\\n",\n        s->macroblock_width, s->macroblock_height, s->macroblock_count);\n    debug_init("  %d fragments, %d x %d, u starts @ %d, v starts @ %d\\n",\n        s->fragment_count,\n        s->fragment_width,\n        s->fragment_height,\n        s->fragment_start[1],\n        s->fragment_start[2]);\n    s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));\n    s->coeffs = av_malloc(s->fragment_count * sizeof(Coeff) * 65);\n    s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int));\n    s->pixel_addresses_initialized = 0;\n    if (!s->theora_tables)\n    {\n        for (i = 0; i < 64; i++) {\n            s->coded_dc_scale_factor[i] = vp31_dc_scale_factor[i];\n            s->coded_ac_scale_factor[i] = vp31_ac_scale_factor[i];\n            s->base_matrix[0][i] = vp31_intra_y_dequant[i];\n            s->base_matrix[1][i] = vp31_intra_c_dequant[i];\n            s->base_matrix[2][i] = vp31_inter_dequant[i];\n            s->filter_limit_values[i] = vp31_filter_limit_values[i];\n        }\n        for(inter=0; inter<2; inter++){\n            for(plane=0; plane<3; plane++){\n                s->qr_count[inter][plane]= 1;\n                s->qr_size [inter][plane][0]= 63;\n                s->qr_base [inter][plane][0]=\n                s->qr_base [inter][plane][1]= 2*inter + (!!plane)*!inter;\n            }\n        }\n        for (i = 0; i < 16; i++) {\n            init_vlc(&s->dc_vlc[i], 5, 32,\n                &dc_bias[i][0][1], 4, 2,\n                &dc_bias[i][0][0], 4, 2, 0);\n            init_vlc(&s->ac_vlc_1[i], 5, 32,\n                &ac_bias_0[i][0][1], 4, 2,\n                &ac_bias_0[i][0][0], 4, 2, 0);\n            init_vlc(&s->ac_vlc_2[i], 5, 32,\n                &ac_bias_1[i][0][1], 4, 2,\n                &ac_bias_1[i][0][0], 4, 2, 0);\n            init_vlc(&s->ac_vlc_3[i], 5, 32,\n                &ac_bias_2[i][0][1], 4, 2,\n                &ac_bias_2[i][0][0], 4, 2, 0);\n            init_vlc(&s->ac_vlc_4[i], 5, 32,\n                &ac_bias_3[i][0][1], 4, 2,\n                &ac_bias_3[i][0][0], 4, 2, 0);\n        }\n    } else {\n        for (i = 0; i < 16; i++) {\n            init_vlc(&s->dc_vlc[i], 5, 32,\n                &s->huffman_table[i][0][1], 4, 2,\n                &s->huffman_table[i][0][0], 4, 2, 0);\n            init_vlc(&s->ac_vlc_1[i], 5, 32,\n                &s->huffman_table[i+16][0][1], 4, 2,\n                &s->huffman_table[i+16][0][0], 4, 2, 0);\n            init_vlc(&s->ac_vlc_2[i], 5, 32,\n                &s->huffman_table[i+16*2][0][1], 4, 2,\n                &s->huffman_table[i+16*2][0][0], 4, 2, 0);\n            init_vlc(&s->ac_vlc_3[i], 5, 32,\n                &s->huffman_table[i+16*3][0][1], 4, 2,\n                &s->huffman_table[i+16*3][0][0], 4, 2, 0);\n            init_vlc(&s->ac_vlc_4[i], 5, 32,\n                &s->huffman_table[i+16*4][0][1], 4, 2,\n                &s->huffman_table[i+16*4][0][0], 4, 2, 0);\n        }\n    }\n    init_vlc(&s->superblock_run_length_vlc, 6, 34,\n        &superblock_run_length_vlc_table[0][1], 4, 2,\n        &superblock_run_length_vlc_table[0][0], 4, 2, 0);\n    init_vlc(&s->fragment_run_length_vlc, 5, 30,\n        &fragment_run_length_vlc_table[0][1], 4, 2,\n        &fragment_run_length_vlc_table[0][0], 4, 2, 0);\n    init_vlc(&s->mode_code_vlc, 3, 8,\n        &mode_code_vlc_table[0][1], 2, 1,\n        &mode_code_vlc_table[0][0], 2, 1, 0);\n    init_vlc(&s->motion_vector_vlc, 6, 63,\n        &motion_vector_vlc_table[0][1], 2, 1,\n        &motion_vector_vlc_table[0][0], 2, 1, 0);\n    s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));\n    s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int));\n    s->macroblock_fragments = av_malloc(s->macroblock_count * 6 * sizeof(int));\n    s->macroblock_coding = av_malloc(s->macroblock_count + 1);\n    init_block_mapping(s);\n    for (i = 0; i < 3; i++) {\n        s->current_frame.data[i] = NULL;\n        s->last_frame.data[i] = NULL;\n        s->golden_frame.data[i] = NULL;\n    }\n    return 0;\n}']