int ff_snow_frame_start(SnowContext *s){

   AVFrame tmp;

   int i, ret;

   int w= s->avctx->width; //FIXME round up to x16 ?

   int h= s->avctx->height;



    if (s->current_picture.data[0] && !(s->avctx->flags&CODEC_FLAG_EMU_EDGE)) {

        s->dsp.draw_edges(s->current_picture.data[0],

                          s->current_picture.linesize[0], w   , h   ,

                          EDGE_WIDTH  , EDGE_WIDTH  , EDGE_TOP | EDGE_BOTTOM);

        s->dsp.draw_edges(s->current_picture.data[1],

                          s->current_picture.linesize[1], w>>s->chroma_h_shift, h>>s->chroma_v_shift,

                          EDGE_WIDTH>>s->chroma_h_shift, EDGE_WIDTH>>s->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM);

        s->dsp.draw_edges(s->current_picture.data[2],

                          s->current_picture.linesize[2], w>>s->chroma_h_shift, h>>s->chroma_v_shift,

                          EDGE_WIDTH>>s->chroma_h_shift, EDGE_WIDTH>>s->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM);

    }



    ff_snow_release_buffer(s->avctx);



    av_frame_move_ref(&tmp, &s->last_picture[s->max_ref_frames-1]);

    for(i=s->max_ref_frames-1; i>0; i--)

        av_frame_move_ref(&s->last_picture[i], &s->last_picture[i-1]);

    memmove(s->halfpel_plane+1, s->halfpel_plane, (s->max_ref_frames-1)*sizeof(void*)*4*4);

    if(USE_HALFPEL_PLANE && s->current_picture.data[0])

        halfpel_interpol(s, s->halfpel_plane[0], &s->current_picture);

    av_frame_move_ref(&s->last_picture[0], &s->current_picture);

    av_frame_move_ref(&s->current_picture, &tmp);



    if(s->keyframe){

        s->ref_frames= 0;

    }else{

        int i;

        for(i=0; i<s->max_ref_frames && s->last_picture[i].data[0]; i++)

            if(i && s->last_picture[i-1].key_frame)

                break;

        s->ref_frames= i;

        if(s->ref_frames==0){

            av_log(s->avctx,AV_LOG_ERROR, "No reference frames\n");

            return -1;

        }

    }



    if ((ret = ff_get_buffer(s->avctx, &s->current_picture, AV_GET_BUFFER_FLAG_REF)) < 0)

        return ret;



    s->current_picture.key_frame= s->keyframe;



    return 0;

}

int ff_snow_frame_start(SnowContext *s){

   AVFrame tmp;

   int i, ret;

   int w= s->avctx->width; 

   int h= s->avctx->height;



    if (s->current_picture.data[0] && !(s->avctx->flags&CODEC_FLAG_EMU_EDGE)) {

        s->dsp.draw_edges(s->current_picture.data[0],

                          s->current_picture.linesize[0], w   , h   ,

                          EDGE_WIDTH  , EDGE_WIDTH  , EDGE_TOP | EDGE_BOTTOM);

        s->dsp.draw_edges(s->current_picture.data[1],

                          s->current_picture.linesize[1], w>>s->chroma_h_shift, h>>s->chroma_v_shift,

                          EDGE_WIDTH>>s->chroma_h_shift, EDGE_WIDTH>>s->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM);

        s->dsp.draw_edges(s->current_picture.data[2],

                          s->current_picture.linesize[2], w>>s->chroma_h_shift, h>>s->chroma_v_shift,

                          EDGE_WIDTH>>s->chroma_h_shift, EDGE_WIDTH>>s->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM);

    }



    ff_snow_release_buffer(s->avctx);



    av_frame_move_ref(&tmp, &s->last_picture[s->max_ref_frames-1]);

    for(i=s->max_ref_frames-1; i>0; i--)

        av_frame_move_ref(&s->last_picture[i], &s->last_picture[i-1]);

    memmove(s->halfpel_plane+1, s->halfpel_plane, (s->max_ref_frames-1)*sizeof(void*)*4*4);

    if(USE_HALFPEL_PLANE && s->current_picture.data[0])

        halfpel_interpol(s, s->halfpel_plane[0], &s->current_picture);

    av_frame_move_ref(&s->last_picture[0], &s->current_picture);

    av_frame_move_ref(&s->current_picture, &tmp);



    if(s->keyframe){

        s->ref_frames= 0;

    }else{

        int i;

        for(i=0; i<s->max_ref_frames && s->last_picture[i].data[0]; i++)

            if(i && s->last_picture[i-1].key_frame)

                break;

        s->ref_frames= i;

        if(s->ref_frames==0){

            av_log(s->avctx,AV_LOG_ERROR, "No reference frames\n");

            return -1;

        }

    }



    if ((ret = ff_get_buffer(s->avctx, &s->current_picture, AV_GET_BUFFER_FLAG_REF)) < 0)

        return ret;



    s->current_picture.key_frame= s->keyframe;



    return 0;

}

    if(USE_HALFPEL_PLANE && s->current_picture.data[0])         halfpel_interpol(s, s->halfpel_plane[0], &s->current_picture);
