Mercurial > libavformat.hg
annotate ipmovie.c @ 260:f3b8a6e60e71 libavformat
PowerPC warnings & optimisations patch by (Dan Christiansen <danchr at daimi dot au dot dk>)
author | michaelni |
---|---|
date | Sun, 28 Sep 2003 22:53:25 +0000 |
parents | 408f620eed8c |
children | 021c58ac2f2c |
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 * |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
6 * 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
|
7 * License as published by the Free Software Foundation; either |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
8 * version 2 of the License, or (at your option) any later version. |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
9 * |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
11 * 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
|
12 * 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
|
13 * Lesser General Public License for more details. |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
14 * |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
18 */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
19 |
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 * @file ipmovie.c |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
22 * Interplay MVE file demuxer |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
23 * by Mike Melanson (melanson@pcisys.net) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
24 * 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
|
25 * http://www.pcisys.net/~melanson/codecs/ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
26 * 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
|
27 * 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
|
28 * 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
|
29 * 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
|
30 * up and sending out the chunks. |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
31 */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
32 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
33 #include "avformat.h" |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
34 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
35 /* 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
|
36 * verbose information about the demux process */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
37 #define DEBUG_IPMOVIE 0 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
38 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
39 #if DEBUG_IPMOVIE |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
40 #define debug_ipmovie printf |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
41 #else |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
42 static inline void debug_ipmovie(const char *format, ...) { } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
43 #endif |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
44 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
45 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
46 #define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0]) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
47 #define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
48 (((uint8_t*)(x))[2] << 16) | \ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
49 (((uint8_t*)(x))[1] << 8) | \ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
50 ((uint8_t*)(x))[0]) |
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 IPMOVIE_SIGNATURE "Interplay MVE File\x1A\0" |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
53 #define IPMOVIE_SIGNATURE_SIZE 20 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
54 #define CHUNK_PREAMBLE_SIZE 4 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
55 #define OPCODE_PREAMBLE_SIZE 4 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
56 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
57 #define CHUNK_INIT_AUDIO 0x0000 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
58 #define CHUNK_AUDIO_ONLY 0x0001 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
59 #define CHUNK_INIT_VIDEO 0x0002 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
60 #define CHUNK_VIDEO 0x0003 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
61 #define CHUNK_SHUTDOWN 0x0004 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
62 #define CHUNK_END 0x0005 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
63 /* these last types are used internally */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
64 #define CHUNK_DONE 0xFFFC |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
65 #define CHUNK_NOMEM 0xFFFD |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
66 #define CHUNK_EOF 0xFFFE |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
67 #define CHUNK_BAD 0xFFFF |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
68 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
69 #define OPCODE_END_OF_STREAM 0x00 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
70 #define OPCODE_END_OF_CHUNK 0x01 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
71 #define OPCODE_CREATE_TIMER 0x02 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
72 #define OPCODE_INIT_AUDIO_BUFFERS 0x03 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
73 #define OPCODE_START_STOP_AUDIO 0x04 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
74 #define OPCODE_INIT_VIDEO_BUFFERS 0x05 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
75 #define OPCODE_UNKNOWN_06 0x06 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
76 #define OPCODE_SEND_BUFFER 0x07 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
77 #define OPCODE_AUDIO_FRAME 0x08 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
78 #define OPCODE_SILENCE_FRAME 0x09 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
79 #define OPCODE_INIT_VIDEO_MODE 0x0A |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
80 #define OPCODE_CREATE_GRADIENT 0x0B |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
81 #define OPCODE_SET_PALETTE 0x0C |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
82 #define OPCODE_SET_PALETTE_COMPRESSED 0x0D |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
83 #define OPCODE_UNKNOWN_0E 0x0E |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
84 #define OPCODE_SET_DECODING_MAP 0x0F |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
85 #define OPCODE_UNKNOWN_10 0x10 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
86 #define OPCODE_VIDEO_DATA 0x11 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
87 #define OPCODE_UNKNOWN_12 0x12 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
88 #define OPCODE_UNKNOWN_13 0x13 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
89 #define OPCODE_UNKNOWN_14 0x14 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
90 #define OPCODE_UNKNOWN_15 0x15 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
91 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
92 #define PALETTE_COUNT 256 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
93 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
94 typedef struct IPMVEContext { |
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 char *buf; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
97 int buf_size; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
98 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
99 int fps; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
100 int frame_pts_inc; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
101 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
102 unsigned int video_width; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
103 unsigned int video_height; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
104 int64_t video_pts; |
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 unsigned int audio_bits; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
107 unsigned int audio_channels; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
108 unsigned int audio_sample_rate; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
109 unsigned int audio_type; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
110 unsigned int audio_frame_count; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
111 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
112 int video_stream_index; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
113 int audio_stream_index; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
114 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
115 offset_t audio_chunk_offset; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
116 int audio_chunk_size; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
117 offset_t video_chunk_offset; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
118 int video_chunk_size; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
119 offset_t decode_map_chunk_offset; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
120 int decode_map_chunk_size; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
121 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
122 offset_t next_chunk_offset; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
123 |
247
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
124 AVPaletteControl palette_control; |
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
125 |
211
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
126 } IPMVEContext; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
127 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
128 static int load_ipmovie_packet(IPMVEContext *s, ByteIOContext *pb, |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
129 AVPacket *pkt) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
130 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
131 int chunk_type; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
132 int64_t audio_pts = 0; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
133 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
134 if (s->audio_chunk_offset) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
135 |
252 | 136 /* adjust for PCM audio by skipping chunk header */ |
137 if (s->audio_type != CODEC_ID_INTERPLAY_DPCM) { | |
138 s->audio_chunk_offset += 6; | |
139 s->audio_chunk_size -= 6; | |
140 } | |
141 | |
211
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
142 url_fseek(pb, s->audio_chunk_offset, SEEK_SET); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
143 s->audio_chunk_offset = 0; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
144 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
145 /* figure out the audio pts */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
146 audio_pts = 90000; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
147 audio_pts *= s->audio_frame_count; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
148 audio_pts /= s->audio_sample_rate; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
149 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
150 if (av_new_packet(pkt, s->audio_chunk_size)) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
151 return CHUNK_NOMEM; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
152 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
153 pkt->stream_index = s->audio_stream_index; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
154 pkt->pts = audio_pts; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
155 if (get_buffer(pb, pkt->data, s->audio_chunk_size) != |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
156 s->audio_chunk_size) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
157 av_free_packet(pkt); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
158 return CHUNK_EOF; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
159 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
160 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
161 /* audio frame maintenance */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
162 if (s->audio_type != CODEC_ID_INTERPLAY_DPCM) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
163 s->audio_frame_count += |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
164 (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
|
165 else |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
166 s->audio_frame_count += |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
167 (s->audio_chunk_size - 6) / s->audio_channels; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
168 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
169 debug_ipmovie("sending audio frame with pts %lld (%d audio frames)\n", |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
170 audio_pts, s->audio_frame_count); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
171 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
172 chunk_type = CHUNK_VIDEO; |
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 } else if (s->decode_map_chunk_offset) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
175 |
247
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
176 /* 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
|
177 |
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
178 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
|
179 return CHUNK_NOMEM; |
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
180 |
211
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
181 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
|
182 s->decode_map_chunk_offset = 0; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
183 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
184 if (get_buffer(pb, pkt->data, s->decode_map_chunk_size) != |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
185 s->decode_map_chunk_size) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
186 av_free_packet(pkt); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
187 return CHUNK_EOF; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
188 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
189 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
190 url_fseek(pb, s->video_chunk_offset, SEEK_SET); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
191 s->video_chunk_offset = 0; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
192 |
247
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
193 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
|
194 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
|
195 av_free_packet(pkt); |
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
196 return CHUNK_EOF; |
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
197 } |
211
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 pkt->stream_index = s->video_stream_index; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
200 pkt->pts = s->video_pts; |
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 s->video_pts += s->frame_pts_inc; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
203 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
204 chunk_type = CHUNK_VIDEO; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
205 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
206 } else { |
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 url_fseek(pb, s->next_chunk_offset, SEEK_SET); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
209 chunk_type = CHUNK_DONE; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
210 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
211 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
212 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
213 return chunk_type; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
214 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
215 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
216 /* 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
|
217 * It returns the type of chunk that was processed. */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
218 static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb, |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
219 AVPacket *pkt) |
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 unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE]; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
222 int chunk_type; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
223 int chunk_size; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
224 unsigned char opcode_preamble[OPCODE_PREAMBLE_SIZE]; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
225 unsigned char opcode_type; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
226 unsigned char opcode_version; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
227 int opcode_size; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
228 unsigned char scratch[1024]; |
247
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
229 int i, j; |
211
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
230 int first_color, last_color; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
231 int audio_flags; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
232 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
233 /* see if there are any pending packets */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
234 chunk_type = load_ipmovie_packet(s, pb, pkt); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
235 if ((chunk_type == CHUNK_VIDEO) && (chunk_type != CHUNK_DONE)) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
236 return chunk_type; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
237 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
238 /* 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
|
239 if (url_feof(pb)) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
240 return CHUNK_EOF; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
241 if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) != |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
242 CHUNK_PREAMBLE_SIZE) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
243 return CHUNK_BAD; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
244 chunk_size = LE_16(&chunk_preamble[0]); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
245 chunk_type = LE_16(&chunk_preamble[2]); |
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 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
|
248 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
249 switch (chunk_type) { |
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_INIT_AUDIO: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
252 debug_ipmovie("initialize 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_AUDIO_ONLY: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
256 debug_ipmovie("audio only\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_INIT_VIDEO: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
260 debug_ipmovie("initialize video\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 case CHUNK_VIDEO: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
264 debug_ipmovie("video (and audio)\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
265 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
266 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
267 case CHUNK_SHUTDOWN: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
268 debug_ipmovie("shutdown\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
269 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
270 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
271 case CHUNK_END: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
272 debug_ipmovie("end\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
273 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
274 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
275 default: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
276 debug_ipmovie("invalid chunk\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
277 chunk_type = CHUNK_BAD; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
278 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
279 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
280 } |
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 while ((chunk_size > 0) && (chunk_type != CHUNK_BAD)) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
283 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
284 /* 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
|
285 if (url_feof(pb)) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
286 chunk_type = CHUNK_EOF; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
287 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
288 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
289 if (get_buffer(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) != |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
290 CHUNK_PREAMBLE_SIZE) { |
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 opcode_size = LE_16(&opcode_preamble[0]); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
296 opcode_type = opcode_preamble[2]; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
297 opcode_version = opcode_preamble[3]; |
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 chunk_size -= OPCODE_PREAMBLE_SIZE; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
300 chunk_size -= opcode_size; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
301 if (chunk_size < 0) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
302 debug_ipmovie("chunk_size countdown just went negative\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
303 chunk_type = CHUNK_BAD; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
304 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
305 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
306 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
307 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
|
308 opcode_type, opcode_version, opcode_size); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
309 switch (opcode_type) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
310 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
311 case OPCODE_END_OF_STREAM: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
312 debug_ipmovie("end of stream\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
313 url_fseek(pb, opcode_size, SEEK_CUR); |
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 case OPCODE_END_OF_CHUNK: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
317 debug_ipmovie("end of chunk\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
318 url_fseek(pb, opcode_size, SEEK_CUR); |
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 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
321 case OPCODE_CREATE_TIMER: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
322 debug_ipmovie("create timer\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
323 if ((opcode_version > 0) || (opcode_size > 6)) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
324 debug_ipmovie("bad create_timer opcode\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
325 chunk_type = CHUNK_BAD; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
326 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
327 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
328 if (get_buffer(pb, scratch, opcode_size) != |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
329 opcode_size) { |
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 s->fps = 1000000 / (LE_32(&scratch[0]) * LE_16(&scratch[4])); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
334 s->fps++; /* above calculation usually yields 14.9; we need 15 */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
335 s->frame_pts_inc = 90000 / s->fps; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
336 debug_ipmovie("%d frames/second (timer div = %d, subdiv = %d)\n", |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
337 s->fps, LE_32(&scratch[0]), LE_16(&scratch[4])); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
338 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
339 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
340 case OPCODE_INIT_AUDIO_BUFFERS: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
341 debug_ipmovie("initialize audio buffers\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
342 if ((opcode_version > 1) || (opcode_size > 10)) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
343 debug_ipmovie("bad init_audio_buffers opcode\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
344 chunk_type = CHUNK_BAD; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
345 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
346 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
347 if (get_buffer(pb, scratch, opcode_size) != |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
348 opcode_size) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
349 chunk_type = CHUNK_BAD; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
350 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
351 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
352 s->audio_sample_rate = LE_16(&scratch[4]); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
353 audio_flags = LE_16(&scratch[2]); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
354 /* bit 0 of the flags: 0 = mono, 1 = stereo */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
355 s->audio_channels = (audio_flags & 1) + 1; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
356 /* 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
|
357 s->audio_bits = (((audio_flags >> 1) & 1) + 1) * 8; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
358 /* bit 2 indicates compressed audio in version 1 opcode */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
359 if ((opcode_version == 1) && (audio_flags & 0x4)) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
360 s->audio_type = CODEC_ID_INTERPLAY_DPCM; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
361 else if (s->audio_bits == 16) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
362 s->audio_type = CODEC_ID_PCM_S16LE; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
363 else |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
364 s->audio_type = CODEC_ID_PCM_U8; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
365 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
|
366 s->audio_bits, |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
367 s->audio_sample_rate, |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
368 (s->audio_channels == 2) ? "stereo" : "mono", |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
369 (s->audio_type == CODEC_ID_INTERPLAY_DPCM) ? |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
370 "Interplay audio" : "PCM"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
371 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
372 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
373 case OPCODE_START_STOP_AUDIO: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
374 debug_ipmovie("start/stop audio\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
375 url_fseek(pb, opcode_size, SEEK_CUR); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
376 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
377 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
378 case OPCODE_INIT_VIDEO_BUFFERS: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
379 debug_ipmovie("initialize video buffers\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
380 if ((opcode_version > 2) || (opcode_size > 8)) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
381 debug_ipmovie("bad init_video_buffers opcode\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
382 chunk_type = CHUNK_BAD; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
383 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
384 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
385 if (get_buffer(pb, scratch, opcode_size) != |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
386 opcode_size) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
387 chunk_type = CHUNK_BAD; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
388 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
389 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
390 s->video_width = LE_16(&scratch[0]) * 8; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
391 s->video_height = LE_16(&scratch[2]) * 8; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
392 debug_ipmovie("video resolution: %d x %d\n", |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
393 s->video_width, s->video_height); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
394 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
395 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
396 case OPCODE_UNKNOWN_06: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
397 case OPCODE_UNKNOWN_0E: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
398 case OPCODE_UNKNOWN_10: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
399 case OPCODE_UNKNOWN_12: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
400 case OPCODE_UNKNOWN_13: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
401 case OPCODE_UNKNOWN_14: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
402 case OPCODE_UNKNOWN_15: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
403 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
|
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_SEND_BUFFER: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
408 debug_ipmovie("send buffer\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_AUDIO_FRAME: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
413 debug_ipmovie("audio frame\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
414 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
415 /* log position and move on for now */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
416 s->audio_chunk_offset = url_ftell(pb); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
417 s->audio_chunk_size = opcode_size; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
418 url_fseek(pb, opcode_size, SEEK_CUR); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
419 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
420 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
421 case OPCODE_SILENCE_FRAME: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
422 debug_ipmovie("silence frame\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
423 url_fseek(pb, opcode_size, SEEK_CUR); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
424 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
425 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
426 case OPCODE_INIT_VIDEO_MODE: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
427 debug_ipmovie("initialize video mode\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
428 url_fseek(pb, opcode_size, SEEK_CUR); |
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 case OPCODE_CREATE_GRADIENT: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
432 debug_ipmovie("create gradient\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
433 url_fseek(pb, opcode_size, SEEK_CUR); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
434 break; |
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 case OPCODE_SET_PALETTE: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
437 debug_ipmovie("set palette\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
438 /* check for the logical maximum palette size |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
439 * (3 * 256 + 4 bytes) */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
440 if (opcode_size > 0x304) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
441 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
|
442 chunk_type = CHUNK_BAD; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
443 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
444 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
445 if (get_buffer(pb, scratch, opcode_size) != opcode_size) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
446 chunk_type = CHUNK_BAD; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
447 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
448 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
449 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
450 /* load the palette into internal data structure */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
451 first_color = LE_16(&scratch[0]); |
253
408f620eed8c
iterate through the appropriate range of palette entries
tmmm
parents:
252
diff
changeset
|
452 last_color = first_color + LE_16(&scratch[2]); |
211
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
453 /* sanity check (since they are 16 bit values) */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
454 if ((first_color > 0xFF) || (last_color > 0xFF)) { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
455 debug_ipmovie("demux_ipmovie: set_palette indices out of range (%d -> %d)\n", |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
456 first_color, last_color); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
457 chunk_type = CHUNK_BAD; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
458 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
459 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
460 j = 4; /* offset of first palette data */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
461 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
|
462 /* 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
|
463 * component is shifted up to a 8-bit range */ |
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
464 s->palette_control.palette[i * 3 + 0] = scratch[j++] * 4; |
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
465 s->palette_control.palette[i * 3 + 1] = scratch[j++] * 4; |
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
466 s->palette_control.palette[i * 3 + 2] = scratch[j++] * 4; |
211
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
467 } |
247
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
468 /* indicate a palette change */ |
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
469 s->palette_control.palette_changed = 1; |
211
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
470 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
471 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
472 case OPCODE_SET_PALETTE_COMPRESSED: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
473 debug_ipmovie("set palette compressed\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
474 url_fseek(pb, opcode_size, SEEK_CUR); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
475 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
476 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
477 case OPCODE_SET_DECODING_MAP: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
478 debug_ipmovie("set decoding map\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
479 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
480 /* log position and move on for now */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
481 s->decode_map_chunk_offset = url_ftell(pb); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
482 s->decode_map_chunk_size = opcode_size; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
483 url_fseek(pb, opcode_size, SEEK_CUR); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
484 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
485 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
486 case OPCODE_VIDEO_DATA: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
487 debug_ipmovie("set video data\n"); |
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 /* log position and move on for now */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
490 s->video_chunk_offset = url_ftell(pb); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
491 s->video_chunk_size = opcode_size; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
492 url_fseek(pb, opcode_size, SEEK_CUR); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
493 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
494 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
495 default: |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
496 debug_ipmovie("*** unknown opcode type\n"); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
497 chunk_type = CHUNK_BAD; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
498 break; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
499 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
500 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
501 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
502 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
503 /* make a note of where the stream is sitting */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
504 s->next_chunk_offset = url_ftell(pb); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
505 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
506 /* dispatch the first of any pending packets */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
507 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
|
508 chunk_type = load_ipmovie_packet(s, pb, pkt); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
509 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
510 return chunk_type; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
511 } |
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 static int ipmovie_probe(AVProbeData *p) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
514 { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
515 if (p->buf_size < IPMOVIE_SIGNATURE_SIZE) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
516 return 0; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
517 if (strncmp(p->buf, IPMOVIE_SIGNATURE, IPMOVIE_SIGNATURE_SIZE) != 0) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
518 return 0; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
519 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
520 return AVPROBE_SCORE_MAX; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
521 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
522 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
523 static int ipmovie_read_header(AVFormatContext *s, |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
524 AVFormatParameters *ap) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
525 { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
526 IPMVEContext *ipmovie = (IPMVEContext *)s->priv_data; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
527 ByteIOContext *pb = &s->pb; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
528 AVPacket pkt; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
529 AVStream *st; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
530 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
531 /* initialize private context members */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
532 ipmovie->video_pts = ipmovie->audio_frame_count = 0; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
533 ipmovie->audio_chunk_offset = ipmovie->video_chunk_offset = |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
534 ipmovie->decode_map_chunk_offset = 0; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
535 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
536 /* on the first read, this will position the stream at the first chunk */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
537 ipmovie->next_chunk_offset = IPMOVIE_SIGNATURE_SIZE + 6; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
538 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
539 /* 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
|
540 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
|
541 return AVERROR_INVALIDDATA; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
542 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
543 /* process the next chunk which should be CHUNK_INIT_AUDIO */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
544 if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
545 return AVERROR_INVALIDDATA; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
546 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
547 /* set the pts reference (1 pts = 1/90000) */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
548 s->pts_num = 1; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
549 s->pts_den = 90000; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
550 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
551 /* initialize the stream decoders */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
552 st = av_new_stream(s, 0); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
553 if (!st) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
554 return AVERROR_NOMEM; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
555 ipmovie->video_stream_index = st->index; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
556 st->codec.codec_type = CODEC_TYPE_VIDEO; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
557 st->codec.codec_id = CODEC_ID_INTERPLAY_VIDEO; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
558 st->codec.codec_tag = 0; /* no fourcc */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
559 st->codec.width = ipmovie->video_width; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
560 st->codec.height = ipmovie->video_height; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
561 |
247
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
562 /* palette considerations */ |
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
563 st->codec.extradata_size = sizeof(AVPaletteControl); |
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
564 st->codec.extradata = &ipmovie->palette_control; |
697dae977e6d
adapt to use interim palette control API; do away with multi-chunk data
tmmm
parents:
211
diff
changeset
|
565 |
211
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
566 st = av_new_stream(s, 0); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
567 if (!st) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
568 return AVERROR_NOMEM; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
569 ipmovie->audio_stream_index = st->index; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
570 st->codec.codec_type = CODEC_TYPE_AUDIO; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
571 st->codec.codec_id = ipmovie->audio_type; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
572 st->codec.codec_tag = 0; /* no tag */ |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
573 st->codec.channels = ipmovie->audio_channels; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
574 st->codec.sample_rate = ipmovie->audio_sample_rate; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
575 st->codec.bits_per_sample = ipmovie->audio_bits; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
576 st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * |
252 | 577 st->codec.bits_per_sample; |
578 if (st->codec.codec_id == CODEC_ID_INTERPLAY_DPCM) | |
579 st->codec.bit_rate /= 2; | |
211
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
580 st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
581 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
582 return 0; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
583 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
584 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
585 static int ipmovie_read_packet(AVFormatContext *s, |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
586 AVPacket *pkt) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
587 { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
588 IPMVEContext *ipmovie = (IPMVEContext *)s->priv_data; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
589 ByteIOContext *pb = &s->pb; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
590 int ret; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
591 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
592 ret = process_ipmovie_chunk(ipmovie, pb, pkt); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
593 if (ret == CHUNK_BAD) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
594 ret = AVERROR_INVALIDDATA; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
595 else if (ret == CHUNK_EOF) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
596 ret = -EIO; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
597 else if (ret == CHUNK_NOMEM) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
598 ret = AVERROR_NOMEM; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
599 else |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
600 ret = 0; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
601 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
602 return ret; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
603 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
604 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
605 static int ipmovie_read_close(AVFormatContext *s) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
606 { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
607 // IPMVEContext *ipmovie = (IPMVEContext *)s->priv_data; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
608 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
609 return 0; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
610 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
611 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
612 static AVInputFormat ipmovie_iformat = { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
613 "ipmovie", |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
614 "Interplay MVE format", |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
615 sizeof(IPMVEContext), |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
616 ipmovie_probe, |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
617 ipmovie_read_header, |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
618 ipmovie_read_packet, |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
619 ipmovie_read_close, |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
620 }; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
621 |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
622 int ipmovie_init(void) |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
623 { |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
624 av_register_input_format(&ipmovie_iformat); |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
625 return 0; |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
626 } |
349d63d52e7e
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
627 |