int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,

                      uint8_t* buf, int buf_size)

{

    int size, i;

    uint8_t *ppcm[4] = {0};



    if (buf_size < DV_PROFILE_BYTES ||

        !(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) ||

        buf_size < c->sys->frame_size) {

          return -1;   /* Broken frame, or not enough data */

    }



    /* Queueing audio packet */

    /* FIXME: in case of no audio/bad audio we have to do something */

    size = dv_extract_audio_info(c, buf);

    for (i = 0; i < c->ach; i++) {

       c->audio_pkt[i].size = size;

       c->audio_pkt[i].pts  = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate;

       ppcm[i] = c->audio_buf[i];

    }

    dv_extract_audio(buf, ppcm, c->sys);



    /* We work with 720p frames split in half, thus even frames have

     * channels 0,1 and odd 2,3. */

    if (c->sys->height == 720) {

        if (buf[1] & 0x0C) {

            c->audio_pkt[2].size = c->audio_pkt[3].size = 0;

        } else {

            c->audio_pkt[0].size = c->audio_pkt[1].size = 0;

            c->abytes += size;

        }

    } else {

        c->abytes += size;

    }



    /* Now it's time to return video packet */

    size = dv_extract_video_info(c, buf);

    av_init_packet(pkt);

    pkt->data         = buf;

    pkt->size         = size;

    pkt->flags       |= AV_PKT_FLAG_KEY;

    pkt->stream_index = c->vst->id;

    pkt->pts          = c->frames;



    c->frames++;



    return size;

}

int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,

                      uint8_t* buf, int buf_size)

{

    int size, i;

    uint8_t *ppcm[4] = {0};



    if (buf_size < DV_PROFILE_BYTES ||

        !(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) ||

        buf_size < c->sys->frame_size) {

          return -1;   

    }



    

    

    size = dv_extract_audio_info(c, buf);

    for (i = 0; i < c->ach; i++) {

       c->audio_pkt[i].size = size;

       c->audio_pkt[i].pts  = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate;

       ppcm[i] = c->audio_buf[i];

    }

    dv_extract_audio(buf, ppcm, c->sys);



    



    if (c->sys->height == 720) {

        if (buf[1] & 0x0C) {

            c->audio_pkt[2].size = c->audio_pkt[3].size = 0;

        } else {

            c->audio_pkt[0].size = c->audio_pkt[1].size = 0;

            c->abytes += size;

        }

    } else {

        c->abytes += size;

    }



    

    size = dv_extract_video_info(c, buf);

    av_init_packet(pkt);

    pkt->data         = buf;

    pkt->size         = size;

    pkt->flags       |= AV_PKT_FLAG_KEY;

    pkt->stream_index = c->vst->id;

    pkt->pts          = c->frames;



    c->frames++;



    return size;

}

    dv_extract_audio(buf, ppcm, c->sys);
int FUNC_0(DVDemuxContext *VAR_0, AVPacket *VAR_1,

                      uint8_t* VAR_2, int VAR_3)

{

    int VAR_4, VAR_5;

    uint8_t *ppcm[4] = {0};



    if (VAR_3 < DV_PROFILE_BYTES ||

        !(VAR_0->sys = avpriv_dv_frame_profile(VAR_0->sys, VAR_2, VAR_3)) ||

        VAR_3 < VAR_0->sys->frame_size) {

          return -1;   

    }



    

    

    VAR_4 = dv_extract_audio_info(VAR_0, VAR_2);

    for (VAR_5 = 0; VAR_5 < VAR_0->ach; VAR_5++) {

       VAR_0->audio_pkt[VAR_5].VAR_4 = VAR_4;

       VAR_0->audio_pkt[VAR_5].pts  = VAR_0->abytes * 30000*8 / VAR_0->ast[VAR_5]->codec->bit_rate;

       ppcm[VAR_5] = VAR_0->audio_buf[VAR_5];

    }

    dv_extract_audio(VAR_2, ppcm, VAR_0->sys);



    



    if (VAR_0->sys->height == 720) {

        if (VAR_2[1] & 0x0C) {

            VAR_0->audio_pkt[2].VAR_4 = VAR_0->audio_pkt[3].VAR_4 = 0;

        } else {

            VAR_0->audio_pkt[0].VAR_4 = VAR_0->audio_pkt[1].VAR_4 = 0;

            VAR_0->abytes += VAR_4;

        }

    } else {

        VAR_0->abytes += VAR_4;

    }



    

    VAR_4 = dv_extract_video_info(VAR_0, VAR_2);

    av_init_packet(VAR_1);

    VAR_1->data         = VAR_2;

    VAR_1->VAR_4         = VAR_4;

    VAR_1->flags       |= AV_PKT_FLAG_KEY;

    VAR_1->stream_index = VAR_0->vst->id;

    VAR_1->pts          = VAR_0->frames;



    VAR_0->frames++;



    return VAR_4;

}

int FUNC_0(DVDemuxContext *VAR_0, AVPacket *VAR_1,
uint8_t* VAR_2, int VAR_3)
{ int VAR_4, VAR_5; uint8_t *ppcm[4] = {0}; if (VAR_3 < DV_PROFILE_BYTES ||
!(VAR_0->sys = avpriv_dv_frame_profile(VAR_0->sys, VAR_2, VAR_3)) ||
VAR_3 < VAR_0->sys->frame_size) { return -1; } VAR_4 = dv_extract_audio_info(VAR_0, VAR_2); for (VAR_5 = 0; VAR_5 < VAR_0->ach; VAR_5++) { VAR_0->audio_pkt[VAR_5].VAR_4 = VAR_4; VAR_0->audio_pkt[VAR_5].pts  = VAR_0->abytes * 30000*8 / VAR_0->ast[VAR_5]->codec->bit_rate; ppcm[VAR_5] = VAR_0->audio_buf[VAR_5]; } dv_extract_audio(VAR_2, ppcm, VAR_0->sys); if (VAR_0->sys->height == 720) { if (VAR_2[1] & 0x0C) { VAR_0->audio_pkt[2].VAR_4 = VAR_0->audio_pkt[3].VAR_4 = 0; } else { VAR_0->audio_pkt[0].VAR_4 = VAR_0->audio_pkt[1].VAR_4 = 0; VAR_0->abytes += VAR_4; } } else { VAR_0->abytes += VAR_4; } VAR_4 = dv_extract_video_info(VAR_0, VAR_2); av_init_packet(VAR_1); VAR_1->data         = VAR_2; VAR_1->VAR_4         = VAR_4; VAR_1->flags       |= AV_PKT_FLAG_KEY; VAR_1->stream_index = VAR_0->vst->id; VAR_1->pts          = VAR_0->frames; VAR_0->frames++; return VAR_4; }