if(avctx->flags&CODEC_FLAG_PASS1){ if(!avctx->stats_out) avctx->stats_out = av_mallocz(256); } if(avctx->flags&CODEC_FLAG_PASS2){ if(ff_rate_control_init(&s->m) < 0) return -1; }
static int encode_init(AVCodecContext *avctx){    SnowContext *s = avctx->priv_data;    int plane_index;    if(avctx->strict_std_compliance >= 0){        av_log(avctx, AV_LOG_ERROR, "this codec is under development, files encoded with it wont be decodeable with future versions!!!\n"               "use vstrict=-1 / -strict -1 to use it anyway\n");        return -1;    }     common_init(avctx);    alloc_blocks(s);     s->version=0;        s->m.me.scratchpad= av_mallocz((avctx->width+64)*2*16*2*sizeof(uint8_t));    s->m.me.map       = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));    s->m.me.score_map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));    h263_encode_init(&s->m); //mv_penalty    for(plane_index=0; plane_index<3; plane_index++){        calculate_vissual_weight(s, &s->plane[plane_index]);    }            avctx->coded_frame= &s->current_picture;    switch(avctx->pix_fmt){//    case PIX_FMT_YUV444P://    case PIX_FMT_YUV422P:    case PIX_FMT_YUV420P:    case PIX_FMT_GRAY8://    case PIX_FMT_YUV411P://    case PIX_FMT_YUV410P:        s->colorspace_type= 0;        break;/*    case PIX_FMT_RGBA32:        s->colorspace= 1;        break;*/    default:        av_log(avctx, AV_LOG_ERROR, "format not supported\n");        return -1;    }//    avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_h_shift, &s->chroma_v_shift);    s->chroma_h_shift= 1;    s->chroma_v_shift= 1;    return 0;}