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

{

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

    MOVStreamContext *sc = st->priv_data;

    int entries, i, j;



    get_be32(pb); // version + flags

    entries = get_be32(pb);

    if (entries >= UINT_MAX / sizeof(*sc->drefs))

        return -1;

    sc->drefs_count = entries;

    sc->drefs = av_mallocz(entries * sizeof(*sc->drefs));



    for (i = 0; i < sc->drefs_count; i++) {

        MOV_dref_t *dref = &sc->drefs[i];

        uint32_t size = get_be32(pb);

        offset_t next = url_ftell(pb) + size - 4;



        dref->type = get_le32(pb);

        get_be32(pb); // version + flags

        dprintf(c->fc, "type %.4s size %d\n", (char*)&dref->type, size);



        if (dref->type == MKTAG('a','l','i','s') && size > 150) {

            /* macintosh alias record */

            uint16_t volume_len, len;

            char volume[28];

            int16_t type;



            url_fskip(pb, 10);



            volume_len = get_byte(pb);

            volume_len = FFMIN(volume_len, 27);

            get_buffer(pb, volume, 27);

            volume[volume_len] = 0;

            av_log(c->fc, AV_LOG_DEBUG, "volume %s, len %d\n", volume, volume_len);



            url_fskip(pb, 112);



            for (type = 0; type != -1 && url_ftell(pb) < next; ) {

                type = get_be16(pb);

                len = get_be16(pb);

                av_log(c->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len);

                if (len&1)

                    len += 1;

                if (type == 2) { // absolute path

                    dref->path = av_mallocz(len+1);

                    get_buffer(pb, dref->path, len);

                    if (!strncmp(dref->path, volume, volume_len)) {

                        len -= volume_len;

                        memmove(dref->path, dref->path+volume_len, len);

                        dref->path[len] = 0;

                    }

                    for (j = 0; j < len; j++)

                        if (dref->path[j] == ':')

                            dref->path[j] = '/';

                    av_log(c->fc, AV_LOG_DEBUG, "path %s\n", dref->path);

                } else

                    url_fskip(pb, len);

            }

        }

        url_fseek(pb, next, SEEK_SET);

    }

    return 0;

}

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

