FFmpeg
Loading...
Searching...
No Matches
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
32#include "libavutil/opt.h"
33#include "avformat.h"
34#include "demux.h"
35#include "internal.h"
36
37#define SCHl_TAG MKTAG('S', 'C', 'H', 'l')
38#define SEAD_TAG MKTAG('S', 'E', 'A', 'D') /* Sxxx header */
39#define SNDC_TAG MKTAG('S', 'N', 'D', 'C') /* Sxxx data */
40#define SEND_TAG MKTAG('S', 'E', 'N', 'D') /* Sxxx end */
41#define SHEN_TAG MKTAG('S', 'H', 'E', 'N') /* SxEN header */
42#define SDEN_TAG MKTAG('S', 'D', 'E', 'N') /* SxEN data */
43#define SEEN_TAG MKTAG('S', 'E', 'E', 'N') /* SxEN end */
44#define ISNh_TAG MKTAG('1', 'S', 'N', 'h') /* 1SNx header */
45#define EACS_TAG MKTAG('E', 'A', 'C', 'S')
46#define ISNd_TAG MKTAG('1', 'S', 'N', 'd') /* 1SNx data */
47#define ISNe_TAG MKTAG('1', 'S', 'N', 'e') /* 1SNx end */
48#define PT00_TAG MKTAG('P', 'T', 0x0, 0x0)
49#define GSTR_TAG MKTAG('G', 'S', 'T', 'R')
50#define SCDl_TAG MKTAG('S', 'C', 'D', 'l')
51#define SCEl_TAG MKTAG('S', 'C', 'E', 'l')
52#define kVGT_TAG MKTAG('k', 'V', 'G', 'T') /* TGV I-frame */
53#define fVGT_TAG MKTAG('f', 'V', 'G', 'T') /* TGV P-frame */
54#define mTCD_TAG MKTAG('m', 'T', 'C', 'D') /* MDEC */
55#define MADk_TAG MKTAG('M', 'A', 'D', 'k') /* MAD I-frame */
56#define MADm_TAG MKTAG('M', 'A', 'D', 'm') /* MAD P-frame */
57#define MADe_TAG MKTAG('M', 'A', 'D', 'e') /* MAD lqp-frame */
58#define MPCh_TAG MKTAG('M', 'P', 'C', 'h') /* MPEG-2 */
59#define TGQs_TAG MKTAG('T', 'G', 'Q', 's') /* TGQ I-frame (appears in .TGQ files) */
60#define pQGT_TAG MKTAG('p', 'Q', 'G', 'T') /* TGQ I-frame (appears in .UV files) */
61#define pIQT_TAG MKTAG('p', 'I', 'Q', 'T') /* TQI/UV2 I-frame (.UV2/.WVE) */
62#define MVhd_TAG MKTAG('M', 'V', 'h', 'd')
63#define MV0K_TAG MKTAG('M', 'V', '0', 'K')
64#define MV0F_TAG MKTAG('M', 'V', '0', 'F')
65#define AVhd_TAG MKTAG('A', 'V', 'h', 'd')
66#define AV0K_TAG MKTAG('A', 'V', '0', 'K')
67#define AV0F_TAG MKTAG('A', 'V', '0', 'F')
68#define MVIh_TAG MKTAG('M', 'V', 'I', 'h') /* CMV header */
69#define MVIf_TAG MKTAG('M', 'V', 'I', 'f') /* CMV I-frame */
70#define AVP6_TAG MKTAG('A', 'V', 'P', '6')
71
79
98
99static uint32_t read_arbitrary(AVIOContext *pb)
100{
101 uint8_t size, byte;
102 int i;
103 uint32_t word;
104
105 size = avio_r8(pb);
106
107 word = 0;
108 for (i = 0; i < size; i++) {
109 byte = avio_r8(pb);
110 word <<= 8;
111 word |= byte;
112 }
113
114 return word;
115}
116
118{
119 EaDemuxContext *ea = s->priv_data;
120 AVIOContext *pb = s->pb;
121 int in_header = 1;
122 int compression_type = -1, revision = -1, revision2 = -1;
123
124 ea->bytes = 2;
125 ea->sample_rate = -1;
126 ea->num_channels = 1;
127
128 while (!avio_feof(pb) && in_header) {
129 int in_subheader;
130 uint8_t byte;
131 byte = avio_r8(pb);
132
133 switch (byte) {
134 case 0xFD:
135 av_log(s, AV_LOG_DEBUG, "entered audio subheader\n");
136 in_subheader = 1;
137 while (!avio_feof(pb) && in_subheader) {
138 uint8_t subbyte;
139 subbyte = avio_r8(pb);
140
141 switch (subbyte) {
142 case 0x80:
143 revision = read_arbitrary(pb);
145 "revision (element 0x80) set to 0x%08x\n", revision);
146 break;
147 case 0x82:
150 "num_channels (element 0x82) set to 0x%08x\n",
151 ea->num_channels);
152 break;
153 case 0x83:
154 compression_type = read_arbitrary(pb);
156 "compression_type (element 0x83) set to 0x%08x\n",
157 compression_type);
158 break;
159 case 0x84:
160 ea->sample_rate = read_arbitrary(pb);
162 "sample_rate (element 0x84) set to %i\n",
163 ea->sample_rate);
164 break;
165 case 0x85:
166 ea->num_samples = read_arbitrary(pb);
168 "num_samples (element 0x85) set to 0x%08x\n",
169 ea->num_samples);
170 break;
171 case 0x8A:
173 "element 0x%02x set to 0x%08"PRIx32"\n",
174 subbyte, read_arbitrary(pb));
175 av_log(s, AV_LOG_DEBUG, "exited audio subheader\n");
176 in_subheader = 0;
177 break;
178 case 0xA0:
179 revision2 = read_arbitrary(pb);
181 "revision2 (element 0xA0) set to 0x%08x\n",
182 revision2);
183 break;
184 case 0xFF:
186 "end of header block reached (within audio subheader)\n");
187 in_subheader = 0;
188 in_header = 0;
189 break;
190 default:
192 "element 0x%02x set to 0x%08"PRIx32"\n",
193 subbyte, read_arbitrary(pb));
194 break;
195 }
196 }
197 break;
198 case 0xFF:
199 av_log(s, AV_LOG_DEBUG, "end of header block reached\n");
200 in_header = 0;
201 break;
202 case 0x1B:
203 ea->video.time_base = (AVRational) {1, read_arbitrary(pb)};
204 av_log(s, AV_LOG_DEBUG, "Setting framerate to %u\n", ea->video.time_base.den);
205 break;
206 default:
208 "header element 0x%02x set to 0x%08"PRIx32"\n",
209 byte, read_arbitrary(pb));
210 break;
211 }
212 }
213
214 switch (compression_type) {
215 case 0:
217 break;
218 case 7:
220 break;
221 case -1:
222 switch (revision) {
223 case 1:
225 break;
226 case 2:
228 break;
229 case 3:
231 break;
232 case -1:
233 break;
234 default:
235 avpriv_request_sample(s, "stream type; revision=%i", revision);
236 return 0;
237 }
238 switch (revision2) {
239 case 8:
241 break;
242 case 10:
243 switch (revision) {
244 case -1:
245 case 2: ea->audio_codec = AV_CODEC_ID_ADPCM_EA_R1; break;
246 case 3: ea->audio_codec = AV_CODEC_ID_ADPCM_EA_R2; break;
247 default:
248 avpriv_request_sample(s, "stream type; revision=%i, revision2=%i", revision, revision2);
249 return 0;
250 }
251 break;
252 case 15:
253 case 16:
255 break;
256 case -1:
257 break;
258 default:
260 avpriv_request_sample(s, "stream type; revision2=%i", revision2);
261 return 0;
262 }
263 break;
264 default:
266 "stream type; compression_type=%i",
267 compression_type);
268 return 0;
269 }
270
271 if (ea->audio_codec == AV_CODEC_ID_NONE && ea->platform == 0x01)
273 if (ea->sample_rate == -1)
274 ea->sample_rate = revision == 3 ? 48000 : 22050;
275
276 return 1;
277}
278
280{
281 EaDemuxContext *ea = s->priv_data;
282 AVIOContext *pb = s->pb;
283 int compression_type;
284
285 ea->sample_rate = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb);
286 ea->bytes = avio_r8(pb); /* 1=8-bit, 2=16-bit */
287 ea->num_channels = avio_r8(pb);
288 compression_type = avio_r8(pb);
289 avio_skip(pb, 13);
290
291 switch (compression_type) {
292 case 0:
293 switch (ea->bytes) {
294 case 1:
296 break;
297 case 2:
299 break;
300 }
301 break;
302 case 1:
304 ea->bytes = 1;
305 break;
306 case 2:
308 break;
309 default:
311 "stream type; audio compression_type=%i",
312 compression_type);
313 }
314}
315
317{
318 EaDemuxContext *ea = s->priv_data;
319 AVIOContext *pb = s->pb;
320
321 ea->sample_rate = avio_rl32(pb);
322 ea->bytes = avio_rl32(pb); /* 1=8-bit, 2=16-bit */
323 ea->num_channels = avio_rl32(pb);
325}
326
328{
329 AVIOContext *pb = s->pb;
330 avio_skip(pb, 4);
331 video->width = avio_rl16(pb);
332 video->height = avio_rl16(pb);
333 if (!video->time_base.num)
334 video->time_base = (AVRational) { 1, 15 };
335 video->codec = AV_CODEC_ID_MDEC;
336}
337
339{
340 AVIOContext *pb = s->pb;
341
342 avio_skip(pb, 8);
343 video->nb_frames = avio_rl32(pb);
344 avio_skip(pb, 4);
345 video->time_base.den = avio_rl32(pb);
346 video->time_base.num = avio_rl32(pb);
347 if (video->time_base.den <= 0 || video->time_base.num <= 0) {
348 av_log(s, AV_LOG_ERROR, "Timebase is invalid\n");
349 return AVERROR_INVALIDDATA;
350 }
351 video->codec = AV_CODEC_ID_VP6;
352
353 return 1;
354}
355
357{
358 int fps;
359
360 avio_skip(s->pb, 10);
361 fps = avio_rl16(s->pb);
362 if (fps)
363 video->time_base = (AVRational) { 1, fps };
364 video->codec = AV_CODEC_ID_CMV;
365}
366
367/* Process EA file header.
368 * Return 1 if the EA file is valid and successfully opened, 0 otherwise. */
370{
371 uint32_t blockid, size = 0;
372 EaDemuxContext *ea = s->priv_data;
373 AVIOContext *pb = s->pb;
374 int i;
375
376 for (i = 0; i < 5 && (!ea->audio_codec || !ea->video.codec); i++) {
377 uint64_t startpos = avio_tell(pb);
378 int err = 0;
379
380 blockid = avio_rl32(pb);
381 size = avio_rl32(pb);
382 if (i == 0)
384 if (ea->big_endian)
386
387 if (size < 8) {
388 av_log(s, AV_LOG_ERROR, "chunk size too small\n");
389 return AVERROR_INVALIDDATA;
390 }
391
392 switch (blockid) {
393 case ISNh_TAG:
394 if (avio_rl32(pb) != EACS_TAG) {
395 avpriv_request_sample(s, "unknown 1SNh headerid");
396 return 0;
397 }
399 break;
400
401 case SCHl_TAG:
402 case SHEN_TAG:
403 blockid = avio_rl32(pb);
404 if (blockid == GSTR_TAG) {
405 avio_skip(pb, 4);
406 } else if ((blockid & 0xFF) != (PT00_TAG & 0xFF)) {
407 blockid = avio_rl32(pb);
408 }
409 ea->platform = (blockid >> 16) & 0xFF;
411 break;
412
413 case SEAD_TAG:
415 break;
416
417 case MVIh_TAG:
419 break;
420
421 case kVGT_TAG:
423 break;
424
425 case mTCD_TAG:
427 break;
428
429 case MPCh_TAG:
431 break;
432
433 case pQGT_TAG:
434 case TGQs_TAG:
436 if (!ea->video.time_base.num)
437 ea->video.time_base = (AVRational) { 1, 15 };
438 break;
439
440 case pIQT_TAG:
442 if (!ea->video.time_base.num)
443 ea->video.time_base = (AVRational) { 1, 15 };
444 break;
445
446 case MADk_TAG:
448 avio_skip(pb, 6);
449 ea->video.time_base = (AVRational) { avio_rl16(pb), 1000 };
450 break;
451
452 case MVhd_TAG:
453 err = process_video_header_vp6(s, &ea->video);
454 break;
455
456 case AVhd_TAG:
457 err = process_video_header_vp6(s, &ea->alpha);
458 if (err >= 0 && ea->video.codec == AV_CODEC_ID_VP6 && ea->merge_alpha) {
459 ea->alpha.codec = 0;
461 }
462 break;
463 }
464
465 if (err < 0) {
466 av_log(s, AV_LOG_ERROR, "error parsing header: %i\n", err);
467 return err;
468 }
469
470 avio_seek(pb, startpos + size, SEEK_SET);
471 }
472
473 avio_seek(pb, 0, SEEK_SET);
474
475 return 1;
476}
477
478static int ea_probe(const AVProbeData *p)
479{
480 unsigned big_endian, size;
481
482 switch (AV_RL32(&p->buf[0])) {
483 case ISNh_TAG:
484 case SCHl_TAG:
485 case SEAD_TAG:
486 case SHEN_TAG:
487 case kVGT_TAG:
488 case MADk_TAG:
489 case MPCh_TAG:
490 case MVhd_TAG:
491 case MVIh_TAG:
492 case AVP6_TAG:
493 break;
494 default:
495 return 0;
496 }
497 size = AV_RL32(&p->buf[4]);
498 big_endian = size > 0x000FFFFF;
499 if (big_endian)
501 if (size > 0xfffff || size < 8)
502 return 0;
503
504 return AVPROBE_SCORE_MAX;
505}
506
508{
509 AVStream *st;
510
511 if (!video->codec)
512 return 0;
513
514 /* initialize the video decoder stream */
516 if (!st)
517 return AVERROR(ENOMEM);
518 video->stream_index = st->index;
520 st->codecpar->codec_id = video->codec;
521 // parsing is necessary to make FFmpeg generate correct timestamps
524 st->codecpar->codec_tag = 0; /* no fourcc */
525 st->codecpar->width = video->width;
526 st->codecpar->height = video->height;
527 st->duration = st->nb_frames = video->nb_frames;
528 if (video->time_base.num)
529 avpriv_set_pts_info(st, 64, video->time_base.num, video->time_base.den);
530 st->r_frame_rate =
531 st->avg_frame_rate = av_inv_q(video->time_base);
532 return 0;
533}
534
536{
537 EaDemuxContext *ea = s->priv_data;
538 AVStream *st;
539
540 if (process_ea_header(s)<=0)
541 return AVERROR_INVALIDDATA;
542
543 if (init_video_stream(s, &ea->video) || init_video_stream(s, &ea->alpha))
544 return AVERROR(ENOMEM);
545
546 if (ea->audio_codec) {
547 if (ea->num_channels <= 0 || ea->num_channels > 2) {
549 "Unsupported number of channels: %d\n", ea->num_channels);
550 goto no_audio;
551 }
552 if (ea->sample_rate <= 0) {
554 "Unsupported sample rate: %d\n", ea->sample_rate);
555 goto no_audio;
556 }
557 if (ea->bytes <= 0 || ea->bytes > 2) {
559 "Invalid number of bytes per sample: %d\n", ea->bytes);
560 goto no_audio;
561 }
562
563 /* initialize the audio decoder stream */
565 if (!st)
566 return AVERROR(ENOMEM);
567 avpriv_set_pts_info(st, 33, 1, ea->sample_rate);
569 st->codecpar->codec_id = ea->audio_codec;
570 st->codecpar->codec_tag = 0; /* no tag */
573 st->codecpar->bits_per_coded_sample = ea->bytes * 8;
575 st->codecpar->sample_rate *
579 ea->audio_stream_index = st->index;
580 st->start_time = 0;
581 return 0;
582 }
583no_audio:
585
586 if (!ea->video.codec)
587 return AVERROR_INVALIDDATA;
588 return 0;
589}
590
592{
593 EaDemuxContext *ea = s->priv_data;
594 AVIOContext *pb = s->pb;
595 int partial_packet = 0;
596 int hit_end = 0;
597 unsigned int chunk_type, chunk_size;
598 int ret = 0, packet_read = 0, key = 0, vp6a;
599 int av_uninit(num_samples);
600
601 while ((!packet_read && !hit_end) || partial_packet) {
602 chunk_type = avio_rl32(pb);
603 if (avio_feof(pb))
604 return AVERROR_EOF;
605 chunk_size = ea->big_endian ? avio_rb32(pb) : avio_rl32(pb);
606 if (chunk_size < 8)
607 return AVERROR_INVALIDDATA;
608 chunk_size -= 8;
609
610 switch (chunk_type) {
611 /* audio data */
612 case ISNh_TAG:
613 /* header chunk also contains data; skip over the header portion */
614 if (chunk_size < 32)
615 return AVERROR_INVALIDDATA;
616 avio_skip(pb, 32);
617 chunk_size -= 32;
619 case ISNd_TAG:
620 case SCDl_TAG:
621 case SNDC_TAG:
622 case SDEN_TAG:
623 if (!ea->audio_codec) {
624 avio_skip(pb, chunk_size);
625 break;
626 } else if (ea->audio_codec == AV_CODEC_ID_PCM_S16LE_PLANAR ||
628 if (chunk_size < 12)
629 return AVERROR_INVALIDDATA;
630 num_samples = avio_rl32(pb);
631 avio_skip(pb, 8);
632 chunk_size -= 12;
633 } else if (ea->audio_codec == AV_CODEC_ID_ADPCM_PSX) {
634 if (chunk_size < 8)
635 return AVERROR_INVALIDDATA;
636 avio_skip(pb, 8);
637 chunk_size -= 8;
638 }
639
640 if (partial_packet) {
641 avpriv_request_sample(s, "video header followed by audio packet");
643 partial_packet = 0;
644 }
645
646 if (!chunk_size)
647 continue;
648
649 ret = av_get_packet(pb, pkt, chunk_size);
650 if (ret < 0)
651 return ret;
652 pkt->stream_index = ea->audio_stream_index;
653
654 switch (ea->audio_codec) {
660 if (pkt->size < 4) {
661 av_log(s, AV_LOG_ERROR, "Packet is too short\n");
662 return AVERROR_INVALIDDATA;
663 }
665 pkt->duration = AV_RB32(pkt->data);
666 else
667 pkt->duration = AV_RL32(pkt->data);
668 break;
670 pkt->duration = ret * 2 / ea->num_channels;
671 break;
673 case AV_CODEC_ID_MP3:
674 pkt->duration = num_samples;
675 break;
677 pkt->duration = chunk_size / (16 * ea->num_channels) * 28;
678 break;
679 default:
680 pkt->duration = chunk_size / (ea->bytes * ea->num_channels);
681 }
682
683 packet_read = 1;
684 break;
685
686 /* ending tag */
687 case 0:
688 case ISNe_TAG:
689 case SCEl_TAG:
690 case SEND_TAG:
691 case SEEN_TAG:
692 while (!avio_feof(pb)) {
693 int tag = avio_rl32(pb);
694
695 if (tag == ISNh_TAG ||
696 tag == SCHl_TAG ||
697 tag == SEAD_TAG ||
698 tag == SHEN_TAG) {
699 avio_skip(pb, -4);
700 break;
701 }
702 }
703 if (avio_feof(pb))
704 ret = AVERROR_EOF;
705 hit_end = 1;
706 break;
707
708 case MVIh_TAG:
709 case kVGT_TAG:
710 case pQGT_TAG:
711 case TGQs_TAG:
712 case MADk_TAG:
715 case MVIf_TAG:
716 case fVGT_TAG:
717 case MADm_TAG:
718 case MADe_TAG:
719 if (chunk_size > INT_MAX - 8)
720 return AVERROR_INVALIDDATA;
721 avio_seek(pb, -8, SEEK_CUR); // include chunk preamble
722 chunk_size += 8;
723 goto get_video_packet;
724
725 case mTCD_TAG:
726 if (chunk_size < 8)
727 return AVERROR_INVALIDDATA;
728
729 avio_skip(pb, 8); // skip ea DCT header
730 chunk_size -= 8;
731 goto get_video_packet;
732
733 case MV0K_TAG:
734 case AV0K_TAG:
735 case MPCh_TAG:
736 case pIQT_TAG:
739 case MV0F_TAG:
740 case AV0F_TAG:
741get_video_packet:
742 if (!chunk_size)
743 continue;
744 if (chunk_size > INT_MAX - 3)
745 return AVERROR_INVALIDDATA;
746
747 vp6a = (ea->video.codec == AV_CODEC_ID_VP6A && (chunk_type == MV0F_TAG || chunk_type == MV0K_TAG));
748
749 if (partial_packet) {
750 ret = av_append_packet(pb, pkt, chunk_size);
751 } else {
752 if (vp6a)
753 avio_seek(pb, -3, SEEK_CUR);
754 ret = av_get_packet(pb, pkt, chunk_size + (vp6a ? 3 : 0));
755 if (ret >= 0 && vp6a)
756 AV_WB24(pkt->data, chunk_size);
757 }
758 packet_read = 1;
759
760 if (ret < 0) {
761 partial_packet = 0;
762 break;
763 }
764 partial_packet = vp6a || chunk_type == MVIh_TAG;
765 if (ea->alpha.codec && (chunk_type == AV0K_TAG || chunk_type == AV0F_TAG))
766 pkt->stream_index = ea->alpha.stream_index;
767 else
768 pkt->stream_index = ea->video.stream_index;
769 pkt->flags |= key;
770 break;
771
772 default:
773 avio_skip(pb, chunk_size);
774 break;
775 }
776 }
777
778 if (ret >= 0 && hit_end && !packet_read)
779 return AVERROR(EAGAIN);
780
781 return ret;
782}
783
784#define OFFSET(x) offsetof(EaDemuxContext, x)
785#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
786static const AVOption options[] = {
787 {"merge_alpha", "return VP6 alpha in the main video stream", OFFSET(merge_alpha), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
788 {NULL}
789};
790
791static const AVClass ea_class = {
792 .class_name = "ea demuxer",
793 .item_name = av_default_item_name,
794 .option = options,
795 .version = LIBAVUTIL_VERSION_INT,
796};
797
799 .p.name = "ea",
800 .p.long_name = NULL_IF_CONFIG_SMALL("Electronic Arts Multimedia"),
801 .p.priv_class = &ea_class,
802 .priv_data_size = sizeof(EaDemuxContext),
806};
const FFInputFormat ff_ea_demuxer
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:834
Main libavformat public API header.
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:114
#define AVPROBE_SCORE_MAX
maximum score
Definition avformat.h:483
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:98
@ AVSTREAM_PARSE_HEADERS
Only parse headers, do not repack.
Definition avformat.h:612
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition aviobuf.c:236
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition aviobuf.c:349
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition avio.h:494
unsigned int avio_rl16(AVIOContext *s)
Definition aviobuf.c:717
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition aviobuf.c:321
unsigned int avio_rl32(AVIOContext *s)
Definition aviobuf.c:733
unsigned int avio_rb32(AVIOContext *s)
Definition aviobuf.c:764
int avio_r8(AVIOContext *s)
Definition aviobuf.c:606
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
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
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
static int read_probe(const AVProbeData *p)
Definition cdg.c:30
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
static AVPacket * pkt
#define MVIh_TAG
Definition eacmv.c:170
#define MADm_TAG
Definition eamad.c:48
#define MADk_TAG
Definition eamad.c:47
#define MADe_TAG
Definition eamad.c:49
#define kVGT_TAG
Definition eatgv.c:40
static int process_ea_header(AVFormatContext *s)
static void process_audio_header_eacs(AVFormatContext *s)
#define SEND_TAG
#define GSTR_TAG
#define SCEl_TAG
#define MVhd_TAG
#define SEEN_TAG
#define ISNe_TAG
#define MVIf_TAG
static int init_video_stream(AVFormatContext *s, VideoProperties *video)
#define EACS_TAG
static int ea_probe(const AVProbeData *p)
#define MPCh_TAG
#define AVP6_TAG
#define pQGT_TAG
static void process_video_header_cmv(AVFormatContext *s, VideoProperties *video)
static int ea_read_packet(AVFormatContext *s, AVPacket *pkt)
#define AV0K_TAG
#define SNDC_TAG
static void process_video_header_mdec(AVFormatContext *s, VideoProperties *video)
#define SCHl_TAG
#define pIQT_TAG
#define ISNh_TAG
static int process_video_header_vp6(AVFormatContext *s, VideoProperties *video)
#define ISNd_TAG
#define MV0F_TAG
#define mTCD_TAG
#define SHEN_TAG
#define SDEN_TAG
#define SCDl_TAG
static uint32_t read_arbitrary(AVIOContext *pb)
#define MV0K_TAG
#define OFFSET(x)
#define TGQs_TAG
static const AVClass ea_class
#define PT00_TAG
static int ea_read_header(AVFormatContext *s)
static int process_audio_header_elements(AVFormatContext *s)
#define AV0F_TAG
#define SEAD_TAG
#define AVhd_TAG
#define fVGT_TAG
static void process_audio_header_sead(AVFormatContext *s)
const char * key
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:578
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:47
@ AV_CODEC_ID_VP6
Definition codec_id.h:141
@ AV_CODEC_ID_CMV
Definition codec_id.h:168
@ AV_CODEC_ID_ADPCM_EA_R1
Definition codec_id.h:390
@ AV_CODEC_ID_ADPCM_IMA_EA_EACS
Definition codec_id.h:394
@ AV_CODEC_ID_TGV
Definition codec_id.h:170
@ AV_CODEC_ID_PCM_S16LE
Definition codec_id.h:330
@ AV_CODEC_ID_ADPCM_IMA_EA_SEAD
Definition codec_id.h:393
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
@ AV_CODEC_ID_MAD
Definition codec_id.h:179
@ AV_CODEC_ID_ADPCM_PSX
Definition codec_id.h:407
@ AV_CODEC_ID_ADPCM_EA_R2
Definition codec_id.h:392
@ AV_CODEC_ID_PCM_S8
Definition codec_id.h:334
@ AV_CODEC_ID_VP6A
Definition codec_id.h:156
@ AV_CODEC_ID_TQI
Definition codec_id.h:172
@ AV_CODEC_ID_MDEC
Definition codec_id.h:87
@ AV_CODEC_ID_TGQ
Definition codec_id.h:171
@ AV_CODEC_ID_ADPCM_EA
Definition codec_id.h:380
@ AV_CODEC_ID_PCM_S16LE_PLANAR
Definition codec_id.h:348
@ AV_CODEC_ID_ADPCM_EA_R3
Definition codec_id.h:391
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition codec_id.h:454
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
Definition codec_id.h:52
@ AV_CODEC_ID_PCM_MULAW
Definition codec_id.h:336
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition packet.c:434
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition packet.h:650
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition rational.h:159
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
#define AV_WB24(p, d)
#define AV_RL32(p)
#define AV_RB32(p)
static av_always_inline FFStream * ffstream(AVStream *st)
Definition internal.h:365
Macro definitions for various function/variable attributes.
#define av_fallthrough
Definition attributes.h:67
#define av_uninit(x)
Definition attributes.h:187
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
uint32_t tag
Definition movenc.c:2087
AVOptions.
#define av_bswap32
Definition bswap.h:47
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
Definition log.h:76
int height
The height of the video frame in pixels.
Definition codec_par.h:150
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition codec_par.h:113
AVChannelLayout ch_layout
The channel layout and number of channels.
Definition codec_par.h:207
int width
The width of the video frame in pixels.
Definition codec_par.h:143
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition codec_par.h:99
enum AVMediaType codec_type
General type of the encoded data.
Definition codec_par.h:53
int block_align
The number of bytes per coded audio frame, required by some formats.
Definition codec_par.h:221
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition codec_par.h:61
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition codec_par.h:57
int sample_rate
The number of audio samples per second.
Definition codec_par.h:213
Format I/O context.
Definition avformat.h:1333
Bytestream IO Context.
Definition avio.h:160
AVOption.
Definition opt.h:428
This structure stores compressed data.
Definition packet.h:580
This structure contains the data a format has to probe a file.
Definition avformat.h:471
Rational number (pair of numerator and denominator).
Definition rational.h:58
int num
Numerator.
Definition rational.h:59
int den
Denominator.
Definition rational.h:60
Stream structure.
Definition avformat.h:766
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition avformat.h:789
int64_t nb_frames
number of frames in this stream if known or 0
Definition avformat.h:827
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition avformat.h:825
int index
stream index in AVFormatContext
Definition avformat.h:772
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
Definition avformat.h:815
AVRational avg_frame_rate
Average framerate.
Definition avformat.h:855
AVRational r_frame_rate
Real base framerate of the stream.
Definition avformat.h:900
VideoProperties alpha
enum AVCodecID audio_codec
VideoProperties video
enum AVStreamParseType need_parsing
Definition internal.h:321
AVRational time_base
enum AVCodecID codec
#define avpriv_request_sample(...)
#define av_log(a,...)
int size