int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)

{

    int len, tag;

    int object_type_id = avio_r8(pb);

    avio_r8(pb); /* stream type */

    avio_rb24(pb); /* buffer size db */

    avio_rb32(pb); /* max bitrate */

    avio_rb32(pb); /* avg bitrate */



    if(avcodec_is_open(st->codec)) {

        av_log(fc, AV_LOG_DEBUG, "codec open in read_dec_config_descr\n");

        return -1;

    }



    st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id);

    av_dlog(fc, "esds object type id 0x%02x\n", object_type_id);

    len = ff_mp4_read_descr(fc, pb, &tag);

    if (tag == MP4DecSpecificDescrTag) {

        av_dlog(fc, "Specific MPEG4 header len=%d\n", len);

        if (!len || (uint64_t)len > (1<<30))

            return -1;

        av_free(st->codec->extradata);

        if (ff_alloc_extradata(st->codec, len))

            return AVERROR(ENOMEM);

        avio_read(pb, st->codec->extradata, len);

        if (st->codec->codec_id == AV_CODEC_ID_AAC) {

            MPEG4AudioConfig cfg = {0};

            avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,

                                         st->codec->extradata_size * 8, 1);

            st->codec->channels = cfg.channels;

            if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4

                st->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];

            else if (cfg.ext_sample_rate)

                st->codec->sample_rate = cfg.ext_sample_rate;

            else

                st->codec->sample_rate = cfg.sample_rate;

            av_dlog(fc, "mp4a config channels %d obj %d ext obj %d "

                    "sample rate %d ext sample rate %d\n", st->codec->channels,

                    cfg.object_type, cfg.ext_object_type,

                    cfg.sample_rate, cfg.ext_sample_rate);

            if (!(st->codec->codec_id = ff_codec_get_id(mp4_audio_types,

                                                        cfg.object_type)))

                st->codec->codec_id = AV_CODEC_ID_AAC;

        }

    }

    return 0;

}

int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)

{

    int len, tag;

    int object_type_id = avio_r8(pb);

    avio_r8(pb); 

    avio_rb24(pb); 

    avio_rb32(pb); 

    avio_rb32(pb); 



    if(avcodec_is_open(st->codec)) {

        av_log(fc, AV_LOG_DEBUG, "codec open in read_dec_config_descr\n");

        return -1;

    }



    st->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id);

    av_dlog(fc, "esds object type id 0x%02x\n", object_type_id);

    len = ff_mp4_read_descr(fc, pb, &tag);

    if (tag == MP4DecSpecificDescrTag) {

        av_dlog(fc, "Specific MPEG4 header len=%d\n", len);

        if (!len || (uint64_t)len > (1<<30))

            return -1;

        av_free(st->codec->extradata);

        if (ff_alloc_extradata(st->codec, len))

            return AVERROR(ENOMEM);

        avio_read(pb, st->codec->extradata, len);

        if (st->codec->codec_id == AV_CODEC_ID_AAC) {

            MPEG4AudioConfig cfg = {0};

            avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,

                                         st->codec->extradata_size * 8, 1);

            st->codec->channels = cfg.channels;

            if (cfg.object_type == 29 && cfg.sampling_index < 3) 

                st->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];

            else if (cfg.ext_sample_rate)

                st->codec->sample_rate = cfg.ext_sample_rate;

            else

                st->codec->sample_rate = cfg.sample_rate;

            av_dlog(fc, "mp4a config channels %d obj %d ext obj %d "

                    "sample rate %d ext sample rate %d\n", st->codec->channels,

                    cfg.object_type, cfg.ext_object_type,

                    cfg.sample_rate, cfg.ext_sample_rate);

            if (!(st->codec->codec_id = ff_codec_get_id(mp4_audio_types,

                                                        cfg.object_type)))

                st->codec->codec_id = AV_CODEC_ID_AAC;

        }

    }

    return 0;

}

        avio_read(pb, st->codec->extradata, len);
int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, AVIOContext *VAR_2)

