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 
181  if (avio_read(pb, pkt->data, s->decode_map_chunk_size) !=
183  av_free_packet(pkt);
184  return CHUNK_EOF;
185  }
186 
187  avio_seek(pb, s->video_chunk_offset, SEEK_SET);
188  s->video_chunk_offset = 0;
189 
190  if (avio_read(pb, pkt->data + s->decode_map_chunk_size,
192  av_free_packet(pkt);
193  return CHUNK_EOF;
194  }
195 
197  pkt->pts = s->video_pts;
198 
199  av_dlog(NULL, "sending video frame with pts %"PRId64"\n", pkt->pts);
200 
201  s->video_pts += s->frame_pts_inc;
202 
203  chunk_type = CHUNK_VIDEO;
204 
205  } else {
206 
207  avio_seek(pb, s->next_chunk_offset, SEEK_SET);
208  chunk_type = CHUNK_DONE;
209 
210  }
211 
212  return chunk_type;
213 }
214 
215 /* This function loads and processes a single chunk in an IP movie file.
216  * It returns the type of chunk that was processed. */
218  AVPacket *pkt)
219 {
220  unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
221  int chunk_type;
222  int chunk_size;
223  unsigned char opcode_preamble[OPCODE_PREAMBLE_SIZE];
224  unsigned char opcode_type;
225  unsigned char opcode_version;
226  int opcode_size;
227  unsigned char scratch[1024];
228  int i, j;
229  int first_color, last_color;
230  int audio_flags;
231  unsigned char r, g, b;
232  unsigned int width, height;
233 
234  /* see if there are any pending packets */
235  chunk_type = load_ipmovie_packet(s, pb, pkt);
236  if (chunk_type != CHUNK_DONE)
237  return chunk_type;
238 
239  /* read the next chunk, wherever the file happens to be pointing */
240  if (url_feof(pb))
241  return CHUNK_EOF;
242  if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
244  return CHUNK_BAD;
245  chunk_size = AV_RL16(&chunk_preamble[0]);
246  chunk_type = AV_RL16(&chunk_preamble[2]);
247 
248  av_dlog(NULL, "chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size);
249 
250  switch (chunk_type) {
251 
252  case CHUNK_INIT_AUDIO:
253  av_dlog(NULL, "initialize audio\n");
254  break;
255 
256  case CHUNK_AUDIO_ONLY:
257  av_dlog(NULL, "audio only\n");
258  break;
259 
260  case CHUNK_INIT_VIDEO:
261  av_dlog(NULL, "initialize video\n");
262  break;
263 
264  case CHUNK_VIDEO:
265  av_dlog(NULL, "video (and audio)\n");
266  break;
267 
268  case CHUNK_SHUTDOWN:
269  av_dlog(NULL, "shutdown\n");
270  break;
271 
272  case CHUNK_END:
273  av_dlog(NULL, "end\n");
274  break;
275 
276  default:
277  av_dlog(NULL, "invalid chunk\n");
278  chunk_type = CHUNK_BAD;
279  break;
280 
281  }
282 
283  while ((chunk_size > 0) && (chunk_type != CHUNK_BAD)) {
284 
285  /* read the next chunk, wherever the file happens to be pointing */
286  if (url_feof(pb)) {
287  chunk_type = CHUNK_EOF;
288  break;
289  }
290  if (avio_read(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
292  chunk_type = CHUNK_BAD;
293  break;
294  }
295 
296  opcode_size = AV_RL16(&opcode_preamble[0]);
297  opcode_type = opcode_preamble[2];
298  opcode_version = opcode_preamble[3];
299 
300  chunk_size -= OPCODE_PREAMBLE_SIZE;
301  chunk_size -= opcode_size;
302  if (chunk_size < 0) {
303  av_dlog(NULL, "chunk_size countdown just went negative\n");
304  chunk_type = CHUNK_BAD;
305  break;
306  }
307 
308  av_dlog(NULL, " opcode type %02X, version %d, 0x%04X bytes: ",
309  opcode_type, opcode_version, opcode_size);
310  switch (opcode_type) {
311 
313  av_dlog(NULL, "end of stream\n");
314  avio_skip(pb, opcode_size);
315  break;
316 
317  case OPCODE_END_OF_CHUNK:
318  av_dlog(NULL, "end of chunk\n");
319  avio_skip(pb, opcode_size);
320  break;
321 
322  case OPCODE_CREATE_TIMER:
323  av_dlog(NULL, "create timer\n");
324  if ((opcode_version > 0) || (opcode_size > 6)) {
325  av_dlog(NULL, "bad create_timer opcode\n");
326  chunk_type = CHUNK_BAD;
327  break;
328  }
329  if (avio_read(pb, scratch, opcode_size) !=
330  opcode_size) {
331  chunk_type = CHUNK_BAD;
332  break;
333  }
334  s->frame_pts_inc = ((uint64_t)AV_RL32(&scratch[0])) * AV_RL16(&scratch[4]);
335  av_dlog(NULL, " %.2f frames/second (timer div = %d, subdiv = %d)\n",
336  1000000.0 / s->frame_pts_inc, AV_RL32(&scratch[0]),
337  AV_RL16(&scratch[4]));
338  break;
339 
341  av_dlog(NULL, "initialize audio buffers\n");
342  if ((opcode_version > 1) || (opcode_size > 10)) {
343  av_dlog(NULL, "bad init_audio_buffers opcode\n");
344  chunk_type = CHUNK_BAD;
345  break;
346  }
347  if (avio_read(pb, scratch, opcode_size) !=
348  opcode_size) {
349  chunk_type = CHUNK_BAD;
350  break;
351  }
352  s->audio_sample_rate = AV_RL16(&scratch[4]);
353  audio_flags = AV_RL16(&scratch[2]);
354  /* bit 0 of the flags: 0 = mono, 1 = stereo */
355  s->audio_channels = (audio_flags & 1) + 1;
356  /* bit 1 of the flags: 0 = 8 bit, 1 = 16 bit */
357  s->audio_bits = (((audio_flags >> 1) & 1) + 1) * 8;
358  /* bit 2 indicates compressed audio in version 1 opcode */
359  if ((opcode_version == 1) && (audio_flags & 0x4))
361  else if (s->audio_bits == 16)
363  else
365  av_dlog(NULL, "audio: %d bits, %d Hz, %s, %s format\n",
367  (s->audio_channels == 2) ? "stereo" : "mono",
369  "Interplay audio" : "PCM");
370  break;
371 
373  av_dlog(NULL, "start/stop audio\n");
374  avio_skip(pb, opcode_size);
375  break;
376 
378  av_dlog(NULL, "initialize video buffers\n");
379  if ((opcode_version > 2) || (opcode_size > 8)) {
380  av_dlog(NULL, "bad init_video_buffers opcode\n");
381  chunk_type = CHUNK_BAD;
382  break;
383  }
384  if (avio_read(pb, scratch, opcode_size) !=
385  opcode_size) {
386  chunk_type = CHUNK_BAD;
387  break;
388  }
389  width = AV_RL16(&scratch[0]) * 8;
390  height = AV_RL16(&scratch[2]) * 8;
391  if (width != s->video_width) {
392  s->video_width = width;
393  s->changed++;
394  }
395  if (height != s->video_height) {
396  s->video_height = height;
397  s->changed++;
398  }
399  if (opcode_version < 2 || !AV_RL16(&scratch[6])) {
400  s->video_bpp = 8;
401  } else {
402  s->video_bpp = 16;
403  }
404  av_dlog(NULL, "video resolution: %d x %d\n",
405  s->video_width, s->video_height);
406  break;
407 
408  case OPCODE_UNKNOWN_06:
409  case OPCODE_UNKNOWN_0E:
410  case OPCODE_UNKNOWN_10:
411  case OPCODE_UNKNOWN_12:
412  case OPCODE_UNKNOWN_13:
413  case OPCODE_UNKNOWN_14:
414  case OPCODE_UNKNOWN_15:
415  av_dlog(NULL, "unknown (but documented) opcode %02X\n", opcode_type);
416  avio_skip(pb, opcode_size);
417  break;
418 
419  case OPCODE_SEND_BUFFER:
420  av_dlog(NULL, "send buffer\n");
421  avio_skip(pb, opcode_size);
422  break;
423 
424  case OPCODE_AUDIO_FRAME:
425  av_dlog(NULL, "audio frame\n");
426 
427  /* log position and move on for now */
428  s->audio_chunk_offset = avio_tell(pb);
429  s->audio_chunk_size = opcode_size;
430  avio_skip(pb, opcode_size);
431  break;
432 
434  av_dlog(NULL, "silence frame\n");
435  avio_skip(pb, opcode_size);
436  break;
437 
439  av_dlog(NULL, "initialize video mode\n");
440  avio_skip(pb, opcode_size);
441  break;
442 
444  av_dlog(NULL, "create gradient\n");
445  avio_skip(pb, opcode_size);
446  break;
447 
448  case OPCODE_SET_PALETTE:
449  av_dlog(NULL, "set palette\n");
450  /* check for the logical maximum palette size
451  * (3 * 256 + 4 bytes) */
452  if (opcode_size > 0x304) {
453  av_dlog(NULL, "demux_ipmovie: set_palette opcode too large\n");
454  chunk_type = CHUNK_BAD;
455  break;
456  }
457  if (avio_read(pb, scratch, opcode_size) != opcode_size) {
458  chunk_type = CHUNK_BAD;
459  break;
460  }
461 
462  /* load the palette into internal data structure */
463  first_color = AV_RL16(&scratch[0]);
464  last_color = first_color + AV_RL16(&scratch[2]) - 1;
465  /* sanity check (since they are 16 bit values) */
466  if ((first_color > 0xFF) || (last_color > 0xFF)) {
467  av_dlog(NULL, "demux_ipmovie: set_palette indexes out of range (%d -> %d)\n",
468  first_color, last_color);
469  chunk_type = CHUNK_BAD;
470  break;
471  }
472  j = 4; /* offset of first palette data */
473  for (i = first_color; i <= last_color; i++) {
474  /* the palette is stored as a 6-bit VGA palette, thus each
475  * component is shifted up to a 8-bit range */
476  r = scratch[j++] * 4;
477  g = scratch[j++] * 4;
478  b = scratch[j++] * 4;
479  s->palette[i] = (0xFFU << 24) | (r << 16) | (g << 8) | (b);
480  s->palette[i] |= s->palette[i] >> 6 & 0x30303;
481  }
482  s->has_palette = 1;
483  break;
484 
486  av_dlog(NULL, "set palette compressed\n");
487  avio_skip(pb, opcode_size);
488  break;
489 
491  av_dlog(NULL, "set decoding map\n");
492 
493  /* log position and move on for now */
495  s->decode_map_chunk_size = opcode_size;
496  avio_skip(pb, opcode_size);
497  break;
498 
499  case OPCODE_VIDEO_DATA:
500  av_dlog(NULL, "set video data\n");
501 
502  /* log position and move on for now */
503  s->video_chunk_offset = avio_tell(pb);
504  s->video_chunk_size = opcode_size;
505  avio_skip(pb, opcode_size);
506  break;
507 
508  default:
509  av_dlog(NULL, "*** unknown opcode type\n");
510  chunk_type = CHUNK_BAD;
511  break;
512 
513  }
514  }
515 
516  /* make a note of where the stream is sitting */
517  s->next_chunk_offset = avio_tell(pb);
518 
519  /* dispatch the first of any pending packets */
520  if ((chunk_type == CHUNK_VIDEO) || (chunk_type == CHUNK_AUDIO_ONLY))
521  chunk_type = load_ipmovie_packet(s, pb, pkt);
522 
523  return chunk_type;
524 }
525 
526 static const char signature[] = "Interplay MVE File\x1A\0\x1A";
527 
529 {
530  const uint8_t *b = p->buf;
531  const uint8_t *b_end = p->buf + p->buf_size - sizeof(signature);
532  do {
533  if (b[0] == signature[0] && memcmp(b, signature, sizeof(signature)) == 0)
534  return AVPROBE_SCORE_MAX;
535  b++;
536  } while (b < b_end);
537 
538  return 0;
539 }
540 
542 {
543  IPMVEContext *ipmovie = s->priv_data;
544  AVIOContext *pb = s->pb;
545  AVPacket pkt;
546  AVStream *st;
547  unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
548  int chunk_type, i;
549  uint8_t signature_buffer[sizeof(signature)];
550 
551  avio_read(pb, signature_buffer, sizeof(signature_buffer));
552  while (memcmp(signature_buffer, signature, sizeof(signature))) {
553  memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1);
554  signature_buffer[sizeof(signature_buffer) - 1] = avio_r8(pb);
555  if (url_feof(pb))
556  return AVERROR_EOF;
557  }
558  /* initialize private context members */
559  ipmovie->video_pts = ipmovie->audio_frame_count = 0;
560  ipmovie->audio_chunk_offset = ipmovie->video_chunk_offset =
561  ipmovie->decode_map_chunk_offset = 0;
562 
563  /* on the first read, this will position the stream at the first chunk */
564  ipmovie->next_chunk_offset = avio_tell(pb) + 4;
565 
566  for (i = 0; i < 256; i++)
567  ipmovie->palette[i] = 0xFFU << 24;
568 
569  /* process the first chunk which should be CHUNK_INIT_VIDEO */
570  if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO)
571  return AVERROR_INVALIDDATA;
572 
573  /* peek ahead to the next chunk-- if it is an init audio chunk, process
574  * it; if it is the first video chunk, this is a silent file */
575  if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
577  return AVERROR(EIO);
578  chunk_type = AV_RL16(&chunk_preamble[2]);
579  avio_seek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
580 
581  if (chunk_type == CHUNK_VIDEO)
582  ipmovie->audio_type = AV_CODEC_ID_NONE; /* no audio */
583  else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
584  return AVERROR_INVALIDDATA;
585 
586  /* initialize the stream decoders */
587  st = avformat_new_stream(s, NULL);
588  if (!st)
589  return AVERROR(ENOMEM);
590  avpriv_set_pts_info(st, 63, 1, 1000000);
591  ipmovie->video_stream_index = st->index;
594  st->codec->codec_tag = 0; /* no fourcc */
595  st->codec->width = ipmovie->video_width;
596  st->codec->height = ipmovie->video_height;
597  st->codec->bits_per_coded_sample = ipmovie->video_bpp;
598 
599  if (ipmovie->audio_type) {
600  st = avformat_new_stream(s, NULL);
601  if (!st)
602  return AVERROR(ENOMEM);
603  avpriv_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate);
604  ipmovie->audio_stream_index = st->index;
606  st->codec->codec_id = ipmovie->audio_type;
607  st->codec->codec_tag = 0; /* no tag */
608  st->codec->channels = ipmovie->audio_channels;
611  st->codec->sample_rate = ipmovie->audio_sample_rate;
612  st->codec->bits_per_coded_sample = ipmovie->audio_bits;
613  st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
616  st->codec->bit_rate /= 2;
618  }
619 
620  return 0;
621 }
622 
624  AVPacket *pkt)
625 {
626  IPMVEContext *ipmovie = s->priv_data;
627  AVIOContext *pb = s->pb;
628  int ret;
629 
630  for (;;) {
631  ret = process_ipmovie_chunk(ipmovie, pb, pkt);
632  if (ret == CHUNK_BAD)
633  ret = AVERROR_INVALIDDATA;
634  else if (ret == CHUNK_EOF)
635  ret = AVERROR(EIO);
636  else if (ret == CHUNK_NOMEM)
637  ret = AVERROR(ENOMEM);
638  else if (ret == CHUNK_VIDEO)
639  ret = 0;
640  else if (ret == CHUNK_INIT_VIDEO || ret == CHUNK_INIT_AUDIO)
641  continue;
642  else
643  ret = -1;
644 
645  return ret;
646  }
647 }
648 
650  .name = "ipmovie",
651  .long_name = NULL_IF_CONFIG_SMALL("Interplay MVE"),
652  .priv_data_size = sizeof(IPMVEContext),
656 };
#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 OPCODE_SEND_BUFFER
Definition: ipmovie.c:62
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
void av_free_packet(AVPacket *pkt)
Free a packet.
Definition: avpacket.c:242
static int ipmovie_read_header(AVFormatContext *s)
Definition: ipmovie.c:541
#define OPCODE_VIDEO_DATA
Definition: ipmovie.c:72
int64_t pos
byte position in stream, -1 if unknown
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.
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:644
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:199
#define CHUNK_INIT_VIDEO
Definition: ipmovie.c:45
#define AV_RL16
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:256
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)
#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...
#define OPCODE_CREATE_GRADIENT
Definition: ipmovie.c:66
static int ipmovie_probe(AVProbeData *p)
Definition: ipmovie.c:528
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
Format I/O context.
Definition: avformat.h:944
static const char signature[]
Definition: ipmovie.c:526
#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
unsigned int audio_channels
Definition: ipmovie.c:96
#define AVPALETTE_SIZE
Definition: pixfmt.h:33
static AVPacket pkt
Definition: demuxing.c:56
#define b
Definition: input.c:42
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
uint8_t * data
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.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:248
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
unsigned int video_bpp
Definition: ipmovie.c:87
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:478
#define U(x)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:73
#define OPCODE_INIT_AUDIO_BUFFERS
Definition: ipmovie.c:58
AVCodecID
Identify the syntax and semantics of the bitstream.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const char * r
Definition: vf_curves.c:94
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.
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
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.
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:469
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:662
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
int buf_size
Definition: ipmovie.c:83
FFT buffer for g
Definition: stft_peak.m:17
int bit_rate
the average bitrate
audio channel layout utility functions
unsigned int audio_bits
Definition: ipmovie.c:95
static int read_probe(AVProbeData *pd)
#define OPCODE_UNKNOWN_10
Definition: ipmovie.c:71
ret
Definition: avfilter.c:821
int width
picture width / height.
#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
int url_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
Definition: aviobuf.c:280
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:517
unsigned char * buf
Definition: ipmovie.c:82
enum AVCodecID audio_type
Definition: ipmovie.c:98
Stream structure.
Definition: avformat.h:643
#define OPCODE_INIT_VIDEO_MODE
Definition: ipmovie.c:65
NULL
Definition: eval.c:55
static int width
Definition: tests/utils.c:158
enum AVMediaType codec_type
enum AVCodecID codec_id
int sample_rate
samples per second
AVIOContext * pb
I/O context.
Definition: avformat.h:977
#define CHUNK_AUDIO_ONLY
Definition: ipmovie.c:44
#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
BYTE int const BYTE int int int height
Definition: avisynth_c.h:713
static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, AVPacket *pkt)
Definition: ipmovie.c:115
#define OPCODE_INIT_VIDEO_BUFFERS
Definition: ipmovie.c:60
synthesis window for stochastic i
struct IPMVEContext IPMVEContext
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: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
static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, AVPacket *pkt)
Definition: ipmovie.c:217
#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, half of that is used for file-extension-based detection
Definition: avformat.h:340
#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
AVInputFormat ff_ipmovie_demuxer
Definition: ipmovie.c:649
#define OPCODE_SET_PALETTE
Definition: ipmovie.c:67
int channels
number of audio channels
unsigned int audio_frame_count
Definition: ipmovie.c:99
void * priv_data
Format private data.
Definition: avformat.h:964
#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:623
#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:461
int has_palette
Definition: ipmovie.c:92
#define CHUNK_VIDEO
Definition: ipmovie.c:46
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:264
#define AV_CH_LAYOUT_MONO
This structure stores compressed data.
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...