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

{

    int64_t end = avio_tell(pb) + atom.size;

    uint8_t *key = NULL, *val = NULL, *mean = NULL;

    int i;

    AVStream *st;

    MOVStreamContext *sc;



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

        return 0;

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

    sc = st->priv_data;



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

        uint8_t **p;

        uint32_t len, tag;

        int ret;



        if (end - avio_tell(pb) <= 12)

            break;



        len = avio_rb32(pb);

        tag = avio_rl32(pb);

        avio_skip(pb, 4); // flags



        if (len < 12 || len - 12 > end - avio_tell(pb))

            break;

        len -= 12;



        if (tag == MKTAG('m', 'e', 'a', 'n'))

            p = &mean;

        else if (tag == MKTAG('n', 'a', 'm', 'e'))

            p = &key;

        else if (tag == MKTAG('d', 'a', 't', 'a') && len > 4) {

            avio_skip(pb, 4);

            len -= 4;

            p = &val;

        } else

            break;



        *p = av_malloc(len + 1);

        if (!*p)

            break;

        ret = ffio_read_size(pb, *p, len);

        if (ret < 0) {

            av_freep(p);

            return ret;

        }

        (*p)[len] = 0;

    }



    if (mean && key && val) {

        if (strcmp(key, "iTunSMPB") == 0) {

            int priming, remainder, samples;

            if(sscanf(val, "%*X %X %X %X", &priming, &remainder, &samples) == 3){

                if(priming>0 && priming<16384)

                    sc->start_pad = priming;

            }

        }

        if (strcmp(key, "cdec") != 0) {

            av_dict_set(&c->fc->metadata, key, val,

                        AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);

            key = val = NULL;

        }

    } else {

        av_log(c->fc, AV_LOG_VERBOSE,

               "Unhandled or malformed custom metadata of size %"PRId64"\n", atom.size);

    }



    avio_seek(pb, end, SEEK_SET);

    av_freep(&key);

    av_freep(&val);

    av_freep(&mean);

    return 0;

}

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

{

    int64_t end = avio_tell(pb) + atom.size;

    uint8_t *key = NULL, *val = NULL, *mean = NULL;

    int i;

    AVStream *st;

    MOVStreamContext *sc;



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

        return 0;

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

    sc = st->priv_data;



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

        uint8_t **p;

        uint32_t len, tag;

        int ret;



        if (end - avio_tell(pb) <= 12)

            break;



        len = avio_rb32(pb);

        tag = avio_rl32(pb);

        avio_skip(pb, 4); 



        if (len < 12 || len - 12 > end - avio_tell(pb))

            break;

        len -= 12;



        if (tag == MKTAG('m', 'e', 'a', 'n'))

            p = &mean;

        else if (tag == MKTAG('n', 'a', 'm', 'e'))

            p = &key;

        else if (tag == MKTAG('d', 'a', 't', 'a') && len > 4) {

            avio_skip(pb, 4);

            len -= 4;

            p = &val;

        } else

            break;



        *p = av_malloc(len + 1);

        if (!*p)

            break;

        ret = ffio_read_size(pb, *p, len);

        if (ret < 0) {

            av_freep(p);

            return ret;

        }

        (*p)[len] = 0;

    }



    if (mean && key && val) {

        if (strcmp(key, "iTunSMPB") == 0) {

            int priming, remainder, samples;

            if(sscanf(val, "%*X %X %X %X", &priming, &remainder, &samples) == 3){

                if(priming>0 && priming<16384)

                    sc->start_pad = priming;

            }

        }

        if (strcmp(key, "cdec") != 0) {

            av_dict_set(&c->fc->metadata, key, val,

                        AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);

            key = val = NULL;

        }

    } else {

        av_log(c->fc, AV_LOG_VERBOSE,

               "Unhandled or malformed custom metadata of size %"PRId64"\n", atom.size);

    }



    avio_seek(pb, end, SEEK_SET);

    av_freep(&key);

    av_freep(&val);

    av_freep(&mean);

    return 0;

}

        int ret;             return ret;     return 0;
static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)

