aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/yop.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/yop.c
parent60b75186b2c878b6257b43c8fcc0b1356ada218e (diff)
parent9200514ad8717c63f82101dc394f4378854325bf (diff)
downloadffmpeg-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/yop.c')
-rw-r--r--libavformat/yop.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/libavformat/yop.c b/libavformat/yop.c
index 9b77f6e30e..997ca4b745 100644
--- a/libavformat/yop.c
+++ b/libavformat/yop.c
@@ -58,7 +58,7 @@ static int yop_read_header(AVFormatContext *s)
YopDecContext *yop = s->priv_data;
AVIOContext *pb = s->pb;
- AVCodecContext *audio_dec, *video_dec;
+ AVCodecParameters *audio_par, *video_par;
AVStream *audio_stream, *video_stream;
int frame_rate, ret;
@@ -69,39 +69,45 @@ static int yop_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
// Extra data that will be passed to the decoder
- if (ff_alloc_extradata(video_stream->codec, 8))
+ if (ff_alloc_extradata(video_stream->codecpar, 8))
return AVERROR(ENOMEM);
+ video_stream->codecpar->extradata = av_mallocz(8 + AV_INPUT_BUFFER_PADDING_SIZE);
+
+ if (!video_stream->codecpar->extradata)
+ return AVERROR(ENOMEM);
+ video_stream->codecpar->extradata_size = 8;
+
// Audio
- audio_dec = audio_stream->codec;
- audio_dec->codec_type = AVMEDIA_TYPE_AUDIO;
- audio_dec->codec_id = AV_CODEC_ID_ADPCM_IMA_APC;
- audio_dec->channels = 1;
- audio_dec->channel_layout = AV_CH_LAYOUT_MONO;
- audio_dec->sample_rate = 22050;
+ audio_par = audio_stream->codecpar;
+ audio_par->codec_type = AVMEDIA_TYPE_AUDIO;
+ audio_par->codec_id = AV_CODEC_ID_ADPCM_IMA_APC;
+ audio_par->channels = 1;
+ audio_par->channel_layout = AV_CH_LAYOUT_MONO;
+ audio_par->sample_rate = 22050;
// Video
- video_dec = video_stream->codec;
- video_dec->codec_type = AVMEDIA_TYPE_VIDEO;
- video_dec->codec_id = AV_CODEC_ID_YOP;
+ video_par = video_stream->codecpar;
+ video_par->codec_type = AVMEDIA_TYPE_VIDEO;
+ video_par->codec_id = AV_CODEC_ID_YOP;
avio_skip(pb, 6);
frame_rate = avio_r8(pb);
yop->frame_size = avio_r8(pb) * 2048;
- video_dec->width = avio_rl16(pb);
- video_dec->height = avio_rl16(pb);
+ video_par->width = avio_rl16(pb);
+ video_par->height = avio_rl16(pb);
video_stream->sample_aspect_ratio = (AVRational){1, 2};
- ret = avio_read(pb, video_dec->extradata, 8);
+ ret = avio_read(pb, video_par->extradata, 8);
if (ret < 8)
return ret < 0 ? ret : AVERROR_EOF;
- yop->palette_size = video_dec->extradata[0] * 3 + 4;
- yop->audio_block_length = AV_RL16(video_dec->extradata + 6);
+ yop->palette_size = video_par->extradata[0] * 3 + 4;
+ yop->audio_block_length = AV_RL16(video_par->extradata + 6);
- video_dec->bit_rate = 8 * (yop->frame_size - yop->audio_block_length) * frame_rate;
+ video_par->bit_rate = 8 * (yop->frame_size - yop->audio_block_length) * frame_rate;
// 1840 samples per frame, 1 nibble per sample; hence 1840/2 = 920
if (yop->audio_block_length < 920 ||