static int flic_read_packet(AVFormatContext *s,

                            AVPacket *pkt)

{

    FlicDemuxContext *flic = (FlicDemuxContext *)s->priv_data;

    ByteIOContext *pb = &s->pb;

    int packet_read = 0;

    unsigned int size;

    int magic;

    int ret = 0;

    unsigned char preamble[FLIC_PREAMBLE_SIZE];



    while (!packet_read) {



        if ((ret = get_buffer(pb, preamble, FLIC_PREAMBLE_SIZE)) !=

            FLIC_PREAMBLE_SIZE) {

            ret = AVERROR_IO;

            break;

        }



        size = LE_32(&preamble[0]);

        magic = LE_16(&preamble[4]);



        if ((magic == FLIC_CHUNK_MAGIC_1) || (magic == FLIC_CHUNK_MAGIC_2)) {

            if (av_new_packet(pkt, size)) {

                ret = AVERROR_IO;

                break;

            }

            pkt->stream_index = flic->video_stream_index;

            pkt->pts = flic->pts;

            memcpy(pkt->data, preamble, FLIC_PREAMBLE_SIZE);

            ret = get_buffer(pb, pkt->data + FLIC_PREAMBLE_SIZE, 

                size - FLIC_PREAMBLE_SIZE);

            if (ret != size - FLIC_PREAMBLE_SIZE) {

                av_free_packet(pkt);

                ret = AVERROR_IO;

            }

            flic->pts += flic->frame_pts_inc;

            packet_read = 1;

        } else {

            /* not interested in this chunk */

            url_fseek(pb, size - 6, SEEK_CUR);

        }

    }



    return ret;

}

static int flic_read_packet(AVFormatContext *s,

                            AVPacket *pkt)

{

    FlicDemuxContext *flic = (FlicDemuxContext *)s->priv_data;

    ByteIOContext *pb = &s->pb;

    int packet_read = 0;

    unsigned int size;

    int magic;

    int ret = 0;

    unsigned char preamble[FLIC_PREAMBLE_SIZE];



    while (!packet_read) {



        if ((ret = get_buffer(pb, preamble, FLIC_PREAMBLE_SIZE)) !=

            FLIC_PREAMBLE_SIZE) {

            ret = AVERROR_IO;

            break;

        }



        size = LE_32(&preamble[0]);

        magic = LE_16(&preamble[4]);



        if ((magic == FLIC_CHUNK_MAGIC_1) || (magic == FLIC_CHUNK_MAGIC_2)) {

            if (av_new_packet(pkt, size)) {

                ret = AVERROR_IO;

                break;

            }

            pkt->stream_index = flic->video_stream_index;

            pkt->pts = flic->pts;

            memcpy(pkt->data, preamble, FLIC_PREAMBLE_SIZE);

            ret = get_buffer(pb, pkt->data + FLIC_PREAMBLE_SIZE, 

                size - FLIC_PREAMBLE_SIZE);

            if (ret != size - FLIC_PREAMBLE_SIZE) {

                av_free_packet(pkt);

                ret = AVERROR_IO;

            }

            flic->pts += flic->frame_pts_inc;

            packet_read = 1;

        } else {

            

            url_fseek(pb, size - 6, SEEK_CUR);

        }

    }



    return ret;

}

        if ((magic == FLIC_CHUNK_MAGIC_1) || (magic == FLIC_CHUNK_MAGIC_2)) {
static int FUNC_0(AVFormatContext *VAR_0,

                            AVPacket *VAR_1)

{

    FlicDemuxContext *flic = (FlicDemuxContext *)VAR_0->priv_data;

    ByteIOContext *pb = &VAR_0->pb;

    int VAR_2 = 0;

    unsigned int VAR_3;

    int VAR_4;

    int VAR_5 = 0;

    unsigned char VAR_6[FLIC_PREAMBLE_SIZE];



    while (!VAR_2) {



        if ((VAR_5 = get_buffer(pb, VAR_6, FLIC_PREAMBLE_SIZE)) !=

            FLIC_PREAMBLE_SIZE) {

            VAR_5 = AVERROR_IO;

            break;

        }



        VAR_3 = LE_32(&VAR_6[0]);

        VAR_4 = LE_16(&VAR_6[4]);



        if ((VAR_4 == FLIC_CHUNK_MAGIC_1) || (VAR_4 == FLIC_CHUNK_MAGIC_2)) {

            if (av_new_packet(VAR_1, VAR_3)) {

                VAR_5 = AVERROR_IO;

                break;

            }

            VAR_1->stream_index = flic->video_stream_index;

            VAR_1->pts = flic->pts;

            memcpy(VAR_1->data, VAR_6, FLIC_PREAMBLE_SIZE);

            VAR_5 = get_buffer(pb, VAR_1->data + FLIC_PREAMBLE_SIZE, 

                VAR_3 - FLIC_PREAMBLE_SIZE);

            if (VAR_5 != VAR_3 - FLIC_PREAMBLE_SIZE) {

                av_free_packet(VAR_1);

                VAR_5 = AVERROR_IO;

            }

            flic->pts += flic->frame_pts_inc;

            VAR_2 = 1;

        } else {

            

            url_fseek(pb, VAR_3 - 6, SEEK_CUR);

        }

    }



    return VAR_5;

}

static int FUNC_0(AVFormatContext *VAR_0,
AVPacket *VAR_1)
{ FlicDemuxContext *flic = (FlicDemuxContext *)VAR_0->priv_data; ByteIOContext *pb = &VAR_0->pb; int VAR_2 = 0; unsigned int VAR_3; int VAR_4; int VAR_5 = 0; unsigned char VAR_6[FLIC_PREAMBLE_SIZE]; while (!VAR_2) { if ((VAR_5 = get_buffer(pb, VAR_6, FLIC_PREAMBLE_SIZE)) !=
FLIC_PREAMBLE_SIZE) { VAR_5 = AVERROR_IO; break; } VAR_3 = LE_32(&VAR_6[0]); VAR_4 = LE_16(&VAR_6[4]); if ((VAR_4 == FLIC_CHUNK_MAGIC_1) || (VAR_4 == FLIC_CHUNK_MAGIC_2)) { if (av_new_packet(VAR_1, VAR_3)) { VAR_5 = AVERROR_IO; break; } VAR_1->stream_index = flic->video_stream_index; VAR_1->pts = flic->pts; memcpy(VAR_1->data, VAR_6, FLIC_PREAMBLE_SIZE); VAR_5 = get_buffer(pb, VAR_1->data + FLIC_PREAMBLE_SIZE,
VAR_3 - FLIC_PREAMBLE_SIZE); if (VAR_5 != VAR_3 - FLIC_PREAMBLE_SIZE) { av_free_packet(VAR_1); VAR_5 = AVERROR_IO; } flic->pts += flic->frame_pts_inc; VAR_2 = 1; } else { url_fseek(pb, VAR_3 - 6, SEEK_CUR); } } return VAR_5; }