annotate ipmovie.c @ 5466:af08ed2b60b8 libavformat

Parse ID3v[12] metadata from TTA files. As a side-effect, this commit also fixes issue 1310.
author jai_menon
date Wed, 16 Dec 2009 19:18:48 +0000
parents a74bea5a7084
children c47a84f46ae2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
1 /*
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
2 * Interplay MVE File Demuxer
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
3 * Copyright (c) 2003 The ffmpeg Project
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
4 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1169
diff changeset
5 * This file is part of FFmpeg.
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1169
diff changeset
6 *
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1169
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1169
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
11 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1169
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
15 * Lesser General Public License for more details.
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
16 *
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1169
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
896
edbe5c3717f9 Update licensing information: The FSF changed postal address.
diego
parents: 885
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
20 */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
21
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
22 /**
4331
49c1d3b27727 Use full internal pathname in doxygen @file directives.
diego
parents: 4201
diff changeset
23 * @file libavformat/ipmovie.c
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
24 * Interplay MVE file demuxer
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
25 * by Mike Melanson (melanson@pcisys.net)
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
26 * For more information regarding the Interplay MVE file format, visit:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
27 * http://www.pcisys.net/~melanson/codecs/
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
28 * The aforementioned site also contains a command line utility for parsing
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
29 * IP MVE files so that you can get a good idea of the typical structure of
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
30 * such files. This demuxer is not the best example to use if you are trying
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
31 * to write your own as it uses a rather roundabout approach for splitting
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
32 * up and sending out the chunks.
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
33 */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
34
4201
7d2f3f1b68d8 Fix build: Add intreadwrite.h and bswap.h #includes where necessary.
diego
parents: 4128
diff changeset
35 #include "libavutil/intreadwrite.h"
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
36 #include "avformat.h"
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
37
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
38 /* debugging support: #define DEBUG_IPMOVIE as non-zero to see extremely
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
39 * verbose information about the demux process */
483
f4e9e55f703c cvs diff before cvs commit
melanson
parents: 482
diff changeset
40 #define DEBUG_IPMOVIE 0
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
41
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
42 #if DEBUG_IPMOVIE
4601
06b665831f43 Hack: #undef printf so compilation works with DEBUG_IPMOVIE set to 1
reimar
parents: 4331
diff changeset
43 #undef printf
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
44 #define debug_ipmovie printf
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
45 #else
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
46 static inline void debug_ipmovie(const char *format, ...) { }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
47 #endif
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
48
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
49 #define CHUNK_PREAMBLE_SIZE 4
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
50 #define OPCODE_PREAMBLE_SIZE 4
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
51
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
52 #define CHUNK_INIT_AUDIO 0x0000
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
53 #define CHUNK_AUDIO_ONLY 0x0001
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
54 #define CHUNK_INIT_VIDEO 0x0002
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
55 #define CHUNK_VIDEO 0x0003
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
56 #define CHUNK_SHUTDOWN 0x0004
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
57 #define CHUNK_END 0x0005
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
58 /* these last types are used internally */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
59 #define CHUNK_DONE 0xFFFC
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
60 #define CHUNK_NOMEM 0xFFFD
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
61 #define CHUNK_EOF 0xFFFE
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
62 #define CHUNK_BAD 0xFFFF
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
63
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
64 #define OPCODE_END_OF_STREAM 0x00
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
65 #define OPCODE_END_OF_CHUNK 0x01
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
66 #define OPCODE_CREATE_TIMER 0x02
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
67 #define OPCODE_INIT_AUDIO_BUFFERS 0x03
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
68 #define OPCODE_START_STOP_AUDIO 0x04
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
69 #define OPCODE_INIT_VIDEO_BUFFERS 0x05
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
70 #define OPCODE_UNKNOWN_06 0x06
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
71 #define OPCODE_SEND_BUFFER 0x07
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
72 #define OPCODE_AUDIO_FRAME 0x08
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
73 #define OPCODE_SILENCE_FRAME 0x09
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
74 #define OPCODE_INIT_VIDEO_MODE 0x0A
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
75 #define OPCODE_CREATE_GRADIENT 0x0B
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
76 #define OPCODE_SET_PALETTE 0x0C
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
77 #define OPCODE_SET_PALETTE_COMPRESSED 0x0D
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
78 #define OPCODE_UNKNOWN_0E 0x0E
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
79 #define OPCODE_SET_DECODING_MAP 0x0F
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
80 #define OPCODE_UNKNOWN_10 0x10
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
81 #define OPCODE_VIDEO_DATA 0x11
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
82 #define OPCODE_UNKNOWN_12 0x12
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
83 #define OPCODE_UNKNOWN_13 0x13
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
84 #define OPCODE_UNKNOWN_14 0x14
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
85 #define OPCODE_UNKNOWN_15 0x15
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
86
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
87 #define PALETTE_COUNT 256
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
88
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
89 typedef struct IPMVEContext {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
90
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
91 unsigned char *buf;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
92 int buf_size;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
93
4603
04f857454909 Simplify ipmovie.c pts calculation by using an appropriate time_base.
reimar
parents: 4601
diff changeset
94 uint64_t frame_pts_inc;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
95
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
96 unsigned int video_width;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
97 unsigned int video_height;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
98 int64_t video_pts;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
99
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
100 unsigned int audio_bits;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
101 unsigned int audio_channels;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
102 unsigned int audio_sample_rate;
4128
e51ace85da6c Fix a warning when compiling with icc:
cehoyos
parents: 3973
diff changeset
103 enum CodecID audio_type;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
104 unsigned int audio_frame_count;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
105
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
106 int video_stream_index;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
107 int audio_stream_index;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
108
3973
549a09cf23fe Remove offset_t typedef and use int64_t directly instead.
diego
parents: 3908
diff changeset
109 int64_t audio_chunk_offset;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
110 int audio_chunk_size;
3973
549a09cf23fe Remove offset_t typedef and use int64_t directly instead.
diego
parents: 3908
diff changeset
111 int64_t video_chunk_offset;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
112 int video_chunk_size;
3973
549a09cf23fe Remove offset_t typedef and use int64_t directly instead.
diego
parents: 3908
diff changeset
113 int64_t decode_map_chunk_offset;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
114 int decode_map_chunk_size;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
115
3973
549a09cf23fe Remove offset_t typedef and use int64_t directly instead.
diego
parents: 3908
diff changeset
116 int64_t next_chunk_offset;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
117
247
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
118 AVPaletteControl palette_control;
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
119
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
120 } IPMVEContext;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
121
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 820
diff changeset
122 static int load_ipmovie_packet(IPMVEContext *s, ByteIOContext *pb,
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
123 AVPacket *pkt) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
124
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
125 int chunk_type;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
126
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
127 if (s->audio_chunk_offset) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
128
252
4aa51913d0b2 provisions for raw PCM audio
tmmm
parents: 247
diff changeset
129 /* adjust for PCM audio by skipping chunk header */
4aa51913d0b2 provisions for raw PCM audio
tmmm
parents: 247
diff changeset
130 if (s->audio_type != CODEC_ID_INTERPLAY_DPCM) {
4aa51913d0b2 provisions for raw PCM audio
tmmm
parents: 247
diff changeset
131 s->audio_chunk_offset += 6;
4aa51913d0b2 provisions for raw PCM audio
tmmm
parents: 247
diff changeset
132 s->audio_chunk_size -= 6;
4aa51913d0b2 provisions for raw PCM audio
tmmm
parents: 247
diff changeset
133 }
4aa51913d0b2 provisions for raw PCM audio
tmmm
parents: 247
diff changeset
134
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
135 url_fseek(pb, s->audio_chunk_offset, SEEK_SET);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
136 s->audio_chunk_offset = 0;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
137
775
c5077fdab490 AVPacket.pos
michael
parents: 483
diff changeset
138 if (s->audio_chunk_size != av_get_packet(pb, pkt, s->audio_chunk_size))
c5077fdab490 AVPacket.pos
michael
parents: 483
diff changeset
139 return CHUNK_EOF;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
140
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
141 pkt->stream_index = s->audio_stream_index;
4603
04f857454909 Simplify ipmovie.c pts calculation by using an appropriate time_base.
reimar
parents: 4601
diff changeset
142 pkt->pts = s->audio_frame_count;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
143
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
144 /* audio frame maintenance */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
145 if (s->audio_type != CODEC_ID_INTERPLAY_DPCM)
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
146 s->audio_frame_count +=
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
147 (s->audio_chunk_size / s->audio_channels / (s->audio_bits / 8));
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
148 else
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
149 s->audio_frame_count +=
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
150 (s->audio_chunk_size - 6) / s->audio_channels;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
151
1443
404048ea11bc Replace most of the %lld and %llx by their (cleaner) PRI*64 counterparts.
diego
parents: 1358
diff changeset
152 debug_ipmovie("sending audio frame with pts %"PRId64" (%d audio frames)\n",
4603
04f857454909 Simplify ipmovie.c pts calculation by using an appropriate time_base.
reimar
parents: 4601
diff changeset
153 pkt->pts, s->audio_frame_count);
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
154
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
155 chunk_type = CHUNK_VIDEO;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
156
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
157 } else if (s->decode_map_chunk_offset) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
158
247
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
159 /* send both the decode map and the video data together */
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
160
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
161 if (av_new_packet(pkt, s->decode_map_chunk_size + s->video_chunk_size))
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
162 return CHUNK_NOMEM;
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
163
775
c5077fdab490 AVPacket.pos
michael
parents: 483
diff changeset
164 pkt->pos= s->decode_map_chunk_offset;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
165 url_fseek(pb, s->decode_map_chunk_offset, SEEK_SET);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
166 s->decode_map_chunk_offset = 0;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
167
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 820
diff changeset
168 if (get_buffer(pb, pkt->data, s->decode_map_chunk_size) !=
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
169 s->decode_map_chunk_size) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
170 av_free_packet(pkt);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
171 return CHUNK_EOF;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
172 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
173
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
174 url_fseek(pb, s->video_chunk_offset, SEEK_SET);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
175 s->video_chunk_offset = 0;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
176
247
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
177 if (get_buffer(pb, pkt->data + s->decode_map_chunk_size,
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
178 s->video_chunk_size) != s->video_chunk_size) {
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
179 av_free_packet(pkt);
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
180 return CHUNK_EOF;
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
181 }
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
182
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
183 pkt->stream_index = s->video_stream_index;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
184 pkt->pts = s->video_pts;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
185
1443
404048ea11bc Replace most of the %lld and %llx by their (cleaner) PRI*64 counterparts.
diego
parents: 1358
diff changeset
186 debug_ipmovie("sending video frame with pts %"PRId64"\n",
269
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
187 pkt->pts);
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
188
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
189 s->video_pts += s->frame_pts_inc;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
190
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
191 chunk_type = CHUNK_VIDEO;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
192
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
193 } else {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
194
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
195 url_fseek(pb, s->next_chunk_offset, SEEK_SET);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
196 chunk_type = CHUNK_DONE;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
197
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
198 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
199
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
200 return chunk_type;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
201 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
202
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
203 /* This function loads and processes a single chunk in an IP movie file.
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
204 * It returns the type of chunk that was processed. */
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 820
diff changeset
205 static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
206 AVPacket *pkt)
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
207 {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
208 unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
209 int chunk_type;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
210 int chunk_size;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
211 unsigned char opcode_preamble[OPCODE_PREAMBLE_SIZE];
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
212 unsigned char opcode_type;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
213 unsigned char opcode_version;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
214 int opcode_size;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
215 unsigned char scratch[1024];
247
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
216 int i, j;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
217 int first_color, last_color;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
218 int audio_flags;
295
bff1a372ae38 revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents: 269
diff changeset
219 unsigned char r, g, b;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
220
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
221 /* see if there are any pending packets */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
222 chunk_type = load_ipmovie_packet(s, pb, pkt);
1800
3edc6f0468be not checking error return, resulting double free
michael
parents: 1673
diff changeset
223 if (chunk_type != CHUNK_DONE)
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
224 return chunk_type;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
225
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
226 /* read the next chunk, wherever the file happens to be pointing */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
227 if (url_feof(pb))
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
228 return CHUNK_EOF;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
229 if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
230 CHUNK_PREAMBLE_SIZE)
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
231 return CHUNK_BAD;
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1443
diff changeset
232 chunk_size = AV_RL16(&chunk_preamble[0]);
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1443
diff changeset
233 chunk_type = AV_RL16(&chunk_preamble[2]);
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
234
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
235 debug_ipmovie("chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
236
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
237 switch (chunk_type) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
238
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
239 case CHUNK_INIT_AUDIO:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
240 debug_ipmovie("initialize audio\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
241 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
242
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
243 case CHUNK_AUDIO_ONLY:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
244 debug_ipmovie("audio only\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
245 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
246
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
247 case CHUNK_INIT_VIDEO:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
248 debug_ipmovie("initialize video\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
249 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
250
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
251 case CHUNK_VIDEO:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
252 debug_ipmovie("video (and audio)\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
253 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
254
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
255 case CHUNK_SHUTDOWN:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
256 debug_ipmovie("shutdown\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
257 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
258
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
259 case CHUNK_END:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
260 debug_ipmovie("end\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
261 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
262
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
263 default:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
264 debug_ipmovie("invalid chunk\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
265 chunk_type = CHUNK_BAD;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
266 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
267
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
268 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
269
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
270 while ((chunk_size > 0) && (chunk_type != CHUNK_BAD)) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
271
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
272 /* read the next chunk, wherever the file happens to be pointing */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
273 if (url_feof(pb)) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
274 chunk_type = CHUNK_EOF;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
275 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
276 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
277 if (get_buffer(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
278 CHUNK_PREAMBLE_SIZE) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
279 chunk_type = CHUNK_BAD;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
280 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
281 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
282
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1443
diff changeset
283 opcode_size = AV_RL16(&opcode_preamble[0]);
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
284 opcode_type = opcode_preamble[2];
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
285 opcode_version = opcode_preamble[3];
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
286
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
287 chunk_size -= OPCODE_PREAMBLE_SIZE;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
288 chunk_size -= opcode_size;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
289 if (chunk_size < 0) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
290 debug_ipmovie("chunk_size countdown just went negative\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
291 chunk_type = CHUNK_BAD;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
292 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
293 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
294
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
295 debug_ipmovie(" opcode type %02X, version %d, 0x%04X bytes: ",
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
296 opcode_type, opcode_version, opcode_size);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
297 switch (opcode_type) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
298
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
299 case OPCODE_END_OF_STREAM:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
300 debug_ipmovie("end of stream\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
301 url_fseek(pb, opcode_size, SEEK_CUR);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
302 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
303
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
304 case OPCODE_END_OF_CHUNK:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
305 debug_ipmovie("end of chunk\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
306 url_fseek(pb, opcode_size, SEEK_CUR);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
307 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
308
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
309 case OPCODE_CREATE_TIMER:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
310 debug_ipmovie("create timer\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
311 if ((opcode_version > 0) || (opcode_size > 6)) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
312 debug_ipmovie("bad create_timer opcode\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
313 chunk_type = CHUNK_BAD;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
314 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
315 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
316 if (get_buffer(pb, scratch, opcode_size) !=
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
317 opcode_size) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
318 chunk_type = CHUNK_BAD;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
319 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
320 }
4603
04f857454909 Simplify ipmovie.c pts calculation by using an appropriate time_base.
reimar
parents: 4601
diff changeset
321 s->frame_pts_inc = ((uint64_t)AV_RL32(&scratch[0])) * AV_RL16(&scratch[4]);
269
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
322 debug_ipmovie(" %.2f frames/second (timer div = %d, subdiv = %d)\n",
4603
04f857454909 Simplify ipmovie.c pts calculation by using an appropriate time_base.
reimar
parents: 4601
diff changeset
323 1000000.0/s->frame_pts_inc, AV_RL32(&scratch[0]), AV_RL16(&scratch[4]));
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
324 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
325
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
326 case OPCODE_INIT_AUDIO_BUFFERS:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
327 debug_ipmovie("initialize audio buffers\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
328 if ((opcode_version > 1) || (opcode_size > 10)) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
329 debug_ipmovie("bad init_audio_buffers opcode\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
330 chunk_type = CHUNK_BAD;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
331 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
332 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
333 if (get_buffer(pb, scratch, opcode_size) !=
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
334 opcode_size) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
335 chunk_type = CHUNK_BAD;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
336 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
337 }
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1443
diff changeset
338 s->audio_sample_rate = AV_RL16(&scratch[4]);
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1443
diff changeset
339 audio_flags = AV_RL16(&scratch[2]);
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
340 /* bit 0 of the flags: 0 = mono, 1 = stereo */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
341 s->audio_channels = (audio_flags & 1) + 1;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
342 /* bit 1 of the flags: 0 = 8 bit, 1 = 16 bit */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
343 s->audio_bits = (((audio_flags >> 1) & 1) + 1) * 8;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
344 /* bit 2 indicates compressed audio in version 1 opcode */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
345 if ((opcode_version == 1) && (audio_flags & 0x4))
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
346 s->audio_type = CODEC_ID_INTERPLAY_DPCM;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
347 else if (s->audio_bits == 16)
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
348 s->audio_type = CODEC_ID_PCM_S16LE;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
349 else
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
350 s->audio_type = CODEC_ID_PCM_U8;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
351 debug_ipmovie("audio: %d bits, %d Hz, %s, %s format\n",
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
352 s->audio_bits,
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
353 s->audio_sample_rate,
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
354 (s->audio_channels == 2) ? "stereo" : "mono",
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 820
diff changeset
355 (s->audio_type == CODEC_ID_INTERPLAY_DPCM) ?
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
356 "Interplay audio" : "PCM");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
357 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
358
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
359 case OPCODE_START_STOP_AUDIO:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
360 debug_ipmovie("start/stop audio\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
361 url_fseek(pb, opcode_size, SEEK_CUR);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
362 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
363
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
364 case OPCODE_INIT_VIDEO_BUFFERS:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
365 debug_ipmovie("initialize video buffers\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
366 if ((opcode_version > 2) || (opcode_size > 8)) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
367 debug_ipmovie("bad init_video_buffers opcode\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
368 chunk_type = CHUNK_BAD;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
369 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
370 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
371 if (get_buffer(pb, scratch, opcode_size) !=
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
372 opcode_size) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
373 chunk_type = CHUNK_BAD;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
374 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
375 }
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1443
diff changeset
376 s->video_width = AV_RL16(&scratch[0]) * 8;
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1443
diff changeset
377 s->video_height = AV_RL16(&scratch[2]) * 8;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
378 debug_ipmovie("video resolution: %d x %d\n",
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
379 s->video_width, s->video_height);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
380 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
381
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
382 case OPCODE_UNKNOWN_06:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
383 case OPCODE_UNKNOWN_0E:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
384 case OPCODE_UNKNOWN_10:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
385 case OPCODE_UNKNOWN_12:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
386 case OPCODE_UNKNOWN_13:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
387 case OPCODE_UNKNOWN_14:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
388 case OPCODE_UNKNOWN_15:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
389 debug_ipmovie("unknown (but documented) opcode %02X\n", opcode_type);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
390 url_fseek(pb, opcode_size, SEEK_CUR);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
391 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
392
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
393 case OPCODE_SEND_BUFFER:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
394 debug_ipmovie("send buffer\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
395 url_fseek(pb, opcode_size, SEEK_CUR);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
396 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
397
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
398 case OPCODE_AUDIO_FRAME:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
399 debug_ipmovie("audio frame\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
400
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
401 /* log position and move on for now */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
402 s->audio_chunk_offset = url_ftell(pb);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
403 s->audio_chunk_size = opcode_size;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
404 url_fseek(pb, opcode_size, SEEK_CUR);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
405 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
406
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
407 case OPCODE_SILENCE_FRAME:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
408 debug_ipmovie("silence frame\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
409 url_fseek(pb, opcode_size, SEEK_CUR);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
410 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
411
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
412 case OPCODE_INIT_VIDEO_MODE:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
413 debug_ipmovie("initialize video mode\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
414 url_fseek(pb, opcode_size, SEEK_CUR);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
415 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
416
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
417 case OPCODE_CREATE_GRADIENT:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
418 debug_ipmovie("create gradient\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
419 url_fseek(pb, opcode_size, SEEK_CUR);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
420 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
421
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
422 case OPCODE_SET_PALETTE:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
423 debug_ipmovie("set palette\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
424 /* check for the logical maximum palette size
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
425 * (3 * 256 + 4 bytes) */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
426 if (opcode_size > 0x304) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
427 debug_ipmovie("demux_ipmovie: set_palette opcode too large\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
428 chunk_type = CHUNK_BAD;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
429 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
430 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
431 if (get_buffer(pb, scratch, opcode_size) != opcode_size) {
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
432 chunk_type = CHUNK_BAD;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
433 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
434 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
435
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
436 /* load the palette into internal data structure */
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1443
diff changeset
437 first_color = AV_RL16(&scratch[0]);
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1443
diff changeset
438 last_color = first_color + AV_RL16(&scratch[2]) - 1;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
439 /* sanity check (since they are 16 bit values) */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
440 if ((first_color > 0xFF) || (last_color > 0xFF)) {
3365
19bd4caf27a9 consistency cosmetics: indices --> indexes
diego
parents: 2771
diff changeset
441 debug_ipmovie("demux_ipmovie: set_palette indexes out of range (%d -> %d)\n",
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
442 first_color, last_color);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
443 chunk_type = CHUNK_BAD;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
444 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
445 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
446 j = 4; /* offset of first palette data */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
447 for (i = first_color; i <= last_color; i++) {
247
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
448 /* the palette is stored as a 6-bit VGA palette, thus each
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
449 * component is shifted up to a 8-bit range */
295
bff1a372ae38 revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents: 269
diff changeset
450 r = scratch[j++] * 4;
bff1a372ae38 revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents: 269
diff changeset
451 g = scratch[j++] * 4;
bff1a372ae38 revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents: 269
diff changeset
452 b = scratch[j++] * 4;
bff1a372ae38 revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents: 269
diff changeset
453 s->palette_control.palette[i] = (r << 16) | (g << 8) | (b);
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
454 }
247
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
455 /* indicate a palette change */
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
456 s->palette_control.palette_changed = 1;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
457 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
458
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
459 case OPCODE_SET_PALETTE_COMPRESSED:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
460 debug_ipmovie("set palette compressed\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
461 url_fseek(pb, opcode_size, SEEK_CUR);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
462 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
463
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
464 case OPCODE_SET_DECODING_MAP:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
465 debug_ipmovie("set decoding map\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
466
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
467 /* log position and move on for now */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
468 s->decode_map_chunk_offset = url_ftell(pb);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
469 s->decode_map_chunk_size = opcode_size;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
470 url_fseek(pb, opcode_size, SEEK_CUR);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
471 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
472
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
473 case OPCODE_VIDEO_DATA:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
474 debug_ipmovie("set video data\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
475
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
476 /* log position and move on for now */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
477 s->video_chunk_offset = url_ftell(pb);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
478 s->video_chunk_size = opcode_size;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
479 url_fseek(pb, opcode_size, SEEK_CUR);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
480 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
481
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
482 default:
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
483 debug_ipmovie("*** unknown opcode type\n");
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
484 chunk_type = CHUNK_BAD;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
485 break;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
486
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
487 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
488 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
489
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
490 /* make a note of where the stream is sitting */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
491 s->next_chunk_offset = url_ftell(pb);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
492
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
493 /* dispatch the first of any pending packets */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
494 if ((chunk_type == CHUNK_VIDEO) || (chunk_type == CHUNK_AUDIO_ONLY))
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
495 chunk_type = load_ipmovie_packet(s, pb, pkt);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
496
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
497 return chunk_type;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
498 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
499
5156
6c50f319725d Extend ipmovie signature to match exactly one place in mve files that have a
reimar
parents: 4603
diff changeset
500 static const char signature[] = "Interplay MVE File\x1A\0\x1A";
6c50f319725d Extend ipmovie signature to match exactly one place in mve files that have a
reimar
parents: 4603
diff changeset
501
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
502 static int ipmovie_probe(AVProbeData *p)
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
503 {
5157
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
504 uint8_t *b = p->buf;
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
505 uint8_t *b_end = p->buf + p->buf_size - sizeof(signature);
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
506 do {
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
507 if (memcmp(b++, signature, sizeof(signature)) == 0)
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
508 return AVPROBE_SCORE_MAX;
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
509 } while (b < b_end);
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
510
5157
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
511 return 0;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
512 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
513
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
514 static int ipmovie_read_header(AVFormatContext *s,
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
515 AVFormatParameters *ap)
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
516 {
2006
2f0154760e5f Get rid of unnecessary pointer casts.
diego
parents: 2001
diff changeset
517 IPMVEContext *ipmovie = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2274
diff changeset
518 ByteIOContext *pb = s->pb;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
519 AVPacket pkt;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
520 AVStream *st;
269
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
521 unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
522 int chunk_type;
5157
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
523 uint8_t signature_buffer[sizeof(signature)];
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
524
5157
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
525 get_buffer(pb, signature_buffer, sizeof(signature_buffer));
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
526 while (memcmp(signature_buffer, signature, sizeof(signature))) {
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
527 memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1);
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
528 signature_buffer[sizeof(signature_buffer) - 1] = get_byte(pb);
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
529 if (url_feof(pb))
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
530 return AVERROR_EOF;
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
531 }
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
532 /* initialize private context members */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
533 ipmovie->video_pts = ipmovie->audio_frame_count = 0;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
534 ipmovie->audio_chunk_offset = ipmovie->video_chunk_offset =
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
535 ipmovie->decode_map_chunk_offset = 0;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
536
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
537 /* on the first read, this will position the stream at the first chunk */
5157
a74bea5a7084 Search for ipmovie signature beyond the start of the file.
reimar
parents: 5156
diff changeset
538 ipmovie->next_chunk_offset = url_ftell(pb) + 4;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
539
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
540 /* process the first chunk which should be CHUNK_INIT_VIDEO */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
541 if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO)
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
542 return AVERROR_INVALIDDATA;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
543
269
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
544 /* peek ahead to the next chunk-- if it is an init audio chunk, process
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
545 * it; if it is the first video chunk, this is a silent file */
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
546 if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
547 CHUNK_PREAMBLE_SIZE)
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
548 return AVERROR(EIO);
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1443
diff changeset
549 chunk_type = AV_RL16(&chunk_preamble[2]);
269
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
550 url_fseek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
551
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
552 if (chunk_type == CHUNK_VIDEO)
4128
e51ace85da6c Fix a warning when compiling with icc:
cehoyos
parents: 3973
diff changeset
553 ipmovie->audio_type = CODEC_ID_NONE; /* no audio */
269
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
554 else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
555 return AVERROR_INVALIDDATA;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
556
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
557 /* initialize the stream decoders */
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
558 st = av_new_stream(s, 0);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
559 if (!st)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2006
diff changeset
560 return AVERROR(ENOMEM);
4603
04f857454909 Simplify ipmovie.c pts calculation by using an appropriate time_base.
reimar
parents: 4601
diff changeset
561 av_set_pts_info(st, 63, 1, 1000000);
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
562 ipmovie->video_stream_index = st->index;
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
563 st->codec->codec_type = CODEC_TYPE_VIDEO;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
564 st->codec->codec_id = CODEC_ID_INTERPLAY_VIDEO;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
565 st->codec->codec_tag = 0; /* no fourcc */
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
566 st->codec->width = ipmovie->video_width;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
567 st->codec->height = ipmovie->video_height;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
568
247
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
569 /* palette considerations */
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
570 st->codec->palctrl = &ipmovie->palette_control;
247
697dae977e6d adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents: 211
diff changeset
571
269
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
572 if (ipmovie->audio_type) {
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
573 st = av_new_stream(s, 0);
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
574 if (!st)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2006
diff changeset
575 return AVERROR(ENOMEM);
4603
04f857454909 Simplify ipmovie.c pts calculation by using an appropriate time_base.
reimar
parents: 4601
diff changeset
576 av_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate);
269
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
577 ipmovie->audio_stream_index = st->index;
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
578 st->codec->codec_type = CODEC_TYPE_AUDIO;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
579 st->codec->codec_id = ipmovie->audio_type;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
580 st->codec->codec_tag = 0; /* no tag */
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
581 st->codec->channels = ipmovie->audio_channels;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
582 st->codec->sample_rate = ipmovie->audio_sample_rate;
3908
1d3d17de20ba Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents: 3484
diff changeset
583 st->codec->bits_per_coded_sample = ipmovie->audio_bits;
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
584 st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
3908
1d3d17de20ba Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents: 3484
diff changeset
585 st->codec->bits_per_coded_sample;
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
586 if (st->codec->codec_id == CODEC_ID_INTERPLAY_DPCM)
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
587 st->codec->bit_rate /= 2;
3908
1d3d17de20ba Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents: 3484
diff changeset
588 st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
269
021c58ac2f2c properly demux silent files; implemented precise framerate calculation
tmmm
parents: 253
diff changeset
589 }
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
590
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
591 return 0;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
592 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
593
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
594 static int ipmovie_read_packet(AVFormatContext *s,
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
595 AVPacket *pkt)
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
596 {
2006
2f0154760e5f Get rid of unnecessary pointer casts.
diego
parents: 2001
diff changeset
597 IPMVEContext *ipmovie = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2274
diff changeset
598 ByteIOContext *pb = s->pb;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
599 int ret;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
600
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
601 ret = process_ipmovie_chunk(ipmovie, pb, pkt);
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
602 if (ret == CHUNK_BAD)
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
603 ret = AVERROR_INVALIDDATA;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
604 else if (ret == CHUNK_EOF)
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
605 ret = AVERROR(EIO);
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
606 else if (ret == CHUNK_NOMEM)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2006
diff changeset
607 ret = AVERROR(ENOMEM);
1800
3edc6f0468be not checking error return, resulting double free
michael
parents: 1673
diff changeset
608 else if (ret == CHUNK_VIDEO)
3edc6f0468be not checking error return, resulting double free
michael
parents: 1673
diff changeset
609 ret = 0;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
610 else
1800
3edc6f0468be not checking error return, resulting double free
michael
parents: 1673
diff changeset
611 ret = -1;
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
612
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
613 return ret;
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
614 }
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
615
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
616 AVInputFormat ipmovie_demuxer = {
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
617 "ipmovie",
3424
7a0230981402 Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents: 3365
diff changeset
618 NULL_IF_CONFIG_SMALL("Interplay MVE format"),
211
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
619 sizeof(IPMVEContext),
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
620 ipmovie_probe,
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
621 ipmovie_read_header,
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
622 ipmovie_read_packet,
349d63d52e7e initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
623 };