summaryrefslogtreecommitdiffstats
path: root/libavformat/riffdec.c
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-10 20:58:15 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-10 20:59:55 +0100
commit6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 (patch)
tree0c2ec8349ff1763d5f48454b8b9f26374dbd80b0 /libavformat/riffdec.c
parent60b75186b2c878b6257b43c8fcc0b1356ada218e (diff)
parent9200514ad8717c63f82101dc394f4378854325bf (diff)
downloadffmpeg-streaming-6f69f7a8bf6a0d013985578df2ef42ee6b1c7994.zip
ffmpeg-streaming-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/riffdec.c')
-rw-r--r--libavformat/riffdec.c94
1 files changed, 47 insertions, 47 deletions
diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c
index 151178d..0b10832 100644
--- a/libavformat/riffdec.c
+++ b/libavformat/riffdec.c
@@ -58,27 +58,27 @@ enum AVCodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid)
* an openended structure.
*/
-static void parse_waveformatex(AVIOContext *pb, AVCodecContext *c)
+static void parse_waveformatex(AVIOContext *pb, AVCodecParameters *par)
{
ff_asf_guid subformat;
int bps = avio_rl16(pb);
if (bps)
- c->bits_per_coded_sample = bps;
+ par->bits_per_coded_sample = bps;
- c->channel_layout = avio_rl32(pb); /* dwChannelMask */
+ par->channel_layout = avio_rl32(pb); /* dwChannelMask */
ff_get_guid(pb, &subformat);
if (!memcmp(subformat + 4,
(const uint8_t[]){ FF_AMBISONIC_BASE_GUID }, 12) ||
!memcmp(subformat + 4,
(const uint8_t[]){ FF_MEDIASUBTYPE_BASE_GUID }, 12)) {
- c->codec_tag = AV_RL32(subformat);
- c->codec_id = ff_wav_codec_get_id(c->codec_tag,
- c->bits_per_coded_sample);
+ par->codec_tag = AV_RL32(subformat);
+ par->codec_id = ff_wav_codec_get_id(par->codec_tag,
+ par->bits_per_coded_sample);
} else {
- c->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subformat);
- if (!c->codec_id)
- av_log(c, AV_LOG_WARNING,
+ par->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subformat);
+ if (!par->codec_id)
+ av_log(pb, AV_LOG_WARNING,
"unknown subformat:"FF_PRI_GUID"\n",
FF_ARG_GUID(subformat));
}
@@ -86,64 +86,64 @@ static void parse_waveformatex(AVIOContext *pb, AVCodecContext *c)
/* "big_endian" values are needed for RIFX file format */
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
- AVCodecContext *codec, int size, int big_endian)
+ AVCodecParameters *par, int size, int big_endian)
{
int id;
uint64_t bitrate = 0;
if (size < 14) {
- avpriv_request_sample(codec, "wav header size < 14");
+ avpriv_request_sample(s, "wav header size < 14");
return AVERROR_INVALIDDATA;
}
- codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ par->codec_type = AVMEDIA_TYPE_AUDIO;
if (!big_endian) {
id = avio_rl16(pb);
if (id != 0x0165) {
- codec->channels = avio_rl16(pb);
- codec->sample_rate = avio_rl32(pb);
+ par->channels = avio_rl16(pb);
+ par->sample_rate = avio_rl32(pb);
bitrate = avio_rl32(pb) * 8LL;
- codec->block_align = avio_rl16(pb);
+ par->block_align = avio_rl16(pb);
}
} else {
id = avio_rb16(pb);
- codec->channels = avio_rb16(pb);
- codec->sample_rate = avio_rb32(pb);
+ par->channels = avio_rb16(pb);
+ par->sample_rate = avio_rb32(pb);
bitrate = avio_rb32(pb) * 8LL;
- codec->block_align = avio_rb16(pb);
+ par->block_align = avio_rb16(pb);
}
if (size == 14) { /* We're dealing with plain vanilla WAVEFORMAT */
- codec->bits_per_coded_sample = 8;
+ par->bits_per_coded_sample = 8;
} else {
if (!big_endian) {
- codec->bits_per_coded_sample = avio_rl16(pb);
+ par->bits_per_coded_sample = avio_rl16(pb);
} else {
- codec->bits_per_coded_sample = avio_rb16(pb);
+ par->bits_per_coded_sample = avio_rb16(pb);
}
}
if (id == 0xFFFE) {
- codec->codec_tag = 0;
+ par->codec_tag = 0;
} else {
- codec->codec_tag = id;
- codec->codec_id = ff_wav_codec_get_id(id,
- codec->bits_per_coded_sample);
+ par->codec_tag = id;
+ par->codec_id = ff_wav_codec_get_id(id,
+ par->bits_per_coded_sample);
}
if (size >= 18 && id != 0x0165) { /* We're obviously dealing with WAVEFORMATEX */
int cbSize = avio_rl16(pb); /* cbSize */
if (big_endian) {
- avpriv_report_missing_feature(codec, "WAVEFORMATEX support for RIFX files");
+ avpriv_report_missing_feature(s, "WAVEFORMATEX support for RIFX files");
return AVERROR_PATCHWELCOME;
}
size -= 18;
cbSize = FFMIN(size, cbSize);
if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */
- parse_waveformatex(pb, codec);
+ parse_waveformatex(pb, par);
cbSize -= 22;
size -= 22;
}
if (cbSize > 0) {
- av_freep(&codec->extradata);
- if (ff_get_extradata(codec, pb, cbSize) < 0)
+ av_freep(&par->extradata);
+ if (ff_get_extradata(par, pb, cbSize) < 0)
return AVERROR(ENOMEM);
size -= cbSize;
}
@@ -155,35 +155,35 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
int nb_streams, i;
size -= 4;
- av_freep(&codec->extradata);
- if (ff_get_extradata(codec, pb, size) < 0)
+ av_freep(&par->extradata);
+ if (ff_get_extradata(par, pb, size) < 0)
return AVERROR(ENOMEM);
- nb_streams = AV_RL16(codec->extradata + 4);
- codec->sample_rate = AV_RL32(codec->extradata + 12);
- codec->channels = 0;
+ nb_streams = AV_RL16(par->extradata + 4);
+ par->sample_rate = AV_RL32(par->extradata + 12);
+ par->channels = 0;
bitrate = 0;
if (size < 8 + nb_streams * 20)
return AVERROR_INVALIDDATA;
for (i = 0; i < nb_streams; i++)
- codec->channels += codec->extradata[8 + i * 20 + 17];
+ par->channels += par->extradata[8 + i * 20 + 17];
}
- codec->bit_rate = bitrate;
+ par->bit_rate = bitrate;
- if (codec->sample_rate <= 0) {
+ if (par->sample_rate <= 0) {
av_log(s, AV_LOG_ERROR,
- "Invalid sample rate: %d\n", codec->sample_rate);
+ "Invalid sample rate: %d\n", par->sample_rate);
return AVERROR_INVALIDDATA;
}
- if (codec->codec_id == AV_CODEC_ID_AAC_LATM) {
+ if (par->codec_id == AV_CODEC_ID_AAC_LATM) {
/* Channels and sample_rate values are those prior to applying SBR
* and/or PS. */
- codec->channels = 0;
- codec->sample_rate = 0;
+ par->channels = 0;
+ par->sample_rate = 0;
}
/* override bits_per_coded_sample for G.726 */
- if (codec->codec_id == AV_CODEC_ID_ADPCM_G726 && codec->sample_rate)
- codec->bits_per_coded_sample = codec->bit_rate / codec->sample_rate;
+ if (par->codec_id == AV_CODEC_ID_ADPCM_G726 && par->sample_rate)
+ par->bits_per_coded_sample = par->bit_rate / par->sample_rate;
return 0;
}
@@ -210,11 +210,11 @@ int ff_get_bmp_header(AVIOContext *pb, AVStream *st, unsigned *esize)
int tag1;
if(esize) *esize = avio_rl32(pb);
else avio_rl32(pb);
- st->codec->width = avio_rl32(pb);
- st->codec->height = (int32_t)avio_rl32(pb);
+ st->codecpar->width = avio_rl32(pb);
+ st->codecpar->height = (int32_t)avio_rl32(pb);
avio_rl16(pb); /* planes */
- st->codec->bits_per_coded_sample = avio_rl16(pb); /* depth */
- tag1 = avio_rl32(pb);
+ st->codecpar->bits_per_coded_sample = avio_rl16(pb); /* depth */
+ tag1 = avio_rl32(pb);
avio_rl32(pb); /* ImageSize */
avio_rl32(pb); /* XPelsPerMeter */
avio_rl32(pb); /* YPelsPerMeter */
OpenPOWER on IntegriCloud