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.
This commit is contained in:
parent
2d0432d918
commit
9f0b6e6827
@ -141,7 +141,6 @@ static int voc_read_header(AVFormatContext *s)
|
|||||||
VocDecContext *voc = s->priv_data;
|
VocDecContext *voc = s->priv_data;
|
||||||
AVIOContext *pb = s->pb;
|
AVIOContext *pb = s->pb;
|
||||||
int header_size;
|
int header_size;
|
||||||
AVStream *st;
|
|
||||||
|
|
||||||
avio_skip(pb, 20);
|
avio_skip(pb, 20);
|
||||||
header_size = avio_rl16(pb) - 22;
|
header_size = avio_rl16(pb) - 22;
|
||||||
@ -150,10 +149,8 @@ static int voc_read_header(AVFormatContext *s)
|
|||||||
return AVERROR(ENOSYS);
|
return AVERROR(ENOSYS);
|
||||||
}
|
}
|
||||||
avio_skip(pb, header_size);
|
avio_skip(pb, header_size);
|
||||||
st = avformat_new_stream(s, NULL);
|
|
||||||
if (!st)
|
s->ctx_flags |= AVFMTCTX_NOHEADER;
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
|
|
||||||
|
|
||||||
voc->remaining_size = 0;
|
voc->remaining_size = 0;
|
||||||
return 0;
|
return 0;
|
||||||
@ -161,6 +158,12 @@ static int voc_read_header(AVFormatContext *s)
|
|||||||
|
|
||||||
static int voc_read_packet(AVFormatContext *s, AVPacket *pkt)
|
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);
|
return ff_voc_get_packet(s, pkt, s->streams[0], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user