aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-12-19 23:53:04 -0500
committerJustin Ruggles <justin.ruggles@gmail.com>2011-12-21 16:51:12 -0500
commit3f9257c5a5b08bc9aa6f7b3e3535e1c5b086ec50 (patch)
treee8020e783fd34002a2cec5ea5645e09ca0cf70c6 /libavformat
parentce94948198f3d22fd1ed53b99ee31e0a3f791f87 (diff)
downloadffmpeg-3f9257c5a5b08bc9aa6f7b3e3535e1c5b086ec50.tar.gz
idroqdec: set AVFMTCTX_NOHEADER and create streams as they occur.
This fixes demuxing of file where the first packet is not audio. Such files are generated by our idroq muxer. It also fixes demuxing of audio only idroq files.
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/idroqdec.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/libavformat/idroqdec.c b/libavformat/idroqdec.c
index 5e347b18ab..d63c395b79 100644
--- a/libavformat/idroqdec.c
+++ b/libavformat/idroqdec.c
@@ -44,6 +44,7 @@
typedef struct RoqDemuxContext {
+ int frame_rate;
int width;
int height;
int audio_channels;
@@ -70,29 +71,21 @@ static int roq_read_header(AVFormatContext *s,
{
RoqDemuxContext *roq = s->priv_data;
AVIOContext *pb = s->pb;
- int framerate;
- AVStream *st;
unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE];
/* get the main header */
if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
- framerate = AV_RL16(&preamble[6]);
+ roq->frame_rate = AV_RL16(&preamble[6]);
/* init private context parameters */
roq->width = roq->height = roq->audio_channels = roq->video_pts =
roq->audio_frame_count = 0;
roq->audio_stream_index = -1;
+ roq->video_stream_index = -1;
- st = avformat_new_stream(s, NULL);
- if (!st)
- return AVERROR(ENOMEM);
- avpriv_set_pts_info(st, 63, 1, framerate);
- roq->video_stream_index = st->index;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = CODEC_ID_ROQ;
- st->codec->codec_tag = 0; /* no fourcc */
+ s->ctx_flags |= AVFMTCTX_NOHEADER;
return 0;
}
@@ -128,8 +121,16 @@ static int roq_read_packet(AVFormatContext *s,
switch (chunk_type) {
case RoQ_INFO:
- if (!roq->width || !roq->height) {
- AVStream *st = s->streams[roq->video_stream_index];
+ if (roq->video_stream_index == -1) {
+ AVStream *st = avformat_new_stream(s, NULL);
+ if (!st)
+ return AVERROR(ENOMEM);
+ avpriv_set_pts_info(st, 63, 1, roq->frame_rate);
+ roq->video_stream_index = st->index;
+ st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codec->codec_id = CODEC_ID_ROQ;
+ st->codec->codec_tag = 0; /* no fourcc */
+
if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR(EIO);
st->codec->width = roq->width = AV_RL16(preamble);