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
31
32 #define MTV_ASUBCHUNK_DATA_SIZE 500
33 #define MTV_HEADER_SIZE 512
34 #define MTV_AUDIO_PADDING_SIZE 12
35 #define MTV_IMAGE_DEFAULT_BPP 16
36 #define MTV_AUDIO_SAMPLING_RATE 44100
37
39
40 unsigned int file_size;
///< filesize, not always right
41 unsigned int segments;
///< number of 512 byte segments
43 unsigned int audio_br;
///< bitrate of audio channel (mp3)
45 unsigned int img_bpp;
///< frame bits per pixel
51
53
55 {
56 /* we need at least 57 bytes from the header
57 * to try parsing all required fields
58 */
60 return 0;
61
62 /* Magic is 'AMV' */
63 if (*p->
buf !=
'A' || *(p->
buf + 1) !=
'M' || *(p->
buf + 2) !=
'V')
64 return 0;
65
66 /* Audio magic is always MP3 */
67 if (p->
buf[43] !=
'M' || p->
buf[44] !=
'P' || p->
buf[45] !=
'3')
68 return 0;
69
70 /* Check for nonzero in bpp and (width|height) header fields */
72 return 0;
73
74 /* If width or height are 0 then imagesize header field should not */
76 {
79 else
80 return 0;
81 }
82
83 /* Image bpp is not an absolutely required
84 * field as we latter claim it should be 16
85 * no matter what. All samples in the wild
86 * are RGB565/555.
87 */
90
91 /* We had enough data to parse header values
92 * but we expect to be able to get 512 bytes
93 * of header to be sure.
94 */
97
99 }
100
102 {
106 unsigned int audio_subsegments;
107
119
120 /* Assume 16bpp even if claimed otherwise.
121 * We know its going to be RGBG565/555 anyway
122 */
127 }
128
129 /* Calculate width and height if missing from header */
130
134
138
140 av_log(
s,
AV_LOG_ERROR,
"width or height or segment_size is invalid and I cannot calculate them from other information\n");
142 }
143
146
147 if (audio_subsegments == 0) {
150 }
151
156
157 // FIXME Add sanity check here
158
159 // all systems go! init decoders
160
161 // video - raw rgb565
162
164 if(!st)
166
177
178 // audio - mp3
179
181 if(!st)
183
189
190 // Jump over header
191
194
195 return 0;
196
197 }
198
200 {
204
206 {
208
212
215
216 }else
217 {
221
223 }
224
226 }
227
235 };
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
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
enum AVMediaType codec_type
General type of the encoded data.
static int mtv_probe(const AVProbeData *p)
int buf_size
Size of buf except extra allocated bytes.
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.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
#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
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static int read_header(FFV1Context *f)
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)
#define MTV_ASUBCHUNK_DATA_SIZE
unsigned int avio_rl24(AVIOContext *s)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
unsigned int img_colorfmt
frame colorfmt rgb 565/555
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.
#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
const AVInputFormat ff_mtv_demuxer
Generated on Wed Aug 24 2022 21:42:17 for FFmpeg by
doxygen
1.8.17