FFmpeg: libavformat/wvdec.c Source File
Go to the documentation of this file. 1 /*
2 * WavPack demuxer
3 * Copyright (c) 2006,2011 Konstantin Shishkov
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
31
45 };
46
48 6000, 8000, 9600, 11025, 12000, 16000, 22050, 24000,
49 32000, 44100, 48000, 64000, 88200, 96000, 192000, -1
50 };
51
60
63
65 {
66 /* check file header */
68 return 0;
75 else
76 return 0;
77 }
78
80 {
83 int rate, bpp, chan;
84 uint32_t chmask,
flags;
85 unsigned rate_x;
86
88
89 /* don't return bogus packets with the ape tag data */
92
96
101 }
102
107 }
108
109 /* Blocks with zero samples don't contain actual audio information
110 * and should be ignored */
112 return 0;
113 // parse flags
124 }
129 "Cannot determine additional parameters\n");
131 }
137 if (id & 0x40)
139 switch (id & 0x3F) {
140 case 0xD:
143 "Insufficient channel information\n");
145 }
148 case 0:
150 break;
151 case 1:
153 break;
154 case 2:
156 break;
157 case 3:
159 break;
160 case 4:
162 chan |= (
avio_r8(pb) & 0xF) << 8;
163 chan += 1;
165 break;
166 case 5:
168 chan |= (
avio_r8(pb) & 0xF) << 8;
169 chan += 1;
171 break;
172 default:
174 "Invalid channel info size %d\n",
size);
176 }
177 break;
178 case 0xE:
181 "Invalid DSD block\n");
183 }
184 rate_x = 1
U << (
avio_r8(pb) & 0x1f);
187 break;
188 case 0x27:
190 break;
191 default:
193 }
194 if (id & 0x40)
196 }
197 if (rate == -1 || rate * (uint64_t)rate_x >= INT_MAX) {
199 "Cannot determine custom sampling rate\n");
201 }
203 }
211 wc->
rate = rate * rate_x;
212
215 "Bits per sample differ, this block: %i, header block: %i\n",
218 }
221 "Channels differ, this block: %i, header block: %i\n",
224 }
227 "Sampling rate differ, this block: %i, header block: %i\n",
228 rate * rate_x, wc->
rate);
230 }
231 return 0;
232 }
233
235 {
240
242 for (;;) {
247 else
248 break;
249 }
250
251 /* now we are ready: build format streams */
253 if (!st)
267
274 }
275
276 return 0;
277 }
278
280 {
283 int off;
285 uint32_t block_samples;
286
292 }
293
301 }
305 }
306
310 }
312
316 }
317 }
323 if (block_samples > INT32_MAX)
325 "Too many samples in block: %"PRIu32"\n", block_samples);
326 else
328
329 return 0;
330 }
331
340 };
#define AV_LOG_WARNING
Something somehow does not look correct.
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
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.
#define AVERROR_EOF
End of file.
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
#define AV_CH_LAYOUT_MONO
static int wv_read_header(AVFormatContext *s)
int av_grow_packet(AVPacket *pkt, int grow_by)
Increase packet size, correctly zeroing padding.
static int wv_read_packet(AVFormatContext *s, AVPacket *pkt)
void ff_id3v1_read(AVFormatContext *s)
Read an ID3v1 tag.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int buf_size
Size of buf except extra allocated bytes.
static int wv_probe(const AVProbeData *p)
int64_t ff_ape_parse_tag(AVFormatContext *s)
Read and parse an APE tag.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int64_t duration
Decoding: duration of the stream, in stream time base.
unsigned int avio_rl16(AVIOContext *s)
#define AV_CH_LAYOUT_STEREO
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
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.
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
#define WV_FLAG_FINAL_BLOCK
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static int read_header(FFV1Context *f)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
This structure contains the data a format has to probe a file.
AVChannelLayout ch_layout
Audio only.
int sample_rate
Audio only.
int ff_wv_parse_header(WvHeader *wv, const uint8_t *data)
Parse a WavPack block header.
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int avio_r8(AVIOContext *s)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
unsigned int avio_rl24(AVIOContext *s)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
uint8_t block_header[WV_HEADER_SIZE]
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
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.
static int read_probe(const AVProbeData *p)
int bits_per_coded_sample
The number of bits per sample in the codedwords.
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
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
const FFInputFormat ff_wv_demuxer
#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.
void * priv_data
Format private data.
static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb)
static const int wv_rates[16]
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Generated on Fri Aug 22 2025 13:59:37 for FFmpeg by
doxygen
1.8.17