annotate libmpdemux/demux_roq.c @ 4479:423ce4451ca8

tested and fixed on 2.2.x, more comments
author alex
date Sat, 02 Feb 2002 17:35:53 +0000
parents 5627d5b58083
children eaa4a2242552
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4451
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
1 /*
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
2 RoQ file demuxer for the MPlayer program
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
3 by Mike Melanson
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
4 based on Dr. Tim Ferguson's RoQ document found at:
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
5 http://www.csse.monash.edu.au/~timf/videocodec.html
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
6 */
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
7
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
8 #include <stdio.h>
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
9 #include <stdlib.h>
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
10 #include <unistd.h>
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
11
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
12 #include "config.h"
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
13 #include "mp_msg.h"
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
14 #include "help_mp.h"
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
15
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
16 #include "stream.h"
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
17 #include "demuxer.h"
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
18 #include "stheader.h"
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
19
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
20 #define RoQ_INFO 0x1001
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
21 #define RoQ_QUAD_CODEBOOK 0x1002
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
22 #define RoQ_QUAD_VQ 0x1011
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
23 #define RoQ_SOUND_MONO 0x1020
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
24 #define RoQ_SOUND_STEREO 0x1021
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
25
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
26 #define CHUNK_TYPE_AUDIO 0
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
27 #define CHUNK_TYPE_VIDEO 1
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
28
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
29 #define RoQ_FPS 24
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
30
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
31 typedef struct roq_chunk_t
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
32 {
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
33 int chunk_type;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
34 off_t chunk_offset;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
35 int chunk_size;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
36 } roq_chunk_t;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
37
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
38 typedef struct roq_data_t
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
39 {
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
40 int total_chunks;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
41 int current_chunk;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
42 roq_chunk_t *chunks;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
43 } roq_data_t;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
44
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
45 // Check if a stream qualifies as a RoQ file based on the magic numbers
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
46 // at the start of the file:
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
47 // 84 10 FF FF FF FF 1E 00
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
48 int roq_check_file(demuxer_t *demuxer)
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
49 {
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
50 stream_reset(demuxer->stream);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
51 stream_seek(demuxer->stream, 0);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
52
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
53 if ((stream_read_dword(demuxer->stream) == 0x8410FFFF) &&
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
54 (stream_read_dword(demuxer->stream) == 0xFFFF1E00))
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
55 return 1;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
56 else
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
57 return 0;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
58 }
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
59
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
60 // return value:
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
61 // 0 = EOF or no stream found
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
62 // 1 = successfully read a packet
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
63 int demux_roq_fill_buffer(demuxer_t *demuxer)
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
64 {
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
65 roq_data_t *roq_data = (roq_data_t *)demuxer->priv;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
66 roq_chunk_t roq_chunk;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
67 demux_stream_t *ds;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
68
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
69 if (roq_data->current_chunk >= roq_data->total_chunks)
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
70 return 0;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
71
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
72 roq_chunk = roq_data->chunks[roq_data->current_chunk];
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
73 if (roq_chunk.chunk_type == CHUNK_TYPE_AUDIO)
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
74 ds = demuxer->audio;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
75 else
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
76 ds = demuxer->video;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
77
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
78 // make sure we're at the right place in the stream and fetch the chunk
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
79 stream_seek(demuxer->stream, roq_chunk.chunk_offset);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
80 ds_read_packet(
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
81 ds,
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
82 demuxer->stream,
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
83 roq_chunk.chunk_size,
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
84 // roq_data->current_frame/sh_video->fps,
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
85 0,
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
86 roq_chunk.chunk_offset,
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
87 0
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
88 );
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
89
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
90 roq_data->current_chunk++;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
91 return 1;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
92 }
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
93
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
94 demuxer_t* demux_open_roq(demuxer_t* demuxer)
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
95 {
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
96 sh_video_t *sh_video = NULL;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
97 sh_audio_t *sh_audio = NULL;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
98
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
99 roq_data_t *roq_data = (roq_data_t *)malloc(sizeof(roq_data_t));
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
100 int chunk_id;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
101 int chunk_size;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
102 int chunk_arg1;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
103 int chunk_arg2;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
104 int chunk_counter = 0;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
105 int last_chunk_id = 0;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
106
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
107 roq_data->chunks = NULL;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
108
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
109 // position the stream and start traversing
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
110 stream_seek(demuxer->stream, 8);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
111 while (!stream_eof(demuxer->stream))
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
112 {
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
113 chunk_id = stream_read_word_le(demuxer->stream);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
114 chunk_size = stream_read_word_le(demuxer->stream);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
115 chunk_arg1 = stream_read_word_le(demuxer->stream);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
116 chunk_arg2 = stream_read_word_le(demuxer->stream);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
117
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
118 // this is the only useful header info in the file
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
119 if (chunk_id == RoQ_INFO)
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
120 {
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
121 // there should only be one RoQ_INFO chunk per file
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
122 if (sh_video)
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
123 {
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
124 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Found more than one RoQ_INFO chunk\n");
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
125 stream_skip(demuxer->stream, 8);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
126 }
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
127 else
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
128 {
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
129 // make the header first
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
130 sh_video = new_sh_video(demuxer, 0);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
131 // make sure the demuxer knows about the new stream header
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
132 demuxer->video->sh = sh_video;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
133 // make sure that the video demuxer stream header knows about its
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
134 // parent video demuxer stream
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
135 sh_video->ds = demuxer->video;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
136
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
137 // this is a good opportunity to create a video stream header
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
138 sh_video->disp_w = stream_read_word_le(demuxer->stream);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
139 sh_video->disp_h = stream_read_word_le(demuxer->stream);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
140 stream_skip(demuxer->stream, 4);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
141
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
142 // custom fourcc for internal MPlayer use
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
143 sh_video->format = mmioFOURCC('R', 'o', 'Q', 'V');
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
144
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
145 // constant frame rate
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
146 sh_video->fps = RoQ_FPS;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
147 sh_video->frametime = 1 / RoQ_FPS;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
148 }
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
149 }
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
150 else if ((chunk_id == RoQ_SOUND_MONO) ||
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
151 (chunk_id == RoQ_SOUND_STEREO))
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
152 {
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
153 // create the audio stream header if it hasn't been created it
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
154 if (sh_audio == NULL)
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
155 {
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
156 // make the header first
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
157 sh_audio = new_sh_audio(demuxer, 0);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
158 // make sure the demuxer knows about the new stream header
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
159 demuxer->audio->sh = sh_audio;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
160 // make sure that the audio demuxer stream header knows about its
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
161 // parent audio demuxer stream
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
162 sh_audio->ds = demuxer->audio;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
163
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
164 // custom fourcc for internal MPlayer use
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
165 sh_audio->format = mmioFOURCC('R', 'o', 'Q', 'A');
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
166 // assume it's mono until there's reason to believe otherwise
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
167 sh_audio->channels = 1;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
168 // always 22KHz, 16-bit
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
169 sh_audio->samplerate = 22050;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
170 sh_audio->samplesize = 2;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
171 }
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
172
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
173 // if it's stereo, promote the channel number
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
174 if (chunk_id == RoQ_SOUND_STEREO)
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
175 sh_audio->channels = 2;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
176
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
177 // index the chunk
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
178 roq_data->chunks = (roq_chunk_t *)realloc(roq_data->chunks,
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
179 (chunk_counter + 1) * sizeof (roq_chunk_t));
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
180 roq_data->chunks[chunk_counter].chunk_type = CHUNK_TYPE_AUDIO;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
181 roq_data->chunks[chunk_counter].chunk_offset =
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
182 stream_tell(demuxer->stream) - 8;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
183 roq_data->chunks[chunk_counter].chunk_size = chunk_size + 8;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
184
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
185 stream_skip(demuxer->stream, chunk_size);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
186 chunk_counter++;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
187 }
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
188 else if ((chunk_id == RoQ_QUAD_CODEBOOK) ||
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
189 ((chunk_id == RoQ_QUAD_VQ) && (last_chunk_id != RoQ_QUAD_CODEBOOK)))
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
190 {
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
191 // index a new chunk if it's a codebook or quad VQ not following a
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
192 // codebook
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
193 roq_data->chunks = (roq_chunk_t *)realloc(roq_data->chunks,
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
194 (chunk_counter + 1) * sizeof (roq_chunk_t));
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
195 roq_data->chunks[chunk_counter].chunk_type = CHUNK_TYPE_VIDEO;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
196 roq_data->chunks[chunk_counter].chunk_offset =
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
197 stream_tell(demuxer->stream) - 8;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
198 roq_data->chunks[chunk_counter].chunk_size = chunk_size + 8;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
199
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
200 stream_skip(demuxer->stream, chunk_size);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
201 chunk_counter++;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
202 }
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
203 else if ((chunk_id == RoQ_QUAD_VQ) && (last_chunk_id == RoQ_QUAD_CODEBOOK))
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
204 {
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
205 // if it's a quad VQ chunk following a codebook chunk, extend the last
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
206 // chunk
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
207 roq_data->chunks[chunk_counter - 1].chunk_size += (chunk_size + 8);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
208 stream_skip(demuxer->stream, chunk_size);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
209 }
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
210 else
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
211 {
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
212 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Unknown RoQ chunk ID: %04X\n", chunk_id);
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
213 }
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
214
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
215 last_chunk_id = chunk_id;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
216 }
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
217
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
218 roq_data->total_chunks = chunk_counter;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
219 roq_data->current_chunk = 0;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
220
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
221 demuxer->priv = roq_data;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
222
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
223 return demuxer;
5627d5b58083 implemented RoQ file demuxing
melanson
parents:
diff changeset
224 }