static int dvvideo_decode_frame(AVCodecContext *avctx,

                                 void *data, int *got_frame,

                                 AVPacket *avpkt)

{

    uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    DVVideoContext *s = avctx->priv_data;

    const uint8_t* vsc_pack;

    int apt, is16_9, ret;

    const DVprofile *sys;



    sys = avpriv_dv_frame_profile2(avctx, s->sys, buf, buf_size);

    if (!sys || buf_size < sys->frame_size) {

        av_log(avctx, AV_LOG_ERROR, "could not find dv frame profile\n");

        return -1; /* NOTE: we only accept several full frames */

    }



    if (sys != s->sys) {

        ret = ff_dv_init_dynamic_tables(s, sys);

        if (ret < 0) {

            av_log(avctx, AV_LOG_ERROR, "Error initializing the work tables.\n");

            return ret;

        }

        s->sys = sys;

    }



    s->frame            = data;

    s->frame->key_frame = 1;

    s->frame->pict_type = AV_PICTURE_TYPE_I;

    avctx->pix_fmt   = s->sys->pix_fmt;

    avctx->time_base = s->sys->time_base;



    ret = ff_set_dimensions(avctx, s->sys->width, s->sys->height);

    if (ret < 0)

        return ret;



    /* Determine the codec's sample_aspect ratio from the packet */

    vsc_pack = buf + 80*5 + 48 + 5;

    if ( *vsc_pack == dv_video_control ) {

        apt = buf[4] & 0x07;

        is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07)));

        ff_set_sar(avctx, s->sys->sar[is16_9]);

    }



    if ((ret = ff_get_buffer(avctx, s->frame, 0)) < 0)

        return ret;

    s->frame->interlaced_frame = 1;

    s->frame->top_field_first  = 0;



    /* Determine the codec's field order from the packet */

    if ( *vsc_pack == dv_video_control ) {

        s->frame->top_field_first = !(vsc_pack[3] & 0x40);

    }



    s->buf = buf;

    avctx->execute(avctx, dv_decode_video_segment, s->work_chunks, NULL,

                   dv_work_pool_size(s->sys), sizeof(DVwork_chunk));



    emms_c();



    /* return image */

    *got_frame = 1;



    return s->sys->frame_size;

}

static int dvvideo_decode_frame(AVCodecContext *avctx,

                                 void *data, int *got_frame,

                                 AVPacket *avpkt)

{

    uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    DVVideoContext *s = avctx->priv_data;

    const uint8_t* vsc_pack;

    int apt, is16_9, ret;

    const DVprofile *sys;



    sys = avpriv_dv_frame_profile2(avctx, s->sys, buf, buf_size);

    if (!sys || buf_size < sys->frame_size) {

        av_log(avctx, AV_LOG_ERROR, "could not find dv frame profile\n");

        return -1; 

    }



    if (sys != s->sys) {

        ret = ff_dv_init_dynamic_tables(s, sys);

        if (ret < 0) {

            av_log(avctx, AV_LOG_ERROR, "Error initializing the work tables.\n");

            return ret;

        }

        s->sys = sys;

    }



    s->frame            = data;

    s->frame->key_frame = 1;

    s->frame->pict_type = AV_PICTURE_TYPE_I;

    avctx->pix_fmt   = s->sys->pix_fmt;

    avctx->time_base = s->sys->time_base;



    ret = ff_set_dimensions(avctx, s->sys->width, s->sys->height);

    if (ret < 0)

        return ret;



    

    vsc_pack = buf + 80*5 + 48 + 5;

    if ( *vsc_pack == dv_video_control ) {

        apt = buf[4] & 0x07;

        is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07)));

        ff_set_sar(avctx, s->sys->sar[is16_9]);

    }



    if ((ret = ff_get_buffer(avctx, s->frame, 0)) < 0)

        return ret;

    s->frame->interlaced_frame = 1;

    s->frame->top_field_first  = 0;



    

    if ( *vsc_pack == dv_video_control ) {

        s->frame->top_field_first = !(vsc_pack[3] & 0x40);

    }



    s->buf = buf;

    avctx->execute(avctx, dv_decode_video_segment, s->work_chunks, NULL,

                   dv_work_pool_size(s->sys), sizeof(DVwork_chunk));



    emms_c();



    

    *got_frame = 1;



    return s->sys->frame_size;

}

static int FUNC_0(AVCodecContext *VAR_0,

                                 void *VAR_1, int *VAR_2,

                                 AVPacket *VAR_3)

