FFmpeg: libavformat/lafdec.c Source File
Go to the documentation of this file. 1 /*
2 * Limitless Audio Format demuxer
3 * Copyright (c) 2022 Paul B Mahol
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
29 #define MAX_STREAMS 4096
30
38
45
47
51
53 {
54 if (memcmp(p->
buf,
"LIMITLESS", 9))
55 return 0;
56 if (memcmp(p->
buf + 9,
"HEAD", 4))
57 return 0;
59 }
60
62 {
65 unsigned st_count,
mode;
66 unsigned sample_rate;
70 int bpp;
71
75
85
86 for (
int i = 0;
i < st_count;
i++) {
88
109 } else {
111 }
112 }
113
116
119
121 case 0:
123 bpp = 1;
124 break;
125 case 1:
127 bpp = 2;
128 break;
129 case 2:
131 bpp = 4;
132 break;
133 case 3:
135 bpp = 3;
136 break;
137 default:
139 }
140
144 if ((
int64_t)bpp * st_count * (
int64_t)sample_rate >= INT32_MAX ||
146 )
148 s->data =
av_calloc(st_count * sample_rate, bpp);
151
152 for (
unsigned i = 0;
i < st_count;
i++) {
156 if (!st)
158
166
168 }
169
171
172 return 0;
173 }
174
176 {
180 const int bpp =
s->bpp;
184
186
190
192 int cur_st = 0, st_count = 0, st_index = 0;
193
197 for (
int i = 0;
i <
s->header_len;
i++) {
198 uint8_t
val =
s->header[
i];
199
200 for (
int j = 0; j < 8 && cur_st <
ctx->
nb_streams; j++, cur_st++) {
202
206 st_count++;
207 }
209 st_index++;
210 }
211 }
212
213 s->index =
s->stored_index = 0;
214 s->nb_stored = st_count;
215 if (!st_count)
220 }
221
223 stp = &
s->p[
s->index];
228 stp = &
s->p[
s->index];
229 }
231
235
236 switch (bpp) {
237 case 1:
239 pkt->
data[n] =
s->data[n *
s->nb_stored +
s->stored_index];
240 break;
241 case 2:
244 break;
245 case 3:
248 break;
249 case 4:
252 break;
253 }
254
259
260 return 0;
261 }
262
264 {
266
268
269 return 0;
270 }
271
274 {
276
277 s->stored_index =
s->index =
s->nb_stored = 0;
278
279 return -1;
280 }
281
285 .p.extensions = "laf",
294 };
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.
This struct describes the properties of an encoded stream.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_EOF
End of file.
static int laf_read_header(AVFormatContext *ctx)
static int laf_read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
AVStream ** streams
A list of all streams in the file.
uint8_t header[(MAX_STREAMS+7)/8]
int nb_channels
Number of channels in this layout.
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about quality
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
static double val(void *priv, double ch)
int64_t duration
Decoding: duration of the stream, in stream time base.
unsigned int avio_rb32(AVIOContext *s)
#define AV_CH_LOW_FREQUENCY
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.
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
StreamParams p[MAX_STREAMS]
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static int read_header(FFV1Context *f)
const FFInputFormat ff_laf_demuxer
AVIOContext * pb
I/O context.
This structure contains the data a format has to probe a file.
#define AV_CH_FRONT_CENTER
AVChannelLayout ch_layout
Audio only.
int sample_rate
Audio only.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
An AVChannelLayout holds information about the channel layout of audio data.
#define MKBETAG(a, b, c, d)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_RL24
int avio_r8(AVIOContext *s)
#define i(width, name, range_min, range_max)
void * av_calloc(size_t nmemb, size_t size)
static int laf_read_packet(AVFormatContext *ctx, AVPacket *pkt)
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 again
static int laf_probe(const AVProbeData *p)
static int laf_read_close(AVFormatContext *ctx)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
#define AV_CH_FRONT_RIGHT
static int read_probe(const AVProbeData *p)
#define AV_CHANNEL_LAYOUT_MONO
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
uint64_t avio_rl64(AVIOContext *s)
#define AV_CHANNEL_LAYOUT_MASK(nb, m)
Macro to define native channel layouts.
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
void * priv_data
Format private data.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Generated on Fri Aug 22 2025 13:59:29 for FFmpeg by
doxygen
1.8.17