aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/vocdec.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2015-10-18 21:21:55 +0200
committerAnton Khirnov <anton@khirnov.net>2015-12-12 21:27:11 +0100
commit9f0b6e6827e21e3477abe1199dc2728e30b8c061 (patch)
tree64f0e5efffc4b5dfdc1e394ec20067ccab3a535d /libavformat/vocdec.c
parent2d0432d918a71468419b7ac1e543ab3b399d3d37 (diff)
downloadffmpeg-9f0b6e6827e21e3477abe1199dc2728e30b8c061.tar.gz
vocdec: do not create the stream in read_header()
The stream parameters are not known until we read a packet, so postpone creating it until then.
Diffstat (limited to 'libavformat/vocdec.c')
-rw-r--r--libavformat/vocdec.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libavformat/vocdec.c b/libavformat/vocdec.c
index 35ced25fe1..459952203e 100644
--- a/libavformat/vocdec.c
+++ b/libavformat/vocdec.c
@@ -141,7 +141,6 @@ static int voc_read_header(AVFormatContext *s)
VocDecContext *voc = s->priv_data;
AVIOContext *pb = s->pb;
int header_size;
- AVStream *st;
avio_skip(pb, 20);
header_size = avio_rl16(pb) - 22;
@@ -150,10 +149,8 @@ static int voc_read_header(AVFormatContext *s)
return AVERROR(ENOSYS);
}
avio_skip(pb, header_size);
- st = avformat_new_stream(s, NULL);
- if (!st)
- return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+
+ s->ctx_flags |= AVFMTCTX_NOHEADER;
voc->remaining_size = 0;
return 0;
@@ -161,6 +158,12 @@ static int voc_read_header(AVFormatContext *s)
static int voc_read_packet(AVFormatContext *s, AVPacket *pkt)
{
+ if (!s->nb_streams) {
+ AVStream *st = avformat_new_stream(s, NULL);
+ if (!st)
+ return AVERROR(ENOMEM);
+ st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ }
return ff_voc_get_packet(s, pkt, s->streams[0], 0);
}