{

    int64_t end = avio_tell(VAR_1) + VAR_2.size;

    uint8_t *key = NULL, *val = NULL, *mean = NULL;

    int VAR_3;

    AVStream *st;

    MOVStreamContext *sc;



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

        return 0;

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

    sc = st->priv_data;



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

        uint8_t **p;

        uint32_t len, tag;

        int VAR_4;



        if (end - avio_tell(VAR_1) <= 12)

            break;



        len = avio_rb32(VAR_1);

        tag = avio_rl32(VAR_1);

        avio_skip(VAR_1, 4); 



        if (len < 12 || len - 12 > end - avio_tell(VAR_1))

            break;

        len -= 12;



        if (tag == MKTAG('m', 'e', 'a', 'n'))

            p = &mean;

        else if (tag == MKTAG('n', 'a', 'm', 'e'))

            p = &key;

        else if (tag == MKTAG('d', 'a', 't', 'a') && len > 4) {

            avio_skip(VAR_1, 4);

            len -= 4;

            p = &val;

        } else

            break;



        *p = av_malloc(len + 1);

        if (!*p)

            break;

        VAR_4 = ffio_read_size(VAR_1, *p, len);

        if (VAR_4 < 0) {

            av_freep(p);

            return VAR_4;

        }

        (*p)[len] = 0;

    }



    if (mean && key && val) {

        if (strcmp(key, "iTunSMPB") == 0) {

            int VAR_5, VAR_6, VAR_7;

            if(sscanf(val, "%*X %X %X %X", &VAR_5, &VAR_6, &VAR_7) == 3){

                if(VAR_5>0 && VAR_5<16384)

                    sc->start_pad = VAR_5;

            }

        }

        if (strcmp(key, "cdec") != 0) {

            av_dict_set(&VAR_0->fc->metadata, key, val,

                        AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);

            key = val = NULL;

        }

    } else {

        av_log(VAR_0->fc, AV_LOG_VERBOSE,

               "Unhandled or malformed custom metadata of size %"PRId64"\n", VAR_2.size);

    }



    avio_seek(VAR_1, end, SEEK_SET);

    av_freep(&key);

    av_freep(&val);

    av_freep(&mean);

    return 0;

}

static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)
{ int64_t end = avio_tell(VAR_1) + VAR_2.size; uint8_t *key = NULL, *val = NULL, *mean = NULL; int VAR_3; AVStream *st; MOVStreamContext *sc; if (VAR_0->fc->nb_streams < 1)
return 0; st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1]; sc = st->priv_data; for (VAR_3 = 0; VAR_3 < 3; VAR_3++) { uint8_t **p; uint32_t len, tag; int VAR_4; if (end - avio_tell(VAR_1) <= 12)
break; len = avio_rb32(VAR_1); tag = avio_rl32(VAR_1); avio_skip(VAR_1, 4); if (len < 12 || len - 12 > end - avio_tell(VAR_1))
break; len -= 12; if (tag == MKTAG('m', 'e', 'a', 'n'))
p = &mean; else if (tag == MKTAG('n', 'a', 'm', 'e'))
p = &key; else if (tag == MKTAG('d', 'a', 't', 'a') && len > 4) { avio_skip(VAR_1, 4); len -= 4; p = &val; } else break; *p = av_malloc(len + 1); if (!*p)
break; VAR_4 = ffio_read_size(VAR_1, *p, len); if (VAR_4 < 0) { av_freep(p); return VAR_4; } (*p)[len] = 0; } if (mean && key && val) { if (strcmp(key, "iTunSMPB") == 0) { int VAR_5, VAR_6, VAR_7; if(sscanf(val, "%*X %X %X %X", &VAR_5, &VAR_6, &VAR_7) == 3){ if(VAR_5>0 && VAR_5<16384)
sc->start_pad = VAR_5; } } if (strcmp(key, "cdec") != 0) { av_dict_set(&VAR_0->fc->metadata, key, val,
AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); key = val = NULL; } } else { av_log(VAR_0->fc, AV_LOG_VERBOSE,
"Unhandled or malformed custom metadata of size %"PRId64"\n", VAR_2.size); } avio_seek(VAR_1, end, SEEK_SET); av_freep(&key); av_freep(&val); av_freep(&mean); return 0; }