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