FFmpeg
electronicarts.c
Go to the documentation of this file.
1 /* Electronic Arts Multimedia File Demuxer
2  * Copyright (c) 2004 The FFmpeg project
3  * Copyright (c) 2006-2008 Peter Ross
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  * Electronic Arts Multimedia file demuxer (WVE/UV2/etc.)
25  * by Robin Kay (komadori at gekkou.co.uk)
26  */
27 
28 #include <inttypes.h>
29 
30 #include "libavutil/intreadwrite.h"
31 #include "libavutil/opt.h"
32 #include "avformat.h"
33 #include "demux.h"
34 #include "internal.h"
35 
36 #define SCHl_TAG MKTAG('S', 'C', 'H', 'l')
37 #define SEAD_TAG MKTAG('S', 'E', 'A', 'D') /* Sxxx header */
38 #define SNDC_TAG MKTAG('S', 'N', 'D', 'C') /* Sxxx data */
39 #define SEND_TAG MKTAG('S', 'E', 'N', 'D') /* Sxxx end */
40 #define SHEN_TAG MKTAG('S', 'H', 'E', 'N') /* SxEN header */
41 #define SDEN_TAG MKTAG('S', 'D', 'E', 'N') /* SxEN data */
42 #define SEEN_TAG MKTAG('S', 'E', 'E', 'N') /* SxEN end */
43 #define ISNh_TAG MKTAG('1', 'S', 'N', 'h') /* 1SNx header */
44 #define EACS_TAG MKTAG('E', 'A', 'C', 'S')
45 #define ISNd_TAG MKTAG('1', 'S', 'N', 'd') /* 1SNx data */
46 #define ISNe_TAG MKTAG('1', 'S', 'N', 'e') /* 1SNx end */
47 #define PT00_TAG MKTAG('P', 'T', 0x0, 0x0)
48 #define GSTR_TAG MKTAG('G', 'S', 'T', 'R')
49 #define SCDl_TAG MKTAG('S', 'C', 'D', 'l')
50 #define SCEl_TAG MKTAG('S', 'C', 'E', 'l')
51 #define kVGT_TAG MKTAG('k', 'V', 'G', 'T') /* TGV I-frame */
52 #define fVGT_TAG MKTAG('f', 'V', 'G', 'T') /* TGV P-frame */
53 #define mTCD_TAG MKTAG('m', 'T', 'C', 'D') /* MDEC */
54 #define MADk_TAG MKTAG('M', 'A', 'D', 'k') /* MAD I-frame */
55 #define MADm_TAG MKTAG('M', 'A', 'D', 'm') /* MAD P-frame */
56 #define MADe_TAG MKTAG('M', 'A', 'D', 'e') /* MAD lqp-frame */
57 #define MPCh_TAG MKTAG('M', 'P', 'C', 'h') /* MPEG-2 */
58 #define TGQs_TAG MKTAG('T', 'G', 'Q', 's') /* TGQ I-frame (appears in .TGQ files) */
59 #define pQGT_TAG MKTAG('p', 'Q', 'G', 'T') /* TGQ I-frame (appears in .UV files) */
60 #define pIQT_TAG MKTAG('p', 'I', 'Q', 'T') /* TQI/UV2 I-frame (.UV2/.WVE) */
61 #define MVhd_TAG MKTAG('M', 'V', 'h', 'd')
62 #define MV0K_TAG MKTAG('M', 'V', '0', 'K')
63 #define MV0F_TAG MKTAG('M', 'V', '0', 'F')
64 #define AVhd_TAG MKTAG('A', 'V', 'h', 'd')
65 #define AV0K_TAG MKTAG('A', 'V', '0', 'K')
66 #define AV0F_TAG MKTAG('A', 'V', '0', 'F')
67 #define MVIh_TAG MKTAG('M', 'V', 'I', 'h') /* CMV header */
68 #define MVIf_TAG MKTAG('M', 'V', 'I', 'f') /* CMV I-frame */
69 #define AVP6_TAG MKTAG('A', 'V', 'P', '6')
70 
71 typedef struct VideoProperties {
74  int width, height;
75  int nb_frames;
78 
79 typedef struct EaDemuxContext {
80  const AVClass *class;
81 
83 
85 
88 
89  int bytes;
93 
94  int platform;
97 
98 static uint32_t read_arbitrary(AVIOContext *pb)
99 {
100  uint8_t size, byte;
101  int i;
102  uint32_t word;
103 
104  size = avio_r8(pb);
105 
106  word = 0;
107  for (i = 0; i < size; i++) {
108  byte = avio_r8(pb);
109  word <<= 8;
110  word |= byte;
111  }
112 
113  return word;
114 }
115 
117 {
118  EaDemuxContext *ea = s->priv_data;
119  AVIOContext *pb = s->pb;
120  int in_header = 1;
121  int compression_type = -1, revision = -1, revision2 = -1;
122 
123  ea->bytes = 2;
124  ea->sample_rate = -1;
125  ea->num_channels = 1;
126 
127  while (!avio_feof(pb) && in_header) {
128  int in_subheader;
129  uint8_t byte;
130  byte = avio_r8(pb);
131 
132  switch (byte) {
133  case 0xFD:
134  av_log(s, AV_LOG_DEBUG, "entered audio subheader\n");
135  in_subheader = 1;
136  while (!avio_feof(pb) && in_subheader) {
137  uint8_t subbyte;
138  subbyte = avio_r8(pb);
139 
140  switch (subbyte) {
141  case 0x80:
142  revision = read_arbitrary(pb);
144  "revision (element 0x80) set to 0x%08x\n", revision);
145  break;
146  case 0x82:
147  ea->num_channels = read_arbitrary(pb);
149  "num_channels (element 0x82) set to 0x%08x\n",
150  ea->num_channels);
151  break;
152  case 0x83:
153  compression_type = read_arbitrary(pb);
155  "compression_type (element 0x83) set to 0x%08x\n",
156  compression_type);
157  break;
158  case 0x84:
159  ea->sample_rate = read_arbitrary(pb);
161  "sample_rate (element 0x84) set to %i\n",
162  ea->sample_rate);
163  break;
164  case 0x85:
165  ea->num_samples = read_arbitrary(pb);
167  "num_samples (element 0x85) set to 0x%08x\n",
168  ea->num_samples);
169  break;
170  case 0x8A:
172  "element 0x%02x set to 0x%08"PRIx32"\n",
173  subbyte, read_arbitrary(pb));
174  av_log(s, AV_LOG_DEBUG, "exited audio subheader\n");
175  in_subheader = 0;
176  break;
177  case 0xA0:
178  revision2 = read_arbitrary(pb);
180  "revision2 (element 0xA0) set to 0x%08x\n",
181  revision2);
182  break;
183  case 0xFF:
185  "end of header block reached (within audio subheader)\n");
186  in_subheader = 0;
187  in_header = 0;
188  break;
189  default:
191  "element 0x%02x set to 0x%08"PRIx32"\n",
192  subbyte, read_arbitrary(pb));
193  break;
194  }
195  }
196  break;
197  case 0xFF:
198  av_log(s, AV_LOG_DEBUG, "end of header block reached\n");
199  in_header = 0;
200  break;
201  default:
203  "header element 0x%02x set to 0x%08"PRIx32"\n",
204  byte, read_arbitrary(pb));
205  break;
206  }
207  }
208 
209  switch (compression_type) {
210  case 0:
212  break;
213  case 7:
215  break;
216  case -1:
217  switch (revision) {
218  case 1:
220  break;
221  case 2:
223  break;
224  case 3:
226  break;
227  case -1:
228  break;
229  default:
230  avpriv_request_sample(s, "stream type; revision=%i", revision);
231  return 0;
232  }
233  switch (revision2) {
234  case 8:
236  break;
237  case 10:
238  switch (revision) {
239  case -1:
240  case 2: ea->audio_codec = AV_CODEC_ID_ADPCM_EA_R1; break;
241  case 3: ea->audio_codec = AV_CODEC_ID_ADPCM_EA_R2; break;
242  default:
243  avpriv_request_sample(s, "stream type; revision=%i, revision2=%i", revision, revision2);
244  return 0;
245  }
246  break;
247  case 15:
248  case 16:
250  break;
251  case -1:
252  break;
253  default:
255  avpriv_request_sample(s, "stream type; revision2=%i", revision2);
256  return 0;
257  }
258  break;
259  default:
261  "stream type; compression_type=%i",
262  compression_type);
263  return 0;
264  }
265 
266  if (ea->audio_codec == AV_CODEC_ID_NONE && ea->platform == 0x01)
268  if (ea->sample_rate == -1)
269  ea->sample_rate = revision == 3 ? 48000 : 22050;
270 
271  return 1;
272 }
273 
275 {
276  EaDemuxContext *ea = s->priv_data;
277  AVIOContext *pb = s->pb;
278  int compression_type;
279 
280  ea->sample_rate = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb);
281  ea->bytes = avio_r8(pb); /* 1=8-bit, 2=16-bit */
282  ea->num_channels = avio_r8(pb);
283  compression_type = avio_r8(pb);
284  avio_skip(pb, 13);
285 
286  switch (compression_type) {
287  case 0:
288  switch (ea->bytes) {
289  case 1:
291  break;
292  case 2:
294  break;
295  }
296  break;
297  case 1:
299  ea->bytes = 1;
300  break;
301  case 2:
303  break;
304  default:
306  "stream type; audio compression_type=%i",
307  compression_type);
308  }
309 }
310 
312 {
313  EaDemuxContext *ea = s->priv_data;
314  AVIOContext *pb = s->pb;
315 
316  ea->sample_rate = avio_rl32(pb);
317  ea->bytes = avio_rl32(pb); /* 1=8-bit, 2=16-bit */
318  ea->num_channels = avio_rl32(pb);
320 }
321 
323 {
324  AVIOContext *pb = s->pb;
325  avio_skip(pb, 4);
326  video->width = avio_rl16(pb);
327  video->height = avio_rl16(pb);
328  video->time_base = (AVRational) { 1, 15 };
329  video->codec = AV_CODEC_ID_MDEC;
330 }
331 
333 {
334  AVIOContext *pb = s->pb;
335 
336  avio_skip(pb, 8);
337  video->nb_frames = avio_rl32(pb);
338  avio_skip(pb, 4);
339  video->time_base.den = avio_rl32(pb);
340  video->time_base.num = avio_rl32(pb);
341  if (video->time_base.den <= 0 || video->time_base.num <= 0) {
342  av_log(s, AV_LOG_ERROR, "Timebase is invalid\n");
343  return AVERROR_INVALIDDATA;
344  }
345  video->codec = AV_CODEC_ID_VP6;
346 
347  return 1;
348 }
349 
351 {
352  int fps;
353 
354  avio_skip(s->pb, 10);
355  fps = avio_rl16(s->pb);
356  if (fps)
357  video->time_base = (AVRational) { 1, fps };
358  video->codec = AV_CODEC_ID_CMV;
359 }
360 
361 /* Process EA file header.
362  * Return 1 if the EA file is valid and successfully opened, 0 otherwise. */
364 {
365  uint32_t blockid, size = 0;
366  EaDemuxContext *ea = s->priv_data;
367  AVIOContext *pb = s->pb;
368  int i;
369 
370  for (i = 0; i < 5 && (!ea->audio_codec || !ea->video.codec); i++) {
371  uint64_t startpos = avio_tell(pb);
372  int err = 0;
373 
374  blockid = avio_rl32(pb);
375  size = avio_rl32(pb);
376  if (i == 0)
377  ea->big_endian = size > av_bswap32(size);
378  if (ea->big_endian)
379  size = av_bswap32(size);
380 
381  if (size < 8) {
382  av_log(s, AV_LOG_ERROR, "chunk size too small\n");
383  return AVERROR_INVALIDDATA;
384  }
385 
386  switch (blockid) {
387  case ISNh_TAG:
388  if (avio_rl32(pb) != EACS_TAG) {
389  avpriv_request_sample(s, "unknown 1SNh headerid");
390  return 0;
391  }
393  break;
394 
395  case SCHl_TAG:
396  case SHEN_TAG:
397  blockid = avio_rl32(pb);
398  if (blockid == GSTR_TAG) {
399  avio_skip(pb, 4);
400  } else if ((blockid & 0xFF) != (PT00_TAG & 0xFF)) {
401  blockid = avio_rl32(pb);
402  }
403  ea->platform = (blockid >> 16) & 0xFF;
405  break;
406 
407  case SEAD_TAG:
409  break;
410 
411  case MVIh_TAG:
413  break;
414 
415  case kVGT_TAG:
417  break;
418 
419  case mTCD_TAG:
421  break;
422 
423  case MPCh_TAG:
425  break;
426 
427  case pQGT_TAG:
428  case TGQs_TAG:
430  ea->video.time_base = (AVRational) { 1, 15 };
431  break;
432 
433  case pIQT_TAG:
435  ea->video.time_base = (AVRational) { 1, 15 };
436  break;
437 
438  case MADk_TAG:
440  avio_skip(pb, 6);
441  ea->video.time_base = (AVRational) { avio_rl16(pb), 1000 };
442  break;
443 
444  case MVhd_TAG:
445  err = process_video_header_vp6(s, &ea->video);
446  break;
447 
448  case AVhd_TAG:
449  err = process_video_header_vp6(s, &ea->alpha);
450  if (err >= 0 && ea->video.codec == AV_CODEC_ID_VP6 && ea->merge_alpha) {
451  ea->alpha.codec = 0;
453  }
454  break;
455  }
456 
457  if (err < 0) {
458  av_log(s, AV_LOG_ERROR, "error parsing header: %i\n", err);
459  return err;
460  }
461 
462  avio_seek(pb, startpos + size, SEEK_SET);
463  }
464 
465  avio_seek(pb, 0, SEEK_SET);
466 
467  return 1;
468 }
469 
470 static int ea_probe(const AVProbeData *p)
471 {
472  unsigned big_endian, size;
473 
474  switch (AV_RL32(&p->buf[0])) {
475  case ISNh_TAG:
476  case SCHl_TAG:
477  case SEAD_TAG:
478  case SHEN_TAG:
479  case kVGT_TAG:
480  case MADk_TAG:
481  case MPCh_TAG:
482  case MVhd_TAG:
483  case MVIh_TAG:
484  case AVP6_TAG:
485  break;
486  default:
487  return 0;
488  }
489  size = AV_RL32(&p->buf[4]);
490  big_endian = size > 0x000FFFFF;
491  if (big_endian)
492  size = av_bswap32(size);
493  if (size > 0xfffff || size < 8)
494  return 0;
495 
496  return AVPROBE_SCORE_MAX;
497 }
498 
500 {
501  AVStream *st;
502 
503  if (!video->codec)
504  return 0;
505 
506  /* initialize the video decoder stream */
507  st = avformat_new_stream(s, NULL);
508  if (!st)
509  return AVERROR(ENOMEM);
510  video->stream_index = st->index;
512  st->codecpar->codec_id = video->codec;
513  // parsing is necessary to make FFmpeg generate correct timestamps
516  st->codecpar->codec_tag = 0; /* no fourcc */
517  st->codecpar->width = video->width;
518  st->codecpar->height = video->height;
519  st->duration = st->nb_frames = video->nb_frames;
520  if (video->time_base.num)
521  avpriv_set_pts_info(st, 64, video->time_base.num, video->time_base.den);
522  st->r_frame_rate =
523  st->avg_frame_rate = av_inv_q(video->time_base);
524  return 0;
525 }
526 
528 {
529  EaDemuxContext *ea = s->priv_data;
530  AVStream *st;
531 
532  if (process_ea_header(s)<=0)
533  return AVERROR(EIO);
534 
535  if (init_video_stream(s, &ea->video) || init_video_stream(s, &ea->alpha))
536  return AVERROR(ENOMEM);
537 
538  if (ea->audio_codec) {
539  if (ea->num_channels <= 0 || ea->num_channels > 2) {
541  "Unsupported number of channels: %d\n", ea->num_channels);
542  goto no_audio;
543  }
544  if (ea->sample_rate <= 0) {
546  "Unsupported sample rate: %d\n", ea->sample_rate);
547  goto no_audio;
548  }
549  if (ea->bytes <= 0 || ea->bytes > 2) {
551  "Invalid number of bytes per sample: %d\n", ea->bytes);
552  goto no_audio;
553  }
554 
555  /* initialize the audio decoder stream */
556  st = avformat_new_stream(s, NULL);
557  if (!st)
558  return AVERROR(ENOMEM);
559  avpriv_set_pts_info(st, 33, 1, ea->sample_rate);
561  st->codecpar->codec_id = ea->audio_codec;
562  st->codecpar->codec_tag = 0; /* no tag */
564  st->codecpar->sample_rate = ea->sample_rate;
565  st->codecpar->bits_per_coded_sample = ea->bytes * 8;
566  st->codecpar->bit_rate = (int64_t)ea->num_channels *
567  st->codecpar->sample_rate *
569  st->codecpar->block_align = ea->num_channels *
571  ea->audio_stream_index = st->index;
572  st->start_time = 0;
573  return 0;
574  }
575 no_audio:
577 
578  if (!ea->video.codec)
579  return AVERROR_INVALIDDATA;
580  return 0;
581 }
582 
584 {
585  EaDemuxContext *ea = s->priv_data;
586  AVIOContext *pb = s->pb;
587  int partial_packet = 0;
588  int hit_end = 0;
589  unsigned int chunk_type, chunk_size;
590  int ret = 0, packet_read = 0, key = 0, vp6a;
591  int av_uninit(num_samples);
592 
593  while ((!packet_read && !hit_end) || partial_packet) {
594  chunk_type = avio_rl32(pb);
595  if (avio_feof(pb))
596  return AVERROR_EOF;
597  chunk_size = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb);
598  if (chunk_size < 8)
599  return AVERROR_INVALIDDATA;
600  chunk_size -= 8;
601 
602  switch (chunk_type) {
603  /* audio data */
604  case ISNh_TAG:
605  /* header chunk also contains data; skip over the header portion */
606  if (chunk_size < 32)
607  return AVERROR_INVALIDDATA;
608  avio_skip(pb, 32);
609  chunk_size -= 32;
610  case ISNd_TAG:
611  case SCDl_TAG:
612  case SNDC_TAG:
613  case SDEN_TAG:
614  if (!ea->audio_codec) {
615  avio_skip(pb, chunk_size);
616  break;
617  } else if (ea->audio_codec == AV_CODEC_ID_PCM_S16LE_PLANAR ||
618  ea->audio_codec == AV_CODEC_ID_MP3) {
619  if (chunk_size < 12)
620  return AVERROR_INVALIDDATA;
621  num_samples = avio_rl32(pb);
622  avio_skip(pb, 8);
623  chunk_size -= 12;
624  } else if (ea->audio_codec == AV_CODEC_ID_ADPCM_PSX) {
625  if (chunk_size < 8)
626  return AVERROR_INVALIDDATA;
627  avio_skip(pb, 8);
628  chunk_size -= 8;
629  }
630 
631  if (partial_packet) {
632  avpriv_request_sample(s, "video header followed by audio packet");
634  partial_packet = 0;
635  }
636 
637  if (!chunk_size)
638  continue;
639 
640  ret = av_get_packet(pb, pkt, chunk_size);
641  if (ret < 0)
642  return ret;
644 
645  switch (ea->audio_codec) {
651  if (pkt->size < 4) {
652  av_log(s, AV_LOG_ERROR, "Packet is too short\n");
653  return AVERROR_INVALIDDATA;
654  }
656  pkt->duration = AV_RB32(pkt->data);
657  else
658  pkt->duration = AV_RL32(pkt->data);
659  break;
661  pkt->duration = ret * 2 / ea->num_channels;
662  break;
664  case AV_CODEC_ID_MP3:
665  pkt->duration = num_samples;
666  break;
668  pkt->duration = chunk_size / (16 * ea->num_channels) * 28;
669  break;
670  default:
671  pkt->duration = chunk_size / (ea->bytes * ea->num_channels);
672  }
673 
674  packet_read = 1;
675  break;
676 
677  /* ending tag */
678  case 0:
679  case ISNe_TAG:
680  case SCEl_TAG:
681  case SEND_TAG:
682  case SEEN_TAG:
683  while (!avio_feof(pb)) {
684  int tag = avio_rl32(pb);
685 
686  if (tag == ISNh_TAG ||
687  tag == SCHl_TAG ||
688  tag == SEAD_TAG ||
689  tag == SHEN_TAG) {
690  avio_skip(pb, -4);
691  break;
692  }
693  }
694  if (avio_feof(pb))
695  ret = AVERROR_EOF;
696  hit_end = 1;
697  break;
698 
699  case MVIh_TAG:
700  case kVGT_TAG:
701  case pQGT_TAG:
702  case TGQs_TAG:
703  case MADk_TAG:
705  case MVIf_TAG:
706  case fVGT_TAG:
707  case MADm_TAG:
708  case MADe_TAG:
709  if (chunk_size > INT_MAX - 8)
710  return AVERROR_INVALIDDATA;
711  avio_seek(pb, -8, SEEK_CUR); // include chunk preamble
712  chunk_size += 8;
713  goto get_video_packet;
714 
715  case mTCD_TAG:
716  if (chunk_size < 8)
717  return AVERROR_INVALIDDATA;
718 
719  avio_skip(pb, 8); // skip ea DCT header
720  chunk_size -= 8;
721  goto get_video_packet;
722 
723  case MV0K_TAG:
724  case AV0K_TAG:
725  case MPCh_TAG:
726  case pIQT_TAG:
728  case MV0F_TAG:
729  case AV0F_TAG:
730 get_video_packet:
731  if (!chunk_size)
732  continue;
733  if (chunk_size > INT_MAX - 3)
734  return AVERROR_INVALIDDATA;
735 
736  vp6a = (ea->video.codec == AV_CODEC_ID_VP6A && (chunk_type == MV0F_TAG || chunk_type == MV0K_TAG));
737 
738  if (partial_packet) {
739  ret = av_append_packet(pb, pkt, chunk_size);
740  } else {
741  if (vp6a)
742  avio_seek(pb, -3, SEEK_CUR);
743  ret = av_get_packet(pb, pkt, chunk_size + (vp6a ? 3 : 0));
744  if (ret >= 0 && vp6a)
745  AV_WB24(pkt->data, chunk_size);
746  }
747  packet_read = 1;
748 
749  if (ret < 0) {
750  partial_packet = 0;
751  break;
752  }
753  partial_packet = vp6a || chunk_type == MVIh_TAG;
754  if (ea->alpha.codec && (chunk_type == AV0K_TAG || chunk_type == AV0F_TAG))
756  else
758  pkt->flags |= key;
759  break;
760 
761  default:
762  avio_skip(pb, chunk_size);
763  break;
764  }
765  }
766 
767  if (ret >= 0 && hit_end && !packet_read)
768  return AVERROR(EAGAIN);
769 
770  return ret;
771 }
772 
773 #define OFFSET(x) offsetof(EaDemuxContext, x)
774 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
775 static const AVOption options[] = {
776  {"merge_alpha", "return VP6 alpha in the main video stream", OFFSET(merge_alpha), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
777  {NULL}
778 };
779 
780 static const AVClass ea_class = {
781  .class_name = "ea demuxer",
782  .item_name = av_default_item_name,
783  .option = options,
784  .version = LIBAVUTIL_VERSION_INT,
785 };
786 
788  .p.name = "ea",
789  .p.long_name = NULL_IF_CONFIG_SMALL("Electronic Arts Multimedia"),
790  .p.priv_class = &ea_class,
791  .priv_data_size = sizeof(EaDemuxContext),
792  .read_probe = ea_probe,
795 };
AV_CODEC_ID_PCM_S16LE
@ AV_CODEC_ID_PCM_S16LE
Definition: codec_id.h:328
SCEl_TAG
#define SCEl_TAG
Definition: electronicarts.c:50
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:427
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
ea_read_header
static int ea_read_header(AVFormatContext *s)
Definition: electronicarts.c:527
SCHl_TAG
#define SCHl_TAG
Definition: electronicarts.c:36
process_video_header_vp6
static int process_video_header_vp6(AVFormatContext *s, VideoProperties *video)
Definition: electronicarts.c:332
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
opt.h
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:51
AV_CODEC_ID_TQI
@ AV_CODEC_ID_TQI
Definition: codec_id.h:174
ea_class
static const AVClass ea_class
Definition: electronicarts.c:780
SEEN_TAG
#define SEEN_TAG
Definition: electronicarts.c:42
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
init_video_stream
static int init_video_stream(AVFormatContext *s, VideoProperties *video)
Definition: electronicarts.c:499
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
int64_t
long long int64_t
Definition: coverity.c:34
VideoProperties::stream_index
int stream_index
Definition: electronicarts.c:76
AVP6_TAG
#define AVP6_TAG
Definition: electronicarts.c:69
MPCh_TAG
#define MPCh_TAG
Definition: electronicarts.c:57
MVIh_TAG
#define MVIh_TAG
Definition: electronicarts.c:67
AVPacket::data
uint8_t * data
Definition: packet.h:522
SEND_TAG
#define SEND_TAG
Definition: electronicarts.c:39
AV_CODEC_ID_VP6
@ AV_CODEC_ID_VP6
Definition: codec_id.h:143
pQGT_TAG
#define pQGT_TAG
Definition: electronicarts.c:59
AVOption
AVOption.
Definition: opt.h:346
AVStream::avg_frame_rate
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:832
AV_CODEC_ID_ADPCM_EA_R3
@ AV_CODEC_ID_ADPCM_EA_R3
Definition: codec_id.h:388
ISNe_TAG
#define ISNe_TAG
Definition: electronicarts.c:46
process_audio_header_sead
static void process_audio_header_sead(AVFormatContext *s)
Definition: electronicarts.c:311
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
EaDemuxContext::num_channels
int num_channels
Definition: electronicarts.c:91
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
AV_CODEC_ID_PCM_S16LE_PLANAR
@ AV_CODEC_ID_PCM_S16LE_PLANAR
Definition: codec_id.h:346
AV_CODEC_ID_TGQ
@ AV_CODEC_ID_TGQ
Definition: codec_id.h:173
AV_CODEC_ID_MAD
@ AV_CODEC_ID_MAD
Definition: codec_id.h:181
AVPROBE_SCORE_MAX
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:463
EaDemuxContext::alpha
VideoProperties alpha
Definition: electronicarts.c:84
EaDemuxContext::bytes
int bytes
Definition: electronicarts.c:89
read_arbitrary
static uint32_t read_arbitrary(AVIOContext *pb)
Definition: electronicarts.c:98
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
kVGT_TAG
#define kVGT_TAG
Definition: electronicarts.c:51
ffstream
static av_always_inline FFStream * ffstream(AVStream *st)
Definition: internal.h:417
MADm_TAG
#define MADm_TAG
Definition: electronicarts.c:55
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:494
AV_CODEC_ID_MP3
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:441
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:802
ISNh_TAG
#define ISNh_TAG
Definition: electronicarts.c:43
MADe_TAG
#define MADe_TAG
Definition: electronicarts.c:56
avio_rl16
unsigned int avio_rl16(AVIOContext *s)
Definition: aviobuf.c:713
EaDemuxContext::audio_codec
enum AVCodecID audio_codec
Definition: electronicarts.c:86
AV_CODEC_ID_PCM_S8
@ AV_CODEC_ID_PCM_S8
Definition: codec_id.h:332
VideoProperties::height
int height
Definition: electronicarts.c:74
avio_rb32
unsigned int avio_rb32(AVIOContext *s)
Definition: aviobuf.c:760
AV_CODEC_ID_MDEC
@ AV_CODEC_ID_MDEC
Definition: codec_id.h:89
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
OFFSET
#define OFFSET(x)
Definition: electronicarts.c:773
MV0K_TAG
#define MV0K_TAG
Definition: electronicarts.c:62
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_read_callback.c:41
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_CODEC_ID_ADPCM_IMA_EA_SEAD
@ AV_CODEC_ID_ADPCM_IMA_EA_SEAD
Definition: codec_id.h:390
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
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:134
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
EaDemuxContext::sample_rate
int sample_rate
Definition: electronicarts.c:90
AV_CODEC_ID_PCM_MULAW
@ AV_CODEC_ID_PCM_MULAW
Definition: codec_id.h:334
ISNd_TAG
#define ISNd_TAG
Definition: electronicarts.c:45
key
const char * key
Definition: hwcontext_opencl.c:189
process_audio_header_elements
static int process_audio_header_elements(AVFormatContext *s)
Definition: electronicarts.c:116
process_video_header_cmv
static void process_video_header_cmv(AVFormatContext *s, VideoProperties *video)
Definition: electronicarts.c:350
FFStream::need_parsing
enum AVStreamParseType need_parsing
Definition: internal.h:386
AVFormatContext
Format I/O context.
Definition: avformat.h:1255
SCDl_TAG
#define SCDl_TAG
Definition: electronicarts.c:49
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:766
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:550
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
AV0F_TAG
#define AV0F_TAG
Definition: electronicarts.c:66
NULL
#define NULL
Definition: coverity.c:32
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AV_CODEC_ID_ADPCM_IMA_EA_EACS
@ AV_CODEC_ID_ADPCM_IMA_EA_EACS
Definition: codec_id.h:391
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:451
TGQs_TAG
#define TGQs_TAG
Definition: electronicarts.c:58
EaDemuxContext
Definition: electronicarts.c:79
GSTR_TAG
#define GSTR_TAG
Definition: electronicarts.c:48
mTCD_TAG
#define mTCD_TAG
Definition: electronicarts.c:53
AVCodecParameters::ch_layout
AVChannelLayout ch_layout
Audio only.
Definition: codec_par.h:180
AV_CODEC_ID_VP6A
@ AV_CODEC_ID_VP6A
Definition: codec_id.h:158
EaDemuxContext::num_samples
int num_samples
Definition: electronicarts.c:92
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:184
AVStream::nb_frames
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:804
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:49
MADk_TAG
#define MADk_TAG
Definition: electronicarts.c:54
avio_rl32
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:729
AVIOContext
Bytestream IO Context.
Definition: avio.h:160
AVPacket::size
int size
Definition: packet.h:523
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
byte
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_WB16 unsigned int_TMPL byte
Definition: bytestream.h:99
av_bswap32
#define av_bswap32
Definition: bswap.h:28
size
int size
Definition: twinvq_data.h:10344
AV_RB32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
Definition: bytestream.h:96
AV_WB24
#define AV_WB24(p, d)
Definition: intreadwrite.h:448
FFInputFormat::p
AVInputFormat p
The public AVInputFormat.
Definition: demux.h:41
MVIf_TAG
#define MVIf_TAG
Definition: electronicarts.c:68
avio_r8
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:602
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:528
EaDemuxContext::video
VideoProperties video
Definition: electronicarts.c:84
ea_read_packet
static int ea_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: electronicarts.c:583
SEAD_TAG
#define SEAD_TAG
Definition: electronicarts.c:37
AV_CODEC_ID_TGV
@ AV_CODEC_ID_TGV
Definition: codec_id.h:172
EaDemuxContext::audio_stream_index
int audio_stream_index
Definition: electronicarts.c:87
pIQT_TAG
#define pIQT_TAG
Definition: electronicarts.c:60
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVCodecParameters::height
int height
Definition: codec_par.h:135
AVCodecParameters::block_align
int block_align
Audio only.
Definition: codec_par.h:191
AV_CODEC_ID_CMV
@ AV_CODEC_ID_CMV
Definition: codec_id.h:170
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
demux.h
EaDemuxContext::platform
int platform
Definition: electronicarts.c:94
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
AV_CODEC_ID_ADPCM_EA
@ AV_CODEC_ID_ADPCM_EA
Definition: codec_id.h:377
VideoProperties::nb_frames
int nb_frames
Definition: electronicarts.c:75
av_uninit
#define av_uninit(x)
Definition: attributes.h:154
options
static const AVOption options[]
Definition: electronicarts.c:775
tag
uint32_t tag
Definition: movenc.c:1791
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:743
ea_probe
static int ea_probe(const AVProbeData *p)
Definition: electronicarts.c:470
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:230
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
av_append_packet
int av_append_packet(AVIOContext *s, AVPacket *pkt, int size)
Read data and append it to the current content of the AVPacket.
Definition: utils.c:119
AVSTREAM_PARSE_HEADERS
@ AVSTREAM_PARSE_HEADERS
Only parse headers, do not repack.
Definition: avformat.h:594
FLAGS
#define FLAGS
Definition: electronicarts.c:774
avformat.h
fVGT_TAG
#define fVGT_TAG
Definition: electronicarts.c:52
VideoProperties::codec
enum AVCodecID codec
Definition: electronicarts.c:72
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
VideoProperties::time_base
AVRational time_base
Definition: electronicarts.c:73
PT00_TAG
#define PT00_TAG
Definition: electronicarts.c:47
EACS_TAG
#define EACS_TAG
Definition: electronicarts.c:44
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:749
EaDemuxContext::big_endian
int big_endian
Definition: electronicarts.c:82
SNDC_TAG
#define SNDC_TAG
Definition: electronicarts.c:38
MVhd_TAG
#define MVhd_TAG
Definition: electronicarts.c:61
video
A Quick Description Of Rate Distortion Theory We want to encode a video
Definition: rate_distortion.txt:3
process_video_header_mdec
static void process_video_header_mdec(AVFormatContext *s, VideoProperties *video)
Definition: electronicarts.c:322
AV_CODEC_ID_ADPCM_EA_R1
@ AV_CODEC_ID_ADPCM_EA_R1
Definition: codec_id.h:387
SDEN_TAG
#define SDEN_TAG
Definition: electronicarts.c:41
AV_CODEC_ID_ADPCM_EA_R2
@ AV_CODEC_ID_ADPCM_EA_R2
Definition: codec_id.h:389
AVStream::r_frame_rate
AVRational r_frame_rate
Real base framerate of the stream.
Definition: avformat.h:909
AVPacket::stream_index
int stream_index
Definition: packet.h:524
AVhd_TAG
#define AVhd_TAG
Definition: electronicarts.c:64
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
process_ea_header
static int process_ea_header(AVFormatContext *s)
Definition: electronicarts.c:363
AVCodecParameters::bits_per_coded_sample
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition: codec_par.h:110
EaDemuxContext::merge_alpha
int merge_alpha
Definition: electronicarts.c:95
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:36
ff_ea_demuxer
const FFInputFormat ff_ea_demuxer
Definition: electronicarts.c:787
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:55
AV0K_TAG
#define AV0K_TAG
Definition: electronicarts.c:65
AVPacket
This structure stores compressed data.
Definition: packet.h:499
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
FFInputFormat
Definition: demux.h:37
VideoProperties::width
int width
Definition: electronicarts.c:74
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
process_audio_header_eacs
static void process_audio_header_eacs(AVFormatContext *s)
Definition: electronicarts.c:274
SHEN_TAG
#define SHEN_TAG
Definition: electronicarts.c:40
AVStream::start_time
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
Definition: avformat.h:792
MV0F_TAG
#define MV0F_TAG
Definition: electronicarts.c:63
AV_CODEC_ID_ADPCM_PSX
@ AV_CODEC_ID_ADPCM_PSX
Definition: codec_id.h:404
AV_CODEC_ID_MPEG2VIDEO
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
Definition: codec_id.h:54
VideoProperties
Definition: electronicarts.c:71
avio_feof
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:345