FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups 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 {
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(s->avf, 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_log(s->avf, AV_LOG_TRACE, "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_packet_unref(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_packet_unref(pkt);
194  return CHUNK_EOF;
195  }
196 
198  pkt->pts = s->video_pts;
199 
200  av_log(s->avf, AV_LOG_TRACE, "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 
217 {
218  IPMVEContext *ipmovie = s->priv_data;
220  if (!st)
221  return AVERROR(ENOMEM);
222  avpriv_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate);
223  ipmovie->audio_stream_index = st->index;
225  st->codecpar->codec_id = ipmovie->audio_type;
226  st->codecpar->codec_tag = 0; /* no tag */
227  st->codecpar->channels = ipmovie->audio_channels;
230  st->codecpar->sample_rate = ipmovie->audio_sample_rate;
231  st->codecpar->bits_per_coded_sample = ipmovie->audio_bits;
235  st->codecpar->bit_rate /= 2;
237 
238  return 0;
239 }
240 
241 /* This function loads and processes a single chunk in an IP movie file.
242  * It returns the type of chunk that was processed. */
244  AVPacket *pkt)
245 {
246  unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
247  int chunk_type;
248  int chunk_size;
249  unsigned char opcode_preamble[OPCODE_PREAMBLE_SIZE];
250  unsigned char opcode_type;
251  unsigned char opcode_version;
252  int opcode_size;
253  unsigned char scratch[1024];
254  int i, j;
255  int first_color, last_color;
256  int audio_flags;
257  unsigned char r, g, b;
258  unsigned int width, height;
259 
260  /* see if there are any pending packets */
261  chunk_type = load_ipmovie_packet(s, pb, pkt);
262  if (chunk_type != CHUNK_DONE)
263  return chunk_type;
264 
265  /* read the next chunk, wherever the file happens to be pointing */
266  if (avio_feof(pb))
267  return CHUNK_EOF;
268  if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
270  return CHUNK_BAD;
271  chunk_size = AV_RL16(&chunk_preamble[0]);
272  chunk_type = AV_RL16(&chunk_preamble[2]);
273 
274  av_log(s->avf, AV_LOG_TRACE, "chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size);
275 
276  switch (chunk_type) {
277 
278  case CHUNK_INIT_AUDIO:
279  av_log(s->avf, AV_LOG_TRACE, "initialize audio\n");
280  break;
281 
282  case CHUNK_AUDIO_ONLY:
283  av_log(s->avf, AV_LOG_TRACE, "audio only\n");
284  break;
285 
286  case CHUNK_INIT_VIDEO:
287  av_log(s->avf, AV_LOG_TRACE, "initialize video\n");
288  break;
289 
290  case CHUNK_VIDEO:
291  av_log(s->avf, AV_LOG_TRACE, "video (and audio)\n");
292  break;
293 
294  case CHUNK_SHUTDOWN:
295  av_log(s->avf, AV_LOG_TRACE, "shutdown\n");
296  break;
297 
298  case CHUNK_END:
299  av_log(s->avf, AV_LOG_TRACE, "end\n");
300  break;
301 
302  default:
303  av_log(s->avf, AV_LOG_TRACE, "invalid chunk\n");
304  chunk_type = CHUNK_BAD;
305  break;
306 
307  }
308 
309  while ((chunk_size > 0) && (chunk_type != CHUNK_BAD)) {
310 
311  /* read the next chunk, wherever the file happens to be pointing */
312  if (avio_feof(pb)) {
313  chunk_type = CHUNK_EOF;
314  break;
315  }
316  if (avio_read(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
318  chunk_type = CHUNK_BAD;
319  break;
320  }
321 
322  opcode_size = AV_RL16(&opcode_preamble[0]);
323  opcode_type = opcode_preamble[2];
324  opcode_version = opcode_preamble[3];
325 
326  chunk_size -= OPCODE_PREAMBLE_SIZE;
327  chunk_size -= opcode_size;
328  if (chunk_size < 0) {
329  av_log(s->avf, AV_LOG_TRACE, "chunk_size countdown just went negative\n");
330  chunk_type = CHUNK_BAD;
331  break;
332  }
333 
334  av_log(s->avf, AV_LOG_TRACE, " opcode type %02X, version %d, 0x%04X bytes: ",
335  opcode_type, opcode_version, opcode_size);
336  switch (opcode_type) {
337 
339  av_log(s->avf, AV_LOG_TRACE, "end of stream\n");
340  avio_skip(pb, opcode_size);
341  break;
342 
343  case OPCODE_END_OF_CHUNK:
344  av_log(s->avf, AV_LOG_TRACE, "end of chunk\n");
345  avio_skip(pb, opcode_size);
346  break;
347 
348  case OPCODE_CREATE_TIMER:
349  av_log(s->avf, AV_LOG_TRACE, "create timer\n");
350  if ((opcode_version > 0) || (opcode_size != 6)) {
351  av_log(s->avf, AV_LOG_TRACE, "bad create_timer opcode\n");
352  chunk_type = CHUNK_BAD;
353  break;
354  }
355  if (avio_read(pb, scratch, opcode_size) !=
356  opcode_size) {
357  chunk_type = CHUNK_BAD;
358  break;
359  }
360  s->frame_pts_inc = ((uint64_t)AV_RL32(&scratch[0])) * AV_RL16(&scratch[4]);
361  break;
362 
364  av_log(s->avf, AV_LOG_TRACE, "initialize audio buffers\n");
365  if (opcode_version > 1 || opcode_size > 10 || opcode_size < 6) {
366  av_log(s->avf, AV_LOG_TRACE, "bad init_audio_buffers opcode\n");
367  chunk_type = CHUNK_BAD;
368  break;
369  }
370  if (avio_read(pb, scratch, opcode_size) !=
371  opcode_size) {
372  chunk_type = CHUNK_BAD;
373  break;
374  }
375  s->audio_sample_rate = AV_RL16(&scratch[4]);
376  audio_flags = AV_RL16(&scratch[2]);
377  /* bit 0 of the flags: 0 = mono, 1 = stereo */
378  s->audio_channels = (audio_flags & 1) + 1;
379  /* bit 1 of the flags: 0 = 8 bit, 1 = 16 bit */
380  s->audio_bits = (((audio_flags >> 1) & 1) + 1) * 8;
381  /* bit 2 indicates compressed audio in version 1 opcode */
382  if ((opcode_version == 1) && (audio_flags & 0x4))
384  else if (s->audio_bits == 16)
386  else
388  av_log(s->avf, AV_LOG_TRACE, "audio: %d bits, %d Hz, %s, %s format\n",
390  (s->audio_channels == 2) ? "stereo" : "mono",
392  "Interplay audio" : "PCM");
393  break;
394 
396  av_log(s->avf, AV_LOG_TRACE, "start/stop audio\n");
397  avio_skip(pb, opcode_size);
398  break;
399 
401  av_log(s->avf, AV_LOG_TRACE, "initialize video buffers\n");
402  if ((opcode_version > 2) || (opcode_size > 8) || opcode_size < 4
403  || opcode_version == 2 && opcode_size < 8
404  ) {
405  av_log(s->avf, AV_LOG_TRACE, "bad init_video_buffers opcode\n");
406  chunk_type = CHUNK_BAD;
407  break;
408  }
409  if (avio_read(pb, scratch, opcode_size) !=
410  opcode_size) {
411  chunk_type = CHUNK_BAD;
412  break;
413  }
414  width = AV_RL16(&scratch[0]) * 8;
415  height = AV_RL16(&scratch[2]) * 8;
416  if (width != s->video_width) {
417  s->video_width = width;
418  s->changed++;
419  }
420  if (height != s->video_height) {
421  s->video_height = height;
422  s->changed++;
423  }
424  if (opcode_version < 2 || !AV_RL16(&scratch[6])) {
425  s->video_bpp = 8;
426  } else {
427  s->video_bpp = 16;
428  }
429  av_log(s->avf, AV_LOG_TRACE, "video resolution: %d x %d\n",
430  s->video_width, s->video_height);
431  break;
432 
433  case OPCODE_UNKNOWN_06:
434  case OPCODE_UNKNOWN_0E:
435  case OPCODE_UNKNOWN_10:
436  case OPCODE_UNKNOWN_12:
437  case OPCODE_UNKNOWN_13:
438  case OPCODE_UNKNOWN_14:
439  case OPCODE_UNKNOWN_15:
440  av_log(s->avf, AV_LOG_TRACE, "unknown (but documented) opcode %02X\n", opcode_type);
441  avio_skip(pb, opcode_size);
442  break;
443 
444  case OPCODE_SEND_BUFFER:
445  av_log(s->avf, AV_LOG_TRACE, "send buffer\n");
446  avio_skip(pb, opcode_size);
447  break;
448 
449  case OPCODE_AUDIO_FRAME:
450  av_log(s->avf, AV_LOG_TRACE, "audio frame\n");
451 
452  /* log position and move on for now */
453  s->audio_chunk_offset = avio_tell(pb);
454  s->audio_chunk_size = opcode_size;
455  avio_skip(pb, opcode_size);
456  break;
457 
459  av_log(s->avf, AV_LOG_TRACE, "silence frame\n");
460  avio_skip(pb, opcode_size);
461  break;
462 
464  av_log(s->avf, AV_LOG_TRACE, "initialize video mode\n");
465  avio_skip(pb, opcode_size);
466  break;
467 
469  av_log(s->avf, AV_LOG_TRACE, "create gradient\n");
470  avio_skip(pb, opcode_size);
471  break;
472 
473  case OPCODE_SET_PALETTE:
474  av_log(s->avf, AV_LOG_TRACE, "set palette\n");
475  /* check for the logical maximum palette size
476  * (3 * 256 + 4 bytes) */
477  if (opcode_size > 0x304 || opcode_size < 4) {
478  av_log(s->avf, AV_LOG_TRACE, "demux_ipmovie: set_palette opcode with invalid size\n");
479  chunk_type = CHUNK_BAD;
480  break;
481  }
482  if (avio_read(pb, scratch, opcode_size) != opcode_size) {
483  chunk_type = CHUNK_BAD;
484  break;
485  }
486 
487  /* load the palette into internal data structure */
488  first_color = AV_RL16(&scratch[0]);
489  last_color = first_color + AV_RL16(&scratch[2]) - 1;
490  /* sanity check (since they are 16 bit values) */
491  if ( (first_color > 0xFF) || (last_color > 0xFF)
492  || (last_color - first_color + 1)*3 + 4 > opcode_size) {
493  av_log(s->avf, AV_LOG_TRACE, "demux_ipmovie: set_palette indexes out of range (%d -> %d)\n",
494  first_color, last_color);
495  chunk_type = CHUNK_BAD;
496  break;
497  }
498  j = 4; /* offset of first palette data */
499  for (i = first_color; i <= last_color; i++) {
500  /* the palette is stored as a 6-bit VGA palette, thus each
501  * component is shifted up to a 8-bit range */
502  r = scratch[j++] * 4;
503  g = scratch[j++] * 4;
504  b = scratch[j++] * 4;
505  s->palette[i] = (0xFFU << 24) | (r << 16) | (g << 8) | (b);
506  s->palette[i] |= s->palette[i] >> 6 & 0x30303;
507  }
508  s->has_palette = 1;
509  break;
510 
512  av_log(s->avf, AV_LOG_TRACE, "set palette compressed\n");
513  avio_skip(pb, opcode_size);
514  break;
515 
517  av_log(s->avf, AV_LOG_TRACE, "set decoding map\n");
518 
519  /* log position and move on for now */
521  s->decode_map_chunk_size = opcode_size;
522  avio_skip(pb, opcode_size);
523  break;
524 
525  case OPCODE_VIDEO_DATA:
526  av_log(s->avf, AV_LOG_TRACE, "set video data\n");
527 
528  /* log position and move on for now */
529  s->video_chunk_offset = avio_tell(pb);
530  s->video_chunk_size = opcode_size;
531  avio_skip(pb, opcode_size);
532  break;
533 
534  default:
535  av_log(s->avf, AV_LOG_TRACE, "*** unknown opcode type\n");
536  chunk_type = CHUNK_BAD;
537  break;
538 
539  }
540  }
541 
542  if (s->avf->nb_streams == 1 && s->audio_type)
543  init_audio(s->avf);
544 
545  /* make a note of where the stream is sitting */
546  s->next_chunk_offset = avio_tell(pb);
547 
548  /* dispatch the first of any pending packets */
549  if ((chunk_type == CHUNK_VIDEO) || (chunk_type == CHUNK_AUDIO_ONLY))
550  chunk_type = load_ipmovie_packet(s, pb, pkt);
551 
552  return chunk_type;
553 }
554 
555 static const char signature[] = "Interplay MVE File\x1A\0\x1A";
556 
558 {
559  const uint8_t *b = p->buf;
560  const uint8_t *b_end = p->buf + p->buf_size - sizeof(signature);
561  do {
562  if (b[0] == signature[0] && memcmp(b, signature, sizeof(signature)) == 0)
563  return AVPROBE_SCORE_MAX;
564  b++;
565  } while (b < b_end);
566 
567  return 0;
568 }
569 
571 {
572  IPMVEContext *ipmovie = s->priv_data;
573  AVIOContext *pb = s->pb;
574  AVPacket pkt;
575  AVStream *st;
576  unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
577  int chunk_type, i;
578  uint8_t signature_buffer[sizeof(signature)];
579 
580  ipmovie->avf = s;
581 
582  avio_read(pb, signature_buffer, sizeof(signature_buffer));
583  while (memcmp(signature_buffer, signature, sizeof(signature))) {
584  memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1);
585  signature_buffer[sizeof(signature_buffer) - 1] = avio_r8(pb);
586  if (avio_feof(pb))
587  return AVERROR_EOF;
588  }
589  /* initialize private context members */
590  ipmovie->video_pts = ipmovie->audio_frame_count = 0;
591  ipmovie->audio_chunk_offset = ipmovie->video_chunk_offset =
592  ipmovie->decode_map_chunk_offset = 0;
593 
594  /* on the first read, this will position the stream at the first chunk */
595  ipmovie->next_chunk_offset = avio_tell(pb) + 4;
596 
597  for (i = 0; i < 256; i++)
598  ipmovie->palette[i] = 0xFFU << 24;
599 
600  /* process the first chunk which should be CHUNK_INIT_VIDEO */
601  if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO)
602  return AVERROR_INVALIDDATA;
603 
604  /* peek ahead to the next chunk-- if it is an init audio chunk, process
605  * it; if it is the first video chunk, this is a silent file */
606  if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
608  return AVERROR(EIO);
609  chunk_type = AV_RL16(&chunk_preamble[2]);
610  avio_seek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
611 
612  if (chunk_type == CHUNK_VIDEO)
613  ipmovie->audio_type = AV_CODEC_ID_NONE; /* no audio */
614  else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
615  return AVERROR_INVALIDDATA;
616 
617  /* initialize the stream decoders */
618  st = avformat_new_stream(s, NULL);
619  if (!st)
620  return AVERROR(ENOMEM);
621  avpriv_set_pts_info(st, 63, 1, 1000000);
622  ipmovie->video_stream_index = st->index;
625  st->codecpar->codec_tag = 0; /* no fourcc */
626  st->codecpar->width = ipmovie->video_width;
627  st->codecpar->height = ipmovie->video_height;
628  st->codecpar->bits_per_coded_sample = ipmovie->video_bpp;
629 
630  if (ipmovie->audio_type) {
631  return init_audio(s);
632  } else
634 
635  return 0;
636 }
637 
639  AVPacket *pkt)
640 {
641  IPMVEContext *ipmovie = s->priv_data;
642  AVIOContext *pb = s->pb;
643  int ret;
644 
645  for (;;) {
646  ret = process_ipmovie_chunk(ipmovie, pb, pkt);
647  if (ret == CHUNK_BAD)
648  ret = AVERROR_INVALIDDATA;
649  else if (ret == CHUNK_EOF)
650  ret = AVERROR(EIO);
651  else if (ret == CHUNK_NOMEM)
652  ret = AVERROR(ENOMEM);
653  else if (ret == CHUNK_VIDEO)
654  ret = 0;
655  else if (ret == CHUNK_INIT_VIDEO || ret == CHUNK_INIT_AUDIO)
656  continue;
657  else
658  continue;
659 
660  return ret;
661  }
662 }
663 
665  .name = "ipmovie",
666  .long_name = NULL_IF_CONFIG_SMALL("Interplay MVE"),
667  .priv_data_size = sizeof(IPMVEContext),
671 };
#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:768
Bytestream IO Context.
Definition: avio.h:155
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
static int ipmovie_read_header(AVFormatContext *s)
Definition: ipmovie.c:570
#define OPCODE_VIDEO_DATA
Definition: ipmovie.c:72
int64_t pos
byte position in stream, -1 if unknown
Definition: avcodec.h:1677
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:4727
const char * g
Definition: vf_curves.c:112
int audio_stream_index
Definition: ipmovie.c:102
#define OPCODE_UNKNOWN_14
Definition: ipmovie.c:75
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: avcodec.h:4074
int index
stream index in AVFormatContext
Definition: avformat.h:890
const char * b
Definition: vf_curves.c:113
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:235
#define CHUNK_INIT_VIDEO
Definition: ipmovie.c:45
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:318
static AVPacket pkt
#define AV_CH_LAYOUT_STEREO
int ctx_flags
Flags signalling stream properties.
Definition: avformat.h:1398
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:87
#define OPCODE_CREATE_GRADIENT
Definition: ipmovie.c:66
static int ipmovie_probe(AVProbeData *p)
Definition: ipmovie.c:557
Format I/O context.
Definition: avformat.h:1349
static const char signature[]
Definition: ipmovie.c:555
#define OPCODE_UNKNOWN_12
Definition: ipmovie.c:73
int64_t audio_chunk_offset
Definition: ipmovie.c:104
#define CHUNK_END
Definition: ipmovie.c:48
uint8_t
int width
Video only.
Definition: avcodec.h:4140
#define AVFMTCTX_NOHEADER
signal that no header is present (streams are added dynamically)
Definition: avformat.h:1302
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:202
unsigned int audio_channels
Definition: ipmovie.c:96
#define AVPALETTE_SIZE
Definition: pixfmt.h:32
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4357
#define height
uint8_t * data
Definition: avcodec.h:1657
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:289
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:527
unsigned int video_bpp
Definition: ipmovie.c:87
uint64_t channel_layout
Audio only.
Definition: avcodec.h:4176
#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:621
AVFormatContext * avf
Definition: ipmovie.c:81
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition: avcodec.h:4103
#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:86
#define OPCODE_INIT_AUDIO_BUFFERS
Definition: ipmovie.c:58
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: avcodec.h:214
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette...
Definition: avcodec.h:1406
#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:179
const char * r
Definition: vf_curves.c:111
enum AVMediaType codec_type
General type of the encoded data.
Definition: avcodec.h:4070
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:4861
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
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:612
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:464
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:463
int buf_size
Definition: ipmovie.c:83
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1405
int block_align
Audio only.
Definition: avcodec.h:4191
audio channel layout utility functions
unsigned int audio_bits
Definition: ipmovie.c:95
#define width
static int read_probe(AVProbeData *pd)
Definition: jvdec.c:55
#define OPCODE_UNKNOWN_10
Definition: ipmovie.c:71
#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
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:509
unsigned char * buf
Definition: ipmovie.c:82
enum AVCodecID audio_type
Definition: ipmovie.c:98
Stream structure.
Definition: avformat.h:889
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
AVIOContext * pb
I/O context.
Definition: avformat.h:1391
#define CHUNK_AUDIO_ONLY
Definition: ipmovie.c:44
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:576
static int init_audio(AVFormatContext *s)
Definition: ipmovie.c:216
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:461
static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, AVPacket *pkt)
Definition: ipmovie.c:243
#define OPCODE_AUDIO_FRAME
Definition: ipmovie.c:63
#define OPCODE_CREATE_TIMER
Definition: ipmovie.c:57
int64_t video_pts
Definition: ipmovie.c:90
int sample_rate
Audio only.
Definition: avcodec.h:4184
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:473
#define CHUNK_DONE
Definition: ipmovie.c:50
Main libavformat public API header.
int video_stream_index
Definition: ipmovie.c:101
if(ret< 0)
Definition: vf_mcdeint.c:282
#define OPCODE_SILENCE_FRAME
Definition: ipmovie.c:64
#define CHUNK_PREAMBLE_SIZE
Definition: ipmovie.c:40
#define AV_WL16(p, v)
Definition: intreadwrite.h:417
AVInputFormat ff_ipmovie_demuxer
Definition: ipmovie.c:664
#define OPCODE_SET_PALETTE
Definition: ipmovie.c:67
unsigned int audio_frame_count
Definition: ipmovie.c:99
void * priv_data
Format private data.
Definition: avformat.h:1377
#define OPCODE_UNKNOWN_15
Definition: ipmovie.c:76
#define CHUNK_NOMEM
Definition: ipmovie.c:51
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition: avcodec.h:4116
static int ipmovie_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: ipmovie.c:638
int channels
Audio only.
Definition: avcodec.h:4180
#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:664
int has_palette
Definition: ipmovie.c:92
#define CHUNK_VIDEO
Definition: ipmovie.c:46
AVCodecParameters * codecpar
Definition: avformat.h:1252
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
Definition: aviobuf.c:345
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: avcodec.h:4078
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:318
int stream_index
Definition: avcodec.h:1659
#define AV_CH_LAYOUT_MONO
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:87
This structure stores compressed data.
Definition: avcodec.h:1634
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:1650