aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/omaenc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2014-06-18 20:42:52 +0200
committerAnton Khirnov <anton@khirnov.net>2016-02-23 17:01:58 +0100
commit9200514ad8717c63f82101dc394f4378854325bf (patch)
tree566b8d48565a88303363198acc81de06363daa7a /libavformat/omaenc.c
parenta8068346e48e123f8d3bdf4d64464d81e53e5fc7 (diff)
downloadffmpeg-9200514ad8717c63f82101dc394f4378854325bf.tar.gz
lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which is used by demuxers to export stream parameters to the caller and by muxers to receive stream parameters from the caller. It is also used internally as the codec context that is passed to parsers. In addition, it is also widely used by the callers as the decoding (when demuxer) or encoding (when muxing) context, though this has been officially discouraged since Libav 11. There are multiple important problems with this approach: - the fields in AVCodecContext are in general one of * stream parameters * codec options * codec state However, it's not clear which ones are which. It is consequently unclear which fields are a demuxer allowed to set or a muxer allowed to read. This leads to erratic behaviour depending on whether decoding or encoding is being performed or not (and whether it uses the AVStream embedded codec context). - various synchronization issues arising from the fact that the same context is used by several different APIs (muxers/demuxers, parsers, bitstream filters and encoders/decoders) simultaneously, with there being no clear rules for who can modify what and the different processes being typically delayed with respect to each other. - avformat_find_stream_info() making it necessary to support opening and closing a single codec context multiple times, thus complicating the semantics of freeing various allocated objects in the codec context. Those problems are resolved by replacing the AVStream embedded codec context with a newly added AVCodecParameters instance, which stores only the stream parameters exported by the demuxers or read by the muxers.
Diffstat (limited to 'libavformat/omaenc.c')
-rw-r--r--libavformat/omaenc.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/libavformat/omaenc.c b/libavformat/omaenc.c
index bfd552a03d..50f369d967 100644
--- a/libavformat/omaenc.c
+++ b/libavformat/omaenc.c
@@ -30,21 +30,21 @@
static av_cold int oma_write_header(AVFormatContext *s)
{
int i;
- AVCodecContext *format;
+ AVCodecParameters *par;
int srate_index;
int isjointstereo;
- format = s->streams[0]->codec;
+ par = s->streams[0]->codecpar;
/* check for support of the format first */
for (srate_index = 0; ; srate_index++) {
if (ff_oma_srate_tab[srate_index] == 0) {
av_log(s, AV_LOG_ERROR, "Sample rate %d not supported in OpenMG audio\n",
- format->sample_rate);
+ par->sample_rate);
return AVERROR(EINVAL);
}
- if (ff_oma_srate_tab[srate_index] * 100 == format->sample_rate)
+ if (ff_oma_srate_tab[srate_index] * 100 == par->sample_rate)
break;
}
@@ -58,16 +58,16 @@ static av_cold int oma_write_header(AVFormatContext *s)
for (i = 0; i < 6; i++)
avio_wl32(s->pb, 0); /* Padding + DRM id */
- switch(format->codec_tag) {
+ switch (par->codec_tag) {
case OMA_CODECID_ATRAC3:
- if (format->channels != 2) {
+ if (par->channels != 2) {
av_log(s, AV_LOG_ERROR, "ATRAC3 in OMA is only supported with 2 channels");
return AVERROR(EINVAL);
}
- if (format->extradata_size == 14) /* WAV format extradata */
- isjointstereo = format->extradata[6] != 0;
- else if(format->extradata_size == 10) /* RM format extradata */
- isjointstereo = format->extradata[8] == 0x12;
+ if (par->extradata_size == 14) /* WAV format extradata */
+ isjointstereo = par->extradata[6] != 0;
+ else if(par->extradata_size == 10) /* RM format extradata */
+ isjointstereo = par->extradata[8] == 0x12;
else {
av_log(s, AV_LOG_ERROR, "ATRAC3: Unsupported extradata size\n");
return AVERROR(EINVAL);
@@ -75,17 +75,17 @@ static av_cold int oma_write_header(AVFormatContext *s)
avio_wb32(s->pb, (OMA_CODECID_ATRAC3 << 24) |
(isjointstereo << 17) |
(srate_index << 13) |
- (format->block_align/8));
+ (par->block_align/8));
break;
case OMA_CODECID_ATRAC3P:
avio_wb32(s->pb, (OMA_CODECID_ATRAC3P << 24) |
(srate_index << 13) |
- (format->channels << 10) |
- (format->block_align/8 - 1));
+ (par->channels << 10) |
+ (par->block_align/8 - 1));
break;
default:
av_log(s, AV_LOG_ERROR, "OMA: unsupported codec tag %d for write\n",
- format->codec_tag);
+ par->codec_tag);
}
for (i = 0; i < (EA3_HEADER_SIZE - 36)/4; i++)
avio_wl32(s->pb, 0); /* Padding */