static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)

{

    AVStream *st;

    MOVStreamContext *sc;

    unsigned int i, entries;



    if (c->fc->nb_streams < 1)

        return 0;

    st = c->fc->streams[c->fc->nb_streams-1];

    sc = st->priv_data;



    avio_r8(pb); /* version */

    avio_rb24(pb); /* flags */



    entries = avio_rb32(pb);



    if (!entries)

        return 0;

    if (entries >= UINT_MAX/sizeof(int64_t))

        return AVERROR_INVALIDDATA;



    sc->chunk_offsets = av_malloc(entries * sizeof(int64_t));

    if (!sc->chunk_offsets)

        return AVERROR(ENOMEM);

    sc->chunk_count = entries;



    if      (atom.type == MKTAG('s','t','c','o'))

        for (i=0; i<entries; i++)

            sc->chunk_offsets[i] = avio_rb32(pb);

    else if (atom.type == MKTAG('c','o','6','4'))

        for (i=0; i<entries; i++)

            sc->chunk_offsets[i] = avio_rb64(pb);

    else

        return AVERROR_INVALIDDATA;



    return 0;

}

static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)

{

    AVStream *st;

    MOVStreamContext *sc;

    unsigned int i, entries;



    if (c->fc->nb_streams < 1)

        return 0;

    st = c->fc->streams[c->fc->nb_streams-1];

    sc = st->priv_data;



    avio_r8(pb); 

    avio_rb24(pb); 



    entries = avio_rb32(pb);



    if (!entries)

        return 0;

    if (entries >= UINT_MAX/sizeof(int64_t))

        return AVERROR_INVALIDDATA;



    sc->chunk_offsets = av_malloc(entries * sizeof(int64_t));

    if (!sc->chunk_offsets)

        return AVERROR(ENOMEM);

    sc->chunk_count = entries;



    if      (atom.type == MKTAG('s','t','c','o'))

        for (i=0; i<entries; i++)

            sc->chunk_offsets[i] = avio_rb32(pb);

    else if (atom.type == MKTAG('c','o','6','4'))

        for (i=0; i<entries; i++)

            sc->chunk_offsets[i] = avio_rb64(pb);

    else

        return AVERROR_INVALIDDATA;



    return 0;

}

static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)

{

    AVStream *st;

    MOVStreamContext *sc;

    unsigned int VAR_3, VAR_4;



    if (VAR_0->fc->nb_streams < 1)

        return 0;

    st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];

    sc = st->priv_data;



    avio_r8(VAR_1); 

    avio_rb24(VAR_1); 



    VAR_4 = avio_rb32(VAR_1);



    if (!VAR_4)

        return 0;

    if (VAR_4 >= UINT_MAX/sizeof(int64_t))

        return AVERROR_INVALIDDATA;



    sc->chunk_offsets = av_malloc(VAR_4 * sizeof(int64_t));

    if (!sc->chunk_offsets)

        return AVERROR(ENOMEM);

    sc->chunk_count = VAR_4;



    if      (VAR_2.type == MKTAG('s','t','VAR_0','o'))

        for (VAR_3=0; VAR_3<VAR_4; VAR_3++)

            sc->chunk_offsets[VAR_3] = avio_rb32(VAR_1);

    else if (VAR_2.type == MKTAG('VAR_0','o','6','4'))

        for (VAR_3=0; VAR_3<VAR_4; VAR_3++)

            sc->chunk_offsets[VAR_3] = avio_rb64(VAR_1);

    else

        return AVERROR_INVALIDDATA;



    return 0;

}

static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)
{ AVStream *st; MOVStreamContext *sc; unsigned int VAR_3, VAR_4; if (VAR_0->fc->nb_streams < 1)
return 0; st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1]; sc = st->priv_data; avio_r8(VAR_1); avio_rb24(VAR_1); VAR_4 = avio_rb32(VAR_1); if (!VAR_4)
return 0; if (VAR_4 >= UINT_MAX/sizeof(int64_t))
return AVERROR_INVALIDDATA; sc->chunk_offsets = av_malloc(VAR_4 * sizeof(int64_t)); if (!sc->chunk_offsets)
return AVERROR(ENOMEM); sc->chunk_count = VAR_4; if      (VAR_2.type == MKTAG('s','t','VAR_0','o'))
for (VAR_3=0; VAR_3<VAR_4; VAR_3++) sc->chunk_offsets[VAR_3] = avio_rb32(VAR_1); else if (VAR_2.type == MKTAG('VAR_0','o','6','4'))
for (VAR_3=0; VAR_3<VAR_4; VAR_3++) sc->chunk_offsets[VAR_3] = avio_rb64(VAR_1); else
return AVERROR_INVALIDDATA; return 0; }