static int dnxhd_init_rc(DNXHDEncContext *ctx)
{
    CHECKED_ALLOCZ(ctx->mb_rc, 8160*ctx->m.avctx->qmax*sizeof(RCEntry));
    if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD)
        CHECKED_ALLOCZ(ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry));
    ctx->frame_bits = (ctx->cid_table->coding_unit_size - 640 - 4) * 8;
    ctx->qscale = 1;
    ctx->lambda = 2<<LAMBDA_FRAC_BITS;
    return 0;
 fail:
    return -1;
}
['static int dnxhd_encode_init(AVCodecContext *avctx)\n{\n    DNXHDEncContext *ctx = avctx->priv_data;\n    int i, index;\n    ctx->cid = ff_dnxhd_find_cid(avctx);\n    if (!ctx->cid || avctx->pix_fmt != PIX_FMT_YUV422P) {\n        av_log(avctx, AV_LOG_ERROR, "video parameters incompatible with DNxHD\\n");\n        return -1;\n    }\n    av_log(avctx, AV_LOG_DEBUG, "cid %d\\n", ctx->cid);\n    index = ff_dnxhd_get_cid_table(ctx->cid);\n    ctx->cid_table = &ff_dnxhd_cid_table[index];\n    ctx->m.avctx = avctx;\n    ctx->m.mb_intra = 1;\n    ctx->m.h263_aic = 1;\n    dsputil_init(&ctx->m.dsp, avctx);\n    ff_dct_common_init(&ctx->m);\n    if (!ctx->m.dct_quantize)\n        ctx->m.dct_quantize = dct_quantize_c;\n    ctx->m.mb_height = (avctx->height + 15) / 16;\n    ctx->m.mb_width  = (avctx->width  + 15) / 16;\n    if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) {\n        ctx->interlaced = 1;\n        ctx->m.mb_height /= 2;\n    }\n    ctx->m.mb_num = ctx->m.mb_height * ctx->m.mb_width;\n    if (avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS)\n        ctx->m.intra_quant_bias = avctx->intra_quant_bias;\n    if (dnxhd_init_qmat(ctx, ctx->m.intra_quant_bias, 0) < 0)\n        return -1;\n    if (dnxhd_init_vlc(ctx) < 0)\n        return -1;\n    if (dnxhd_init_rc(ctx) < 0)\n        return -1;\n    CHECKED_ALLOCZ(ctx->slice_size, ctx->m.mb_height*sizeof(uint32_t));\n    CHECKED_ALLOCZ(ctx->mb_bits,    ctx->m.mb_num   *sizeof(uint16_t));\n    CHECKED_ALLOCZ(ctx->mb_qscale,  ctx->m.mb_num   *sizeof(uint8_t));\n    ctx->frame.key_frame = 1;\n    ctx->frame.pict_type = FF_I_TYPE;\n    ctx->m.avctx->coded_frame = &ctx->frame;\n    if (avctx->thread_count > MAX_THREADS || (avctx->thread_count > ctx->m.mb_height)) {\n        av_log(avctx, AV_LOG_ERROR, "too many threads\\n");\n        return -1;\n    }\n    ctx->thread[0] = ctx;\n    for (i = 1; i < avctx->thread_count; i++) {\n        ctx->thread[i] =  av_malloc(sizeof(DNXHDEncContext));\n        memcpy(ctx->thread[i], ctx, sizeof(DNXHDEncContext));\n    }\n    for (i = 0; i < avctx->thread_count; i++) {\n        ctx->thread[i]->m.start_mb_y = (ctx->m.mb_height*(i  ) + avctx->thread_count/2) / avctx->thread_count;\n        ctx->thread[i]->m.end_mb_y   = (ctx->m.mb_height*(i+1) + avctx->thread_count/2) / avctx->thread_count;\n    }\n    return 0;\n fail:\n    return -1;\n}', 'void dsputil_init(DSPContext* c, AVCodecContext *avctx)\n{\n    int i;\n    ff_check_alignment();\n#ifdef CONFIG_ENCODERS\n    if(avctx->dct_algo==FF_DCT_FASTINT) {\n        c->fdct = fdct_ifast;\n        c->fdct248 = fdct_ifast248;\n    }\n    else if(avctx->dct_algo==FF_DCT_FAAN) {\n        c->fdct = ff_faandct;\n        c->fdct248 = ff_faandct248;\n    }\n    else {\n        c->fdct = ff_jpeg_fdct_islow;\n        c->fdct248 = ff_fdct248_islow;\n    }\n#endif\n    if(avctx->lowres==1){\n        if(avctx->idct_algo==FF_IDCT_INT || avctx->idct_algo==FF_IDCT_AUTO || !ENABLE_H264_DECODER){\n            c->idct_put= ff_jref_idct4_put;\n            c->idct_add= ff_jref_idct4_add;\n        }else{\n            c->idct_put= ff_h264_lowres_idct_put_c;\n            c->idct_add= ff_h264_lowres_idct_add_c;\n        }\n        c->idct    = j_rev_dct4;\n        c->idct_permutation_type= FF_NO_IDCT_PERM;\n    }else if(avctx->lowres==2){\n        c->idct_put= ff_jref_idct2_put;\n        c->idct_add= ff_jref_idct2_add;\n        c->idct    = j_rev_dct2;\n        c->idct_permutation_type= FF_NO_IDCT_PERM;\n    }else if(avctx->lowres==3){\n        c->idct_put= ff_jref_idct1_put;\n        c->idct_add= ff_jref_idct1_add;\n        c->idct    = j_rev_dct1;\n        c->idct_permutation_type= FF_NO_IDCT_PERM;\n    }else{\n        if(avctx->idct_algo==FF_IDCT_INT){\n            c->idct_put= ff_jref_idct_put;\n            c->idct_add= ff_jref_idct_add;\n            c->idct    = j_rev_dct;\n            c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;\n        }else if((ENABLE_VP3_DECODER || ENABLE_VP5_DECODER || ENABLE_VP6_DECODER || ENABLE_THEORA_DECODER ) &&\n                avctx->idct_algo==FF_IDCT_VP3){\n            c->idct_put= ff_vp3_idct_put_c;\n            c->idct_add= ff_vp3_idct_add_c;\n            c->idct    = ff_vp3_idct_c;\n            c->idct_permutation_type= FF_NO_IDCT_PERM;\n        }else if(avctx->idct_algo==FF_IDCT_WMV2){\n            c->idct_put= ff_wmv2_idct_put_c;\n            c->idct_add= ff_wmv2_idct_add_c;\n            c->idct    = ff_wmv2_idct_c;\n            c->idct_permutation_type= FF_NO_IDCT_PERM;\n        }else if(avctx->idct_algo==FF_IDCT_FAAN){\n            c->idct_put= ff_faanidct_put;\n            c->idct_add= ff_faanidct_add;\n            c->idct    = ff_faanidct;\n            c->idct_permutation_type= FF_NO_IDCT_PERM;\n        }else{\n            c->idct_put= ff_simple_idct_put;\n            c->idct_add= ff_simple_idct_add;\n            c->idct    = ff_simple_idct;\n            c->idct_permutation_type= FF_NO_IDCT_PERM;\n        }\n    }\n    if (ENABLE_H264_DECODER) {\n        c->h264_idct_add= ff_h264_idct_add_c;\n        c->h264_idct8_add= ff_h264_idct8_add_c;\n        c->h264_idct_dc_add= ff_h264_idct_dc_add_c;\n        c->h264_idct8_dc_add= ff_h264_idct8_dc_add_c;\n    }\n    c->get_pixels = get_pixels_c;\n    c->diff_pixels = diff_pixels_c;\n    c->put_pixels_clamped = put_pixels_clamped_c;\n    c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;\n    c->add_pixels_clamped = add_pixels_clamped_c;\n    c->add_pixels8 = add_pixels8_c;\n    c->add_pixels4 = add_pixels4_c;\n    c->sum_abs_dctelem = sum_abs_dctelem_c;\n    c->gmc1 = gmc1_c;\n    c->gmc = ff_gmc_c;\n    c->clear_blocks = clear_blocks_c;\n    c->pix_sum = pix_sum_c;\n    c->pix_norm1 = pix_norm1_c;\n    c->pix_abs[0][0] = pix_abs16_c;\n    c->pix_abs[0][1] = pix_abs16_x2_c;\n    c->pix_abs[0][2] = pix_abs16_y2_c;\n    c->pix_abs[0][3] = pix_abs16_xy2_c;\n    c->pix_abs[1][0] = pix_abs8_c;\n    c->pix_abs[1][1] = pix_abs8_x2_c;\n    c->pix_abs[1][2] = pix_abs8_y2_c;\n    c->pix_abs[1][3] = pix_abs8_xy2_c;\n#define dspfunc(PFX, IDX, NUM) \\\n    c->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## NUM ## _c;     \\\n    c->PFX ## _pixels_tab[IDX][1] = PFX ## _pixels ## NUM ## _x2_c;  \\\n    c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## NUM ## _y2_c;  \\\n    c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## NUM ## _xy2_c\n    dspfunc(put, 0, 16);\n    dspfunc(put_no_rnd, 0, 16);\n    dspfunc(put, 1, 8);\n    dspfunc(put_no_rnd, 1, 8);\n    dspfunc(put, 2, 4);\n    dspfunc(put, 3, 2);\n    dspfunc(avg, 0, 16);\n    dspfunc(avg_no_rnd, 0, 16);\n    dspfunc(avg, 1, 8);\n    dspfunc(avg_no_rnd, 1, 8);\n    dspfunc(avg, 2, 4);\n    dspfunc(avg, 3, 2);\n#undef dspfunc\n    c->put_no_rnd_pixels_l2[0]= put_no_rnd_pixels16_l2_c;\n    c->put_no_rnd_pixels_l2[1]= put_no_rnd_pixels8_l2_c;\n    c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;\n    c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;\n    c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;\n    c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;\n    c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;\n    c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;\n    c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;\n    c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;\n    c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;\n    c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;\n    c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;\n    c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;\n    c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;\n    c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;\n    c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;\n    c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;\n    c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;\n    c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;\n#define dspfunc(PFX, IDX, NUM) \\\n    c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \\\n    c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \\\n    c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \\\n    c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \\\n    c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \\\n    c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \\\n    c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \\\n    c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \\\n    c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \\\n    c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \\\n    c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \\\n    c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \\\n    c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \\\n    c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \\\n    c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \\\n    c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c\n    dspfunc(put_qpel, 0, 16);\n    dspfunc(put_no_rnd_qpel, 0, 16);\n    dspfunc(avg_qpel, 0, 16);\n    dspfunc(put_qpel, 1, 8);\n    dspfunc(put_no_rnd_qpel, 1, 8);\n    dspfunc(avg_qpel, 1, 8);\n    dspfunc(put_h264_qpel, 0, 16);\n    dspfunc(put_h264_qpel, 1, 8);\n    dspfunc(put_h264_qpel, 2, 4);\n    dspfunc(put_h264_qpel, 3, 2);\n    dspfunc(avg_h264_qpel, 0, 16);\n    dspfunc(avg_h264_qpel, 1, 8);\n    dspfunc(avg_h264_qpel, 2, 4);\n#undef dspfunc\n    c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_c;\n    c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_c;\n    c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_c;\n    c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_c;\n    c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_c;\n    c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_c;\n    c->put_no_rnd_h264_chroma_pixels_tab[0]= put_no_rnd_h264_chroma_mc8_c;\n    c->weight_h264_pixels_tab[0]= weight_h264_pixels16x16_c;\n    c->weight_h264_pixels_tab[1]= weight_h264_pixels16x8_c;\n    c->weight_h264_pixels_tab[2]= weight_h264_pixels8x16_c;\n    c->weight_h264_pixels_tab[3]= weight_h264_pixels8x8_c;\n    c->weight_h264_pixels_tab[4]= weight_h264_pixels8x4_c;\n    c->weight_h264_pixels_tab[5]= weight_h264_pixels4x8_c;\n    c->weight_h264_pixels_tab[6]= weight_h264_pixels4x4_c;\n    c->weight_h264_pixels_tab[7]= weight_h264_pixels4x2_c;\n    c->weight_h264_pixels_tab[8]= weight_h264_pixels2x4_c;\n    c->weight_h264_pixels_tab[9]= weight_h264_pixels2x2_c;\n    c->biweight_h264_pixels_tab[0]= biweight_h264_pixels16x16_c;\n    c->biweight_h264_pixels_tab[1]= biweight_h264_pixels16x8_c;\n    c->biweight_h264_pixels_tab[2]= biweight_h264_pixels8x16_c;\n    c->biweight_h264_pixels_tab[3]= biweight_h264_pixels8x8_c;\n    c->biweight_h264_pixels_tab[4]= biweight_h264_pixels8x4_c;\n    c->biweight_h264_pixels_tab[5]= biweight_h264_pixels4x8_c;\n    c->biweight_h264_pixels_tab[6]= biweight_h264_pixels4x4_c;\n    c->biweight_h264_pixels_tab[7]= biweight_h264_pixels4x2_c;\n    c->biweight_h264_pixels_tab[8]= biweight_h264_pixels2x4_c;\n    c->biweight_h264_pixels_tab[9]= biweight_h264_pixels2x2_c;\n    c->draw_edges = draw_edges_c;\n#ifdef CONFIG_CAVS_DECODER\n    ff_cavsdsp_init(c,avctx);\n#endif\n#if defined(CONFIG_VC1_DECODER) || defined(CONFIG_WMV3_DECODER)\n    ff_vc1dsp_init(c,avctx);\n#endif\n#if defined(CONFIG_WMV2_DECODER) || defined(CONFIG_VC1_DECODER) || defined(CONFIG_WMV3_DECODER)\n    ff_intrax8dsp_init(c,avctx);\n#endif\n#if defined(CONFIG_H264_ENCODER)\n    ff_h264dspenc_init(c,avctx);\n#endif\n    c->put_mspel_pixels_tab[0]= put_mspel8_mc00_c;\n    c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;\n    c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c;\n    c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c;\n    c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c;\n    c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c;\n    c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;\n    c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;\n#define SET_CMP_FUNC(name) \\\n    c->name[0]= name ## 16_c;\\\n    c->name[1]= name ## 8x8_c;\n    SET_CMP_FUNC(hadamard8_diff)\n    c->hadamard8_diff[4]= hadamard8_intra16_c;\n    SET_CMP_FUNC(dct_sad)\n    SET_CMP_FUNC(dct_max)\n#ifdef CONFIG_GPL\n    SET_CMP_FUNC(dct264_sad)\n#endif\n    c->sad[0]= pix_abs16_c;\n    c->sad[1]= pix_abs8_c;\n    c->sse[0]= sse16_c;\n    c->sse[1]= sse8_c;\n    c->sse[2]= sse4_c;\n    SET_CMP_FUNC(quant_psnr)\n    SET_CMP_FUNC(rd)\n    SET_CMP_FUNC(bit)\n    c->vsad[0]= vsad16_c;\n    c->vsad[4]= vsad_intra16_c;\n    c->vsse[0]= vsse16_c;\n    c->vsse[4]= vsse_intra16_c;\n    c->nsse[0]= nsse16_c;\n    c->nsse[1]= nsse8_c;\n#ifdef CONFIG_SNOW_ENCODER\n    c->w53[0]= w53_16_c;\n    c->w53[1]= w53_8_c;\n    c->w97[0]= w97_16_c;\n    c->w97[1]= w97_8_c;\n#endif\n    c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;\n    c->add_bytes= add_bytes_c;\n    c->add_bytes_l2= add_bytes_l2_c;\n    c->diff_bytes= diff_bytes_c;\n    c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;\n    c->bswap_buf= bswap_buf;\n#ifdef CONFIG_PNG_DECODER\n    c->add_png_paeth_prediction= ff_add_png_paeth_prediction;\n#endif\n    c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_c;\n    c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_c;\n    c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_c;\n    c->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_c;\n    c->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_c;\n    c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_c;\n    c->h264_loop_filter_strength= NULL;\n    if (ENABLE_ANY_H263) {\n        c->h263_h_loop_filter= h263_h_loop_filter_c;\n        c->h263_v_loop_filter= h263_v_loop_filter_c;\n    }\n    c->h261_loop_filter= h261_loop_filter_c;\n    c->try_8x8basis= try_8x8basis_c;\n    c->add_8x8basis= add_8x8basis_c;\n#ifdef CONFIG_SNOW_DECODER\n    c->vertical_compose97i = ff_snow_vertical_compose97i;\n    c->horizontal_compose97i = ff_snow_horizontal_compose97i;\n    c->inner_add_yblock = ff_snow_inner_add_yblock;\n#endif\n#ifdef CONFIG_VORBIS_DECODER\n    c->vorbis_inverse_coupling = vorbis_inverse_coupling;\n#endif\n#ifdef CONFIG_FLAC_ENCODER\n    c->flac_compute_autocorr = ff_flac_compute_autocorr;\n#endif\n    c->vector_fmul = vector_fmul_c;\n    c->vector_fmul_reverse = vector_fmul_reverse_c;\n    c->vector_fmul_add_add = ff_vector_fmul_add_add_c;\n    c->float_to_int16 = ff_float_to_int16_c;\n    c->shrink[0]= ff_img_copy_plane;\n    c->shrink[1]= ff_shrink22;\n    c->shrink[2]= ff_shrink44;\n    c->shrink[3]= ff_shrink88;\n    c->prefetch= just_return;\n    memset(c->put_2tap_qpel_pixels_tab, 0, sizeof(c->put_2tap_qpel_pixels_tab));\n    memset(c->avg_2tap_qpel_pixels_tab, 0, sizeof(c->avg_2tap_qpel_pixels_tab));\n    if (ENABLE_MMX)      dsputil_init_mmx   (c, avctx);\n    if (ENABLE_ARMV4L)   dsputil_init_armv4l(c, avctx);\n    if (ENABLE_MLIB)     dsputil_init_mlib  (c, avctx);\n    if (ENABLE_VIS)      dsputil_init_vis   (c, avctx);\n    if (ENABLE_ALPHA)    dsputil_init_alpha (c, avctx);\n    if (ENABLE_POWERPC)  dsputil_init_ppc   (c, avctx);\n    if (ENABLE_MMI)      dsputil_init_mmi   (c, avctx);\n    if (ENABLE_SH4)      dsputil_init_sh4   (c, avctx);\n    if (ENABLE_BFIN)     dsputil_init_bfin  (c, avctx);\n    for(i=0; i<64; i++){\n        if(!c->put_2tap_qpel_pixels_tab[0][i])\n            c->put_2tap_qpel_pixels_tab[0][i]= c->put_h264_qpel_pixels_tab[0][i];\n        if(!c->avg_2tap_qpel_pixels_tab[0][i])\n            c->avg_2tap_qpel_pixels_tab[0][i]= c->avg_h264_qpel_pixels_tab[0][i];\n    }\n    switch(c->idct_permutation_type){\n    case FF_NO_IDCT_PERM:\n        for(i=0; i<64; i++)\n            c->idct_permutation[i]= i;\n        break;\n    case FF_LIBMPEG2_IDCT_PERM:\n        for(i=0; i<64; i++)\n            c->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);\n        break;\n    case FF_SIMPLE_IDCT_PERM:\n        for(i=0; i<64; i++)\n            c->idct_permutation[i]= simple_mmx_permutation[i];\n        break;\n    case FF_TRANSPOSE_IDCT_PERM:\n        for(i=0; i<64; i++)\n            c->idct_permutation[i]= ((i&7)<<3) | (i>>3);\n        break;\n    case FF_PARTTRANS_IDCT_PERM:\n        for(i=0; i<64; i++)\n            c->idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3);\n        break;\n    default:\n        av_log(avctx, AV_LOG_ERROR, "Internal error, IDCT permutation not set\\n");\n    }\n}', 'int ff_dct_common_init(MpegEncContext *s)\n{\n    s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_c;\n    s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_c;\n    s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c;\n    s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_c;\n    s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_c;\n    if(s->flags & CODEC_FLAG_BITEXACT)\n        s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_bitexact;\n    s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_c;\n#if defined(HAVE_MMX)\n    MPV_common_init_mmx(s);\n#elif defined(ARCH_ALPHA)\n    MPV_common_init_axp(s);\n#elif defined(CONFIG_MLIB)\n    MPV_common_init_mlib(s);\n#elif defined(HAVE_MMI)\n    MPV_common_init_mmi(s);\n#elif defined(ARCH_ARMV4L)\n    MPV_common_init_armv4l(s);\n#elif defined(HAVE_ALTIVEC)\n    MPV_common_init_altivec(s);\n#elif defined(ARCH_BFIN)\n    MPV_common_init_bfin(s);\n#endif\n    if(s->alternate_scan){\n        ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable  , ff_alternate_vertical_scan);\n        ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable  , ff_alternate_vertical_scan);\n    }else{\n        ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable  , ff_zigzag_direct);\n        ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable  , ff_zigzag_direct);\n    }\n    ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);\n    ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);\n    return 0;\n}', 'void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable){\n    int i;\n    int end;\n    st->scantable= src_scantable;\n    for(i=0; i<64; i++){\n        int j;\n        j = src_scantable[i];\n        st->permutated[i] = permutation[j];\n#ifdef ARCH_POWERPC\n        st->inverse[j] = i;\n#endif\n    }\n    end=-1;\n    for(i=0; i<64; i++){\n        int j;\n        j = st->permutated[i];\n        if(j>end) end=j;\n        st->raster_end[i]= end;\n    }\n}', 'static int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias)\n{\n    uint16_t weight_matrix[64] = {1,};\n    int qscale, i;\n    CHECKED_ALLOCZ(ctx->qmatrix_l,   (ctx->m.avctx->qmax+1) * 64 * sizeof(int));\n    CHECKED_ALLOCZ(ctx->qmatrix_c,   (ctx->m.avctx->qmax+1) * 64 * sizeof(int));\n    CHECKED_ALLOCZ(ctx->qmatrix_l16, (ctx->m.avctx->qmax+1) * 64 * 2 * sizeof(uint16_t));\n    CHECKED_ALLOCZ(ctx->qmatrix_c16, (ctx->m.avctx->qmax+1) * 64 * 2 * sizeof(uint16_t));\n    for (i = 1; i < 64; i++) {\n        int j = ctx->m.dsp.idct_permutation[ff_zigzag_direct[i]];\n        weight_matrix[j] = ctx->cid_table->luma_weight[i];\n    }\n    ff_convert_matrix(&ctx->m.dsp, ctx->qmatrix_l, ctx->qmatrix_l16, weight_matrix,\n                      ctx->m.intra_quant_bias, 1, ctx->m.avctx->qmax, 1);\n    for (i = 1; i < 64; i++) {\n        int j = ctx->m.dsp.idct_permutation[ff_zigzag_direct[i]];\n        weight_matrix[j] = ctx->cid_table->chroma_weight[i];\n    }\n    ff_convert_matrix(&ctx->m.dsp, ctx->qmatrix_c, ctx->qmatrix_c16, weight_matrix,\n                      ctx->m.intra_quant_bias, 1, ctx->m.avctx->qmax, 1);\n    for (qscale = 1; qscale <= ctx->m.avctx->qmax; qscale++) {\n        for (i = 0; i < 64; i++) {\n            ctx->qmatrix_l  [qscale]   [i] <<= 2; ctx->qmatrix_c  [qscale]   [i] <<= 2;\n            ctx->qmatrix_l16[qscale][0][i] <<= 2; ctx->qmatrix_l16[qscale][1][i] <<= 2;\n            ctx->qmatrix_c16[qscale][0][i] <<= 2; ctx->qmatrix_c16[qscale][1][i] <<= 2;\n        }\n    }\n    return 0;\n fail:\n    return -1;\n}', 'static int dnxhd_init_vlc(DNXHDEncContext *ctx)\n{\n    int i;\n    CHECKED_ALLOCZ(ctx->table_vlc_codes, 449*2);\n    CHECKED_ALLOCZ(ctx->table_vlc_bits,    449);\n    CHECKED_ALLOCZ(ctx->table_run_codes,  63*2);\n    CHECKED_ALLOCZ(ctx->table_run_bits,     63);\n    for (i = 0; i < 257; i++) {\n        int level = ctx->cid_table->ac_level[i] +\n            (ctx->cid_table->ac_run_flag[i] << 7) + (ctx->cid_table->ac_index_flag[i] << 8);\n        assert(level < 449);\n        if (ctx->cid_table->ac_level[i] == 64 && ctx->cid_table->ac_index_flag[i])\n            level -= 64;\n        ctx->table_vlc_codes[level] = ctx->cid_table->ac_codes[i];\n        ctx->table_vlc_bits [level] = ctx->cid_table->ac_bits[i];\n    }\n    for (i = 0; i < 62; i++) {\n        int run = ctx->cid_table->run[i];\n        assert(run < 63);\n        ctx->table_run_codes[run] = ctx->cid_table->run_codes[i];\n        ctx->table_run_bits [run] = ctx->cid_table->run_bits[i];\n    }\n    return 0;\n fail:\n    return -1;\n}', 'static int dnxhd_init_rc(DNXHDEncContext *ctx)\n{\n    CHECKED_ALLOCZ(ctx->mb_rc, 8160*ctx->m.avctx->qmax*sizeof(RCEntry));\n    if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD)\n        CHECKED_ALLOCZ(ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry));\n    ctx->frame_bits = (ctx->cid_table->coding_unit_size - 640 - 4) * 8;\n    ctx->qscale = 1;\n    ctx->lambda = 2<<LAMBDA_FRAC_BITS;\n    return 0;\n fail:\n    return -1;\n}']