if(orientation&1) b->buf += (w+1)>>1; if(orientation>1) b->buf += b->stride>>1;
b->stride_line = 1 << (s->spatial_decomposition_count - level); b->buf_x_offset = 0; b->buf_y_offset = 0;  if(orientation&1){ b->buf += (w+1)>>1; b->buf_x_offset = (w+1)>>1; } if(orientation>1){ b->buf += b->stride>>1; b->buf_y_offset = b->stride_line >> 1; }
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]=\        s->dsp.put_h264_qpel_pixels_tab[0][dy+dx/4];\    s->dsp.put_qpel_pixels_tab       [1][dy+dx/4]=\    s->dsp.put_no_rnd_qpel_pixels_tab[1][dy+dx/4]=\        s->dsp.put_h264_qpel_pixels_tab[1][dy+dx/4];    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 ## 16;\    s->dsp.put_pixels_tab       [1][dy/4+dx/8]=\    s->dsp.put_no_rnd_pixels_tab[1][dy/4+dx/8]=\        mc_block_hpel ## dx ## dy ## 8;    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);        width= s->avctx->width;    height= s->avctx->height;    s->spatial_dwt_buffer= av_mallocz(width*height*sizeof(DWTELEM));        s->mv_scale= (s->avctx->flags & CODEC_FLAG_QPEL) ? 2 : 4;    s->block_max_depth= (s->avctx->flags & CODEC_FLAG_4MV) ? 1 : 0;        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];                b->x    = av_mallocz(((b->width+1) * b->height+1)*sizeof(int16_t));                b->coeff= av_mallocz(((b->width+1) * b->height+1)*sizeof(DWTELEM));            }            w= (w+1)>>1;            h= (h+1)>>1;        }    }        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;}