static int common_init(AVCodecContext *avctx){

    SnowContext *s = avctx->priv_data;

    int width, height;

    int level, orientation, plane_index, dec;



    s->avctx= avctx;

        

    dsputil_init(&s->dsp, avctx);



#define mcf(dx,dy)\

    s->dsp.put_qpel_pixels_tab       [0][dy+dx/4]=\

    s->dsp.put_no_rnd_qpel_pixels_tab[0][dy+dx/4]=\

        mc_block ## dx ## dy;



    mcf( 0, 0)

    mcf( 4, 0)

    mcf( 8, 0)

    mcf(12, 0)

    mcf( 0, 4)

    mcf( 4, 4)

    mcf( 8, 4)

    mcf(12, 4)

    mcf( 0, 8)

    mcf( 4, 8)

    mcf( 8, 8)

    mcf(12, 8)

    mcf( 0,12)

    mcf( 4,12)

    mcf( 8,12)

    mcf(12,12)



#define mcfh(dx,dy)\

    s->dsp.put_pixels_tab       [0][dy/4+dx/8]=\

    s->dsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\

        mc_block_hpel ## dx ## dy;



    mcfh(0, 0)

    mcfh(8, 0)

    mcfh(0, 8)

    mcfh(8, 8)

        

    dec= s->spatial_decomposition_count= 5;

    s->spatial_decomposition_type= avctx->prediction_method; //FIXME add decorrelator type r transform_type

    

    s->chroma_h_shift= 1; //FIXME XXX

    s->chroma_v_shift= 1;

    

//    dec += FFMAX(s->chroma_h_shift, s->chroma_v_shift);

    

    s->b_width = (s->avctx->width +(1<<dec)-1)>>dec;

    s->b_height= (s->avctx->height+(1<<dec)-1)>>dec;

    

    s->spatial_dwt_buffer= av_mallocz(s->b_width*s->b_height*sizeof(DWTELEM)<<(2*dec));

    s->pred_buffer= av_mallocz(s->b_width*s->b_height*sizeof(DWTELEM)<<(2*dec));

    

    s->mv_scale= (s->avctx->flags & CODEC_FLAG_QPEL) ? 2 : 4;

    

    for(plane_index=0; plane_index<3; plane_index++){    

        int w= s->avctx->width;

        int h= s->avctx->height;



        if(plane_index){

            w>>= s->chroma_h_shift;

            h>>= s->chroma_v_shift;

        }

        s->plane[plane_index].width = w;

        s->plane[plane_index].height= h;

//av_log(NULL, AV_LOG_DEBUG, "%d %d\n", w, h);

        for(level=s->spatial_decomposition_count-1; level>=0; level--){

            for(orientation=level ? 1 : 0; orientation<4; orientation++){

                SubBand *b= &s->plane[plane_index].band[level][orientation];

                

                b->buf= s->spatial_dwt_buffer;

                b->level= level;

                b->stride= s->plane[plane_index].width << (s->spatial_decomposition_count - level);

                b->width = (w + !(orientation&1))>>1;

                b->height= (h + !(orientation>1))>>1;

                

                if(orientation&1) b->buf += (w+1)>>1;

                if(orientation>1) b->buf += b->stride>>1;

                

                if(level)

                    b->parent= &s->plane[plane_index].band[level-1][orientation];

            }

            w= (w+1)>>1;

            h= (h+1)>>1;

        }

    }

    

    //FIXME init_subband() ?

    s->mb_band.stride= s->mv_band[0].stride= s->mv_band[1].stride=

    s->mb_band.width = s->mv_band[0].width = s->mv_band[1].width = (s->avctx->width + 15)>>4;

    s->mb_band.height= s->mv_band[0].height= s->mv_band[1].height= (s->avctx->height+ 15)>>4;

    s->mb_band   .buf= av_mallocz(s->mb_band   .stride * s->mb_band   .height*sizeof(DWTELEM));

    s->mv_band[0].buf= av_mallocz(s->mv_band[0].stride * s->mv_band[0].height*sizeof(DWTELEM));

    s->mv_band[1].buf= av_mallocz(s->mv_band[1].stride * s->mv_band[1].height*sizeof(DWTELEM));



    reset_contexts(s);

/*    

    width= s->width= avctx->width;

    height= s->height= avctx->height;

    

    assert(width && height);

*/

    s->avctx->get_buffer(s->avctx, &s->mconly_picture);

    

    return 0;

}