{

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

    MOVStreamContext *sc = st->priv_data;

    int entries, i, j;



    get_be32(pb); 

    entries = get_be32(pb);

    if (entries >= UINT_MAX / sizeof(*sc->drefs))

        return -1;

    sc->drefs_count = entries;

    sc->drefs = av_mallocz(entries * sizeof(*sc->drefs));



    for (i = 0; i < sc->drefs_count; i++) {

        MOV_dref_t *dref = &sc->drefs[i];

        uint32_t size = get_be32(pb);

        offset_t next = url_ftell(pb) + size - 4;



        dref->type = get_le32(pb);

        get_be32(pb); 

        dprintf(c->fc, "type %.4s size %d\n", (char*)&dref->type, size);



        if (dref->type == MKTAG('a','l','i','s') && size > 150) {

            

            uint16_t volume_len, len;

            char volume[28];

            int16_t type;



            url_fskip(pb, 10);



            volume_len = get_byte(pb);

            volume_len = FFMIN(volume_len, 27);

            get_buffer(pb, volume, 27);

            volume[volume_len] = 0;

            av_log(c->fc, AV_LOG_DEBUG, "volume %s, len %d\n", volume, volume_len);



            url_fskip(pb, 112);



            for (type = 0; type != -1 && url_ftell(pb) < next; ) {

                type = get_be16(pb);

                len = get_be16(pb);

                av_log(c->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len);

                if (len&1)

                    len += 1;

                if (type == 2) { 

                    dref->path = av_mallocz(len+1);

                    get_buffer(pb, dref->path, len);

                    if (!strncmp(dref->path, volume, volume_len)) {

                        len -= volume_len;

                        memmove(dref->path, dref->path+volume_len, len);

                        dref->path[len] = 0;

                    }

                    for (j = 0; j < len; j++)

                        if (dref->path[j] == ':')

                            dref->path[j] = '/';

                    av_log(c->fc, AV_LOG_DEBUG, "path %s\n", dref->path);

                } else

                    url_fskip(pb, len);

            }

        }

        url_fseek(pb, next, SEEK_SET);

    }

    return 0;

}

                    if (!strncmp(dref->path, volume, volume_len)) {
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;

    int VAR_3, VAR_4, VAR_5;



    get_be32(VAR_1); 

    VAR_3 = get_be32(VAR_1);

    if (VAR_3 >= UINT_MAX / sizeof(*sc->drefs))

        return -1;

    sc->drefs_count = VAR_3;

    sc->drefs = av_mallocz(VAR_3 * sizeof(*sc->drefs));



    for (VAR_4 = 0; VAR_4 < sc->drefs_count; VAR_4++) {

        MOV_dref_t *dref = &sc->drefs[VAR_4];

        uint32_t size = get_be32(VAR_1);

        offset_t next = url_ftell(VAR_1) + size - 4;



        dref->type = get_le32(VAR_1);

        get_be32(VAR_1); 

        dprintf(VAR_0->fc, "type %.4s size %d\n", (char*)&dref->type, size);



        if (dref->type == MKTAG('a','l','VAR_4','s') && size > 150) {

            

            uint16_t volume_len, len;

            char volume[28];

            int16_t type;



            url_fskip(VAR_1, 10);



            volume_len = get_byte(VAR_1);

            volume_len = FFMIN(volume_len, 27);

            get_buffer(VAR_1, volume, 27);

            volume[volume_len] = 0;

            av_log(VAR_0->fc, AV_LOG_DEBUG, "volume %s, len %d\n", volume, volume_len);



            url_fskip(VAR_1, 112);



            for (type = 0; type != -1 && url_ftell(VAR_1) < next; ) {

                type = get_be16(VAR_1);

                len = get_be16(VAR_1);

                av_log(VAR_0->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len);

                if (len&1)

                    len += 1;

                if (type == 2) { 

                    dref->path = av_mallocz(len+1);

                    get_buffer(VAR_1, dref->path, len);

                    if (!strncmp(dref->path, volume, volume_len)) {

                        len -= volume_len;

                        memmove(dref->path, dref->path+volume_len, len);

                        dref->path[len] = 0;

                    }

                    for (VAR_5 = 0; VAR_5 < len; VAR_5++)

                        if (dref->path[VAR_5] == ':')

                            dref->path[VAR_5] = '/';

                    av_log(VAR_0->fc, AV_LOG_DEBUG, "path %s\n", dref->path);

                } else

                    url_fskip(VAR_1, len);

            }

        }

        url_fseek(VAR_1, next, SEEK_SET);

    }

    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; int VAR_3, VAR_4, VAR_5; get_be32(VAR_1); VAR_3 = get_be32(VAR_1); if (VAR_3 >= UINT_MAX / sizeof(*sc->drefs))
return -1; sc->drefs_count = VAR_3; sc->drefs = av_mallocz(VAR_3 * sizeof(*sc->drefs)); for (VAR_4 = 0; VAR_4 < sc->drefs_count; VAR_4++) { MOV_dref_t *dref = &sc->drefs[VAR_4]; uint32_t size = get_be32(VAR_1); offset_t next = url_ftell(VAR_1) + size - 4; dref->type = get_le32(VAR_1); get_be32(VAR_1); dprintf(VAR_0->fc, "type %.4s size %d\n", (char*)&dref->type, size); if (dref->type == MKTAG('a','l','VAR_4','s') && size > 150) { uint16_t volume_len, len; char volume[28]; int16_t type; url_fskip(VAR_1, 10); volume_len = get_byte(VAR_1); volume_len = FFMIN(volume_len, 27); get_buffer(VAR_1, volume, 27); volume[volume_len] = 0; av_log(VAR_0->fc, AV_LOG_DEBUG, "volume %s, len %d\n", volume, volume_len); url_fskip(VAR_1, 112); for (type = 0; type != -1 && url_ftell(VAR_1) < next; ) { type = get_be16(VAR_1); len = get_be16(VAR_1); av_log(VAR_0->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len); if (len&1)
len += 1; if (type == 2) { dref->path = av_mallocz(len+1); get_buffer(VAR_1, dref->path, len); if (!strncmp(dref->path, volume, volume_len)) { len -= volume_len; memmove(dref->path, dref->path+volume_len, len); dref->path[len] = 0; } for (VAR_5 = 0; VAR_5 < len; VAR_5++) if (dref->path[VAR_5] == ':')
dref->path[VAR_5] = '/'; av_log(VAR_0->fc, AV_LOG_DEBUG, "path %s\n", dref->path); } else url_fskip(VAR_1, len); } } url_fseek(VAR_1, next, SEEK_SET); } return 0; }