static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)

{

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

    MOVStreamContext *sc = st->priv_data;

    unsigned int i, entries;



    get_byte(pb); /* version */

    get_be24(pb); /* flags */

    entries = get_be32(pb);

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

        return -1;



    sc->ctts_count = entries;

    sc->ctts_data = av_malloc(entries * sizeof(MOV_stts_t));

    if (!sc->ctts_data)

        return -1;

    dprintf(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);



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

        int count    =get_be32(pb);

        int duration =get_be32(pb);



        if (duration < 0) {

            av_log(c->fc, AV_LOG_ERROR, "negative ctts, ignoring\n");

            sc->ctts_count = 0;

            url_fskip(pb, 8 * (entries - i - 1));

            break;

        }

        sc->ctts_data[i].count   = count;

        sc->ctts_data[i].duration= duration;



        sc->time_rate= ff_gcd(sc->time_rate, duration);

    }

    return 0;

}

static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)

{

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

    MOVStreamContext *sc = st->priv_data;

    unsigned int i, entries;



    get_byte(pb); 

    get_be24(pb); 

    entries = get_be32(pb);

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

        return -1;



    sc->ctts_count = entries;

    sc->ctts_data = av_malloc(entries * sizeof(MOV_stts_t));

    if (!sc->ctts_data)

        return -1;

    dprintf(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);



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

        int count    =get_be32(pb);

        int duration =get_be32(pb);



        if (duration < 0) {

            av_log(c->fc, AV_LOG_ERROR, "negative ctts, ignoring\n");

            sc->ctts_count = 0;

            url_fskip(pb, 8 * (entries - i - 1));

            break;

        }

        sc->ctts_data[i].count   = count;

        sc->ctts_data[i].duration= duration;



        sc->time_rate= ff_gcd(sc->time_rate, duration);

    }

    return 0;

}

static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOV_atom_t VAR_2)

{

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

    MOVStreamContext *sc = st->priv_data;

    unsigned int VAR_3, VAR_4;



    get_byte(VAR_1); 

    get_be24(VAR_1); 

    VAR_4 = get_be32(VAR_1);

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

        return -1;



    sc->ctts_count = VAR_4;

    sc->ctts_data = av_malloc(VAR_4 * sizeof(MOV_stts_t));

    if (!sc->ctts_data)

        return -1;

    dprintf(VAR_0->fc, "track[%VAR_3].ctts.VAR_4 = %VAR_3\n", VAR_0->fc->nb_streams-1, VAR_4);



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

        int VAR_5    =get_be32(VAR_1);

        int VAR_6 =get_be32(VAR_1);



        if (VAR_6 < 0) {

            av_log(VAR_0->fc, AV_LOG_ERROR, "negative ctts, ignoring\n");

            sc->ctts_count = 0;

            url_fskip(VAR_1, 8 * (VAR_4 - VAR_3 - 1));

            break;

        }

        sc->ctts_data[VAR_3].VAR_5   = VAR_5;

        sc->ctts_data[VAR_3].VAR_6= VAR_6;



        sc->time_rate= ff_gcd(sc->time_rate, VAR_6);

    }

    return 0;

}

static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOV_atom_t VAR_2)
{ AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1]; MOVStreamContext *sc = st->priv_data; unsigned int VAR_3, VAR_4; get_byte(VAR_1); get_be24(VAR_1); VAR_4 = get_be32(VAR_1); if(VAR_4 >= UINT_MAX / sizeof(MOV_stts_t))
return -1; sc->ctts_count = VAR_4; sc->ctts_data = av_malloc(VAR_4 * sizeof(MOV_stts_t)); if (!sc->ctts_data)
return -1; dprintf(VAR_0->fc, "track[%VAR_3].ctts.VAR_4 = %VAR_3\n", VAR_0->fc->nb_streams-1, VAR_4); for(VAR_3=0; VAR_3<VAR_4; VAR_3++) { int VAR_5    =get_be32(VAR_1); int VAR_6 =get_be32(VAR_1); if (VAR_6 < 0) { av_log(VAR_0->fc, AV_LOG_ERROR, "negative ctts, ignoring\n"); sc->ctts_count = 0; url_fskip(VAR_1, 8 * (VAR_4 - VAR_3 - 1)); break; } sc->ctts_data[VAR_3].VAR_5   = VAR_5; sc->ctts_data[VAR_3].VAR_6= VAR_6; sc->time_rate= ff_gcd(sc->time_rate, VAR_6); } return 0; }