FFmpeg  2.6.9
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ipmovie.c
Go to the documentation of this file.
1 /*
2  * Interplay MVE File Demuxer
3  * Copyright (c) 2003 The FFmpeg Project
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * Interplay MVE file demuxer
25  * by Mike Melanson (melanson@pcisys.net)
26  * For more information regarding the Interplay MVE file format, visit:
27  * http://www.pcisys.net/~melanson/codecs/
28  * The aforementioned site also contains a command line utility for parsing
29  * IP MVE files so that you can get a good idea of the typical structure of
30  * such files. This demuxer is not the best example to use if you are trying
31  * to write your own as it uses a rather roundabout approach for splitting
32  * up and sending out the chunks.
33  */
34 
36 #include "libavutil/intreadwrite.h"
37 #include "avformat.h"
38 #include "internal.h"
39 
40 #define CHUNK_PREAMBLE_SIZE 4
41 #define OPCODE_PREAMBLE_SIZE 4
42 
43 #define CHUNK_INIT_AUDIO 0x0000
44 #define CHUNK_AUDIO_ONLY 0x0001
45 #define CHUNK_INIT_VIDEO 0x0002
46 #define CHUNK_VIDEO 0x0003
47 #define CHUNK_SHUTDOWN 0x0004
48 #define CHUNK_END 0x0005
49 /* these last types are used internally */
50 #define CHUNK_DONE 0xFFFC
51 #define CHUNK_NOMEM 0xFFFD
52 #define CHUNK_EOF 0xFFFE
53 #define CHUNK_BAD 0xFFFF
54 
55 #define OPCODE_END_OF_STREAM 0x00
56 #define OPCODE_END_OF_CHUNK 0x01
57 #define OPCODE_CREATE_TIMER 0x02
58 #define OPCODE_INIT_AUDIO_BUFFERS 0x03
59 #define OPCODE_START_STOP_AUDIO 0x04
60 #define OPCODE_INIT_VIDEO_BUFFERS 0x05
61 #define OPCODE_UNKNOWN_06 0x06
62 #define OPCODE_SEND_BUFFER 0x07
63 #define OPCODE_AUDIO_FRAME 0x08
64 #define OPCODE_SILENCE_FRAME 0x09
65 #define OPCODE_INIT_VIDEO_MODE 0x0A
66 #define OPCODE_CREATE_GRADIENT 0x0B
67 #define OPCODE_SET_PALETTE 0x0C
68 #define OPCODE_SET_PALETTE_COMPRESSED 0x0D
69 #define OPCODE_UNKNOWN_0E 0x0E
70 #define OPCODE_SET_DECODING_MAP 0x0F
71 #define OPCODE_UNKNOWN_10 0x10
72 #define OPCODE_VIDEO_DATA 0x11
73 #define OPCODE_UNKNOWN_12 0x12
74 #define OPCODE_UNKNOWN_13 0x13
75 #define OPCODE_UNKNOWN_14 0x14
76 #define OPCODE_UNKNOWN_15 0x15
77 
78 #define PALETTE_COUNT 256
79 
80 typedef struct IPMVEContext {
81 
82  unsigned char *buf;
83  int buf_size;
84 
85  uint64_t frame_pts_inc;
86 
87  unsigned int video_bpp;
88  unsigned int video_width;
89  unsigned int video_height;
90  int64_t video_pts;
91  uint32_t palette[256];
93  int changed;
94 
95  unsigned int audio_bits;
96  unsigned int audio_channels;
97  unsigned int audio_sample_rate;
99  unsigned int audio_frame_count;
100 
103 
110 
112 
113 } IPMVEContext;
114 
116  AVPacket *pkt) {
117 
118  int chunk_type;
119 
120  if (s->audio_chunk_offset && s->audio_channels && s->audio_bits) {
121  if (s->audio_type == AV_CODEC_ID_NONE) {
122  av_log(NULL, AV_LOG_ERROR, "Can not read audio packet before"
123  "audio codec is known\n");
124  return CHUNK_BAD;
125  }
126 
127  /* adjust for PCM audio by skipping chunk header */
129  s->audio_chunk_offset += 6;
130  s->audio_chunk_size -= 6;
131  }
132 
133  avio_seek(pb, s->audio_chunk_offset, SEEK_SET);
134  s->audio_chunk_offset = 0;
135 
136  if (s->audio_chunk_size != av_get_packet(pb, pkt, s->audio_chunk_size))
137  return CHUNK_EOF;
138 
140  pkt->pts = s->audio_frame_count;
141 
142  /* audio frame maintenance */
144  s->audio_frame_count +=
145  (s->audio_chunk_size / s->audio_channels / (s->audio_bits / 8));
146  else
147  s->audio_frame_count +=
149 
150  av_dlog(NULL, "sending audio frame with pts %"PRId64" (%d audio frames)\n",
151  pkt->pts, s->audio_frame_count);
152 
153  chunk_type = CHUNK_VIDEO;
154 
155  } else if (s->decode_map_chunk_offset) {
156 
157  /* send both the decode map and the video data together */
158 
160  return CHUNK_NOMEM;
161 
162  if (s->has_palette) {
163  uint8_t *pal;
164 
167  if (pal) {
168  memcpy(pal, s->palette, AVPALETTE_SIZE);
169  s->has_palette = 0;
170  }
171  }
172 
173  if (s->changed) {
174  ff_add_param_change(pkt, 0, 0, 0, s->video_width, s->video_height);
175  s->changed = 0;
176  }
177  pkt->pos= s->decode_map_chunk_offset;
178  avio_seek(pb, s->decode_map_chunk_offset, SEEK_SET);
180 
182  if (avio_read(pb, pkt->data + 2, s->decode_map_chunk_size) !=
184  av_free_packet(pkt);
185  return CHUNK_EOF;
186  }
187 
188  avio_seek(pb, s->video_chunk_offset, SEEK_SET);
189  s->video_chunk_offset = 0;
190 
191  if (avio_read(pb, pkt->data + 2 + s->decode_map_chunk_size,
193  av_free_packet(pkt);
194  return CHUNK_EOF;
195  }
196 
198  pkt->pts = s->video_pts;
199 
200  av_dlog(NULL, "sending video frame with pts %"PRId64"\n", pkt->pts);
201 
202  s->video_pts += s->frame_pts_inc;
203 
204  chunk_type = CHUNK_VIDEO;
205 
206  } else {
207 
208  avio_seek(pb, s->next_chunk_offset, SEEK_SET);
209  chunk_type = CHUNK_DONE;
210 
211  }
212 
213  return chunk_type;
214 }
215 
216 /* This function loads and processes a single chunk in an IP movie file.
217  * It returns the type of chunk that was processed. */
219  AVPacket *pkt)
220 {
221  unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
222  int chunk_type;
223  int chunk_size;
224  unsigned char opcode_preamble[OPCODE_PREAMBLE_SIZE];
225  unsigned char opcode_type;
226  unsigned char opcode_version;
227  int opcode_size;
228  unsigned char scratch[1024];
229  int i, j;
230  int first_color, last_color;
231  int audio_flags;
232  unsigned char r, g, b;
233  unsigned int width, height;
234 
235  /* see if there are any pending packets */
236  chunk_type = load_ipmovie_packet(s, pb, pkt);
237  if (chunk_type != CHUNK_DONE)
238  return chunk_type;
239 
240  /* read the next chunk, wherever the file happens to be pointing */
241  if (avio_feof(pb))
242  return CHUNK_EOF;
243  if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
245  return CHUNK_BAD;
246  chunk_size = AV_RL16(&chunk_preamble[0]);
247  chunk_type = AV_RL16(&chunk_preamble[2]);
248 
249  av_dlog(NULL, "chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size);
250 
251  switch (chunk_type) {
252 
253  case CHUNK_INIT_AUDIO:
254  av_dlog(NULL, "initialize audio\n");
255  break;
256 
257  case CHUNK_AUDIO_ONLY:
258  av_dlog(NULL, "audio only\n");
259  break;
260 
261  case CHUNK_INIT_VIDEO:
262  av_dlog(NULL, "initialize video\n");
263  break;
264 
265  case CHUNK_VIDEO:
266  av_dlog(NULL, "video (and audio)\n");
267  break;
268 
269  case CHUNK_SHUTDOWN:
270  av_dlog(NULL, "shutdown\n");
271  break;
272 
273  case CHUNK_END:
274  av_dlog(NULL, "end\n");
275  break;
276 
277  default:
278  av_dlog(NULL, "invalid chunk\n");
279  chunk_type = CHUNK_BAD;
280  break;
281 
282  }
283 
284  while ((chunk_size > 0) && (chunk_type != CHUNK_BAD)) {
285 
286  /* read the next chunk, wherever the file happens to be pointing */
287  if (avio_feof(pb)) {
288  chunk_type = CHUNK_EOF;
289  break;
290  }
291  if (avio_read(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
293  chunk_type = CHUNK_BAD;
294  break;
295  }
296 
297  opcode_size = AV_RL16(&opcode_preamble[0]);
298  opcode_type = opcode_preamble[2];
299  opcode_version = opcode_preamble[3];
300 
301  chunk_size -= OPCODE_PREAMBLE_SIZE;
302  chunk_size -= opcode_size;
303  if (chunk_size < 0) {
304  av_dlog(NULL, "chunk_size countdown just went negative\n");
305  chunk_type = CHUNK_BAD;
306  break;
307  }
308 
309  av_dlog(NULL, " opcode type %02X, version %d, 0x%04X bytes: ",
310  opcode_type, opcode_version, opcode_size);
311  switch (opcode_type) {
312 
314  av_dlog(NULL, "end of stream\n");
315  avio_skip(pb, opcode_size);
316  break;
317 
318  case OPCODE_END_OF_CHUNK:
319  av_dlog(NULL, "end of chunk\n");
320  avio_skip(pb, opcode_size);
321  break;
322 
323  case OPCODE_CREATE_TIMER:
324  av_dlog(NULL, "create timer\n");
325  if ((opcode_version > 0) || (opcode_size != 6)) {
326  av_dlog(NULL, "bad create_timer opcode\n");
327  chunk_type = CHUNK_BAD;
328  break;
329  }
330  if (avio_read(pb, scratch, opcode_size) !=
331  opcode_size) {
332  chunk_type = CHUNK_BAD;
333  break;
334  }
335  s->frame_pts_inc = ((uint64_t)AV_RL32(&scratch[0])) * AV_RL16(&scratch[4]);
336  av_dlog(NULL, " %.2f frames/second (timer div = %d, subdiv = %d)\n",
337  1000000.0 / s->frame_pts_inc, AV_RL32(&scratch[0]),
338  AV_RL16(&scratch[4]));
339  break;
340 
342  av_dlog(NULL, "initialize audio buffers\n");
343  if (opcode_version > 1 || opcode_size > 10 || opcode_size < 6) {
344  av_dlog(NULL, "bad init_audio_buffers opcode\n");
345  chunk_type = CHUNK_BAD;
346  break;
347  }
348  if (avio_read(pb, scratch, opcode_size) !=
349  opcode_size) {
350  chunk_type = CHUNK_BAD;
351  break;
352  }
353  s->audio_sample_rate = AV_RL16(&scratch[4]);
354  audio_flags = AV_RL16(&scratch[2]);
355  /* bit 0 of the flags: 0 = mono, 1 = stereo */
356  s->audio_channels = (audio_flags & 1) + 1;
357  /* bit 1 of the flags: 0 = 8 bit, 1 = 16 bit */
358  s->audio_bits = (((audio_flags >> 1) & 1) + 1) * 8;
359  /* bit 2 indicates compressed audio in version 1 opcode */
360  if ((opcode_version == 1) && (audio_flags & 0x4))
362  else if (s->audio_bits == 16)
364  else
366  av_dlog(NULL, "audio: %d bits, %d Hz, %s, %s format\n",
368  (s->audio_channels == 2) ? "stereo" : "mono",
370  "Interplay audio" : "PCM");
371  break;
372 
374  av_dlog(NULL, "start/stop audio\n");
375  avio_skip(pb, opcode_size);
376  break;
377 
379  av_dlog(NULL, "initialize video buffers\n");
380  if ((opcode_version > 2) || (opcode_size > 8) || opcode_size < 4
381  || opcode_version == 2 && opcode_size < 8
382  ) {
383  av_dlog(NULL, "bad init_video_buffers opcode\n");
384  chunk_type = CHUNK_BAD;
385  break;
386  }
387  if (avio_read(pb, scratch, opcode_size) !=
388  opcode_size) {
389  chunk_type = CHUNK_BAD;
390  break;
391  }
392  width = AV_RL16(&scratch[0]) * 8;
393  height = AV_RL16(&scratch[2]) * 8;
394  if (width != s->video_width) {
395  s->video_width = width;
396  s->changed++;
397  }
398  if (height != s->video_height) {
399  s->video_height = height;
400  s->changed++;
401  }
402  if (opcode_version < 2 || !AV_RL16(&scratch[6])) {
403  s->video_bpp = 8;
404  } else {
405  s->video_bpp = 16;
406  }
407  av_dlog(NULL, "video resolution: %d x %d\n",
408  s->video_width, s->video_height);
409  break;
410 
411  case OPCODE_UNKNOWN_06:
412  case OPCODE_UNKNOWN_0E:
413  case OPCODE_UNKNOWN_10:
414  case OPCODE_UNKNOWN_12:
415  case OPCODE_UNKNOWN_13:
416  case OPCODE_UNKNOWN_14:
417  case OPCODE_UNKNOWN_15:
418  av_dlog(NULL, "unknown (but documented) opcode %02X\n", opcode_type);
419  avio_skip(pb, opcode_size);
420  break;
421 
422  case OPCODE_SEND_BUFFER:
423  av_dlog(NULL, "send buffer\n");
424  avio_skip(pb, opcode_size);
425  break;
426 
427  case OPCODE_AUDIO_FRAME:
428  av_dlog(NULL, "audio frame\n");
429 
430  /* log position and move on for now */
431  s->audio_chunk_offset = avio_tell(pb);
432  s->audio_chunk_size = opcode_size;
433  avio_skip(pb, opcode_size);
434  break;
435 
437  av_dlog(NULL, "silence frame\n");
438  avio_skip(pb, opcode_size);
439  break;
440 
442  av_dlog(NULL, "initialize video mode\n");
443  avio_skip(pb, opcode_size);
444  break;
445 
447  av_dlog(NULL, "create gradient\n");
448  avio_skip(pb, opcode_size);
449  break;
450 
451  case OPCODE_SET_PALETTE:
452  av_dlog(NULL, "set palette\n");
453  /* check for the logical maximum palette size
454  * (3 * 256 + 4 bytes) */
455  if (opcode_size > 0x304 || opcode_size < 4) {
456  av_dlog(NULL, "demux_ipmovie: set_palette opcode with invalid size\n");
457  chunk_type = CHUNK_BAD;
458  break;
459  }
460  if (avio_read(pb, scratch, opcode_size) != opcode_size) {
461  chunk_type = CHUNK_BAD;
462  break;
463  }
464 
465  /* load the palette into internal data structure */
466  first_color = AV_RL16(&scratch[0]);
467  last_color = first_color + AV_RL16(&scratch[2]) - 1;
468  /* sanity check (since they are 16 bit values) */
469  if ( (first_color > 0xFF) || (last_color > 0xFF)
470  || (last_color - first_color + 1)*3 + 4 > opcode_size) {
471  av_dlog(NULL, "demux_ipmovie: set_palette indexes out of range (%d -> %d)\n",
472  first_color, last_color);
473  chunk_type = CHUNK_BAD;
474  break;
475  }
476  j = 4; /* offset of first palette data */
477  for (i = first_color; i <= last_color; i++) {
478  /* the palette is stored as a 6-bit VGA palette, thus each
479  * component is shifted up to a 8-bit range */
480  r = scratch[j++] * 4;
481  g = scratch[j++] * 4;
482  b = scratch[j++] * 4;
483  s->palette[i] = (0xFFU << 24) | (r << 16) | (g << 8) | (b);
484  s->palette[i] |= s->palette[i] >> 6 & 0x30303;
485  }
486  s->has_palette = 1;
487  break;
488 
490  av_dlog(NULL, "set palette compressed\n");
491  avio_skip(pb, opcode_size);
492  break;
493 
495  av_dlog(NULL, "set decoding map\n");
496 
497  /* log position and move on for now */
499  s->decode_map_chunk_size = opcode_size;
500  avio_skip(pb, opcode_size);
501  break;
502 
503  case OPCODE_VIDEO_DATA:
504  av_dlog(NULL, "set video data\n");
505 
506  /* log position and move on for now */
507  s->video_chunk_offset = avio_tell(pb);
508  s->video_chunk_size = opcode_size;
509  avio_skip(pb, opcode_size);
510  break;
511 
512  default:
513  av_dlog(NULL, "*** unknown opcode type\n");
514  chunk_type = CHUNK_BAD;
515  break;
516 
517  }
518  }
519 
520  /* make a note of where the stream is sitting */
521  s->next_chunk_offset = avio_tell(pb);
522 
523  /* dispatch the first of any pending packets */
524  if ((chunk_type == CHUNK_VIDEO) || (chunk_type == CHUNK_AUDIO_ONLY))
525  chunk_type = load_ipmovie_packet(s, pb, pkt);
526 
527  return chunk_type;
528 }
529 
530 static const char signature[] = "Interplay MVE File\x1A\0\x1A";
531 
533 {
534  const uint8_t *b = p->buf;
535  const uint8_t *b_end = p->buf + p->buf_size - sizeof(signature);
536  do {
537  if (b[0] == signature[0] && memcmp(b, signature, sizeof(signature)) == 0)
538  return AVPROBE_SCORE_MAX;
539  b++;
540  } while (b < b_end);
541 
542  return 0;
543 }
544 
546 {
547  IPMVEContext *ipmovie = s->priv_data;
548  AVIOContext *pb = s->pb;
549  AVPacket pkt;
550  AVStream *st;
551  unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
552  int chunk_type, i;
553  uint8_t signature_buffer[sizeof(signature)];
554 
555  avio_read(pb, signature_buffer, sizeof(signature_buffer));
556  while (memcmp(signature_buffer, signature, sizeof(signature))) {
557  memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1);
558  signature_buffer[sizeof(signature_buffer) - 1] = avio_r8(pb);
559  if (avio_feof(pb))
560  return AVERROR_EOF;
561  }
562  /* initialize private context members */
563  ipmovie->video_pts = ipmovie->audio_frame_count = 0;
564  ipmovie->audio_chunk_offset = ipmovie->video_chunk_offset =
565  ipmovie->decode_map_chunk_offset = 0;
566 
567  /* on the first read, this will position the stream at the first chunk */
568  ipmovie->next_chunk_offset = avio_tell(pb) + 4;
569 
570  for (i = 0; i < 256; i++)
571  ipmovie->palette[i] = 0xFFU << 24;
572 
573  /* process the first chunk which should be CHUNK_INIT_VIDEO */
574  if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO)
575  return AVERROR_INVALIDDATA;
576 
577  /* peek ahead to the next chunk-- if it is an init audio chunk, process
578  * it; if it is the first video chunk, this is a silent file */
579  if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
581  return AVERROR(EIO);
582  chunk_type = AV_RL16(&chunk_preamble[2]);
583  avio_seek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
584 
585  if (chunk_type == CHUNK_VIDEO)
586  ipmovie->audio_type = AV_CODEC_ID_NONE; /* no audio */
587  else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
588  return AVERROR_INVALIDDATA;
589 
590  /* initialize the stream decoders */
591  st = avformat_new_stream(s, NULL);
592  if (!st)
593  return AVERROR(ENOMEM);
594  avpriv_set_pts_info(st, 63, 1, 1000000);
595  ipmovie->video_stream_index = st->index;
598  st->codec->codec_tag = 0; /* no fourcc */
599  st->codec->width = ipmovie->video_width;
600  st->codec->height = ipmovie->video_height;
601  st->codec->bits_per_coded_sample = ipmovie->video_bpp;
602 
603  if (ipmovie->audio_type) {
604  st = avformat_new_stream(s, NULL);
605  if (!st)
606  return AVERROR(ENOMEM);
607  avpriv_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate);
608  ipmovie->audio_stream_index = st->index;
610  st->codec->codec_id = ipmovie->audio_type;
611  st->codec->codec_tag = 0; /* no tag */
612  st->codec->channels = ipmovie->audio_channels;
615  st->codec->sample_rate = ipmovie->audio_sample_rate;
616  st->codec->bits_per_coded_sample = ipmovie->audio_bits;
617  st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
620  st->codec->bit_rate /= 2;
622  }
623 
624  return 0;
625 }
626 
628  AVPacket *pkt)
629 {
630  IPMVEContext *ipmovie = s->priv_data;
631  AVIOContext *pb = s->pb;
632  int ret;
633 
634  for (;;) {
635  ret = process_ipmovie_chunk(ipmovie, pb, pkt);
636  if (ret == CHUNK_BAD)
637  ret = AVERROR_INVALIDDATA;
638  else if (ret == CHUNK_EOF)
639  ret = AVERROR(EIO);
640  else if (ret == CHUNK_NOMEM)
641  ret = AVERROR(ENOMEM);
642  else if (ret == CHUNK_VIDEO)
643  ret = 0;
644  else if (ret == CHUNK_INIT_VIDEO || ret == CHUNK_INIT_AUDIO)
645  continue;
646  else
647  ret = -1;
648 
649  return ret;
650  }
651 }
652 
654  .name = "ipmovie",
655  .long_name = NULL_IF_CONFIG_SMALL("Interplay MVE"),
656  .priv_data_size = sizeof(IPMVEContext),
660 };
#define OPCODE_SET_PALETTE_COMPRESSED
Definition: ipmovie.c:68
int64_t decode_map_chunk_offset
Definition: ipmovie.c:108
#define OPCODE_UNKNOWN_06
Definition: ipmovie.c:61
#define NULL
Definition: coverity.c:32
#define OPCODE_SEND_BUFFER
Definition: ipmovie.c:62
const char * s
Definition: avisynth_c.h:669
Bytestream IO Context.
Definition: avio.h:68
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
void av_free_packet(AVPacket *pkt)
Free a packet.
Definition: avpacket.c:281
static int ipmovie_read_header(AVFormatContext *s)
Definition: ipmovie.c:545
#define OPCODE_VIDEO_DATA
Definition: ipmovie.c:72
int64_t pos
byte position in stream, -1 if unknown
Definition: avcodec.h:1185
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:3997
const char * g
Definition: vf_curves.c:108
int audio_stream_index
Definition: ipmovie.c:102
#define OPCODE_UNKNOWN_14
Definition: ipmovie.c:75
int index
stream index in AVFormatContext
Definition: avformat.h:808
const char * b
Definition: vf_curves.c:109
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:203
#define CHUNK_INIT_VIDEO
Definition: ipmovie.c:45
#define AV_RL16
Definition: intreadwrite.h:42
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:276
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
static AVPacket pkt
#define AV_CH_LAYOUT_STEREO
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
Definition: avcodec.h:2020
#define OPCODE_CREATE_GRADIENT
Definition: ipmovie.c:66
static int ipmovie_probe(AVProbeData *p)
Definition: ipmovie.c:532
Format I/O context.
Definition: avformat.h:1226
static const char signature[]
Definition: ipmovie.c:530
#define OPCODE_UNKNOWN_12
Definition: ipmovie.c:73
int64_t audio_chunk_offset
Definition: ipmovie.c:104
if()
Definition: avfilter.c:975
#define CHUNK_END
Definition: ipmovie.c:48
uint8_t
unsigned int audio_channels
Definition: ipmovie.c:96
#define AVPALETTE_SIZE
Definition: pixfmt.h:33
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:3663
uint8_t * data
Definition: avcodec.h:1160
int decode_map_chunk_size
Definition: ipmovie.c:109
int64_t next_chunk_offset
Definition: ipmovie.c:111
#define AVERROR_EOF
End of file.
Definition: error.h:55
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:240
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:273
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:2718
unsigned int video_bpp
Definition: ipmovie.c:87
#define av_log(a,...)
unsigned int video_height
Definition: ipmovie.c:89
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:537
#define U(x)
Definition: vp56_arith.h:37
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:84
#define OPCODE_INIT_AUDIO_BUFFERS
Definition: ipmovie.c:58
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: avcodec.h:102
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:175
#define AVERROR(e)
Definition: error.h:43
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:180
const char * r
Definition: vf_curves.c:107
int ff_add_param_change(AVPacket *pkt, int32_t channels, uint64_t channel_layout, int32_t sample_rate, int32_t width, int32_t height)
Add side data to a packet for changing parameters to the given values.
Definition: utils.c:4136
int video_chunk_size
Definition: ipmovie.c:107
#define OPCODE_UNKNOWN_13
Definition: ipmovie.c:74
#define OPCODE_SET_DECODING_MAP
Definition: ipmovie.c:70
#define OPCODE_END_OF_CHUNK
Definition: ipmovie.c:56
uint64_t channel_layout
Audio channel layout.
Definition: avcodec.h:2044
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:528
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:826
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:416
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:415
int buf_size
Definition: ipmovie.c:83
int bit_rate
the average bitrate
Definition: avcodec.h:1303
audio channel layout utility functions
unsigned int audio_bits
Definition: ipmovie.c:95
static int read_probe(AVProbeData *pd)
Definition: jvdec.c:55
#define OPCODE_UNKNOWN_10
Definition: ipmovie.c:71
ret
Definition: avfilter.c:974
int width
picture width / height.
Definition: avcodec.h:1412
#define OPCODE_PREAMBLE_SIZE
Definition: ipmovie.c:41
#define CHUNK_SHUTDOWN
Definition: ipmovie.c:47
#define OPCODE_START_STOP_AUDIO
Definition: ipmovie.c:59
#define OPCODE_UNKNOWN_0E
Definition: ipmovie.c:69
#define OPCODE_END_OF_STREAM
Definition: ipmovie.c:55
#define AV_RL32
Definition: intreadwrite.h:146
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:629
unsigned char * buf
Definition: ipmovie.c:82
enum AVCodecID audio_type
Definition: ipmovie.c:98
Stream structure.
Definition: avformat.h:807
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
#define OPCODE_INIT_VIDEO_MODE
Definition: ipmovie.c:65
enum AVMediaType codec_type
Definition: avcodec.h:1247
enum AVCodecID codec_id
Definition: avcodec.h:1256
int sample_rate
samples per second
Definition: avcodec.h:1983
AVIOContext * pb
I/O context.
Definition: avformat.h:1268
#define CHUNK_AUDIO_ONLY
Definition: ipmovie.c:44
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:1271
BYTE int const BYTE int int int height
Definition: avisynth_c.h:714
static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, AVPacket *pkt)
Definition: ipmovie.c:115
#define OPCODE_INIT_VIDEO_BUFFERS
Definition: ipmovie.c:60
int64_t video_chunk_offset
Definition: ipmovie.c:106
unsigned int video_width
Definition: ipmovie.c:88
int audio_chunk_size
Definition: ipmovie.c:105
uint32_t palette[256]
Definition: ipmovie.c:91
#define CHUNK_INIT_AUDIO
Definition: ipmovie.c:43
This structure contains the data a format has to probe a file.
Definition: avformat.h:413
static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, AVPacket *pkt)
Definition: ipmovie.c:218
#define OPCODE_AUDIO_FRAME
Definition: ipmovie.c:63
#define OPCODE_CREATE_TIMER
Definition: ipmovie.c:57
int64_t video_pts
Definition: ipmovie.c:90
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:425
#define CHUNK_DONE
Definition: ipmovie.c:50
Main libavformat public API header.
int video_stream_index
Definition: ipmovie.c:101
#define OPCODE_SILENCE_FRAME
Definition: ipmovie.c:64
#define CHUNK_PREAMBLE_SIZE
Definition: ipmovie.c:40
#define AV_WL16(p, v)
Definition: intreadwrite.h:412
AVInputFormat ff_ipmovie_demuxer
Definition: ipmovie.c:653
#define OPCODE_SET_PALETTE
Definition: ipmovie.c:67
int channels
number of audio channels
Definition: avcodec.h:1984
unsigned int audio_frame_count
Definition: ipmovie.c:99
void * priv_data
Format private data.
Definition: avformat.h:1254
#define OPCODE_UNKNOWN_15
Definition: ipmovie.c:76
#define CHUNK_NOMEM
Definition: ipmovie.c:51
static int ipmovie_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: ipmovie.c:627
#define CHUNK_BAD
Definition: ipmovie.c:53
#define CHUNK_EOF
Definition: ipmovie.c:52
uint64_t frame_pts_inc
Definition: ipmovie.c:85
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:593
int has_palette
Definition: ipmovie.c:92
#define CHUNK_VIDEO
Definition: ipmovie.c:46
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
Definition: aviobuf.c:300
int changed
Definition: ipmovie.c:93
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
Definition: avpacket.c:300
int stream_index
Definition: avcodec.h:1162
#define AV_CH_LAYOUT_MONO
This structure stores compressed data.
Definition: avcodec.h:1137
unsigned int audio_sample_rate
Definition: ipmovie.c:97
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1153
static int width