FFmpeg
Loading...
Searching...
No Matches
xmv.c
Go to the documentation of this file.
1/*
2 * Microsoft XMV demuxer
3 * Copyright (c) 2011 Sven Hesse <drmccoy@drmccoy.de>
4 * Copyright (c) 2011 Matthew Hoops <clone2727@gmail.com>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23/**
24 * @file
25 * Microsoft XMV demuxer
26 */
27
28#include <inttypes.h>
29
31#include "libavutil/mem.h"
32
33#include "avformat.h"
34#include "avio_internal.h"
35#include "demux.h"
36#include "internal.h"
37#include "riff.h"
38#include "libavutil/avassert.h"
39
40/** The min size of an XMV header. */
41#define XMV_MIN_HEADER_SIZE 36
42
43/** Audio flag: ADPCM'd 5.1 stream, front left / right channels */
44#define XMV_AUDIO_ADPCM51_FRONTLEFTRIGHT 1
45/** Audio flag: ADPCM'd 5.1 stream, front center / low frequency channels */
46#define XMV_AUDIO_ADPCM51_FRONTCENTERLOW 2
47/** Audio flag: ADPCM'd 5.1 stream, rear left / right channels */
48#define XMV_AUDIO_ADPCM51_REARLEFTRIGHT 4
49
50/** Audio flag: Any of the ADPCM'd 5.1 stream flags. */
51#define XMV_AUDIO_ADPCM51 (XMV_AUDIO_ADPCM51_FRONTLEFTRIGHT | \
52 XMV_AUDIO_ADPCM51_FRONTCENTERLOW | \
53 XMV_AUDIO_ADPCM51_REARLEFTRIGHT)
54
55#define XMV_BLOCK_ALIGN_SIZE 36
56
57/** A video packet with an XMV file. */
58typedef struct XMVVideoPacket {
60 int stream_index; ///< The decoder stream index for this video packet.
61
62 uint32_t data_size; ///< The size of the remaining video data.
63 uint64_t data_offset; ///< The offset of the video data within the file.
64
65 uint32_t current_frame; ///< The current frame within this video packet.
66 uint32_t frame_count; ///< The amount of frames within this video packet.
67
68 int has_extradata; ///< Does the video packet contain extra data?
69 uint8_t extradata[4]; ///< The extra data
70
71 int64_t last_pts; ///< PTS of the last video frame.
72 int64_t pts; ///< PTS of the most current video frame.
74
75/** An audio packet with an XMV file. */
76typedef struct XMVAudioPacket {
78 int stream_index; ///< The decoder stream index for this audio packet.
79
80 /* Stream format properties. */
81 uint16_t compression; ///< The type of compression.
82 uint16_t channels; ///< Number of channels.
83 int32_t sample_rate; ///< Sampling rate.
84 uint16_t bits_per_sample; ///< Bits per compressed sample.
85 uint64_t bit_rate; ///< Bits of compressed data per second.
86 uint16_t flags; ///< Flags
87 unsigned block_align; ///< Bytes per compressed block.
88
89 enum AVCodecID codec_id; ///< The codec ID of the compression scheme.
90
91 uint32_t data_size; ///< The size of the remaining audio data.
92 uint64_t data_offset; ///< The offset of the audio data within the file.
93
94 uint32_t frame_size; ///< Number of bytes to put into an audio frame.
96
97/** Context for demuxing an XMV file. */
98typedef struct XMVDemuxContext {
99 uint16_t audio_track_count; ///< Number of audio track in this file.
100
101 uint32_t this_packet_size; ///< Size of the current packet.
102 uint32_t next_packet_size; ///< Size of the next packet.
103
104 uint64_t this_packet_offset; ///< Offset of the current packet.
105 uint64_t next_packet_offset; ///< Offset of the next packet.
106
107 uint16_t current_stream; ///< The index of the stream currently handling.
108 uint16_t stream_count; ///< The number of streams in this file.
109
111 uint32_t video_width;
112 uint32_t video_height;
113
114 XMVVideoPacket video; ///< The video packet contained in each packet.
115 XMVAudioPacket *audio; ///< The audio packets contained in each packet.
117
118static int xmv_probe(const AVProbeData *p)
119{
120 uint32_t file_version;
121
122 if (p->buf_size < XMV_MIN_HEADER_SIZE)
123 return 0;
124
125 file_version = AV_RL32(p->buf + 16);
126 if ((file_version == 0) || (file_version > 4))
127 return 0;
128
129 if (!memcmp(p->buf + 12, "xobX", 4))
130 return AVPROBE_SCORE_MAX;
131
132 return 0;
133}
134
136{
137 XMVDemuxContext *xmv = s->priv_data;
138
139 av_freep(&xmv->audio);
140
141 return 0;
142}
143
145{
146 XMVDemuxContext *xmv = s->priv_data;
147 AVIOContext *pb = s->pb;
148
149 uint32_t file_version;
150 uint32_t this_packet_size;
151 uint16_t audio_track;
152
153 s->ctx_flags |= AVFMTCTX_NOHEADER;
154
155 avio_skip(pb, 4); /* Next packet size */
156
157 this_packet_size = avio_rl32(pb);
158
159 avio_skip(pb, 4); /* Max packet size */
160 avio_skip(pb, 4); /* "xobX" */
161
162 file_version = avio_rl32(pb);
163 if ((file_version != 4) && (file_version != 2))
164 avpriv_request_sample(s, "Uncommon version %"PRIu32"", file_version);
165
166 /* Video tracks */
167
168 xmv->video_width = avio_rl32(pb);
169 xmv->video_height = avio_rl32(pb);
170 xmv->video_duration = avio_rl32(pb);
171
172 /* Audio tracks */
173
174 xmv->audio_track_count = avio_rl16(pb);
175
176 avio_skip(pb, 2); /* Unknown (padding?) */
177
178 xmv->audio = av_calloc(xmv->audio_track_count, sizeof(*xmv->audio));
179 if (!xmv->audio)
180 return AVERROR(ENOMEM);
181
182 for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
183 XMVAudioPacket *packet = &xmv->audio[audio_track];
184
185 packet->compression = avio_rl16(pb);
186 packet->channels = avio_rl16(pb);
187 packet->sample_rate = avio_rl32(pb);
188 packet->bits_per_sample = avio_rl16(pb);
189 packet->flags = avio_rl16(pb);
190
191 packet->bit_rate = (uint64_t)packet->bits_per_sample *
192 packet->sample_rate *
193 packet->channels;
194 packet->block_align = XMV_BLOCK_ALIGN_SIZE * packet->channels;
195 packet->codec_id = ff_wav_codec_get_id(packet->compression,
196 packet->bits_per_sample);
197
198 packet->stream_index = -1;
199
200 packet->frame_size = 0;
201
202 /* TODO: ADPCM'd 5.1 sound is encoded in three separate streams.
203 * Those need to be interleaved to a proper 5.1 stream. */
204 if (packet->flags & XMV_AUDIO_ADPCM51)
205 av_log(s, AV_LOG_WARNING, "Unsupported 5.1 ADPCM audio stream "
206 "(0x%04X)\n", packet->flags);
207
208 if (!packet->channels || packet->sample_rate <= 0 ||
209 packet->channels >= UINT16_MAX / XMV_BLOCK_ALIGN_SIZE) {
210 av_log(s, AV_LOG_ERROR, "Invalid parameters for audio track %"PRIu16".\n",
211 audio_track);
212 return AVERROR_INVALIDDATA;
213 }
214 }
215
216
217 /* Initialize the packet context */
218
219 xmv->next_packet_offset = avio_tell(pb);
220 if (this_packet_size < xmv->next_packet_offset)
221 return AVERROR_INVALIDDATA;
222 xmv->next_packet_size = this_packet_size - xmv->next_packet_offset;
223 xmv->stream_count = xmv->audio_track_count + 1;
224
225 return 0;
226}
227
228static void xmv_read_extradata(uint8_t *extradata, AVIOContext *pb)
229{
230 /* Read the XMV extradata */
231
232 uint32_t data = avio_rl32(pb);
233
234 int mspel_bit = !!(data & 0x01);
235 int loop_filter = !!(data & 0x02);
236 int abt_flag = !!(data & 0x04);
237 int j_type_bit = !!(data & 0x08);
238 int top_left_mv_flag = !!(data & 0x10);
239 int per_mb_rl_bit = !!(data & 0x20);
240 int slice_count = (data >> 6) & 7;
241
242 /* Write it back as standard WMV2 extradata */
243
244 data = 0;
245
246 data |= mspel_bit << 15;
247 data |= loop_filter << 14;
248 data |= abt_flag << 13;
249 data |= j_type_bit << 12;
250 data |= top_left_mv_flag << 11;
251 data |= per_mb_rl_bit << 10;
252 data |= slice_count << 7;
253
254 AV_WB32(extradata, data);
255}
256
258{
259 XMVDemuxContext *xmv = s->priv_data;
260 AVIOContext *pb = s->pb;
261 int ret;
262
263 uint8_t data[8];
264 uint16_t audio_track;
265 uint64_t data_offset;
266
267 /* Next packet size */
268 xmv->next_packet_size = avio_rl32(pb);
269
270 /* Packet video header */
271
272 if ((ret = ffio_read_size(pb, data, 8)) < 0)
273 return ret;
274
275 xmv->video.data_size = AV_RL32(data) & 0x007FFFFF;
276
277 xmv->video.current_frame = 0;
278 xmv->video.frame_count = (AV_RL32(data) >> 23) & 0xFF;
279
280 xmv->video.has_extradata = (data[3] & 0x80) != 0;
281
282 if (!xmv->video.created) {
284 if (!vst)
285 return AVERROR(ENOMEM);
286
287 avpriv_set_pts_info(vst, 32, 1, 1000);
288
291 vst->codecpar->codec_tag = MKBETAG('W', 'M', 'V', '2');
292 vst->codecpar->width = xmv->video_width;
293 vst->codecpar->height = xmv->video_height;
294
295 vst->duration = xmv->video_duration;
296
297 xmv->video.stream_index = vst->index;
298
299 xmv->video.created = 1;
300 }
301
302 /* Adding the audio data sizes and the video data size keeps you 4 bytes
303 * short for every audio track. But as playing around with XMV files with
304 * ADPCM audio showed, taking the extra 4 bytes from the audio data gives
305 * you either completely distorted audio or click (when skipping the
306 * remaining 68 bytes of the ADPCM block). Subtracting 4 bytes for every
307 * audio track from the video data works at least for the audio. Probably
308 * some alignment thing?
309 * The video data has (always?) lots of padding, so it should work out...
310 */
311 xmv->video.data_size -= xmv->audio_track_count * 4;
312
313 xmv->current_stream = 0;
314 if (!xmv->video.frame_count) {
315 xmv->video.frame_count = 1;
316 xmv->current_stream = xmv->stream_count > 1;
317 }
318
319 /* Packet audio header */
320
321 for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
322 XMVAudioPacket *packet = &xmv->audio[audio_track];
323
324 if ((ret = ffio_read_size(pb, data, 4)) < 0)
325 return ret;
326
327 if (!packet->created) {
329 if (!ast)
330 return AVERROR(ENOMEM);
331
333 ast->codecpar->codec_id = packet->codec_id;
334 ast->codecpar->codec_tag = packet->compression;
335 ast->codecpar->ch_layout.nb_channels = packet->channels;
336 ast->codecpar->sample_rate = packet->sample_rate;
338 ast->codecpar->bit_rate = packet->bit_rate;
339 ast->codecpar->block_align = 36 * packet->channels;
340
341 avpriv_set_pts_info(ast, 32, 1, packet->sample_rate);
342
343 packet->stream_index = ast->index;
344
345 ast->duration = xmv->video_duration;
346
347 packet->created = 1;
348 }
349
350 packet->data_size = AV_RL32(data) & 0x007FFFFF;
351 if ((packet->data_size == 0) && (audio_track != 0))
352 /* This happens when I create an XMV with several identical audio
353 * streams. From the size calculations, duplicating the previous
354 * stream's size works out, but the track data itself is silent.
355 * Maybe this should also redirect the offset to the previous track?
356 */
357 packet->data_size = xmv->audio[audio_track - 1].data_size;
358
359 /* Carve up the audio data in frame_count slices */
360 packet->frame_size = packet->data_size / xmv->video.frame_count;
361 packet->frame_size -= packet->frame_size % packet->block_align;
362 }
363
364 /* Packet data offsets */
365
366 data_offset = avio_tell(pb);
367
368 xmv->video.data_offset = data_offset;
369 data_offset += xmv->video.data_size;
370
371 for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
372 xmv->audio[audio_track].data_offset = data_offset;
373 data_offset += xmv->audio[audio_track].data_size;
374 }
375
376 /* Video frames header */
377
378 /* Read new video extra data */
379 if (xmv->video.data_size > 0) {
380 if (xmv->video.has_extradata) {
382
383 xmv->video.data_size -= 4;
384 xmv->video.data_offset += 4;
385
386 if (xmv->video.stream_index >= 0) {
387 AVStream *vst = s->streams[xmv->video.stream_index];
388
389 av_assert0(xmv->video.stream_index < s->nb_streams);
390
391 if (vst->codecpar->extradata_size < 4) {
392 if ((ret = ff_alloc_extradata(vst->codecpar, 4)) < 0)
393 return ret;
394 }
395
396 memcpy(vst->codecpar->extradata, xmv->video.extradata, 4);
397 }
398 }
399 }
400
401 return 0;
402}
403
405{
406 XMVDemuxContext *xmv = s->priv_data;
407 AVIOContext *pb = s->pb;
408 int result;
409
410 if (xmv->next_packet_size == 0)
411 return AVERROR_EOF;
412
413 /* Seek to it */
415 if (avio_seek(pb, xmv->this_packet_offset, SEEK_SET) != xmv->this_packet_offset)
416 return AVERROR_INVALIDDATA;
417
418 /* Update the size */
420 if (xmv->this_packet_size < (12 + xmv->audio_track_count * 4))
421 return AVERROR_INVALIDDATA;
422
423 /* Process the header */
425 if (result)
426 return result;
427
428 /* Update the offset */
430
431 return 0;
432}
433
435 AVPacket *pkt, uint32_t stream)
436{
437 XMVDemuxContext *xmv = s->priv_data;
438 AVIOContext *pb = s->pb;
439 XMVAudioPacket *audio = &xmv->audio[stream];
440
441 uint32_t data_size;
442 int result;
443
444 /* Seek to it */
445 if (avio_seek(pb, audio->data_offset, SEEK_SET) != audio->data_offset)
446 return AVERROR_INVALIDDATA;
447
448 if ((xmv->video.current_frame + 1) < xmv->video.frame_count)
449 /* Not the last frame, get at most frame_size bytes. */
450 data_size = FFMIN(audio->frame_size, audio->data_size);
451 else
452 /* Last frame, get the rest. */
453 data_size = audio->data_size;
454
455 /* Read the packet */
456 result = av_get_packet(pb, pkt, data_size);
457 if (result <= 0)
458 return result;
459
460 pkt->stream_index = audio->stream_index;
461
462 /* Advance offset */
463 audio->data_size -= data_size;
464 audio->data_offset += data_size;
465
466 return 0;
467}
468
470 AVPacket *pkt)
471{
472 XMVDemuxContext *xmv = s->priv_data;
473 AVIOContext *pb = s->pb;
474 XMVVideoPacket *video = &xmv->video;
475
476 int result;
477 uint32_t frame_header;
478 uint32_t frame_size, frame_timestamp;
479 uint8_t *data, *end;
480
481 /* Seek to it */
482 if (avio_seek(pb, video->data_offset, SEEK_SET) != video->data_offset)
483 return AVERROR_INVALIDDATA;
484
485 /* Read the frame header */
487
488 frame_size = (frame_header & 0x1FFFF) * 4 + 4;
489 frame_timestamp = (frame_header >> 17);
490
491 if ((frame_size + 4) > video->data_size)
492 return AVERROR_INVALIDDATA;
493
494 /* Get the packet data */
495 result = av_get_packet(pb, pkt, frame_size);
496 if (result != frame_size)
497 return result;
498
499 /* Contrary to normal WMV2 video, the bit stream in XMV's
500 * WMV2 is little-endian.
501 * TODO: This manual swap is of course suboptimal.
502 */
503 for (data = pkt->data, end = pkt->data + frame_size; data < end; data += 4)
505
506 pkt->stream_index = video->stream_index;
507
508 /* Calculate the PTS */
509
510 video->last_pts = frame_timestamp + video->pts;
511
512 pkt->duration = 0;
513 pkt->pts = video->last_pts;
514 pkt->dts = AV_NOPTS_VALUE;
515
516 video->pts += frame_timestamp;
517
518 /* Keyframe? */
519 pkt->flags = (pkt->data[0] & 0x80) ? 0 : AV_PKT_FLAG_KEY;
520
521 /* Advance offset */
522 video->data_size -= frame_size + 4;
523 video->data_offset += frame_size + 4;
524
525 return 0;
526}
527
529 AVPacket *pkt)
530{
531 XMVDemuxContext *xmv = s->priv_data;
532 int result;
533
534 if (xmv->video.current_frame == xmv->video.frame_count) {
535 /* No frames left in this packet, so we fetch a new one */
536
537 result = xmv_fetch_new_packet(s);
538 if (result)
539 return result;
540 }
541
542 if (xmv->current_stream == 0) {
543 /* Fetch a video frame */
544
545 result = xmv_fetch_video_packet(s, pkt);
546 } else {
547 /* Fetch an audio frame */
548
549 result = xmv_fetch_audio_packet(s, pkt, xmv->current_stream - 1);
550 }
551 if (result) {
552 xmv->current_stream = 0;
554 return result;
555 }
556
557
558 /* Increase our counters */
559 if (++xmv->current_stream >= xmv->stream_count) {
560 xmv->current_stream = 0;
561 xmv->video.current_frame += 1;
562 }
563
564 return 0;
565}
566
568 .p.name = "xmv",
569 .p.long_name = NULL_IF_CONFIG_SMALL("Microsoft XMV"),
570 .p.extensions = "xmv",
571 .priv_data_size = sizeof(XMVDemuxContext),
572 .flags_internal = FF_INFMT_FLAG_INIT_CLEANUP,
577};
const FFInputFormat ff_xmv_demuxer
Definition xmv.c:567
int32_t
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition avformat.c:834
Main libavformat public API header.
#define AVPROBE_SCORE_MAX
maximum score
Definition avformat.h:483
#define AVFMTCTX_NOHEADER
signal that no header is present (streams are added dynamically)
Definition avformat.h:1284
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition utils.c:98
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition aviobuf.c:236
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition avio.h:494
unsigned int avio_rl16(AVIOContext *s)
Definition aviobuf.c:717
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition aviobuf.c:321
unsigned int avio_rl32(AVIOContext *s)
Definition aviobuf.c:733
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition aviobuf.c:665
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define s(width, name)
Definition cbs_vp9.c:198
static int read_probe(const AVProbeData *p)
Definition cdg.c:30
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
#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...
Definition demux.h:35
static AVPacket * pkt
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:578
static const uint8_t frame_size[4]
Definition g723_1.h:222
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:47
@ AV_CODEC_ID_WMV2
Definition codec_id.h:68
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition packet.h:650
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.
Definition error.h:61
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition avutil.h:247
static void loop_filter(const H264Context *h, H264SliceContext *sl, int start_x, int end_x)
#define AV_WB32(p, v)
#define AV_RL32(p)
int ff_alloc_extradata(AVCodecParameters *par, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0.
Definition utils.c:237
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static av_cold int read_close(AVFormatContext *ctx)
Definition libcdio.c:143
#define FFMIN(a, b)
Definition macros.h:49
#define MKBETAG(a, b, c, d)
Definition macros.h:56
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:264
Memory handling functions.
const char data[16]
Definition mxf.c:149
internal header for RIFF based (de)muxers do NOT include this in end user applications
enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps)
Definition riffdec.c:277
int nb_channels
Number of channels in this layout.
int extradata_size
Size of the extradata content in bytes.
Definition codec_par.h:75
int height
The height of the video frame in pixels.
Definition codec_par.h:150
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition codec_par.h:113
AVChannelLayout ch_layout
The channel layout and number of channels.
Definition codec_par.h:207
int width
The width of the video frame in pixels.
Definition codec_par.h:143
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition codec_par.h:99
enum AVMediaType codec_type
General type of the encoded data.
Definition codec_par.h:53
int block_align
The number of bytes per coded audio frame, required by some formats.
Definition codec_par.h:221
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition codec_par.h:61
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition codec_par.h:71
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition codec_par.h:57
int sample_rate
The number of audio samples per second.
Definition codec_par.h:213
Format I/O context.
Definition avformat.h:1333
Bytestream IO Context.
Definition avio.h:160
This structure stores compressed data.
Definition packet.h:580
This structure contains the data a format has to probe a file.
Definition avformat.h:471
Stream structure.
Definition avformat.h:766
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition avformat.h:789
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition avformat.h:825
int index
stream index in AVFormatContext
Definition avformat.h:772
An audio packet with an XMV file.
Definition xmv.c:76
uint16_t channels
Number of channels.
Definition xmv.c:82
int32_t sample_rate
Sampling rate.
Definition xmv.c:83
int created
Definition xmv.c:77
uint64_t bit_rate
Bits of compressed data per second.
Definition xmv.c:85
uint16_t compression
The type of compression.
Definition xmv.c:81
unsigned block_align
Bytes per compressed block.
Definition xmv.c:87
uint16_t flags
Flags.
Definition xmv.c:86
uint64_t data_offset
The offset of the audio data within the file.
Definition xmv.c:92
int stream_index
The decoder stream index for this audio packet.
Definition xmv.c:78
enum AVCodecID codec_id
The codec ID of the compression scheme.
Definition xmv.c:89
uint16_t bits_per_sample
Bits per compressed sample.
Definition xmv.c:84
uint32_t data_size
The size of the remaining audio data.
Definition xmv.c:91
uint32_t frame_size
Number of bytes to put into an audio frame.
Definition xmv.c:94
Context for demuxing an XMV file.
Definition xmv.c:98
uint32_t video_width
Definition xmv.c:111
uint32_t video_duration
Definition xmv.c:110
uint32_t next_packet_size
Size of the next packet.
Definition xmv.c:102
XMVVideoPacket video
The video packet contained in each packet.
Definition xmv.c:114
uint64_t this_packet_offset
Offset of the current packet.
Definition xmv.c:104
uint16_t audio_track_count
Number of audio track in this file.
Definition xmv.c:99
uint16_t current_stream
The index of the stream currently handling.
Definition xmv.c:107
XMVAudioPacket * audio
The audio packets contained in each packet.
Definition xmv.c:115
uint16_t stream_count
The number of streams in this file.
Definition xmv.c:108
uint64_t next_packet_offset
Offset of the next packet.
Definition xmv.c:105
uint32_t this_packet_size
Size of the current packet.
Definition xmv.c:101
uint32_t video_height
Definition xmv.c:112
A video packet with an XMV file.
Definition xmv.c:58
int64_t pts
PTS of the most current video frame.
Definition xmv.c:72
int created
Definition xmv.c:59
uint64_t data_offset
The offset of the video data within the file.
Definition xmv.c:63
int64_t last_pts
PTS of the last video frame.
Definition xmv.c:71
uint32_t frame_count
The amount of frames within this video packet.
Definition xmv.c:66
uint8_t extradata[4]
The extra data.
Definition xmv.c:69
uint32_t data_size
The size of the remaining video data.
Definition xmv.c:62
uint32_t current_frame
The current frame within this video packet.
Definition xmv.c:65
int stream_index
The decoder stream index for this video packet.
Definition xmv.c:60
int has_extradata
Does the video packet contain extra data?
Definition xmv.c:68
#define avpriv_request_sample(...)
#define av_freep(p)
#define av_log(a,...)
static int xmv_probe(const AVProbeData *p)
Definition xmv.c:118
static int xmv_read_close(AVFormatContext *s)
Definition xmv.c:135
#define XMV_BLOCK_ALIGN_SIZE
Definition xmv.c:55
static int xmv_fetch_audio_packet(AVFormatContext *s, AVPacket *pkt, uint32_t stream)
Definition xmv.c:434
static int xmv_fetch_video_packet(AVFormatContext *s, AVPacket *pkt)
Definition xmv.c:469
#define XMV_MIN_HEADER_SIZE
The min size of an XMV header.
Definition xmv.c:41
static int xmv_process_packet_header(AVFormatContext *s)
Definition xmv.c:257
#define XMV_AUDIO_ADPCM51
Audio flag: Any of the ADPCM'd 5.1 stream flags.
Definition xmv.c:51
static int xmv_fetch_new_packet(AVFormatContext *s)
Definition xmv.c:404
static int xmv_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition xmv.c:528
static void xmv_read_extradata(uint8_t *extradata, AVIOContext *pb)
Definition xmv.c:228
static int xmv_read_header(AVFormatContext *s)
Definition xmv.c:144