summaryrefslogtreecommitdiff
path: root/libavformat/idroqdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-12-22 00:48:38 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-12-22 01:51:53 +0100
commit52c522c72090233edeeb0486a9bd8bee925a710a (patch)
tree23f091bb1fb649e8358d01516670360c13cb08e6 /libavformat/idroqdec.c
parenta40f43db647bfacafbd1e27a4cd5f6134c6e6c53 (diff)
parente9dc92012773aab5f51d8d37eb14564988c5f217 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: (27 commits) asfdec: add side data to ASFStream packet instead of output packet. idroqdec: set AVFMTCTX_NOHEADER and create streams as they occur. nellymoserdec: Indicate that the decoder can handle changed parameters libavcodec: Apply parameter change side data when decoding audio flvdec: Add param change side data if the sample rate or channels have changed libavformat: Add a utility function for adding parameter change side data libavcodec: Define a side data type for parameter changes aacdec: Handle new extradata passed as side data flvdec: Export new AAC/H.264 extradata as side data on the next packet libavcodec: Define a side data type for new extradata flacdec: skip all track indices at once instead of looping. mxf: Add PictureEssenceCoding UL for V210. mxfdec: consider QuantizationBits between 17 and 24 to be pcm_s24* mxfenc: Add support for MPEG-2 MP@HL-14 in mxf container. mxf: H.264/MPEG-4 AVC Intra support configure: Show whether the safe bitstream reader is enabled x86: Tighten register constraints for decode_significance*_x86. Replace Subversion revisions in comments by Git hashes. h264_cabac: synchronize decode_significance_*_x86 conditionals w32threads: wait for the waked thread in pthread_cond_signal. ... Conflicts: libavcodec/avcodec.h libavcodec/version.h libavformat/flvdec.c libavformat/utils.c tests/ref/lavfi/pixdesc tests/ref/lavfi/pixfmts_copy tests/ref/lavfi/pixfmts_null tests/ref/lavfi/pixfmts_scale tests/ref/lavfi/pixfmts_vflip Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/idroqdec.c')
-rw-r--r--libavformat/idroqdec.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/libavformat/idroqdec.c b/libavformat/idroqdec.c
index 9ac32eb668..fffee9d76e 100644
--- a/libavformat/idroqdec.c
+++ b/libavformat/idroqdec.c
@@ -45,6 +45,7 @@
typedef struct RoqDemuxContext {
+ int frame_rate;
int width;
int height;
int audio_channels;
@@ -71,29 +72,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;
}
@@ -131,8 +124,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);