FFmpeg: libavformat/mtv.c Source File
Go to the documentation of this file. 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
32
33 #define MTV_ASUBCHUNK_DATA_SIZE 500
34 #define MTV_HEADER_SIZE 512
35 #define MTV_AUDIO_PADDING_SIZE 12
36 #define MTV_IMAGE_DEFAULT_BPP 16
37 #define MTV_AUDIO_SAMPLING_RATE 44100
38
40
41 unsigned int file_size;
///< filesize, not always right
42 unsigned int segments;
///< number of 512 byte segments
44 unsigned int audio_br;
///< bitrate of audio channel (mp3)
46 unsigned int img_bpp;
///< frame bits per pixel
52
54
56 {
57 /* we need at least 57 bytes from the header
58 * to try parsing all required fields
59 */
61 return 0;
62
63 /* Magic is 'AMV' */
64 if (*
p->buf !=
'A' || *(
p->buf + 1) !=
'M' || *(
p->buf + 2) !=
'V')
65 return 0;
66
67 /* Audio magic is always MP3 */
68 if (
p->buf[43] !=
'M' ||
p->buf[44] !=
'P' ||
p->buf[45] !=
'3')
69 return 0;
70
71 /* Check for nonzero in bpp and (width|height) header fields */
73 return 0;
74
75 /* If width or height are 0 then imagesize header field should not */
77 {
80 else
81 return 0;
82 }
83
84 /* Image bpp is not an absolutely required
85 * field as we latter claim it should be 16
86 * no matter what. All samples in the wild
87 * are RGB565/555.
88 */
91
92 /* We had enough data to parse header values
93 * but we expect to be able to get 512 bytes
94 * of header to be sure.
95 */
98
100 }
101
103 {
107 unsigned int audio_subsegments;
108
120
121 /* Assume 16bpp even if claimed otherwise.
122 * We know its going to be RGBG565/555 anyway
123 */
128 }
129
130 /* Calculate width and height if missing from header */
131
135
139
141 av_log(
s,
AV_LOG_ERROR,
"width or height or segment_size is invalid and I cannot calculate them from other information\n");
143 }
144
147
148 if (audio_subsegments == 0) {
151 }
152
157
158 // FIXME Add sanity check here
159
160 // all systems go! init decoders
161
162 // video - raw rgb565
163
165 if(!st)
167
178
179 // audio - mp3
180
182 if(!st)
184
190
191 // Jump over header
192
195
196 return 0;
197
198 }
199
201 {
205
207 {
209
213
216
217 }else
218 {
222
224 }
225
227 }
228
236 };
unsigned int file_size
filesize, not always right
static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt)
#define AV_LOG_WARNING
Something somehow does not look correct.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
unsigned int full_segment_size
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVMediaType codec_type
General type of the encoded data.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
static int mtv_probe(const AVProbeData *p)
unsigned int img_segment_size
size of image segment
#define MTV_IMAGE_DEFAULT_BPP
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
unsigned int avio_rl16(AVIOContext *s)
unsigned int audio_br
bitrate of audio channel (mp3)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define MTV_AUDIO_SAMPLING_RATE
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
enum AVStreamParseType need_parsing
const FFInputFormat ff_mtv_demuxer
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static int mtv_read_header(AVFormatContext *s)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
unsigned int img_bpp
frame bits per pixel
This structure contains the data a format has to probe a file.
unsigned int segments
number of 512 byte segments
int extradata_size
Size of the extradata content in bytes.
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define MTV_AUDIO_PADDING_SIZE
int avio_r8(AVIOContext *s)
static int read_header(FFV1Context *f, RangeCoder *c)
#define MTV_ASUBCHUNK_DATA_SIZE
unsigned int avio_rl24(AVIOContext *s)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
unsigned int img_colorfmt
frame colorfmt rgb 565/555
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
@ AV_PIX_FMT_RGB565BE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
char * av_strdup(const char *s)
Duplicate a string.
static int read_probe(const AVProbeData *p)
#define avpriv_request_sample(...)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int64_t pos
byte position in stream, -1 if unknown
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
unsigned int audio_identifier
'MP3' on all files I have seen
Generated on Sat Oct 18 2025 19:23:26 for FFmpeg by
doxygen
1.8.17