diff options
author | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-10 20:58:15 +0100 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-10 20:59:55 +0100 |
commit | 6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 (patch) | |
tree | 0c2ec8349ff1763d5f48454b8b9f26374dbd80b0 /libavformat/genh.c | |
parent | 60b75186b2c878b6257b43c8fcc0b1356ada218e (diff) | |
parent | 9200514ad8717c63f82101dc394f4378854325bf (diff) | |
download | ffmpeg-6f69f7a8bf6a0d013985578df2ef42ee6b1c7994.tar.gz |
Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf':
lavf: replace AVStream.codec with AVStream.codecpar
This has been a HUGE effort from:
- Derek Buitenhuis <derek.buitenhuis@gmail.com>
- Hendrik Leppkes <h.leppkes@gmail.com>
- wm4 <nfxjfg@googlemail.com>
- Clément Bœsch <clement@stupeflix.com>
- James Almer <jamrial@gmail.com>
- Michael Niedermayer <michael@niedermayer.cc>
- Rostislav Pehlivanov <atomnuker@gmail.com>
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavformat/genh.c')
-rw-r--r-- | libavformat/genh.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/libavformat/genh.c b/libavformat/genh.c index cb1a02f277..b683e026d1 100644 --- a/libavformat/genh.c +++ b/libavformat/genh.c @@ -52,50 +52,50 @@ static int genh_read_header(AVFormatContext *s) if (!st) return AVERROR(ENOMEM); - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->channels = avio_rl32(s->pb); - if (st->codec->channels <= 0) + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->channels = avio_rl32(s->pb); + if (st->codecpar->channels <= 0) return AVERROR_INVALIDDATA; - if (st->codec->channels == 1) - st->codec->channel_layout = AV_CH_LAYOUT_MONO; - else if (st->codec->channels == 2) - st->codec->channel_layout = AV_CH_LAYOUT_STEREO; + if (st->codecpar->channels == 1) + st->codecpar->channel_layout = AV_CH_LAYOUT_MONO; + else if (st->codecpar->channels == 2) + st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO; align = c->interleave_size = avio_rl32(s->pb); - if (align < 0 || align > INT_MAX / st->codec->channels) + if (align < 0 || align > INT_MAX / st->codecpar->channels) return AVERROR_INVALIDDATA; - st->codec->block_align = align * st->codec->channels; - st->codec->sample_rate = avio_rl32(s->pb); + st->codecpar->block_align = align * st->codecpar->channels; + st->codecpar->sample_rate = avio_rl32(s->pb); avio_skip(s->pb, 4); st->duration = avio_rl32(s->pb); codec = avio_rl32(s->pb); switch (codec) { - case 0: st->codec->codec_id = AV_CODEC_ID_ADPCM_PSX; break; + case 0: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX; break; case 1: - case 11: st->codec->bits_per_coded_sample = 4; - st->codec->block_align = 36 * st->codec->channels; - st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_WAV; break; - case 2: st->codec->codec_id = AV_CODEC_ID_ADPCM_DTK; break; - case 3: st->codec->codec_id = st->codec->block_align > 0 ? + case 11: st->codecpar->bits_per_coded_sample = 4; + st->codecpar->block_align = 36 * st->codecpar->channels; + st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_WAV; break; + case 2: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_DTK; break; + case 3: st->codecpar->codec_id = st->codecpar->block_align > 0 ? AV_CODEC_ID_PCM_S16BE_PLANAR : AV_CODEC_ID_PCM_S16BE; break; - case 4: st->codec->codec_id = st->codec->block_align > 0 ? + case 4: st->codecpar->codec_id = st->codecpar->block_align > 0 ? AV_CODEC_ID_PCM_S16LE_PLANAR : AV_CODEC_ID_PCM_S16LE; break; - case 5: st->codec->codec_id = st->codec->block_align > 0 ? + case 5: st->codecpar->codec_id = st->codecpar->block_align > 0 ? AV_CODEC_ID_PCM_S8_PLANAR : AV_CODEC_ID_PCM_S8; break; - case 6: st->codec->codec_id = AV_CODEC_ID_SDX2_DPCM; break; - case 7: ret = ff_alloc_extradata(st->codec, 2); + case 6: st->codecpar->codec_id = AV_CODEC_ID_SDX2_DPCM; break; + case 7: ret = ff_alloc_extradata(st->codecpar, 2); if (ret < 0) return ret; - AV_WL16(st->codec->extradata, 3); - st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_WS; break; - case 10: st->codec->codec_id = AV_CODEC_ID_ADPCM_AICA; break; - case 12: st->codec->codec_id = AV_CODEC_ID_ADPCM_THP; break; - case 13: st->codec->codec_id = AV_CODEC_ID_PCM_U8; break; - case 17: st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_QT; break; + AV_WL16(st->codecpar->extradata, 3); + st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_WS; break; + case 10: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_AICA; break; + case 12: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_THP; break; + case 13: st->codecpar->codec_id = AV_CODEC_ID_PCM_U8; break; + case 17: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_QT; break; default: avpriv_request_sample(s, "codec %d", codec); return AVERROR_PATCHWELCOME; @@ -117,25 +117,25 @@ static int genh_read_header(AVFormatContext *s) coef_splitted[0] = avio_rl32(s->pb); coef_splitted[1] = avio_rl32(s->pb); - if (st->codec->codec_id == AV_CODEC_ID_ADPCM_THP) { - if (st->codec->channels > 2) { - avpriv_request_sample(s, "channels %d>2", st->codec->channels); + if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_THP) { + if (st->codecpar->channels > 2) { + avpriv_request_sample(s, "channels %d>2", st->codecpar->channels); return AVERROR_PATCHWELCOME; } - ff_alloc_extradata(st->codec, 32 * st->codec->channels); - for (ch = 0; ch < st->codec->channels; ch++) { + ff_alloc_extradata(st->codecpar, 32 * st->codecpar->channels); + for (ch = 0; ch < st->codecpar->channels; ch++) { if (coef_type & 1) { avpriv_request_sample(s, "coef_type & 1"); return AVERROR_PATCHWELCOME; } else { avio_seek(s->pb, coef[ch], SEEK_SET); - avio_read(s->pb, st->codec->extradata + 32 * ch, 32); + avio_read(s->pb, st->codecpar->extradata + 32 * ch, 32); } } if (c->dsp_int_type == 1) { - st->codec->block_align = 8 * st->codec->channels; + st->codecpar->block_align = 8 * st->codecpar->channels; if (c->interleave_size != 1 && c->interleave_size != 2 && c->interleave_size != 4) @@ -145,38 +145,38 @@ static int genh_read_header(AVFormatContext *s) avio_skip(s->pb, start_offset - avio_tell(s->pb)); - avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); + avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); return 0; } static int genh_read_packet(AVFormatContext *s, AVPacket *pkt) { - AVCodecContext *codec = s->streams[0]->codec; + AVCodecParameters *par = s->streams[0]->codecpar; GENHDemuxContext *c = s->priv_data; int ret; - if (c->dsp_int_type == 1 && codec->codec_id == AV_CODEC_ID_ADPCM_THP && - codec->channels > 1) { + if (c->dsp_int_type == 1 && par->codec_id == AV_CODEC_ID_ADPCM_THP && + par->channels > 1) { int i, ch; if (avio_feof(s->pb)) return AVERROR_EOF; - ret = av_new_packet(pkt, 8 * codec->channels); + ret = av_new_packet(pkt, 8 * par->channels); if (ret < 0) return ret; for (i = 0; i < 8 / c->interleave_size; i++) { - for (ch = 0; ch < codec->channels; ch++) { + for (ch = 0; ch < par->channels; ch++) { pkt->data[ch * 8 + i*c->interleave_size+0] = avio_r8(s->pb); pkt->data[ch * 8 + i*c->interleave_size+1] = avio_r8(s->pb); } } ret = 0; - } else if (codec->codec_id == AV_CODEC_ID_SDX2_DPCM) { - ret = av_get_packet(s->pb, pkt, codec->block_align * 1024); + } else if (par->codec_id == AV_CODEC_ID_SDX2_DPCM) { + ret = av_get_packet(s->pb, pkt, par->block_align * 1024); } else { - ret = av_get_packet(s->pb, pkt, codec->block_align ? codec->block_align : 1024 * codec->channels); + ret = av_get_packet(s->pb, pkt, par->block_align ? par->block_align : 1024 * par->channels); } pkt->stream_index = 0; |