FFmpeg  4.4.6
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 
30 #include "libavutil/intreadwrite.h"
31 
32 #include "avformat.h"
33 #include "internal.h"
34 #include "riff.h"
35 #include "libavutil/avassert.h"
36 
37 /** The min size of an XMV header. */
38 #define XMV_MIN_HEADER_SIZE 36
39 
40 /** Audio flag: ADPCM'd 5.1 stream, front left / right channels */
41 #define XMV_AUDIO_ADPCM51_FRONTLEFTRIGHT 1
42 /** Audio flag: ADPCM'd 5.1 stream, front center / low frequency channels */
43 #define XMV_AUDIO_ADPCM51_FRONTCENTERLOW 2
44 /** Audio flag: ADPCM'd 5.1 stream, rear left / right channels */
45 #define XMV_AUDIO_ADPCM51_REARLEFTRIGHT 4
46 
47 /** Audio flag: Any of the ADPCM'd 5.1 stream flags. */
48 #define XMV_AUDIO_ADPCM51 (XMV_AUDIO_ADPCM51_FRONTLEFTRIGHT | \
49  XMV_AUDIO_ADPCM51_FRONTCENTERLOW | \
50  XMV_AUDIO_ADPCM51_REARLEFTRIGHT)
51 
52 #define XMV_BLOCK_ALIGN_SIZE 36
53 
54 /** A video packet with an XMV file. */
55 typedef struct XMVVideoPacket {
56  int created;
57  int stream_index; ///< The decoder stream index for this video packet.
58 
59  uint32_t data_size; ///< The size of the remaining video data.
60  uint64_t data_offset; ///< The offset of the video data within the file.
61 
62  uint32_t current_frame; ///< The current frame within this video packet.
63  uint32_t frame_count; ///< The amount of frames within this video packet.
64 
65  int has_extradata; ///< Does the video packet contain extra data?
66  uint8_t extradata[4]; ///< The extra data
67 
68  int64_t last_pts; ///< PTS of the last video frame.
69  int64_t pts; ///< PTS of the most current video frame.
71 
72 /** An audio packet with an XMV file. */
73 typedef struct XMVAudioPacket {
74  int created;
75  int stream_index; ///< The decoder stream index for this audio packet.
76 
77  /* Stream format properties. */
78  uint16_t compression; ///< The type of compression.
79  uint16_t channels; ///< Number of channels.
80  int32_t sample_rate; ///< Sampling rate.
81  uint16_t bits_per_sample; ///< Bits per compressed sample.
82  uint64_t bit_rate; ///< Bits of compressed data per second.
83  uint16_t flags; ///< Flags
84  unsigned block_align; ///< Bytes per compressed block.
85  uint16_t block_samples; ///< Decompressed samples per compressed block.
86 
87  enum AVCodecID codec_id; ///< The codec ID of the compression scheme.
88 
89  uint32_t data_size; ///< The size of the remaining audio data.
90  uint64_t data_offset; ///< The offset of the audio data within the file.
91 
92  uint32_t frame_size; ///< Number of bytes to put into an audio frame.
93 
94  uint64_t block_count; ///< Running counter of decompressed audio block.
96 
97 /** Context for demuxing an XMV file. */
98 typedef 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 
110  uint32_t video_duration;
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 
118 static 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  int ret;
153 
154  s->ctx_flags |= AVFMTCTX_NOHEADER;
155 
156  avio_skip(pb, 4); /* Next packet size */
157 
158  this_packet_size = avio_rl32(pb);
159 
160  avio_skip(pb, 4); /* Max packet size */
161  avio_skip(pb, 4); /* "xobX" */
162 
163  file_version = avio_rl32(pb);
164  if ((file_version != 4) && (file_version != 2))
165  avpriv_request_sample(s, "Uncommon version %"PRIu32"", file_version);
166 
167  /* Video tracks */
168 
169  xmv->video_width = avio_rl32(pb);
170  xmv->video_height = avio_rl32(pb);
171  xmv->video_duration = avio_rl32(pb);
172 
173  /* Audio tracks */
174 
175  xmv->audio_track_count = avio_rl16(pb);
176 
177  avio_skip(pb, 2); /* Unknown (padding?) */
178 
180  if (!xmv->audio) {
181  ret = AVERROR(ENOMEM);
182  goto fail;
183  }
184 
185  for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
186  XMVAudioPacket *packet = &xmv->audio[audio_track];
187 
188  packet->compression = avio_rl16(pb);
189  packet->channels = avio_rl16(pb);
190  packet->sample_rate = avio_rl32(pb);
191  packet->bits_per_sample = avio_rl16(pb);
192  packet->flags = avio_rl16(pb);
193 
194  packet->bit_rate = (uint64_t)packet->bits_per_sample *
195  packet->sample_rate *
196  packet->channels;
197  packet->block_align = XMV_BLOCK_ALIGN_SIZE * packet->channels;
198  packet->block_samples = 64;
199  packet->codec_id = ff_wav_codec_get_id(packet->compression,
200  packet->bits_per_sample);
201 
202  packet->stream_index = -1;
203 
204  packet->frame_size = 0;
205  packet->block_count = 0;
206 
207  /* TODO: ADPCM'd 5.1 sound is encoded in three separate streams.
208  * Those need to be interleaved to a proper 5.1 stream. */
209  if (packet->flags & XMV_AUDIO_ADPCM51)
210  av_log(s, AV_LOG_WARNING, "Unsupported 5.1 ADPCM audio stream "
211  "(0x%04X)\n", packet->flags);
212 
213  if (!packet->channels || packet->sample_rate <= 0 ||
214  packet->channels >= UINT16_MAX / XMV_BLOCK_ALIGN_SIZE) {
215  av_log(s, AV_LOG_ERROR, "Invalid parameters for audio track %"PRIu16".\n",
216  audio_track);
217  ret = AVERROR_INVALIDDATA;
218  goto fail;
219  }
220  }
221 
222 
223  /* Initialize the packet context */
224 
225  xmv->next_packet_offset = avio_tell(pb);
226  if (this_packet_size < xmv->next_packet_offset)
227  return AVERROR_INVALIDDATA;
228  xmv->next_packet_size = this_packet_size - xmv->next_packet_offset;
229  xmv->stream_count = xmv->audio_track_count + 1;
230 
231  return 0;
232 
233 fail:
234  xmv_read_close(s);
235  return ret;
236 }
237 
238 static void xmv_read_extradata(uint8_t *extradata, AVIOContext *pb)
239 {
240  /* Read the XMV extradata */
241 
242  uint32_t data = avio_rl32(pb);
243 
244  int mspel_bit = !!(data & 0x01);
245  int loop_filter = !!(data & 0x02);
246  int abt_flag = !!(data & 0x04);
247  int j_type_bit = !!(data & 0x08);
248  int top_left_mv_flag = !!(data & 0x10);
249  int per_mb_rl_bit = !!(data & 0x20);
250  int slice_count = (data >> 6) & 7;
251 
252  /* Write it back as standard WMV2 extradata */
253 
254  data = 0;
255 
256  data |= mspel_bit << 15;
257  data |= loop_filter << 14;
258  data |= abt_flag << 13;
259  data |= j_type_bit << 12;
260  data |= top_left_mv_flag << 11;
261  data |= per_mb_rl_bit << 10;
262  data |= slice_count << 7;
263 
264  AV_WB32(extradata, data);
265 }
266 
268 {
269  XMVDemuxContext *xmv = s->priv_data;
270  AVIOContext *pb = s->pb;
271  int ret;
272 
273  uint8_t data[8];
274  uint16_t audio_track;
275  uint64_t data_offset;
276 
277  /* Next packet size */
278  xmv->next_packet_size = avio_rl32(pb);
279 
280  /* Packet video header */
281 
282  if (avio_read(pb, data, 8) != 8)
283  return AVERROR(EIO);
284 
285  xmv->video.data_size = AV_RL32(data) & 0x007FFFFF;
286 
287  xmv->video.current_frame = 0;
288  xmv->video.frame_count = (AV_RL32(data) >> 23) & 0xFF;
289 
290  xmv->video.has_extradata = (data[3] & 0x80) != 0;
291 
292  if (!xmv->video.created) {
294  if (!vst)
295  return AVERROR(ENOMEM);
296 
297  avpriv_set_pts_info(vst, 32, 1, 1000);
298 
301  vst->codecpar->codec_tag = MKBETAG('W', 'M', 'V', '2');
302  vst->codecpar->width = xmv->video_width;
303  vst->codecpar->height = xmv->video_height;
304 
305  vst->duration = xmv->video_duration;
306 
307  xmv->video.stream_index = vst->index;
308 
309  xmv->video.created = 1;
310  }
311 
312  /* Adding the audio data sizes and the video data size keeps you 4 bytes
313  * short for every audio track. But as playing around with XMV files with
314  * ADPCM audio showed, taking the extra 4 bytes from the audio data gives
315  * you either completely distorted audio or click (when skipping the
316  * remaining 68 bytes of the ADPCM block). Subtracting 4 bytes for every
317  * audio track from the video data works at least for the audio. Probably
318  * some alignment thing?
319  * The video data has (always?) lots of padding, so it should work out...
320  */
321  xmv->video.data_size -= xmv->audio_track_count * 4;
322 
323  xmv->current_stream = 0;
324  if (!xmv->video.frame_count) {
325  xmv->video.frame_count = 1;
326  xmv->current_stream = xmv->stream_count > 1;
327  }
328 
329  /* Packet audio header */
330 
331  for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
332  XMVAudioPacket *packet = &xmv->audio[audio_track];
333 
334  if (avio_read(pb, data, 4) != 4)
335  return AVERROR(EIO);
336 
337  if (!packet->created) {
339  if (!ast)
340  return AVERROR(ENOMEM);
341 
343  ast->codecpar->codec_id = packet->codec_id;
344  ast->codecpar->codec_tag = packet->compression;
345  ast->codecpar->channels = packet->channels;
346  ast->codecpar->sample_rate = packet->sample_rate;
348  ast->codecpar->bit_rate = packet->bit_rate;
349  ast->codecpar->block_align = 36 * packet->channels;
350 
351  avpriv_set_pts_info(ast, 32, packet->block_samples, packet->sample_rate);
352 
353  packet->stream_index = ast->index;
354 
355  ast->duration = xmv->video_duration;
356 
357  packet->created = 1;
358  }
359 
360  packet->data_size = AV_RL32(data) & 0x007FFFFF;
361  if ((packet->data_size == 0) && (audio_track != 0))
362  /* This happens when I create an XMV with several identical audio
363  * streams. From the size calculations, duplicating the previous
364  * stream's size works out, but the track data itself is silent.
365  * Maybe this should also redirect the offset to the previous track?
366  */
367  packet->data_size = xmv->audio[audio_track - 1].data_size;
368 
369  /* Carve up the audio data in frame_count slices */
370  packet->frame_size = packet->data_size / xmv->video.frame_count;
371  packet->frame_size -= packet->frame_size % packet->block_align;
372  }
373 
374  /* Packet data offsets */
375 
376  data_offset = avio_tell(pb);
377 
378  xmv->video.data_offset = data_offset;
379  data_offset += xmv->video.data_size;
380 
381  for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
382  xmv->audio[audio_track].data_offset = data_offset;
383  data_offset += xmv->audio[audio_track].data_size;
384  }
385 
386  /* Video frames header */
387 
388  /* Read new video extra data */
389  if (xmv->video.data_size > 0) {
390  if (xmv->video.has_extradata) {
392 
393  xmv->video.data_size -= 4;
394  xmv->video.data_offset += 4;
395 
396  if (xmv->video.stream_index >= 0) {
397  AVStream *vst = s->streams[xmv->video.stream_index];
398 
399  av_assert0(xmv->video.stream_index < s->nb_streams);
400 
401  if (vst->codecpar->extradata_size < 4) {
402  if ((ret = ff_alloc_extradata(vst->codecpar, 4)) < 0)
403  return ret;
404  }
405 
406  memcpy(vst->codecpar->extradata, xmv->video.extradata, 4);
407  }
408  }
409  }
410 
411  return 0;
412 }
413 
415 {
416  XMVDemuxContext *xmv = s->priv_data;
417  AVIOContext *pb = s->pb;
418  int result;
419 
420  if (xmv->this_packet_offset == xmv->next_packet_offset)
421  return AVERROR_EOF;
422 
423  /* Seek to it */
425  if (avio_seek(pb, xmv->this_packet_offset, SEEK_SET) != xmv->this_packet_offset)
426  return AVERROR(EIO);
427 
428  /* Update the size */
430  if (xmv->this_packet_size < (12 + xmv->audio_track_count * 4))
431  return AVERROR(EIO);
432 
433  /* Process the header */
434  result = xmv_process_packet_header(s);
435  if (result)
436  return result;
437 
438  /* Update the offset */
440 
441  return 0;
442 }
443 
445  AVPacket *pkt, uint32_t stream)
446 {
447  XMVDemuxContext *xmv = s->priv_data;
448  AVIOContext *pb = s->pb;
449  XMVAudioPacket *audio = &xmv->audio[stream];
450 
451  uint32_t data_size;
452  uint32_t block_count;
453  int result;
454 
455  /* Seek to it */
456  if (avio_seek(pb, audio->data_offset, SEEK_SET) != audio->data_offset)
457  return AVERROR(EIO);
458 
459  if ((xmv->video.current_frame + 1) < xmv->video.frame_count)
460  /* Not the last frame, get at most frame_size bytes. */
461  data_size = FFMIN(audio->frame_size, audio->data_size);
462  else
463  /* Last frame, get the rest. */
464  data_size = audio->data_size;
465 
466  /* Read the packet */
467  result = av_get_packet(pb, pkt, data_size);
468  if (result <= 0)
469  return result;
470 
471  pkt->stream_index = audio->stream_index;
472 
473  /* Calculate the PTS */
474 
475  block_count = data_size / audio->block_align;
476 
477  pkt->duration = block_count;
478  pkt->pts = audio->block_count;
480 
481  audio->block_count += block_count;
482 
483  /* Advance offset */
484  audio->data_size -= data_size;
485  audio->data_offset += data_size;
486 
487  return 0;
488 }
489 
491  AVPacket *pkt)
492 {
493  XMVDemuxContext *xmv = s->priv_data;
494  AVIOContext *pb = s->pb;
495  XMVVideoPacket *video = &xmv->video;
496 
497  int result;
498  uint32_t frame_header;
499  uint32_t frame_size, frame_timestamp;
500  uint8_t *data, *end;
501 
502  /* Seek to it */
503  if (avio_seek(pb, video->data_offset, SEEK_SET) != video->data_offset)
504  return AVERROR(EIO);
505 
506  /* Read the frame header */
507  frame_header = avio_rl32(pb);
508 
509  frame_size = (frame_header & 0x1FFFF) * 4 + 4;
510  frame_timestamp = (frame_header >> 17);
511 
512  if ((frame_size + 4) > video->data_size)
513  return AVERROR(EIO);
514 
515  /* Get the packet data */
516  result = av_get_packet(pb, pkt, frame_size);
517  if (result != frame_size)
518  return result;
519 
520  /* Contrary to normal WMV2 video, the bit stream in XMV's
521  * WMV2 is little-endian.
522  * TODO: This manual swap is of course suboptimal.
523  */
524  for (data = pkt->data, end = pkt->data + frame_size; data < end; data += 4)
526 
527  pkt->stream_index = video->stream_index;
528 
529  /* Calculate the PTS */
530 
531  video->last_pts = frame_timestamp + video->pts;
532 
533  pkt->duration = 0;
534  pkt->pts = video->last_pts;
536 
537  video->pts += frame_timestamp;
538 
539  /* Keyframe? */
540  pkt->flags = (pkt->data[0] & 0x80) ? 0 : AV_PKT_FLAG_KEY;
541 
542  /* Advance offset */
543  video->data_size -= frame_size + 4;
544  video->data_offset += frame_size + 4;
545 
546  return 0;
547 }
548 
550  AVPacket *pkt)
551 {
552  XMVDemuxContext *xmv = s->priv_data;
553  int result;
554 
555  if (xmv->video.current_frame == xmv->video.frame_count) {
556  /* No frames left in this packet, so we fetch a new one */
557 
558  result = xmv_fetch_new_packet(s);
559  if (result)
560  return result;
561  }
562 
563  if (xmv->current_stream == 0) {
564  /* Fetch a video frame */
565 
566  result = xmv_fetch_video_packet(s, pkt);
567  } else {
568  /* Fetch an audio frame */
569 
570  result = xmv_fetch_audio_packet(s, pkt, xmv->current_stream - 1);
571  }
572  if (result) {
573  xmv->current_stream = 0;
574  xmv->video.current_frame = xmv->video.frame_count;
575  return result;
576  }
577 
578 
579  /* Increase our counters */
580  if (++xmv->current_stream >= xmv->stream_count) {
581  xmv->current_stream = 0;
582  xmv->video.current_frame += 1;
583  }
584 
585  return 0;
586 }
587 
589  .name = "xmv",
590  .long_name = NULL_IF_CONFIG_SMALL("Microsoft XMV"),
591  .extensions = "xmv",
592  .priv_data_size = sizeof(XMVDemuxContext),
597 };
uint8_t
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:37
Main libavformat public API header.
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:453
#define AVFMTCTX_NOHEADER
signal that no header is present (streams are added dynamically)
Definition: avformat.h:1177
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:310
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:253
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:557
unsigned int avio_rl16(AVIOContext *s)
Definition: aviobuf.c:734
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:337
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:633
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:750
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
#define AV_RL32
Definition: intreadwrite.h:146
static int FUNC() frame_header(CodedBitstreamContext *ctx, RWContext *rw, JPEGRawFrameHeader *current)
#define s(width, name)
Definition: cbs_vp9.c:257
#define fail()
Definition: checkasm.h:133
#define FFMIN(a, b)
Definition: common.h:105
#define MKBETAG(a, b, c, d)
Definition: common.h:479
#define NULL
Definition: coverity.c:32
long long int64_t
Definition: coverity.c:34
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:545
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:46
@ AV_CODEC_ID_WMV2
Definition: codec_id.h:67
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:410
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4509
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
#define AVERROR_EOF
End of file.
Definition: error.h:55
#define AVERROR(e)
Definition: error.h:43
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:200
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
Definition: mem.c:190
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
static void loop_filter(const H264Context *h, H264SliceContext *sl, int start_x, int end_x)
Definition: h264_slice.c:2460
#define AV_WB32(p, v)
Definition: intreadwrite.h:419
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:4945
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:3314
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
const char data[16]
Definition: mxf.c:142
int frame_size
Definition: mxfenc.c:2206
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:192
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:78
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition: codec_par.h:102
int channels
Audio only.
Definition: codec_par.h:166
int width
Video only.
Definition: codec_par.h:126
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition: codec_par.h:89
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
int block_align
Audio only.
Definition: codec_par.h:177
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: codec_par.h:64
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:74
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
int sample_rate
Audio only.
Definition: codec_par.h:170
Format I/O context.
Definition: avformat.h:1232
Bytestream IO Context.
Definition: avio.h:161
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:645
This structure stores compressed data.
Definition: packet.h:346
int stream_index
Definition: packet.h:371
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:375
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:387
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:362
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:368
uint8_t * data
Definition: packet.h:369
This structure contains the data a format has to probe a file.
Definition: avformat.h:441
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:444
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:443
Stream structure.
Definition: avformat.h:873
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1038
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:922
int index
stream index in AVFormatContext
Definition: avformat.h:874
An audio packet with an XMV file.
Definition: xmv.c:73
uint16_t channels
Number of channels.
Definition: xmv.c:79
int32_t sample_rate
Sampling rate.
Definition: xmv.c:80
int created
Definition: xmv.c:74
uint64_t bit_rate
Bits of compressed data per second.
Definition: xmv.c:82
uint16_t compression
The type of compression.
Definition: xmv.c:78
unsigned block_align
Bytes per compressed block.
Definition: xmv.c:84
uint16_t flags
Flags.
Definition: xmv.c:83
uint64_t data_offset
The offset of the audio data within the file.
Definition: xmv.c:90
uint16_t block_samples
Decompressed samples per compressed block.
Definition: xmv.c:85
int stream_index
The decoder stream index for this audio packet.
Definition: xmv.c:75
uint64_t block_count
Running counter of decompressed audio block.
Definition: xmv.c:94
enum AVCodecID codec_id
The codec ID of the compression scheme.
Definition: xmv.c:87
uint16_t bits_per_sample
Bits per compressed sample.
Definition: xmv.c:81
uint32_t data_size
The size of the remaining audio data.
Definition: xmv.c:89
uint32_t frame_size
Number of bytes to put into an audio frame.
Definition: xmv.c:92
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:55
int64_t pts
PTS of the most current video frame.
Definition: xmv.c:69
int created
Definition: xmv.c:56
uint64_t data_offset
The offset of the video data within the file.
Definition: xmv.c:60
int64_t last_pts
PTS of the last video frame.
Definition: xmv.c:68
uint32_t frame_count
The amount of frames within this video packet.
Definition: xmv.c:63
uint8_t extradata[4]
The extra data.
Definition: xmv.c:66
uint32_t data_size
The size of the remaining video data.
Definition: xmv.c:59
uint32_t current_frame
The current frame within this video packet.
Definition: xmv.c:62
int stream_index
The decoder stream index for this video packet.
Definition: xmv.c:57
int has_extradata
Does the video packet contain extra data?
Definition: xmv.c:65
#define avpriv_request_sample(...)
#define av_freep(p)
#define av_log(a,...)
AVPacket * pkt
Definition: movenc.c:59
AVInputFormat ff_xmv_demuxer
Definition: xmv.c:588
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:52
static int xmv_fetch_audio_packet(AVFormatContext *s, AVPacket *pkt, uint32_t stream)
Definition: xmv.c:444
static int xmv_fetch_video_packet(AVFormatContext *s, AVPacket *pkt)
Definition: xmv.c:490
#define XMV_MIN_HEADER_SIZE
The min size of an XMV header.
Definition: xmv.c:38
static int xmv_process_packet_header(AVFormatContext *s)
Definition: xmv.c:267
#define XMV_AUDIO_ADPCM51
Audio flag: Any of the ADPCM'd 5.1 stream flags.
Definition: xmv.c:48
static int xmv_fetch_new_packet(AVFormatContext *s)
Definition: xmv.c:414
static int xmv_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: xmv.c:549
static void xmv_read_extradata(uint8_t *extradata, AVIOContext *pb)
Definition: xmv.c:238
static int xmv_read_header(AVFormatContext *s)
Definition: xmv.c:144