1 /*
2 * NuppelVideo demuxer.
3 * Copyright (c) 2006 Reimar Doeffinger
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
28
33 };
34
40
48
50 {
51 if (!memcmp(p->
buf,
"NuppelVideo", 12))
53 if (!memcmp(p->
buf,
"MythTVVideo", 12))
55 return 0;
56 }
57
58 /// little macro to sanitize packet size
59 #define PKTSIZE(s) (s & 0xffffff)
60
61 /**
62 * @brief read until we found all data needed for decoding
63 * @param vst video stream of which to change parameters
64 * @param ast video stream of which to change parameters
65 * @param myth set if this is a MythTVVideo format file
66 * @return 0 or AVERROR code
67 */
70 {
72
73 if (!vst && !myth)
74 return 1; // no codec data needed
77
79 switch (frametype) {
84 if (vst && subtype == 'R') {
88 }
92 size = 0;
93 if (!myth)
94 return 0;
95 }
96 break;
100 if (size != 128 * 4)
101 break;
103 if (vst) {
109 } else
111
112 if (ast) {
114
120
127 0, 0, ~1);
128 }
130
132 } else
134
135 size -= 6 * 4;
137 return 0;
139 size = 11;
140 break;
141 default:
144 break;
145 }
147 }
148
149 return 0;
150 }
151
153 {
156 char id_string[12];
157 double aspect, fps;
160
162 is_mythtv = !memcmp(id_string, "MythTVVideo", 12);
168 avio_rl32(pb);
// unused, "desiredheight"
169 avio_r8(pb);
// 'P' == progressive, 'I' == interlaced
172 if (aspect > 0.9999 && aspect < 1.0001)
173 aspect = 4.0 / 3.0;
175
176 // number of packets per stream type, -1 means unknown, e.g. streaming
180
182
183 if (v_packs) {
185 if (!vst)
188
195 10000);
196 #if FF_API_R_FRAME_RATE
198 #endif
201 } else
203
204 if (a_packs) {
206 if (!ast)
208 ctx->
a_id = ast->index;
209
212 ast->codec->channels = 2;
214 ast->codec->sample_rate = 44100;
215 ast->codec->bit_rate = 2 * 2 * 44100 * 8;
216 ast->codec->block_align = 2 * 2;
217 ast->codec->bits_per_coded_sample = 16;
219 } else
221
224
226
227 return 0;
228 }
229
231
233 {
239
243
246 return ret < 0 ? ret :
AVERROR(EIO);
247
248 frametype = hdr[0];
250
251 switch (frametype) {
255 break;
256 }
261 break;
262 }
264 if (ret < 0)
266
271 memcpy(pkt->
data, hdr, copyhdrsize);
273 if (ret < 0) {
276 }
277 if (ret < size)
279 return 0;
284 break;
285 }
291 if (ret < 0)
293 return 0;
295 // contains no data, size value is invalid
296 break;
297 default:
299 break;
300 }
301 }
302
304 }
305
306 /**
307 * \brief looks for the string RTjjjjjjjjjj in the stream too resync reading
308 * \return 1 if the syncword is found 0 otherwise.
309 */
314 tag = (tag << 8) |
avio_r8(pb);
315 if (tag ==
MKBETAG(
'R',
'T',
'j',
'j') &&
318 return 1;
319 }
320 return 0;
321 }
322
323 /**
324 * \brief attempts to read a timestamp from stream at the given stream position
325 * \return timestamp if successful and AV_NOPTS_VALUE if failure
326 */
328 int64_t *ppos, int64_t pos_limit)
329 {
335 int64_t pos, dts;
336
339
342
346 frametype = hdr[0];
348 switch (frametype) {
350 break;
355 key = hdr[2] == 0;
356 } else {
358 key = 1;
359 }
360 if (stream_index == idx) {
361
364
365 // TODO - add general support in av_gen_search, so it adds positions after reading timestamps
368
369 *ppos = pos;
370 return dts;
371 }
372 default:
374 break;
375 }
376 }
378 }
379
380
390 };