{

    uint8_t *buf = VAR_3->VAR_1;

    int VAR_4 = VAR_3->size;

    DVVideoContext *s = VAR_0->priv_data;

    const uint8_t* VAR_5;

    int VAR_6, VAR_7, VAR_8;

    const DVprofile *VAR_9;



    VAR_9 = avpriv_dv_frame_profile2(VAR_0, s->VAR_9, buf, VAR_4);

    if (!VAR_9 || VAR_4 < VAR_9->frame_size) {

        av_log(VAR_0, AV_LOG_ERROR, "could not find dv frame profile\n");

        return -1; 

    }



    if (VAR_9 != s->VAR_9) {

        VAR_8 = ff_dv_init_dynamic_tables(s, VAR_9);

        if (VAR_8 < 0) {

            av_log(VAR_0, AV_LOG_ERROR, "Error initializing the work tables.\n");

            return VAR_8;

        }

        s->VAR_9 = VAR_9;

    }



    s->frame            = VAR_1;

    s->frame->key_frame = 1;

    s->frame->pict_type = AV_PICTURE_TYPE_I;

    VAR_0->pix_fmt   = s->VAR_9->pix_fmt;

    VAR_0->time_base = s->VAR_9->time_base;



    VAR_8 = ff_set_dimensions(VAR_0, s->VAR_9->width, s->VAR_9->height);

    if (VAR_8 < 0)

        return VAR_8;



    

    VAR_5 = buf + 80*5 + 48 + 5;

    if ( *VAR_5 == dv_video_control ) {

        VAR_6 = buf[4] & 0x07;

        VAR_7 = (VAR_5 && ((VAR_5[2] & 0x07) == 0x02 || (!VAR_6 && (VAR_5[2] & 0x07) == 0x07)));

        ff_set_sar(VAR_0, s->VAR_9->sar[VAR_7]);

    }



    if ((VAR_8 = ff_get_buffer(VAR_0, s->frame, 0)) < 0)

        return VAR_8;

    s->frame->interlaced_frame = 1;

    s->frame->top_field_first  = 0;



    

    if ( *VAR_5 == dv_video_control ) {

        s->frame->top_field_first = !(VAR_5[3] & 0x40);

    }



    s->buf = buf;

    VAR_0->execute(VAR_0, dv_decode_video_segment, s->work_chunks, NULL,

                   dv_work_pool_size(s->VAR_9), sizeof(DVwork_chunk));



    emms_c();



    

    *VAR_2 = 1;



    return s->VAR_9->frame_size;

}

static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{ uint8_t *buf = VAR_3->VAR_1; int VAR_4 = VAR_3->size; DVVideoContext *s = VAR_0->priv_data; const uint8_t* VAR_5; int VAR_6, VAR_7, VAR_8; const DVprofile *VAR_9; VAR_9 = avpriv_dv_frame_profile2(VAR_0, s->VAR_9, buf, VAR_4); if (!VAR_9 || VAR_4 < VAR_9->frame_size) { av_log(VAR_0, AV_LOG_ERROR, "could not find dv frame profile\n"); return -1; } if (VAR_9 != s->VAR_9) { VAR_8 = ff_dv_init_dynamic_tables(s, VAR_9); if (VAR_8 < 0) { av_log(VAR_0, AV_LOG_ERROR, "Error initializing the work tables.\n"); return VAR_8; } s->VAR_9 = VAR_9; } s->frame            = VAR_1; s->frame->key_frame = 1; s->frame->pict_type = AV_PICTURE_TYPE_I; VAR_0->pix_fmt   = s->VAR_9->pix_fmt; VAR_0->time_base = s->VAR_9->time_base; VAR_8 = ff_set_dimensions(VAR_0, s->VAR_9->width, s->VAR_9->height); if (VAR_8 < 0)
return VAR_8; VAR_5 = buf + 80*5 + 48 + 5; if ( *VAR_5 == dv_video_control ) { VAR_6 = buf[4] & 0x07; VAR_7 = (VAR_5 && ((VAR_5[2] & 0x07) == 0x02 || (!VAR_6 && (VAR_5[2] & 0x07) == 0x07))); ff_set_sar(VAR_0, s->VAR_9->sar[VAR_7]); } if ((VAR_8 = ff_get_buffer(VAR_0, s->frame, 0)) < 0)
return VAR_8; s->frame->interlaced_frame = 1; s->frame->top_field_first  = 0; if ( *VAR_5 == dv_video_control ) { s->frame->top_field_first = !(VAR_5[3] & 0x40); } s->buf = buf; VAR_0->execute(VAR_0, dv_decode_video_segment, s->work_chunks, NULL,
dv_work_pool_size(s->VAR_9), sizeof(DVwork_chunk)); emms_c(); *VAR_2 = 1; return s->VAR_9->frame_size; }