FFmpeg: libavformat/vqf.c Source File
Go to the documentation of this file. 1 /*
2 * VQF demuxer
3 * Copyright (c) 2009 Vitor Sessak
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
34
36 {
38 return 0;
39
40 if (!memcmp(probe_packet->
buf + 4,
"97012000", 8))
42
43 if (!memcmp(probe_packet->
buf + 4,
"00052200", 8))
45
48
50 }
51
53 unsigned int tag_len, unsigned int remaining)
54 {
56 char *buf,
key[5] = {0};
57
59 return;
60
62 if (!buf)
63 return;
68 }
69
71 { "(c) ", "copyright" },
72 { "ARNG", "arranger" },
73 { "AUTH", "author" },
74 { "BAND", "band" },
75 { "CDCT", "conductor" },
76 { "COMT", "comment" },
77 { "FILE", "filename" },
78 { "GENR", "genre" },
79 { "LABL", "publisher" },
80 { "MUSC", "composer" },
81 { "NAME", "title" },
82 { "NOTE", "note" },
83 { "PROD", "producer" },
84 { "PRSN", "personnel" },
85 { "REMX", "remixer" },
86 { "SING", "singer" },
87 { "TRCK", "track" },
88 { "WORD", "words" },
89 { 0 },
90 };
91
93 {
96 int chunk_tag;
97 int rate_flag = -1;
98 int header_size;
99 int read_bitrate = 0;
101 uint8_t comm_chunk[12];
102
103 if (!st)
105
107
109
110 if (header_size < 0)
112
116
117 do {
120
121 if (chunk_tag ==
MKTAG(
'D',
'A',
'T',
'A'))
122 break;
123
125
126 if ((
unsigned)
len > INT_MAX/2 || header_size < 8) {
128 return -1;
129 }
130
131 header_size -= 8;
132
133 switch(chunk_tag){
134 case MKTAG(
'C',
'O',
'M',
'M'):
137
140 read_bitrate =
AV_RB32(comm_chunk + 4);
141 rate_flag =
AV_RB32(comm_chunk + 8);
143
147 }
148
150 break;
151 case MKTAG(
'D',
'S',
'I',
'Z'):
// size of compressed data
152 {
154 }
155 break;
156 case MKTAG(
'Y',
'E',
'A',
'R'):
// recording date
157 case MKTAG(
'E',
'N',
'C',
'D'):
// compression date
158 case MKTAG(
'E',
'X',
'T',
'R'):
// reserved
159 case MKTAG(
'_',
'Y',
'M',
'H'):
// reserved
160 case MKTAG(
'_',
'N',
'T',
'T'):
// reserved
161 case MKTAG(
'_',
'I',
'D',
'3'):
// reserved for ID3 tags
163 break;
164 default:
166 break;
167 }
168
170
171 }
while (header_size >= 0 && !
avio_feof(
s->pb));
172
173 switch (rate_flag) {
174 case -1:
176 return -1;
177 case 44:
179 break;
180 case 22:
182 break;
183 case 11:
185 break;
186 default:
187 if (rate_flag < 8 || rate_flag > 44) {
190 }
192 break;
193 }
194
200 }
201
204 case (11<<8) + 8 :
205 case (8 <<8) + 8 :
206 case (11<<8) + 10:
207 case (22<<8) + 32:
209 break;
210 case (16<<8) + 16:
211 case (22<<8) + 20:
212 case (22<<8) + 24:
214 break;
215 case (44<<8) + 40:
216 case (44<<8) + 48:
218 break;
219 default:
222 return -1;
223 }
226
227 /* put first 12 bytes of COMM chunk in extradata */
231
233
234 return 0;
235 }
236
238 {
241 int size = (
c->frame_bit_len -
c->remaining_bits + 7)>>3;
242
245
249
250 pkt->
data[0] = 8 -
c->remaining_bits;
// Number of bits to skip
253
256 }
257
259 c->remaining_bits = (
size << 3) -
c->frame_bit_len +
c->remaining_bits;
260
262 }
263
265 int stream_index, int64_t timestamp,
int flags)
266 {
271
272 st =
s->streams[stream_index];
278 pos *=
c->frame_bit_len;
279
282
285
286 c->remaining_bits = -7 - ((
pos-7)&7);
287 return 0;
288 }
289
298 .extensions = "vqf,vql,vqe",
299 };
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
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.
static int vqf_probe(const AVProbeData *probe_packet)
enum AVMediaType codec_type
General type of the encoded data.
static int vqf_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
static void add_metadata(AVFormatContext *s, uint32_t tag, unsigned int tag_len, unsigned int remaining)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int nb_channels
Number of channels in this layout.
const AVInputFormat ff_vqf_demuxer
static const AVMetadataConv vqf_metadata_conv[]
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
@ AV_ROUND_UP
Round toward +infinity.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
unsigned int avio_rb32(AVIOContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static int vqf_read_packet(AVFormatContext *s, AVPacket *pkt)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static int read_header(FFV1Context *f)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
This structure contains the data a format has to probe a file.
AVChannelLayout ch_layout
Audio only.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int sample_rate
Audio only.
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
static int vqf_read_header(AVFormatContext *s)
@ AV_ROUND_DOWN
Round toward -infinity.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
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.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set that converts the value to a string and stores it.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int64_t pos
byte position in stream, -1 if unknown
#define flags(name, subs,...)
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Generated on Wed Aug 24 2022 21:42:21 for FFmpeg by
doxygen
1.8.17