+ if (st->codec->codec_id == CODEC_ID_AAC ||
+ st->codec->codec_id == CODEC_ID_H264) {
+ int type = get_byte(s->pb);
+ size--;
+ if (st->codec->codec_id == CODEC_ID_H264) {
+ int32_t cts = (get_be24(s->pb)+0xff800000)^0xff800000; // sign extension
+ pts = dts + cts;
+ if (cts < 0) { // dts are wrong
+ flv->wrong_dts = 1;
+ av_log(s, AV_LOG_WARNING, "negative cts, previous timestamps might be wrong\n");
+ }
+ if (flv->wrong_dts)
+ dts = AV_NOPTS_VALUE;
+ }
+ if (type == 0) {
+ if ((ret = flv_get_extradata(s, st, size)) < 0)
+ return ret;
+ if (st->codec->codec_id == CODEC_ID_AAC) {
+ MPEG4AudioConfig cfg;
+ ff_mpeg4audio_get_config(&cfg, st->codec->extradata,
+ st->codec->extradata_size);
+ if (cfg.chan_config > 7)
+ return -1;
+ st->codec->channels = ff_mpeg4audio_channels[cfg.chan_config];
+ st->codec->sample_rate = cfg.sample_rate;
+ dprintf(s, "mp4a config channels %d sample rate %d\n",
+ st->codec->channels, st->codec->sample_rate);
+ }
+
+ return AVERROR(EAGAIN);
+ }
+ }
+
+ /* skip empty data packets */
+ if (!size)
+ return AVERROR(EAGAIN);
+
+ ret= av_get_packet(s->pb, pkt, size);
+ if (ret < 0) {