static int svq1_encode_frame(AVCodecContext *avctx, unsigned char *buf, 

    int buf_size, void *data)

{

    SVQ1Context * const s = avctx->priv_data;

    AVFrame *pict = data;

    AVFrame * const p= (AVFrame*)&s->picture;

    AVFrame temp;

    int i;



    if(avctx->pix_fmt != PIX_FMT_YUV410P){

        av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n");

        return -1;

    }

    

    if(!s->current_picture.data[0]){

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

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

    }

    

    temp= s->current_picture;

    s->current_picture= s->last_picture;

    s->last_picture= temp;

    

    init_put_bits(&s->pb, buf, buf_size);



    *p = *pict;

    p->pict_type = avctx->frame_number % avctx->gop_size ? P_TYPE : I_TYPE;

    p->key_frame = p->pict_type == I_TYPE;



    svq1_write_header(s, p->pict_type);

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

        svq1_encode_plane(s, i,

            s->picture.data[i], s->last_picture.data[i], s->current_picture.data[i],

            s->frame_width / (i?4:1), s->frame_height / (i?4:1), 

            s->picture.linesize[i], s->current_picture.linesize[i]);

    }



//    align_put_bits(&s->pb);

    while(put_bits_count(&s->pb) & 31)

        put_bits(&s->pb, 1, 0);

        

    flush_put_bits(&s->pb);



    return (put_bits_count(&s->pb) / 8);

}

static int svq1_encode_frame(AVCodecContext *avctx, unsigned char *buf, 

    int buf_size, void *data)

{

    SVQ1Context * const s = avctx->priv_data;

    AVFrame *pict = data;

    AVFrame * const p= (AVFrame*)&s->picture;

    AVFrame temp;

    int i;



    if(avctx->pix_fmt != PIX_FMT_YUV410P){

        av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n");

        return -1;

    }

    

    if(!s->current_picture.data[0]){

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

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

    }

    

    temp= s->current_picture;

    s->current_picture= s->last_picture;

    s->last_picture= temp;

    

    init_put_bits(&s->pb, buf, buf_size);



    *p = *pict;

    p->pict_type = avctx->frame_number % avctx->gop_size ? P_TYPE : I_TYPE;

    p->key_frame = p->pict_type == I_TYPE;



    svq1_write_header(s, p->pict_type);

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

        svq1_encode_plane(s, i,

            s->picture.data[i], s->last_picture.data[i], s->current_picture.data[i],

            s->frame_width / (i?4:1), s->frame_height / (i?4:1), 

            s->picture.linesize[i], s->current_picture.linesize[i]);

    }





    while(put_bits_count(&s->pb) & 31)

        put_bits(&s->pb, 1, 0);

        

    flush_put_bits(&s->pb);



    return (put_bits_count(&s->pb) / 8);

}

        svq1_encode_plane(s, i,             s->picture.linesize[i], s->current_picture.linesize[i]);
static int FUNC_0(AVCodecContext *VAR_0, unsigned char *VAR_1, 

    int VAR_2, void *VAR_3)

{

    SVQ1Context * const s = VAR_0->priv_data;

    AVFrame *pict = VAR_3;

    AVFrame * const p= (AVFrame*)&s->picture;

    AVFrame temp;

    int VAR_4;



    if(VAR_0->pix_fmt != PIX_FMT_YUV410P){

        av_log(VAR_0, AV_LOG_ERROR, "unsupported pixel format\n");

        return -1;

    }

    

    if(!s->current_picture.VAR_3[0]){

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

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

    }

    

    temp= s->current_picture;

    s->current_picture= s->last_picture;

    s->last_picture= temp;

    

    init_put_bits(&s->pb, VAR_1, VAR_2);



    *p = *pict;

    p->pict_type = VAR_0->frame_number % VAR_0->gop_size ? P_TYPE : I_TYPE;

    p->key_frame = p->pict_type == I_TYPE;



    svq1_write_header(s, p->pict_type);

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

        svq1_encode_plane(s, VAR_4,

            s->picture.VAR_3[VAR_4], s->last_picture.VAR_3[VAR_4], s->current_picture.VAR_3[VAR_4],

            s->frame_width / (VAR_4?4:1), s->frame_height / (VAR_4?4:1), 

            s->picture.linesize[VAR_4], s->current_picture.linesize[VAR_4]);

    }





    while(put_bits_count(&s->pb) & 31)

        put_bits(&s->pb, 1, 0);

        

    flush_put_bits(&s->pb);



    return (put_bits_count(&s->pb) / 8);

}

static int FUNC_0(AVCodecContext *VAR_0, unsigned char *VAR_1,
int VAR_2, void *VAR_3)
{ SVQ1Context * const s = VAR_0->priv_data; AVFrame *pict = VAR_3; AVFrame * const p= (AVFrame*)&s->picture; AVFrame temp; int VAR_4; if(VAR_0->pix_fmt != PIX_FMT_YUV410P){ av_log(VAR_0, AV_LOG_ERROR, "unsupported pixel format\n"); return -1; } if(!s->current_picture.VAR_3[0]){ VAR_0->get_buffer(VAR_0, &s->current_picture); VAR_0->get_buffer(VAR_0, &s->last_picture); } temp= s->current_picture; s->current_picture= s->last_picture; s->last_picture= temp; init_put_bits(&s->pb, VAR_1, VAR_2); *p = *pict; p->pict_type = VAR_0->frame_number % VAR_0->gop_size ? P_TYPE : I_TYPE; p->key_frame = p->pict_type == I_TYPE; svq1_write_header(s, p->pict_type); for(VAR_4=0; VAR_4<3; VAR_4++){ svq1_encode_plane(s, VAR_4,
s->picture.VAR_3[VAR_4], s->last_picture.VAR_3[VAR_4], s->current_picture.VAR_3[VAR_4],
s->frame_width / (VAR_4?4:1), s->frame_height / (VAR_4?4:1),
s->picture.linesize[VAR_4], s->current_picture.linesize[VAR_4]); } while(put_bits_count(&s->pb) & 31)
put_bits(&s->pb, 1, 0); flush_put_bits(&s->pb); return (put_bits_count(&s->pb) / 8); }