FFmpeg: libavformat/usmdec.c Source File
Go to the documentation of this file. 1 /*
2 * USM demuxer
3 * Copyright (c) 2023 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
24
28
33
46
53
55 {
57 return 0;
58
60 return 0;
61
63 }
64
66 {
68 return 0;
69 }
70
73 uint32_t parent_chunk_size)
74 {
77 uint32_t chunk_type, chunk_size,
offset;
78 uint32_t unique_offset, string_offset;
79 int nb_items, unique_size, nb_dictionaries;
82
85
86 if (chunk_type !=
MKBETAG(
'@',
'U',
'T',
'F'))
88
89 if (!chunk_size || chunk_size >= parent_chunk_size)
91
95
98
100 ugb = gb;
101 sgb = gb;
102 unique_offset = bytestream2_get_be32(&gb);
103 string_offset = bytestream2_get_be32(&gb);
104 /*byte_offset =*/ bytestream2_get_be32(&gb);
105 /*payload_name_offset =*/ bytestream2_get_be32(&gb);
106 nb_items = bytestream2_get_be16(&gb);
107 unique_size = bytestream2_get_be16(&gb);
108 nb_dictionaries = bytestream2_get_be32(&gb);
109 if (nb_dictionaries == 0)
111
116
118
119 for (
int i = 0;
i < nb_items;
i++) {
123 int n = 0;
124
125 type = bytestream2_get_byte(&gb);
126 offset = bytestream2_get_be32(&gb);
127
130 key[n] = bytestream2_get_byte(&sgb);
132 break;
133 if (n >=
sizeof(
key) - 1)
134 break;
135 n++;
136 }
138
139 if ((
type >> 5) == 1)
140 xgb = &gb;
141 else
142 xgb = &ugb;
143
144 switch (
type & 0x1F) {
145 case 0x10:
146 case 0x11:
147 value = bytestream2_get_byte(xgb);
148 break;
149 case 0x12:
150 case 0x13:
151 value = bytestream2_get_be16(xgb);
152 break;
153 case 0x14:
154 case 0x15:
155 value = bytestream2_get_be32(xgb);
156 break;
157 case 0x16:
158 case 0x17:
159 value = bytestream2_get_be64(xgb);
160 break;
161 case 0x18:
163 break;
164 case 0x19:
166 break;
167 case 0x1A:
168 break;
169 }
170
172 if (!strcmp(
key,
"sampling_rate")) {
175 }
else if (!strcmp(
key,
"num_channels")) {
177 }
else if (!strcmp(
key,
"total_samples")) {
179 }
else if (!strcmp(
key,
"audio_codec")) {
181 case 2:
183 break;
184 case 4:
186 break;
187 default:
189 break;
190 }
191 }
193 if (!strcmp(
key,
"width")) {
195 }
else if (!strcmp(
key,
"height")) {
197 }
else if (!strcmp(
key,
"total_frames")) {
199 }
else if (!strcmp(
key,
"framerate_n")) {
201 }
else if (!strcmp(
key,
"framerate_d")) {
203 }
else if (!strcmp(
key,
"mpeg_codec")) {
205 case 1:
207 break;
208 case 5:
210 break;
211 case 9:
213 break;
214 default:
216 break;
217 }
218 }
219 }
220 }
221
224
225 return 0;
226 }
227
229 uint32_t chunk_type, uint32_t chunk_size,
231 {
232 const int is_audio = chunk_type ==
MKBETAG(
'@',
'S',
'F',
'A');
233 const int is_alpha = chunk_type ==
MKBETAG(
'@',
'A',
'L',
'P');
234 const int is_subtt = chunk_type ==
MKBETAG(
'@',
'S',
'B',
'T');
236 int padding_size, payload_type, payload_offset;
238 int stream_index, frame_rate;
240
260
261 if (payload_type == 1) {
262 if (usm->
ch[ch_type][stream_index].
used == 0) {
264
265 switch (ch_type) {
269 break;
272 break;
275 break;
276 default:
278 }
279
283
287 }
288 } else if (payload_type == 0) {
289 if (usm->
ch[ch_type][stream_index].
used == 1) {
291 int get_extradata = 0;
292 uint32_t pkt_size;
294
298 if (!st)
304
310 break;
315 break;
316 }
317
322
326 }
327
331
333 if (get_extradata) {
336 } else {
340 } else {
344
346 }
347 }
348
350
353 if (get_extradata == 0)
355 }
356 }
357
365 }
366
368 {
371
373 uint32_t chunk_type, chunk_size;
374 int got_packet = 0;
376
382 if (!chunk_size)
384
385 switch (chunk_type) {
387 default:
389 break;
395 got_packet =
ret > 0;
396 break;
397 }
398
399 if (got_packet)
401
402 if (got_packet ||
ret < 0)
403 break;
404 }
405
407 }
408
410 {
414 return 0;
415 }
416
420 .p.extensions = "usm",
427 };
static int chunk_start(AVFormatContext *s)
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 av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
int nb_channels
Number of channels in this layout.
int ff_get_extradata(void *logctx, AVCodecParameters *par, AVIOContext *pb, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0 and f...
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
int64_t duration
Decoding: duration of the stream, in stream time base.
unsigned int avio_rb32(AVIOContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static int64_t parse_chunk(AVFormatContext *s, AVIOContext *pb, uint32_t chunk_type, uint32_t chunk_size, AVPacket *pkt)
enum AVStreamParseType need_parsing
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static int read_header(FFV1Context *f)
Rational number (pair of numerator and denominator).
This structure contains the data a format has to probe a file.
AVChannelLayout ch_layout
Audio only.
int sample_rate
Audio only.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
int64_t nb_frames
number of frames in this stream if known or 0
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static AVRational av_make_q(int num, int den)
Create an AVRational.
#define MKBETAG(a, b, c, d)
int avio_r8(AVIOContext *s)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
const FFInputFormat ff_usm_demuxer
#define FFERROR_REDO
Returned by demuxers to indicate that data was consumed but discarded (ignored streams or junk data).
#define i(width, name, range_min, range_max)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
static int usm_probe(const AVProbeData *p)
unsigned int avio_rb16(AVIOContext *s)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
int index
stream index in AVFormatContext
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int usm_read_header(AVFormatContext *s)
static int parse_utf(AVFormatContext *s, AVIOContext *pb, USMChannel *ch, int ch_type, uint32_t parent_chunk_size)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static int usm_read_close(AVFormatContext *s)
static int read_probe(const AVProbeData *p)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
int64_t pos
byte position in stream, -1 if unknown
static int usm_read_packet(AVFormatContext *s, AVPacket *pkt)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#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 Thu Sep 26 2024 23:15:53 for FFmpeg by
doxygen
1.8.17