1 /*
2 * mtv demuxer
3 * Copyright (c) 2006 Reynaldo H. Verdejo Pinochet
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
22 /**
23 * @file
24 * MTV demuxer.
25 */
26
31
32 #define MTV_ASUBCHUNK_DATA_SIZE 500
33 #define MTV_HEADER_SIZE 512
34 #define MTV_AUDIO_PADDING_SIZE 12
35 #define AUDIO_SAMPLING_RATE 44100
36
38
39 unsigned int file_size;
///< filesize, not always right
40 unsigned int segments;
///< number of 512 byte segments
42 unsigned int audio_br;
///< bitrate of audio channel (mp3)
44 unsigned int img_bpp;
///< frame bits per pixel
50
52
54 {
55 /* Magic is 'AMV' */
56 if (*p->
buf !=
'A' || *(p->
buf + 1) !=
'M' || *(p->
buf + 2) !=
'V')
57 return 0;
58
59 /* Check for nonzero in bpp and (width|height) header fields */
61 return 0;
62
63 /* If width or height are 0 then imagesize header field should not */
65 {
68 else
69 return 0;
70 }
71
74
76 }
77
79 {
83 unsigned int audio_subsegments;
84
96
97 /* Calculate width and height if missing from header */
98
103
107 }
109 av_log(s,
AV_LOG_ERROR,
"width or height or segment_size is invalid and I cannot calculate them from other information\n");
111 }
112
115
116 if (audio_subsegments == 0) {
119 }
120
125
126 // FIXME Add sanity check here
127
128 // all systems go! init decoders
129
130 // video - raw rgb565
131
133 if(!st)
135
145
146 // audio - mp3
147
149 if(!st)
151
157
158 // Jump over header
159
162
163 return 0;
164
165 }
166
168 {
172
174 {
176
178 if(ret < 0)
180
183
184 }else
185 {
187 if(ret < 0)
189
191 }
192
194 }
195
203 };