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 <stdint.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 /** A video packet with an XMV file. */
53 typedef struct XMVVideoPacket {
54  int stream_index; ///< The decoder stream index for this video packet.
55 
56  uint32_t data_size; ///< The size of the remaining video data.
57  uint64_t data_offset; ///< The offset of the video data within the file.
58 
59  uint32_t current_frame; ///< The current frame within this video packet.
60  uint32_t frame_count; ///< The amount of frames within this video packet.
61 
62  int has_extradata; ///< Does the video packet contain extra data?
63  uint8_t extradata[4]; ///< The extra data
64 
65  int64_t last_pts; ///< PTS of the last video frame.
66  int64_t pts; ///< PTS of the most current video frame.
68 
69 /** An audio packet with an XMV file. */
70 typedef struct XMVAudioPacket {
71  int stream_index; ///< The decoder stream index for this audio packet.
72 
73  /* Stream format properties. */
74  uint16_t compression; ///< The type of compression.
75  uint16_t channels; ///< Number of channels.
76  uint32_t sample_rate; ///< Sampling rate.
77  uint16_t bits_per_sample; ///< Bits per compressed sample.
78  uint32_t bit_rate; ///< Bits of compressed data per second.
79  uint16_t flags; ///< Flags
80  unsigned block_align; ///< Bytes per compressed block.
81  uint16_t block_samples; ///< Decompressed samples per compressed block.
82 
83  enum AVCodecID codec_id; ///< The codec ID of the compression scheme.
84 
85  uint32_t data_size; ///< The size of the remaining audio data.
86  uint64_t data_offset; ///< The offset of the audio data within the file.
87 
88  uint32_t frame_size; ///< Number of bytes to put into an audio frame.
89 
90  uint64_t block_count; ///< Running counter of decompressed audio block.
92 
93 /** Context for demuxing an XMV file. */
94 typedef struct XMVDemuxContext {
95  uint16_t audio_track_count; ///< Number of audio track in this file.
96 
97  uint32_t this_packet_size; ///< Size of the current packet.
98  uint32_t next_packet_size; ///< Size of the next packet.
99 
100  uint64_t this_packet_offset; ///< Offset of the current packet.
101  uint64_t next_packet_offset; ///< Offset of the next packet.
102 
103  uint16_t current_stream; ///< The index of the stream currently handling.
104  uint16_t stream_count; ///< The number of streams in this file.
105 
106  XMVVideoPacket video; ///< The video packet contained in each packet.
107  XMVAudioPacket *audio; ///< The audio packets contained in each packet.
109 
110 static int xmv_probe(AVProbeData *p)
111 {
112  uint32_t file_version;
113 
114  if (p->buf_size < XMV_MIN_HEADER_SIZE)
115  return 0;
116 
117  file_version = AV_RL32(p->buf + 16);
118  if ((file_version == 0) || (file_version > 4))
119  return 0;
120 
121  if (!memcmp(p->buf + 12, "xobX", 4))
122  return AVPROBE_SCORE_MAX;
123 
124  return 0;
125 }
126 
128 {
129  XMVDemuxContext *xmv = s->priv_data;
130 
131  av_freep(&xmv->audio);
132 
133  return 0;
134 }
135 
137 {
138  XMVDemuxContext *xmv = s->priv_data;
139  AVIOContext *pb = s->pb;
140  AVStream *vst = NULL;
141 
142  uint32_t file_version;
143  uint32_t this_packet_size;
144  uint16_t audio_track;
145  int ret;
146 
147  avio_skip(pb, 4); /* Next packet size */
148 
149  this_packet_size = avio_rl32(pb);
150 
151  avio_skip(pb, 4); /* Max packet size */
152  avio_skip(pb, 4); /* "xobX" */
153 
154  file_version = avio_rl32(pb);
155  if ((file_version != 4) && (file_version != 2))
156  avpriv_request_sample(s, "Uncommon version %d", file_version);
157 
158 
159  /* Video track */
160 
161  vst = avformat_new_stream(s, NULL);
162  if (!vst)
163  return AVERROR(ENOMEM);
164 
165  avpriv_set_pts_info(vst, 32, 1, 1000);
166 
169  vst->codec->codec_tag = MKBETAG('W', 'M', 'V', '2');
170  vst->codec->width = avio_rl32(pb);
171  vst->codec->height = avio_rl32(pb);
172 
173  vst->duration = avio_rl32(pb);
174 
175  xmv->video.stream_index = vst->index;
176 
177  /* Audio tracks */
178 
179  xmv->audio_track_count = avio_rl16(pb);
180 
181  avio_skip(pb, 2); /* Unknown (padding?) */
182 
183  xmv->audio = av_malloc(xmv->audio_track_count * sizeof(XMVAudioPacket));
184  if (!xmv->audio) {
185  ret = AVERROR(ENOMEM);
186  goto fail;
187  }
188 
189  for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
190  XMVAudioPacket *packet = &xmv->audio[audio_track];
191  AVStream *ast = NULL;
192 
193  packet->compression = avio_rl16(pb);
194  packet->channels = avio_rl16(pb);
195  packet->sample_rate = avio_rl32(pb);
196  packet->bits_per_sample = avio_rl16(pb);
197  packet->flags = avio_rl16(pb);
198 
199  packet->bit_rate = packet->bits_per_sample *
200  packet->sample_rate *
201  packet->channels;
202  packet->block_align = 36 * packet->channels;
203  packet->block_samples = 64;
204  packet->codec_id = ff_wav_codec_get_id(packet->compression,
205  packet->bits_per_sample);
206 
207  packet->stream_index = -1;
208 
209  packet->frame_size = 0;
210  packet->block_count = 0;
211 
212  /* TODO: ADPCM'd 5.1 sound is encoded in three separate streams.
213  * Those need to be interleaved to a proper 5.1 stream. */
214  if (packet->flags & XMV_AUDIO_ADPCM51)
215  av_log(s, AV_LOG_WARNING, "Unsupported 5.1 ADPCM audio stream "
216  "(0x%04X)\n", packet->flags);
217 
218  if (!packet->channels || !packet->sample_rate) {
219  av_log(s, AV_LOG_ERROR, "Invalid parameters for audio track %d.\n",
220  audio_track);
221  ret = AVERROR_INVALIDDATA;
222  goto fail;
223  }
224 
225  ast = avformat_new_stream(s, NULL);
226  if (!ast) {
227  ret = AVERROR(ENOMEM);
228  goto fail;
229  }
230 
232  ast->codec->codec_id = packet->codec_id;
233  ast->codec->codec_tag = packet->compression;
234  ast->codec->channels = packet->channels;
235  ast->codec->sample_rate = packet->sample_rate;
237  ast->codec->bit_rate = packet->bit_rate;
238  ast->codec->block_align = 36 * packet->channels;
239 
240  avpriv_set_pts_info(ast, 32, packet->block_samples, packet->sample_rate);
241 
242  packet->stream_index = ast->index;
243 
244  ast->duration = vst->duration;
245  }
246 
247 
248  /* Initialize the packet context */
249 
250  xmv->next_packet_offset = avio_tell(pb);
251  xmv->next_packet_size = this_packet_size - xmv->next_packet_offset;
252  xmv->stream_count = xmv->audio_track_count + 1;
253 
254  return 0;
255 
256 fail:
257  xmv_read_close(s);
258  return ret;
259 }
260 
262 {
263  /* Read the XMV extradata */
264 
265  uint32_t data = avio_rl32(pb);
266 
267  int mspel_bit = !!(data & 0x01);
268  int loop_filter = !!(data & 0x02);
269  int abt_flag = !!(data & 0x04);
270  int j_type_bit = !!(data & 0x08);
271  int top_left_mv_flag = !!(data & 0x10);
272  int per_mb_rl_bit = !!(data & 0x20);
273  int slice_count = (data >> 6) & 7;
274 
275  /* Write it back as standard WMV2 extradata */
276 
277  data = 0;
278 
279  data |= mspel_bit << 15;
280  data |= loop_filter << 14;
281  data |= abt_flag << 13;
282  data |= j_type_bit << 12;
283  data |= top_left_mv_flag << 11;
284  data |= per_mb_rl_bit << 10;
285  data |= slice_count << 7;
286 
287  AV_WB32(extradata, data);
288 }
289 
291 {
292  XMVDemuxContext *xmv = s->priv_data;
293  AVIOContext *pb = s->pb;
294 
295  uint8_t data[8];
296  uint16_t audio_track;
297  uint64_t data_offset;
298 
299  /* Next packet size */
300  xmv->next_packet_size = avio_rl32(pb);
301 
302  /* Packet video header */
303 
304  if (avio_read(pb, data, 8) != 8)
305  return AVERROR(EIO);
306 
307  xmv->video.data_size = AV_RL32(data) & 0x007FFFFF;
308 
309  xmv->video.current_frame = 0;
310  xmv->video.frame_count = (AV_RL32(data) >> 23) & 0xFF;
311 
312  xmv->video.has_extradata = (data[3] & 0x80) != 0;
313 
314  /* Adding the audio data sizes and the video data size keeps you 4 bytes
315  * short for every audio track. But as playing around with XMV files with
316  * ADPCM audio showed, taking the extra 4 bytes from the audio data gives
317  * you either completely distorted audio or click (when skipping the
318  * remaining 68 bytes of the ADPCM block). Subtracting 4 bytes for every
319  * audio track from the video data works at least for the audio. Probably
320  * some alignment thing?
321  * The video data has (always?) lots of padding, so it should work out...
322  */
323  xmv->video.data_size -= xmv->audio_track_count * 4;
324 
325  xmv->current_stream = 0;
326  if (!xmv->video.frame_count) {
327  xmv->video.frame_count = 1;
328  xmv->current_stream = xmv->stream_count > 1;
329  }
330 
331  /* Packet audio header */
332 
333  for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
334  XMVAudioPacket *packet = &xmv->audio[audio_track];
335 
336  if (avio_read(pb, data, 4) != 4)
337  return AVERROR(EIO);
338 
339  packet->data_size = AV_RL32(data) & 0x007FFFFF;
340  if ((packet->data_size == 0) && (audio_track != 0))
341  /* This happens when I create an XMV with several identical audio
342  * streams. From the size calculations, duplicating the previous
343  * stream's size works out, but the track data itself is silent.
344  * Maybe this should also redirect the offset to the previous track?
345  */
346  packet->data_size = xmv->audio[audio_track - 1].data_size;
347 
348  /* Carve up the audio data in frame_count slices */
349  packet->frame_size = packet->data_size / xmv->video.frame_count;
350  packet->frame_size -= packet->frame_size % packet->block_align;
351  }
352 
353  /* Packet data offsets */
354 
355  data_offset = avio_tell(pb);
356 
358  data_offset += xmv->video.data_size;
359 
360  for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
361  xmv->audio[audio_track].data_offset = data_offset;
362  data_offset += xmv->audio[audio_track].data_size;
363  }
364 
365  /* Video frames header */
366 
367  /* Read new video extra data */
368  if (xmv->video.data_size > 0) {
369  if (xmv->video.has_extradata) {
371 
372  xmv->video.data_size -= 4;
373  xmv->video.data_offset += 4;
374 
375  if (xmv->video.stream_index >= 0) {
376  AVStream *vst = s->streams[xmv->video.stream_index];
377 
379 
380  if (vst->codec->extradata_size < 4) {
381  av_free(vst->codec->extradata);
382 
383  vst->codec->extradata =
385  vst->codec->extradata_size = 4;
386  }
387 
388  memcpy(vst->codec->extradata, xmv->video.extradata, 4);
389  }
390  }
391  }
392 
393  return 0;
394 }
395 
397 {
398  XMVDemuxContext *xmv = s->priv_data;
399  AVIOContext *pb = s->pb;
400  int result;
401 
402  if (xmv->this_packet_offset == xmv->next_packet_offset)
403  return AVERROR_EOF;
404 
405  /* Seek to it */
407  if (avio_seek(pb, xmv->this_packet_offset, SEEK_SET) != xmv->this_packet_offset)
408  return AVERROR(EIO);
409 
410  /* Update the size */
412  if (xmv->this_packet_size < (12 + xmv->audio_track_count * 4))
413  return AVERROR(EIO);
414 
415  /* Process the header */
416  result = xmv_process_packet_header(s);
417  if (result)
418  return result;
419 
420  /* Update the offset */
422 
423  return 0;
424 }
425 
427  AVPacket *pkt, uint32_t stream)
428 {
429  XMVDemuxContext *xmv = s->priv_data;
430  AVIOContext *pb = s->pb;
431  XMVAudioPacket *audio = &xmv->audio[stream];
432 
433  uint32_t data_size;
434  uint32_t block_count;
435  int result;
436 
437  /* Seek to it */
438  if (avio_seek(pb, audio->data_offset, SEEK_SET) != audio->data_offset)
439  return AVERROR(EIO);
440 
441  if ((xmv->video.current_frame + 1) < xmv->video.frame_count)
442  /* Not the last frame, get at most frame_size bytes. */
443  data_size = FFMIN(audio->frame_size, audio->data_size);
444  else
445  /* Last frame, get the rest. */
446  data_size = audio->data_size;
447 
448  /* Read the packet */
449  result = av_get_packet(pb, pkt, data_size);
450  if (result <= 0)
451  return result;
452 
453  pkt->stream_index = audio->stream_index;
454 
455  /* Calculate the PTS */
456 
457  block_count = data_size / audio->block_align;
458 
459  pkt->duration = block_count;
460  pkt->pts = audio->block_count;
461  pkt->dts = AV_NOPTS_VALUE;
462 
463  audio->block_count += block_count;
464 
465  /* Advance offset */
466  audio->data_size -= data_size;
467  audio->data_offset += data_size;
468 
469  return 0;
470 }
471 
473  AVPacket *pkt)
474 {
475  XMVDemuxContext *xmv = s->priv_data;
476  AVIOContext *pb = s->pb;
477  XMVVideoPacket *video = &xmv->video;
478 
479  int result;
480  uint32_t frame_header;
481  uint32_t frame_size, frame_timestamp;
482  uint8_t *data, *end;
483 
484  /* Seek to it */
485  if (avio_seek(pb, video->data_offset, SEEK_SET) != video->data_offset)
486  return AVERROR(EIO);
487 
488  /* Read the frame header */
489  frame_header = avio_rl32(pb);
490 
491  frame_size = (frame_header & 0x1FFFF) * 4 + 4;
492  frame_timestamp = (frame_header >> 17);
493 
494  if ((frame_size + 4) > video->data_size)
495  return AVERROR(EIO);
496 
497  /* Get the packet data */
498  result = av_get_packet(pb, pkt, frame_size);
499  if (result != frame_size)
500  return result;
501 
502  /* Contrary to normal WMV2 video, the bit stream in XMV's
503  * WMV2 is little-endian.
504  * TODO: This manual swap is of course suboptimal.
505  */
506  for (data = pkt->data, end = pkt->data + frame_size; data < end; data += 4)
507  AV_WB32(data, AV_RL32(data));
508 
509  pkt->stream_index = video->stream_index;
510 
511  /* Calculate the PTS */
512 
513  video->last_pts = frame_timestamp + video->pts;
514 
515  pkt->duration = 0;
516  pkt->pts = video->last_pts;
517  pkt->dts = AV_NOPTS_VALUE;
518 
519  video->pts += frame_timestamp;
520 
521  /* Keyframe? */
522  pkt->flags = (pkt->data[0] & 0x80) ? 0 : AV_PKT_FLAG_KEY;
523 
524  /* Advance offset */
525  video->data_size -= frame_size + 4;
526  video->data_offset += frame_size + 4;
527 
528  return 0;
529 }
530 
532  AVPacket *pkt)
533 {
534  XMVDemuxContext *xmv = s->priv_data;
535  int result;
536 
537  if (xmv->video.current_frame == xmv->video.frame_count) {
538  /* No frames left in this packet, so we fetch a new one */
539 
540  result = xmv_fetch_new_packet(s);
541  if (result)
542  return result;
543  }
544 
545  if (xmv->current_stream == 0) {
546  /* Fetch a video frame */
547 
548  result = xmv_fetch_video_packet(s, pkt);
549  if (result)
550  return result;
551 
552  } else {
553  /* Fetch an audio frame */
554 
555  result = xmv_fetch_audio_packet(s, pkt, xmv->current_stream - 1);
556  if (result)
557  return result;
558  }
559 
560  /* Increase our counters */
561  if (++xmv->current_stream >= xmv->stream_count) {
562  xmv->current_stream = 0;
563  xmv->video.current_frame += 1;
564  }
565 
566  return 0;
567 }
568 
570  .name = "xmv",
571  .long_name = NULL_IF_CONFIG_SMALL("Microsoft XMV"),
572  .priv_data_size = sizeof(XMVDemuxContext),
577 };
uint32_t next_packet_size
Size of the next packet.
Definition: xmv.c:98
const char * s
Definition: avisynth_c.h:668
Bytestream IO Context.
Definition: avio.h:68
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
uint16_t compression
The type of compression.
Definition: xmv.c:74
XMVAudioPacket * audio
The audio packets contained in each packet.
Definition: xmv.c:107
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.
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:154
XMVVideoPacket video
The video packet contained in each packet.
Definition: xmv.c:106
int index
stream index in AVFormatContext
Definition: avformat.h:644
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:199
uint64_t data_offset
The offset of the audio data within the file.
Definition: xmv.c:86
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:256
static int xmv_fetch_new_packet(AVFormatContext *s)
Definition: xmv.c:396
static void xmv_read_extradata(uint8_t *extradata, AVIOContext *pb)
Definition: xmv.c:261
struct XMVDemuxContext XMVDemuxContext
Context for demuxing an XMV file.
static int xmv_probe(AVProbeData *p)
Definition: xmv.c:110
static int xmv_fetch_video_packet(AVFormatContext *s, AVPacket *pkt)
Definition: xmv.c:472
uint32_t data_size
The size of the remaining audio data.
Definition: xmv.c:85
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
static int xmv_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: xmv.c:531
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:198
uint32_t data_size
The size of the remaining video data.
Definition: xmv.c:56
Format I/O context.
Definition: avformat.h:944
#define AV_WB32(p, darg)
Definition: intreadwrite.h:265
uint16_t stream_count
The number of streams in this file.
Definition: xmv.c:104
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
struct XMVAudioPacket XMVAudioPacket
An audio packet with an XMV file.
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
uint8_t
static AVPacket pkt
Definition: demuxing.c:56
uint16_t flags
Flags.
Definition: xmv.c:79
end end
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
An audio packet with an XMV file.
Definition: xmv.c:70
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
Definition: avformat.h:992
uint32_t frame_count
The amount of frames within this video packet.
Definition: xmv.c:60
uint32_t this_packet_size
Size of the current packet.
Definition: xmv.c:97
uint8_t * data
#define AVERROR_EOF
End of file.
Definition: error.h:55
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
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.
uint64_t data_offset
The offset of the video data within the file.
Definition: xmv.c:57
int64_t last_pts
PTS of the last video frame.
Definition: xmv.c:65
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:248
uint32_t frame_size
Number of bytes to put into an audio frame.
Definition: xmv.c:88
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:478
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static const uint8_t frame_size[4]
Definition: g723_1_data.h:58
AVCodecID
Identify the syntax and semantics of the bitstream.
A video packet with an XMV file.
Definition: xmv.c:53
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
Definition: mem.c:183
struct XMVVideoPacket XMVVideoPacket
A video packet with an XMV file.
uint64_t block_count
Running counter of decompressed audio block.
Definition: xmv.c:90
uint16_t bits_per_sample
Bits per compressed sample.
Definition: xmv.c:77
uint32_t sample_rate
Sampling rate.
Definition: xmv.c:76
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:579
Context for demuxing an XMV file.
Definition: xmv.c:94
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
uint64_t next_packet_offset
Offset of the next packet.
Definition: xmv.c:101
Spectrum Plot time data
unsigned block_align
Bytes per compressed block.
Definition: xmv.c:80
simple assert() macros that are a bit more flexible than ISO C assert().
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
enum AVCodecID codec_id
Definition: mov_chan.c:433
#define XMV_AUDIO_ADPCM51
Audio flag: Any of the ADPCM&#39;d 5.1 stream flags.
Definition: xmv.c:48
uint64_t this_packet_offset
Offset of the current packet.
Definition: xmv.c:100
int flags
A combination of AV_PKT_FLAG values.
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:662
uint16_t current_stream
The index of the stream currently handling.
Definition: xmv.c:103
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:337
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:336
uint8_t extradata[4]
The extra data.
Definition: xmv.c:63
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
unsigned int nb_streams
A list of all streams in the file.
Definition: avformat.h:991
int stream_index
The decoder stream index for this video packet.
Definition: xmv.c:54
int bit_rate
the average bitrate
#define FFMIN(a, b)
Definition: common.h:58
static int xmv_read_header(AVFormatContext *s)
Definition: xmv.c:136
static int read_probe(AVProbeData *pd)
ret
Definition: avfilter.c:821
int width
picture width / height.
AVInputFormat ff_xmv_demuxer
Definition: xmv.c:569
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
#define XMV_MIN_HEADER_SIZE
The min size of an XMV header.
Definition: xmv.c:38
int64_t pts
PTS of the most current video frame.
Definition: xmv.c:66
#define AV_RL32
static int xmv_process_packet_header(AVFormatContext *s)
Definition: xmv.c:290
static void loop_filter(H264Context *h, int start_x, int end_x)
Definition: h264.c:4141
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:517
Stream structure.
Definition: avformat.h:643
NULL
Definition: eval.c:55
enum AVMediaType codec_type
enum AVCodecID codec_id
int sample_rate
samples per second
AVIOContext * pb
I/O context.
Definition: avformat.h:977
static int xmv_fetch_audio_packet(AVFormatContext *s, AVPacket *pkt, uint32_t stream)
Definition: xmv.c:426
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> (&#39;D&#39;<<24) + (&#39;C&#39;<<16) + (&#39;B&#39;<<8) + &#39;A&#39;).
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
Definition: libcdio.c:114
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:73
uint16_t audio_track_count
Number of audio track in this file.
Definition: xmv.c:95
uint16_t channels
Number of channels.
Definition: xmv.c:75
enum AVCodecID codec_id
The codec ID of the compression scheme.
Definition: xmv.c:83
uint32_t bit_rate
Bits of compressed data per second.
Definition: xmv.c:78
This structure contains the data a format has to probe a file.
Definition: avformat.h:334
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer 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.Buffer references ownership and permissions
int has_extradata
Does the video packet contain extra data?
Definition: xmv.c:62
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:696
#define AVPROBE_SCORE_MAX
maximum score, half of that is used for file-extension-based detection
Definition: avformat.h:340
unsigned int avio_rl16(AVIOContext *s)
Definition: aviobuf.c:563
Main libavformat public API header.
enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps)
#define MKBETAG(a, b, c, d)
Definition: common.h:283
uint16_t block_samples
Decompressed samples per compressed block.
Definition: xmv.c:81
A Quick Description Of Rate Distortion Theory We want to encode a video
int channels
number of audio channels
void * priv_data
Format private data.
Definition: avformat.h:964
uint32_t current_frame
The current frame within this video packet.
Definition: xmv.c:59
int stream_index
The decoder stream index for this audio packet.
Definition: xmv.c:71
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:461
static int xmv_read_close(AVFormatContext *s)
Definition: xmv.c:127
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:190