static void extract_mpeg4_header(AVFormatContext *infile)

{

    int mpeg4_count, i, size;

    AVPacket pkt;

    AVStream *st;

    const uint8_t *p;



    mpeg4_count = 0;

    for(i=0;i<infile->nb_streams;i++) {

        st = infile->streams[i];

        if (st->codec.codec_id == CODEC_ID_MPEG4 &&

            st->codec.extradata_size == 0) {

            mpeg4_count++;

        }

    }

    if (!mpeg4_count)

        return;



    printf("MPEG4 without extra data: trying to find header\n");

    while (mpeg4_count > 0) {

        if (av_read_packet(infile, &pkt) < 0)

            break;

        st = infile->streams[pkt.stream_index];

        if (st->codec.codec_id == CODEC_ID_MPEG4 &&

            st->codec.extradata_size == 0) {

            av_freep(&st->codec.extradata);

            /* fill extradata with the header */

            /* XXX: we make hard suppositions here ! */

            p = pkt.data;

            while (p < pkt.data + pkt.size - 4) {

                /* stop when vop header is found */

                if (p[0] == 0x00 && p[1] == 0x00 && 

                    p[2] == 0x01 && p[3] == 0xb6) {

                    size = p - pkt.data;

                    //                    av_hex_dump(pkt.data, size);

                    st->codec.extradata = av_malloc(size);

                    st->codec.extradata_size = size;

                    memcpy(st->codec.extradata, pkt.data, size);

                    break;

                }

                p++;

            }

            mpeg4_count--;

        }

        av_free_packet(&pkt);

    }

}

static void extract_mpeg4_header(AVFormatContext *infile)

{

    int mpeg4_count, i, size;

    AVPacket pkt;

    AVStream *st;

    const uint8_t *p;



    mpeg4_count = 0;

    for(i=0;i<infile->nb_streams;i++) {

        st = infile->streams[i];

        if (st->codec.codec_id == CODEC_ID_MPEG4 &&

            st->codec.extradata_size == 0) {

            mpeg4_count++;

        }

    }

    if (!mpeg4_count)

        return;



    printf("MPEG4 without extra data: trying to find header\n");

    while (mpeg4_count > 0) {

        if (av_read_packet(infile, &pkt) < 0)

            break;

        st = infile->streams[pkt.stream_index];

        if (st->codec.codec_id == CODEC_ID_MPEG4 &&

            st->codec.extradata_size == 0) {

            av_freep(&st->codec.extradata);

            

            

            p = pkt.data;

            while (p < pkt.data + pkt.size - 4) {

                

                if (p[0] == 0x00 && p[1] == 0x00 && 

                    p[2] == 0x01 && p[3] == 0xb6) {

                    size = p - pkt.data;

                    

                    st->codec.extradata = av_malloc(size);

                    st->codec.extradata_size = size;

                    memcpy(st->codec.extradata, pkt.data, size);

                    break;

                }

                p++;

            }

            mpeg4_count--;

        }

        av_free_packet(&pkt);

    }

}

    printf("MPEG4 without extra data: trying to find header\n");
static void FUNC_0(AVFormatContext *VAR_0)

{

    int VAR_1, VAR_2, VAR_3;

    AVPacket pkt;

    AVStream *st;

    const uint8_t *VAR_4;



    VAR_1 = 0;

    for(VAR_2=0;VAR_2<VAR_0->nb_streams;VAR_2++) {

        st = VAR_0->streams[VAR_2];

        if (st->codec.codec_id == CODEC_ID_MPEG4 &&

            st->codec.extradata_size == 0) {

            VAR_1++;

        }

    }

    if (!VAR_1)

        return;



    printf("MPEG4 without extra data: trying to find header\n");

    while (VAR_1 > 0) {

        if (av_read_packet(VAR_0, &pkt) < 0)

            break;

        st = VAR_0->streams[pkt.stream_index];

        if (st->codec.codec_id == CODEC_ID_MPEG4 &&

            st->codec.extradata_size == 0) {

            av_freep(&st->codec.extradata);

            

            

            VAR_4 = pkt.data;

            while (VAR_4 < pkt.data + pkt.VAR_3 - 4) {

                

                if (VAR_4[0] == 0x00 && VAR_4[1] == 0x00 && 

                    VAR_4[2] == 0x01 && VAR_4[3] == 0xb6) {

                    VAR_3 = VAR_4 - pkt.data;

                    

                    st->codec.extradata = av_malloc(VAR_3);

                    st->codec.extradata_size = VAR_3;

                    memcpy(st->codec.extradata, pkt.data, VAR_3);

                    break;

                }

                VAR_4++;

            }

            VAR_1--;

        }

        av_free_packet(&pkt);

    }

}

static void FUNC_0(AVFormatContext *VAR_0)
{ int VAR_1, VAR_2, VAR_3; AVPacket pkt; AVStream *st; const uint8_t *VAR_4; VAR_1 = 0; for(VAR_2=0;VAR_2<VAR_0->nb_streams;VAR_2++) { st = VAR_0->streams[VAR_2]; if (st->codec.codec_id == CODEC_ID_MPEG4 &&
st->codec.extradata_size == 0) { VAR_1++; } } if (!VAR_1)
return; printf("MPEG4 without extra data: trying to find header\n"); while (VAR_1 > 0) { if (av_read_packet(VAR_0, &pkt) < 0)
break; st = VAR_0->streams[pkt.stream_index]; if (st->codec.codec_id == CODEC_ID_MPEG4 &&
st->codec.extradata_size == 0) { av_freep(&st->codec.extradata); VAR_4 = pkt.data; while (VAR_4 < pkt.data + pkt.VAR_3 - 4) { if (VAR_4[0] == 0x00 && VAR_4[1] == 0x00 &&
VAR_4[2] == 0x01 && VAR_4[3] == 0xb6) { VAR_3 = VAR_4 - pkt.data; st->codec.extradata = av_malloc(VAR_3); st->codec.extradata_size = VAR_3; memcpy(st->codec.extradata, pkt.data, VAR_3); break; } VAR_4++; } VAR_1--; } av_free_packet(&pkt); } }