static int common_init(AVCodecContext *avctx){

    SnowContext *s = avctx->priv_data;

    int width, height;

    int level, orientation, plane_index, dec;



    s->avctx= avctx;

        

    dsputil_init(&s->dsp, avctx);



#define mcf(dx,dy)\

    s->dsp.put_qpel_pixels_tab       [0][dy+dx/4]=\

    s->dsp.put_no_rnd_qpel_pixels_tab[0][dy+dx/4]=\

        mc_block ## dx ## dy;



    mcf( 0, 0)

    mcf( 4, 0)

    mcf( 8, 0)

    mcf(12, 0)

    mcf( 0, 4)

    mcf( 4, 4)

    mcf( 8, 4)

    mcf(12, 4)

    mcf( 0, 8)

    mcf( 4, 8)

    mcf( 8, 8)

    mcf(12, 8)

    mcf( 0,12)

    mcf( 4,12)

    mcf( 8,12)

    mcf(12,12)



#define mcfh(dx,dy)\

    s->dsp.put_pixels_tab       [0][dy/4+dx/8]=\

    s->dsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\

        mc_block_hpel ## dx ## dy;



    mcfh(0, 0)

    mcfh(8, 0)

    mcfh(0, 8)

    mcfh(8, 8)

        

    dec= s->spatial_decomposition_count= 5;

    s->spatial_decomposition_type= avctx->prediction_method; 

    

    s->chroma_h_shift= 1; 

    s->chroma_v_shift= 1;

    



    

    s->b_width = (s->avctx->width +(1<<dec)-1)>>dec;

    s->b_height= (s->avctx->height+(1<<dec)-1)>>dec;

    

    s->spatial_dwt_buffer= av_mallocz(s->b_width*s->b_height*sizeof(DWTELEM)<<(2*dec));

    s->pred_buffer= av_mallocz(s->b_width*s->b_height*sizeof(DWTELEM)<<(2*dec));

    

    s->mv_scale= (s->avctx->flags & CODEC_FLAG_QPEL) ? 2 : 4;

    

    for(plane_index=0; plane_index<3; plane_index++){    

        int w= s->avctx->width;

        int h= s->avctx->height;



        if(plane_index){

            w>>= s->chroma_h_shift;

            h>>= s->chroma_v_shift;

        }

        s->plane[plane_index].width = w;

        s->plane[plane_index].height= h;



        for(level=s->spatial_decomposition_count-1; level>=0; level--){

            for(orientation=level ? 1 : 0; orientation<4; orientation++){

                SubBand *b= &s->plane[plane_index].band[level][orientation];

                

                b->buf= s->spatial_dwt_buffer;

                b->level= level;

                b->stride= s->plane[plane_index].width << (s->spatial_decomposition_count - level);

                b->width = (w + !(orientation&1))>>1;

                b->height= (h + !(orientation>1))>>1;

                

                if(orientation&1) b->buf += (w+1)>>1;

                if(orientation>1) b->buf += b->stride>>1;

                

                if(level)

                    b->parent= &s->plane[plane_index].band[level-1][orientation];

            }

            w= (w+1)>>1;

            h= (h+1)>>1;

        }

    }

    

    

    s->mb_band.stride= s->mv_band[0].stride= s->mv_band[1].stride=

    s->mb_band.width = s->mv_band[0].width = s->mv_band[1].width = (s->avctx->width + 15)>>4;

    s->mb_band.height= s->mv_band[0].height= s->mv_band[1].height= (s->avctx->height+ 15)>>4;

    s->mb_band   .buf= av_mallocz(s->mb_band   .stride * s->mb_band   .height*sizeof(DWTELEM));

    s->mv_band[0].buf= av_mallocz(s->mv_band[0].stride * s->mv_band[0].height*sizeof(DWTELEM));

    s->mv_band[1].buf= av_mallocz(s->mv_band[1].stride * s->mv_band[1].height*sizeof(DWTELEM));



    reset_contexts(s);













    s->avctx->get_buffer(s->avctx, &s->mconly_picture);

    

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0){

    SnowContext *s = VAR_0->priv_data;

    int VAR_1, VAR_2;

    int VAR_3, VAR_4, VAR_5, VAR_6;



    s->VAR_0= VAR_0;

        

    dsputil_init(&s->dsp, VAR_0);



#define mcf(dx,dy)\

    s->dsp.put_qpel_pixels_tab       [0][dy+dx/4]=\

    s->dsp.put_no_rnd_qpel_pixels_tab[0][dy+dx/4]=\

        mc_block ## dx ## dy;



    mcf( 0, 0)

    mcf( 4, 0)

    mcf( 8, 0)

    mcf(12, 0)

    mcf( 0, 4)

    mcf( 4, 4)

    mcf( 8, 4)

    mcf(12, 4)

    mcf( 0, 8)

    mcf( 4, 8)

    mcf( 8, 8)

    mcf(12, 8)

    mcf( 0,12)

    mcf( 4,12)

    mcf( 8,12)

    mcf(12,12)



#define mcfh(dx,dy)\

    s->dsp.put_pixels_tab       [0][dy/4+dx/8]=\

    s->dsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\

        mc_block_hpel ## dx ## dy;



    mcfh(0, 0)

    mcfh(8, 0)

    mcfh(0, 8)

    mcfh(8, 8)

        

    VAR_6= s->spatial_decomposition_count= 5;

    s->spatial_decomposition_type= VAR_0->prediction_method; 

    

    s->chroma_h_shift= 1; 

    s->chroma_v_shift= 1;

    



    

    s->b_width = (s->VAR_0->VAR_1 +(1<<VAR_6)-1)>>VAR_6;

    s->b_height= (s->VAR_0->VAR_2+(1<<VAR_6)-1)>>VAR_6;

    

    s->spatial_dwt_buffer= av_mallocz(s->b_width*s->b_height*sizeof(DWTELEM)<<(2*VAR_6));

    s->pred_buffer= av_mallocz(s->b_width*s->b_height*sizeof(DWTELEM)<<(2*VAR_6));

    

    s->mv_scale= (s->VAR_0->flags & CODEC_FLAG_QPEL) ? 2 : 4;

    

    for(VAR_5=0; VAR_5<3; VAR_5++){    

        int VAR_7= s->VAR_0->VAR_1;

        int VAR_8= s->VAR_0->VAR_2;



        if(VAR_5){

            VAR_7>>= s->chroma_h_shift;

            VAR_8>>= s->chroma_v_shift;

        }

        s->plane[VAR_5].VAR_1 = VAR_7;

        s->plane[VAR_5].VAR_2= VAR_8;



        for(VAR_3=s->spatial_decomposition_count-1; VAR_3>=0; VAR_3--){

            for(VAR_4=VAR_3 ? 1 : 0; VAR_4<4; VAR_4++){

                SubBand *b= &s->plane[VAR_5].band[VAR_3][VAR_4];

                

                b->buf= s->spatial_dwt_buffer;

                b->VAR_3= VAR_3;

                b->stride= s->plane[VAR_5].VAR_1 << (s->spatial_decomposition_count - VAR_3);

                b->VAR_1 = (VAR_7 + !(VAR_4&1))>>1;

                b->VAR_2= (VAR_8 + !(VAR_4>1))>>1;

                

                if(VAR_4&1) b->buf += (VAR_7+1)>>1;

                if(VAR_4>1) b->buf += b->stride>>1;

                

                if(VAR_3)

                    b->parent= &s->plane[VAR_5].band[VAR_3-1][VAR_4];

            }

            VAR_7= (VAR_7+1)>>1;

            VAR_8= (VAR_8+1)>>1;

        }

    }

    

    

    s->mb_band.stride= s->mv_band[0].stride= s->mv_band[1].stride=

    s->mb_band.VAR_1 = s->mv_band[0].VAR_1 = s->mv_band[1].VAR_1 = (s->VAR_0->VAR_1 + 15)>>4;

    s->mb_band.VAR_2= s->mv_band[0].VAR_2= s->mv_band[1].VAR_2= (s->VAR_0->VAR_2+ 15)>>4;

    s->mb_band   .buf= av_mallocz(s->mb_band   .stride * s->mb_band   .VAR_2*sizeof(DWTELEM));

    s->mv_band[0].buf= av_mallocz(s->mv_band[0].stride * s->mv_band[0].VAR_2*sizeof(DWTELEM));

    s->mv_band[1].buf= av_mallocz(s->mv_band[1].stride * s->mv_band[1].VAR_2*sizeof(DWTELEM));



    reset_contexts(s);













    s->VAR_0->get_buffer(s->VAR_0, &s->mconly_picture);

    

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0){ SnowContext *s = VAR_0->priv_data; int VAR_1, VAR_2; int VAR_3, VAR_4, VAR_5, VAR_6; s->VAR_0= VAR_0; dsputil_init(&s->dsp, VAR_0); #define mcf(dx,dy)\
s->dsp.put_qpel_pixels_tab       [0][dy+dx/4]=\
s->dsp.put_no_rnd_qpel_pixels_tab[0][dy+dx/4]=\
mc_block ## dx ## dy; mcf( 0, 0)
mcf( 4, 0)
mcf( 8, 0)
mcf(12, 0)
mcf( 0, 4)
mcf( 4, 4)
mcf( 8, 4)
mcf(12, 4)
mcf( 0, 8)
mcf( 4, 8)
mcf( 8, 8)
mcf(12, 8)
mcf( 0,12)
mcf( 4,12)
mcf( 8,12)
mcf(12,12)
#define mcfh(dx,dy)\
s->dsp.put_pixels_tab       [0][dy/4+dx/8]=\
s->dsp.put_no_rnd_pixels_tab[0][dy/4+dx/8]=\
mc_block_hpel ## dx ## dy; mcfh(0, 0)
mcfh(8, 0)
mcfh(0, 8)
mcfh(8, 8)
VAR_6= s->spatial_decomposition_count= 5; s->spatial_decomposition_type= VAR_0->prediction_method; s->chroma_h_shift= 1; s->chroma_v_shift= 1; s->b_width = (s->VAR_0->VAR_1 +(1<<VAR_6)-1)>>VAR_6; s->b_height= (s->VAR_0->VAR_2+(1<<VAR_6)-1)>>VAR_6; s->spatial_dwt_buffer= av_mallocz(s->b_width*s->b_height*sizeof(DWTELEM)<<(2*VAR_6)); s->pred_buffer= av_mallocz(s->b_width*s->b_height*sizeof(DWTELEM)<<(2*VAR_6)); s->mv_scale= (s->VAR_0->flags & CODEC_FLAG_QPEL) ? 2 : 4; for(VAR_5=0; VAR_5<3; VAR_5++){ int VAR_7= s->VAR_0->VAR_1; int VAR_8= s->VAR_0->VAR_2; if(VAR_5){ VAR_7>>= s->chroma_h_shift; VAR_8>>= s->chroma_v_shift; } s->plane[VAR_5].VAR_1 = VAR_7; s->plane[VAR_5].VAR_2= VAR_8; for(VAR_3=s->spatial_decomposition_count-1; VAR_3>=0; VAR_3--){ for(VAR_4=VAR_3 ? 1 : 0; VAR_4<4; VAR_4++){ SubBand *b= &s->plane[VAR_5].band[VAR_3][VAR_4]; b->buf= s->spatial_dwt_buffer; b->VAR_3= VAR_3; b->stride= s->plane[VAR_5].VAR_1 << (s->spatial_decomposition_count - VAR_3); b->VAR_1 = (VAR_7 + !(VAR_4&1))>>1; b->VAR_2= (VAR_8 + !(VAR_4>1))>>1; if(VAR_4&1) b->buf += (VAR_7+1)>>1; if(VAR_4>1) b->buf += b->stride>>1; if(VAR_3)
b->parent= &s->plane[VAR_5].band[VAR_3-1][VAR_4]; } VAR_7= (VAR_7+1)>>1; VAR_8= (VAR_8+1)>>1; } } s->mb_band.stride= s->mv_band[0].stride= s->mv_band[1].stride=
s->mb_band.VAR_1 = s->mv_band[0].VAR_1 = s->mv_band[1].VAR_1 = (s->VAR_0->VAR_1 + 15)>>4; s->mb_band.VAR_2= s->mv_band[0].VAR_2= s->mv_band[1].VAR_2= (s->VAR_0->VAR_2+ 15)>>4; s->mb_band   .buf= av_mallocz(s->mb_band   .stride * s->mb_band   .VAR_2*sizeof(DWTELEM)); s->mv_band[0].buf= av_mallocz(s->mv_band[0].stride * s->mv_band[0].VAR_2*sizeof(DWTELEM)); s->mv_band[1].buf= av_mallocz(s->mv_band[1].stride * s->mv_band[1].VAR_2*sizeof(DWTELEM)); reset_contexts(s); s->VAR_0->get_buffer(s->VAR_0, &s->mconly_picture); return 0; }