{

    int VAR_3, VAR_4;

    int VAR_5 = avio_r8(VAR_2);

    avio_r8(VAR_2); 

    avio_rb24(VAR_2); 

    avio_rb32(VAR_2); 

    avio_rb32(VAR_2); 



    if(avcodec_is_open(VAR_1->codec)) {

        av_log(VAR_0, AV_LOG_DEBUG, "codec open in read_dec_config_descr\n");

        return -1;

    }



    VAR_1->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, VAR_5);

    av_dlog(VAR_0, "esds object type id 0x%02x\n", VAR_5);

    VAR_3 = ff_mp4_read_descr(VAR_0, VAR_2, &VAR_4);

    if (VAR_4 == MP4DecSpecificDescrTag) {

        av_dlog(VAR_0, "Specific MPEG4 header VAR_3=%d\n", VAR_3);

        if (!VAR_3 || (uint64_t)VAR_3 > (1<<30))

            return -1;

        av_free(VAR_1->codec->extradata);

        if (ff_alloc_extradata(VAR_1->codec, VAR_3))

            return AVERROR(ENOMEM);

        avio_read(VAR_2, VAR_1->codec->extradata, VAR_3);

        if (VAR_1->codec->codec_id == AV_CODEC_ID_AAC) {

            MPEG4AudioConfig cfg = {0};

            avpriv_mpeg4audio_get_config(&cfg, VAR_1->codec->extradata,

                                         VAR_1->codec->extradata_size * 8, 1);

            VAR_1->codec->channels = cfg.channels;

            if (cfg.object_type == 29 && cfg.sampling_index < 3) 

                VAR_1->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];

            else if (cfg.ext_sample_rate)

                VAR_1->codec->sample_rate = cfg.ext_sample_rate;

            else

                VAR_1->codec->sample_rate = cfg.sample_rate;

            av_dlog(VAR_0, "mp4a config channels %d obj %d ext obj %d "

                    "sample rate %d ext sample rate %d\n", VAR_1->codec->channels,

                    cfg.object_type, cfg.ext_object_type,

                    cfg.sample_rate, cfg.ext_sample_rate);

            if (!(VAR_1->codec->codec_id = ff_codec_get_id(mp4_audio_types,

                                                        cfg.object_type)))

                VAR_1->codec->codec_id = AV_CODEC_ID_AAC;

        }

    }

    return 0;

}

int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, AVIOContext *VAR_2)
{ int VAR_3, VAR_4; int VAR_5 = avio_r8(VAR_2); avio_r8(VAR_2); avio_rb24(VAR_2); avio_rb32(VAR_2); avio_rb32(VAR_2); if(avcodec_is_open(VAR_1->codec)) { av_log(VAR_0, AV_LOG_DEBUG, "codec open in read_dec_config_descr\n"); return -1; } VAR_1->codec->codec_id= ff_codec_get_id(ff_mp4_obj_type, VAR_5); av_dlog(VAR_0, "esds object type id 0x%02x\n", VAR_5); VAR_3 = ff_mp4_read_descr(VAR_0, VAR_2, &VAR_4); if (VAR_4 == MP4DecSpecificDescrTag) { av_dlog(VAR_0, "Specific MPEG4 header VAR_3=%d\n", VAR_3); if (!VAR_3 || (uint64_t)VAR_3 > (1<<30))
return -1; av_free(VAR_1->codec->extradata); if (ff_alloc_extradata(VAR_1->codec, VAR_3))
return AVERROR(ENOMEM); avio_read(VAR_2, VAR_1->codec->extradata, VAR_3); if (VAR_1->codec->codec_id == AV_CODEC_ID_AAC) { MPEG4AudioConfig cfg = {0}; avpriv_mpeg4audio_get_config(&cfg, VAR_1->codec->extradata,
VAR_1->codec->extradata_size * 8, 1); VAR_1->codec->channels = cfg.channels; if (cfg.object_type == 29 && cfg.sampling_index < 3)
VAR_1->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index]; else if (cfg.ext_sample_rate)
VAR_1->codec->sample_rate = cfg.ext_sample_rate; else
VAR_1->codec->sample_rate = cfg.sample_rate; av_dlog(VAR_0, "mp4a config channels %d obj %d ext obj %d "
"sample rate %d ext sample rate %d\n", VAR_1->codec->channels,
cfg.object_type, cfg.ext_object_type,
cfg.sample_rate, cfg.ext_sample_rate); if (!(VAR_1->codec->codec_id = ff_codec_get_id(mp4_audio_types,
cfg.object_type)))
VAR_1->codec->codec_id = AV_CODEC_ID_AAC; } } return 0; }