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 }
91 size = 0;
92 if (!myth)
93 return 0;
94 }
95 break;
99 if (size != 128 * 4)
100 break;
102 if (vst) {
108 } else
110
111 if (ast) {
113
119
126 0, 0, ~1);
127 }
129
131 } else
133
134 size -= 6 * 4;
136 return 0;
138 size = 11;
139 break;
140 default:
143 break;
144 }
146 }
147
148 return 0;
149 }
150
152 {
155 char id_string[12];
156 double aspect, fps;
159
161 is_mythtv = !memcmp(id_string, "MythTVVideo", 12);
167 avio_rl32(pb);
// unused, "desiredheight"
168 avio_r8(pb);
// 'P' == progressive, 'I' == interlaced
171 if (aspect > 0.9999 && aspect < 1.0001)
172 aspect = 4.0 / 3.0;
174
175 // number of packets per stream type, -1 means unknown, e.g. streaming
179
181
182 if (v_packs) {
184 if (!vst)
187
194 10000);
195 #if FF_API_R_FRAME_RATE
197 #endif
200 } else
202
203 if (a_packs) {
205 if (!ast)
207 ctx->
a_id = ast->index;
208
211 ast->codec->channels = 2;
213 ast->codec->sample_rate = 44100;
214 ast->codec->bit_rate = 2 * 2 * 44100 * 8;
215 ast->codec->block_align = 2 * 2;
216 ast->codec->bits_per_coded_sample = 16;
218 } else
220
223
225
226 return 0;
227 }
228
230
232 {
238
242
245 return ret < 0 ? ret :
AVERROR(EIO);
246
247 frametype = hdr[0];
249
250 switch (frametype) {
254 break;
255 }
260 break;
261 }
263 if (ret < 0)
265
270 memcpy(pkt->
data, hdr, copyhdrsize);
272 if (ret < 0) {
275 }
276 if (ret < size)
278 return 0;
283 break;
284 }
290 if (ret < 0)
292 return 0;
294 // contains no data, size value is invalid
295 break;
296 default:
298 break;
299 }
300 }
301
303 }
304
305 /**
306 * \brief looks for the string RTjjjjjjjjjj in the stream too resync reading
307 * \return 1 if the syncword is found 0 otherwise.
308 */
313 tag = (tag << 8) |
avio_r8(pb);
314 if (tag ==
MKBETAG(
'R',
'T',
'j',
'j') &&
317 return 1;
318 }
319 return 0;
320 }
321
322 /**
323 * \brief attempts to read a timestamp from stream at the given stream position
324 * \return timestamp if successful and AV_NOPTS_VALUE if failure
325 */
327 int64_t *ppos, int64_t pos_limit)
328 {
334 int64_t pos, dts;
335
338
341
345 frametype = hdr[0];
347 switch (frametype) {
349 break;
354 key = hdr[2] == 0;
355 } else {
357 key = 1;
358 }
359 if (stream_index == idx) {
360
363
364 // TODO - add general support in av_gen_search, so it adds positions after reading timestamps
367
368 *ppos = pos;
369 return dts;
370 }
371 default:
373 break;
374 }
375 }
377 }
378
379
389 };