75 uint32_t parent_chunk_size)
79 uint32_t chunk_type, chunk_size,
offset;
80 uint32_t unique_offset, string_offset;
81 int nb_items, unique_size, nb_dictionaries;
88 if (chunk_type !=
MKBETAG(
'@',
'U',
'T',
'F'))
91 if (!chunk_size || chunk_size >= parent_chunk_size)
104 unique_offset = bytestream2_get_be32(&gb);
105 string_offset = bytestream2_get_be32(&gb);
106 bytestream2_get_be32(&gb);
107 bytestream2_get_be32(&gb);
108 nb_items = bytestream2_get_be16(&gb);
109 unique_size = bytestream2_get_be16(&gb);
110 nb_dictionaries = bytestream2_get_be32(&gb);
111 if (nb_dictionaries == 0)
121 for (
int i = 0;
i < nb_items;
i++) {
127 type = bytestream2_get_byte(&gb);
128 offset = bytestream2_get_be32(&gb);
132 key[n] = bytestream2_get_byte(&sgb);
135 if (n >=
sizeof(
key) - 1)
141 if ((
type >> 5) == 1)
146 switch (
type & 0x1F) {
149 value = bytestream2_get_byte(xgb);
153 value = bytestream2_get_be16(xgb);
157 value = bytestream2_get_be32(xgb);
161 value = bytestream2_get_be64(xgb);
174 if (!strcmp(
key,
"sampling_rate")) {
177 }
else if (!strcmp(
key,
"num_channels")) {
179 }
else if (!strcmp(
key,
"total_samples")) {
181 }
else if (!strcmp(
key,
"audio_codec")) {
195 if (!strcmp(
key,
"width")) {
197 }
else if (!strcmp(
key,
"height")) {
199 }
else if (!strcmp(
key,
"total_frames")) {
201 }
else if (!strcmp(
key,
"framerate_n")) {
203 }
else if (!strcmp(
key,
"framerate_d")) {
205 }
else if (!strcmp(
key,
"mpeg_codec")) {
231 uint32_t chunk_type, uint32_t chunk_size,
234 const int is_audio = chunk_type ==
MKBETAG(
'@',
'S',
'F',
'A');
235 const int is_alpha = chunk_type ==
MKBETAG(
'@',
'A',
'L',
'P');
236 const int is_subtt = chunk_type ==
MKBETAG(
'@',
'S',
'B',
'T');
238 int padding_size, payload_type, payload_offset;
240 int stream_index, frame_rate;
263 if (payload_type == 1) {
264 if (usm->
ch[ch_type][stream_index].
used == 0) {
286 ret =
parse_utf(
s, pb, ch, ch_type, chunk_size);
290 }
else if (payload_type == 0) {
291 if (usm->
ch[ch_type][stream_index].
used == 1) {
293 int get_extradata = 0;
334 pkt_size = chunk_size - (ret -
chunk_start) - padding_size;
355 if (get_extradata == 0)
375 uint32_t chunk_type, chunk_size;
387 switch (chunk_type) {
397 got_packet = ret > 0;
404 if (got_packet || ret < 0)
422 .p.extensions =
"usm",
unsigned int avio_rb16(AVIOContext *s)
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
unsigned int avio_rb32(AVIOContext *s)
int avio_r8(AVIOContext *s)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
#define FFERROR_REDO
Returned by demuxers to indicate that data was consumed but discarded (ignored streams or junk data).
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 int read_header(FFV1Context *f, RangeCoder *c)
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static AVRational av_make_q(int num, int den)
Create an AVRational.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int read_close(AVFormatContext *ctx)
#define MKTAG(a, b, c, d)
#define MKBETAG(a, b, c, d)
Memory handling functions.
int nb_channels
Number of channels in this layout.
This struct describes the properties of an encoded stream.
int height
The height of the video frame in pixels.
AVChannelLayout ch_layout
The channel layout and number of channels.
int width
The width of the video frame in pixels.
enum AVMediaType codec_type
General type of the encoded data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
This structure stores compressed data.
This structure contains the data a format has to probe a file.
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int64_t nb_frames
number of frames in this stream if known or 0
int64_t duration
Decoding: duration of the stream, in stream time base.
int index
stream index in AVFormatContext
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
enum AVStreamParseType need_parsing
static int usm_read_header(AVFormatContext *s)
static int usm_read_close(AVFormatContext *s)
static int usm_probe(const AVProbeData *p)
static int usm_read_packet(AVFormatContext *s, AVPacket *pkt)
static int parse_utf(AVFormatContext *s, AVIOContext *pb, USMChannel *ch, int ch_type, uint32_t parent_chunk_size)
static int64_t parse_chunk(AVFormatContext *s, AVIOContext *pb, uint32_t chunk_type, uint32_t chunk_size, AVPacket *pkt)
static int chunk_start(AVFormatContext *s)