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