int FUNC_0(SnowContext *VAR_0){

   AVFrame tmp;

   int VAR_5, VAR_2;

   int VAR_3= VAR_0->avctx->width; 

   int VAR_4= VAR_0->avctx->height;



    if (VAR_0->current_picture.data[0] && !(VAR_0->avctx->flags&CODEC_FLAG_EMU_EDGE)) {

        VAR_0->dsp.draw_edges(VAR_0->current_picture.data[0],

                          VAR_0->current_picture.linesize[0], VAR_3   , VAR_4   ,

                          EDGE_WIDTH  , EDGE_WIDTH  , EDGE_TOP | EDGE_BOTTOM);

        VAR_0->dsp.draw_edges(VAR_0->current_picture.data[1],

                          VAR_0->current_picture.linesize[1], VAR_3>>VAR_0->chroma_h_shift, VAR_4>>VAR_0->chroma_v_shift,

                          EDGE_WIDTH>>VAR_0->chroma_h_shift, EDGE_WIDTH>>VAR_0->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM);

        VAR_0->dsp.draw_edges(VAR_0->current_picture.data[2],

                          VAR_0->current_picture.linesize[2], VAR_3>>VAR_0->chroma_h_shift, VAR_4>>VAR_0->chroma_v_shift,

                          EDGE_WIDTH>>VAR_0->chroma_h_shift, EDGE_WIDTH>>VAR_0->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM);

    }



    ff_snow_release_buffer(VAR_0->avctx);



    av_frame_move_ref(&tmp, &VAR_0->last_picture[VAR_0->max_ref_frames-1]);

    for(VAR_5=VAR_0->max_ref_frames-1; VAR_5>0; VAR_5--)

        av_frame_move_ref(&VAR_0->last_picture[VAR_5], &VAR_0->last_picture[VAR_5-1]);

    memmove(VAR_0->halfpel_plane+1, VAR_0->halfpel_plane, (VAR_0->max_ref_frames-1)*sizeof(void*)*4*4);

    if(USE_HALFPEL_PLANE && VAR_0->current_picture.data[0])

        halfpel_interpol(VAR_0, VAR_0->halfpel_plane[0], &VAR_0->current_picture);

    av_frame_move_ref(&VAR_0->last_picture[0], &VAR_0->current_picture);

    av_frame_move_ref(&VAR_0->current_picture, &tmp);



    if(VAR_0->keyframe){

        VAR_0->ref_frames= 0;

    }else{

        int VAR_5;

        for(VAR_5=0; VAR_5<VAR_0->max_ref_frames && VAR_0->last_picture[VAR_5].data[0]; VAR_5++)

            if(VAR_5 && VAR_0->last_picture[VAR_5-1].key_frame)

                break;

        VAR_0->ref_frames= VAR_5;

        if(VAR_0->ref_frames==0){

            av_log(VAR_0->avctx,AV_LOG_ERROR, "No reference frames\n");

            return -1;

        }

    }



    if ((VAR_2 = ff_get_buffer(VAR_0->avctx, &VAR_0->current_picture, AV_GET_BUFFER_FLAG_REF)) < 0)

        return VAR_2;



    VAR_0->current_picture.key_frame= VAR_0->keyframe;



    return 0;

}

int FUNC_0(SnowContext *VAR_0){ AVFrame tmp; int VAR_5, VAR_2; int VAR_3= VAR_0->avctx->width; int VAR_4= VAR_0->avctx->height; if (VAR_0->current_picture.data[0] && !(VAR_0->avctx->flags&CODEC_FLAG_EMU_EDGE)) { VAR_0->dsp.draw_edges(VAR_0->current_picture.data[0],
VAR_0->current_picture.linesize[0], VAR_3   , VAR_4   ,
EDGE_WIDTH  , EDGE_WIDTH  , EDGE_TOP | EDGE_BOTTOM); VAR_0->dsp.draw_edges(VAR_0->current_picture.data[1],
VAR_0->current_picture.linesize[1], VAR_3>>VAR_0->chroma_h_shift, VAR_4>>VAR_0->chroma_v_shift,
EDGE_WIDTH>>VAR_0->chroma_h_shift, EDGE_WIDTH>>VAR_0->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM); VAR_0->dsp.draw_edges(VAR_0->current_picture.data[2],
VAR_0->current_picture.linesize[2], VAR_3>>VAR_0->chroma_h_shift, VAR_4>>VAR_0->chroma_v_shift,
EDGE_WIDTH>>VAR_0->chroma_h_shift, EDGE_WIDTH>>VAR_0->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM); } ff_snow_release_buffer(VAR_0->avctx); av_frame_move_ref(&tmp, &VAR_0->last_picture[VAR_0->max_ref_frames-1]); for(VAR_5=VAR_0->max_ref_frames-1; VAR_5>0; VAR_5--) av_frame_move_ref(&VAR_0->last_picture[VAR_5], &VAR_0->last_picture[VAR_5-1]); memmove(VAR_0->halfpel_plane+1, VAR_0->halfpel_plane, (VAR_0->max_ref_frames-1)*sizeof(void*)*4*4); if(USE_HALFPEL_PLANE && VAR_0->current_picture.data[0])
halfpel_interpol(VAR_0, VAR_0->halfpel_plane[0], &VAR_0->current_picture); av_frame_move_ref(&VAR_0->last_picture[0], &VAR_0->current_picture); av_frame_move_ref(&VAR_0->current_picture, &tmp); if(VAR_0->keyframe){ VAR_0->ref_frames= 0; }else{ int VAR_5; for(VAR_5=0; VAR_5<VAR_0->max_ref_frames && VAR_0->last_picture[VAR_5].data[0]; VAR_5++) if(VAR_5 && VAR_0->last_picture[VAR_5-1].key_frame)
break; VAR_0->ref_frames= VAR_5; if(VAR_0->ref_frames==0){ av_log(VAR_0->avctx,AV_LOG_ERROR, "No reference frames\n"); return -1; } } if ((VAR_2 = ff_get_buffer(VAR_0->avctx, &VAR_0->current_picture, AV_GET_BUFFER_FLAG_REF)) < 0)
return VAR_2; VAR_0->current_picture.key_frame= VAR_0->keyframe; return 0; }