annotate idroqdec.c @ 6434:ca5676c4563d libavformat

cosmetic
author aurel
date Sun, 29 Aug 2010 21:23:52 +0000
parents ee9bbe013610
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6426
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
1 /*
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
2 * id RoQ (.roq) File Demuxer
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
3 * Copyright (c) 2003 The ffmpeg Project
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
4 *
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
5 * This file is part of FFmpeg.
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
6 *
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
11 *
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
15 * Lesser General Public License for more details.
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
16 *
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
20 */
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
21
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
22 /**
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
23 * @file
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
24 * id RoQ format file demuxer
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
25 * by Mike Melanson (melanson@pcisys.net)
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
26 * for more information on the .roq file format, visit:
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
27 * http://www.csse.monash.edu.au/~timf/
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
28 */
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
29
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
30 #include "libavutil/intreadwrite.h"
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
31 #include "avformat.h"
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
32
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
33 #define RoQ_MAGIC_NUMBER 0x1084
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
34 #define RoQ_CHUNK_PREAMBLE_SIZE 8
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
35 #define RoQ_AUDIO_SAMPLE_RATE 22050
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
36 #define RoQ_CHUNKS_TO_SCAN 30
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
37
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
38 #define RoQ_INFO 0x1001
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
39 #define RoQ_QUAD_CODEBOOK 0x1002
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
40 #define RoQ_QUAD_VQ 0x1011
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
41 #define RoQ_SOUND_MONO 0x1020
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
42 #define RoQ_SOUND_STEREO 0x1021
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
43
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
44 typedef struct RoqDemuxContext {
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
45
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
46 int width;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
47 int height;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
48 int audio_channels;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
49
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
50 int video_stream_index;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
51 int audio_stream_index;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
52
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
53 int64_t video_pts;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
54 unsigned int audio_frame_count;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
55
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
56 } RoqDemuxContext;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
57
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
58 static int roq_probe(AVProbeData *p)
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
59 {
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
60 if ((AV_RL16(&p->buf[0]) != RoQ_MAGIC_NUMBER) ||
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
61 (AV_RL32(&p->buf[2]) != 0xFFFFFFFF))
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
62 return 0;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
63
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
64 return AVPROBE_SCORE_MAX;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
65 }
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
66
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
67 static int roq_read_header(AVFormatContext *s,
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
68 AVFormatParameters *ap)
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
69 {
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
70 RoqDemuxContext *roq = s->priv_data;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
71 ByteIOContext *pb = s->pb;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
72 int framerate;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
73 AVStream *st;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
74 unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE];
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
75
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
76 /* get the main header */
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
77 if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
78 RoQ_CHUNK_PREAMBLE_SIZE)
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
79 return AVERROR(EIO);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
80 framerate = AV_RL16(&preamble[6]);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
81
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
82 /* init private context parameters */
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
83 roq->width = roq->height = roq->audio_channels = roq->video_pts =
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
84 roq->audio_frame_count = 0;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
85 roq->audio_stream_index = -1;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
86
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
87 st = av_new_stream(s, 0);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
88 if (!st)
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
89 return AVERROR(ENOMEM);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
90 av_set_pts_info(st, 63, 1, framerate);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
91 roq->video_stream_index = st->index;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
92 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
93 st->codec->codec_id = CODEC_ID_ROQ;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
94 st->codec->codec_tag = 0; /* no fourcc */
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
95
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
96 return 0;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
97 }
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
98
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
99 static int roq_read_packet(AVFormatContext *s,
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
100 AVPacket *pkt)
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
101 {
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
102 RoqDemuxContext *roq = s->priv_data;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
103 ByteIOContext *pb = s->pb;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
104 int ret = 0;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
105 unsigned int chunk_size;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
106 unsigned int chunk_type;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
107 unsigned int codebook_size;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
108 unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE];
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
109 int packet_read = 0;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
110 int64_t codebook_offset;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
111
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
112 while (!packet_read) {
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
113
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
114 if (url_feof(s->pb))
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
115 return AVERROR(EIO);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
116
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
117 /* get the next chunk preamble */
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
118 if ((ret = get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE)) !=
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
119 RoQ_CHUNK_PREAMBLE_SIZE)
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
120 return AVERROR(EIO);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
121
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
122 chunk_type = AV_RL16(&preamble[0]);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
123 chunk_size = AV_RL32(&preamble[2]);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
124 if(chunk_size > INT_MAX)
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
125 return AVERROR_INVALIDDATA;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
126
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
127 switch (chunk_type) {
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
128
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
129 case RoQ_INFO:
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
130 if (!roq->width || !roq->height) {
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
131 AVStream *st = s->streams[roq->video_stream_index];
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
132 if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE)
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
133 return AVERROR(EIO);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
134 st->codec->width = roq->width = AV_RL16(preamble);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
135 st->codec->height = roq->height = AV_RL16(preamble + 2);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
136 break;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
137 }
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
138 /* don't care about this chunk anymore */
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
139 url_fseek(pb, RoQ_CHUNK_PREAMBLE_SIZE, SEEK_CUR);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
140 break;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
141
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
142 case RoQ_QUAD_CODEBOOK:
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
143 /* packet needs to contain both this codebook and next VQ chunk */
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
144 codebook_offset = url_ftell(pb) - RoQ_CHUNK_PREAMBLE_SIZE;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
145 codebook_size = chunk_size;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
146 url_fseek(pb, codebook_size, SEEK_CUR);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
147 if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
148 RoQ_CHUNK_PREAMBLE_SIZE)
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
149 return AVERROR(EIO);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
150 chunk_size = AV_RL32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 +
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
151 codebook_size;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
152
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
153 /* rewind */
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
154 url_fseek(pb, codebook_offset, SEEK_SET);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
155
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
156 /* load up the packet */
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
157 ret= av_get_packet(pb, pkt, chunk_size);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
158 if (ret != chunk_size)
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
159 return AVERROR(EIO);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
160 pkt->stream_index = roq->video_stream_index;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
161 pkt->pts = roq->video_pts++;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
162
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
163 packet_read = 1;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
164 break;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
165
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
166 case RoQ_SOUND_MONO:
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
167 case RoQ_SOUND_STEREO:
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
168 if (roq->audio_stream_index == -1) {
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
169 AVStream *st = av_new_stream(s, 1);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
170 if (!st)
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
171 return AVERROR(ENOMEM);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
172 av_set_pts_info(st, 32, 1, RoQ_AUDIO_SAMPLE_RATE);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
173 roq->audio_stream_index = st->index;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
174 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
175 st->codec->codec_id = CODEC_ID_ROQ_DPCM;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
176 st->codec->codec_tag = 0; /* no tag */
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
177 st->codec->channels = roq->audio_channels = chunk_type == RoQ_SOUND_STEREO ? 2 : 1;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
178 st->codec->sample_rate = RoQ_AUDIO_SAMPLE_RATE;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
179 st->codec->bits_per_coded_sample = 16;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
180 st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
181 st->codec->bits_per_coded_sample;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
182 st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
183 }
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
184 case RoQ_QUAD_VQ:
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
185 /* load up the packet */
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
186 if (av_new_packet(pkt, chunk_size + RoQ_CHUNK_PREAMBLE_SIZE))
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
187 return AVERROR(EIO);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
188 /* copy over preamble */
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
189 memcpy(pkt->data, preamble, RoQ_CHUNK_PREAMBLE_SIZE);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
190
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
191 if (chunk_type == RoQ_QUAD_VQ) {
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
192 pkt->stream_index = roq->video_stream_index;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
193 pkt->pts = roq->video_pts++;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
194 } else {
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
195 pkt->stream_index = roq->audio_stream_index;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
196 pkt->pts = roq->audio_frame_count;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
197 roq->audio_frame_count += (chunk_size / roq->audio_channels);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
198 }
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
199
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
200 pkt->pos= url_ftell(pb);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
201 ret = get_buffer(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE,
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
202 chunk_size);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
203 if (ret != chunk_size)
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
204 ret = AVERROR(EIO);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
205
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
206 packet_read = 1;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
207 break;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
208
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
209 default:
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
210 av_log(s, AV_LOG_ERROR, " unknown RoQ chunk (%04X)\n", chunk_type);
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
211 return AVERROR_INVALIDDATA;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
212 break;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
213 }
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
214 }
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
215
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
216 return ret;
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
217 }
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
218
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
219 AVInputFormat roq_demuxer = {
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
220 "RoQ",
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
221 NULL_IF_CONFIG_SMALL("id RoQ format"),
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
222 sizeof(RoqDemuxContext),
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
223 roq_probe,
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
224 roq_read_header,
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
225 roq_read_packet,
ee9bbe013610 rename idroq.c to idroqdec.c
aurel
parents:
diff changeset
226 };