annotate interplayvideo.c @ 1468:92c1f24f7754 libavcodec

initial Interplay video decoder
author tmmm
date Sun, 14 Sep 2003 19:39:18 +0000
parents a4d00b1f0271
children 873100cd2108
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1439
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
1 /*
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
2 * Interplay MVE Video Decoder
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
3 * Copyright (C) 2003 the ffmpeg project
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
4 *
a4d00b1f0271 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
a4d00b1f0271 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
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
a4d00b1f0271 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.
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
9 *
a4d00b1f0271 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,
a4d00b1f0271 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
a4d00b1f0271 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
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
13 * Lesser General Public License for more details.
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
14 *
a4d00b1f0271 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
a4d00b1f0271 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
a4d00b1f0271 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
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
18 *
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
19 */
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
20
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
21 /**
1468
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
22 * @file interplayvideo.c
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
23 * Interplay MVE Video Decoder by Mike Melanson (melanson@pcisys.net)
1439
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
24 * For more information about the Interplay MVE format, visit:
1468
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
25 * http://www.pcisys.net/~melanson/codecs/interplay-mve.txt
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
26 * This code is written in such a way that the identifiers match up
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
27 * with the encoding descriptions in the document.
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
28 *
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
29 * This decoder presently only supports a PAL8 output colorspace.
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
30 *
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
31 * An Interplay video frame consists of 2 parts: The decoding map and
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
32 * the video data. A demuxer must load these 2 parts together in a single
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
33 * buffer before sending it through the stream to this decoder.
1439
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
34 */
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
35
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
36 #include <stdio.h>
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
37 #include <stdlib.h>
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
38 #include <string.h>
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
39 #include <unistd.h>
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
40
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
41 #include "common.h"
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
42 #include "avcodec.h"
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
43 #include "dsputil.h"
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
44
1468
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
45 #define PALETTE_COUNT 256
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
46
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
47 /* debugging support */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
48 #define DEBUG_INTERPLAY 0
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
49 #if DEBUG_INTERPLAY
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
50 #define debug_interplay printf
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
51 #else
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
52 static inline void debug_interplay(const char *format, ...) { }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
53 #endif
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
54
1439
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
55 typedef struct IpvideoContext {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
56
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
57 AVCodecContext *avctx;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
58 DSPContext dsp;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
59 AVFrame last_frame;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
60 AVFrame current_frame;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
61 int first_frame;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
62 unsigned char *decoding_map;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
63 int decoding_map_size;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
64
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
65 unsigned char *buf;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
66 int size;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
67
1468
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
68 unsigned char palette[PALETTE_COUNT * 4];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
69
1439
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
70 } IpvideoContext;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
71
1468
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
72 #define CHECK_STREAM_PTR(n) \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
73 if ((sg_stream_ptr + n) > sg_stream_end) { \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
74 printf ("Interplay video warning: stream_ptr out of bounds (%p >= %p)\n", \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
75 sg_stream_ptr + n, sg_stream_end); \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
76 return -1; \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
77 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
78
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
79 static void ipvideo_new_palette(IpvideoContext *s, unsigned char *palette) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
80
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
81 int i;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
82 unsigned char r, g, b;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
83 unsigned int *palette32;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
84
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
85 switch (s->avctx->pix_fmt) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
86
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
87 case PIX_FMT_PAL8:
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
88 palette32 = (unsigned int *)s->palette;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
89 for (i = 0; i < PALETTE_COUNT; i++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
90 r = *palette++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
91 g = *palette++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
92 b = *palette++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
93 palette32[i] = (r << 16) | (g << 8) | (b);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
94 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
95 break;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
96
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
97 default:
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
98 printf ("Interplay video: Unhandled video format\n");
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
99 break;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
100 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
101 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
102
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
103 static unsigned char *sg_stream_ptr;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
104 static unsigned char *sg_stream_end;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
105 static unsigned char *sg_current_plane;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
106 static unsigned char *sg_output_plane;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
107 static unsigned char *sg_last_plane;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
108 static int sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
109 static int sg_stride;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
110 static int sg_upper_motion_limit_offset;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
111 static DSPContext sg_dsp;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
112
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
113 static int ipvideo_decode_block_opcode_0x0_0x1(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
114 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
115 int x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
116 unsigned char *src_block;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
117
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
118 /* skip block, which actually means to copy from previous frame */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
119 src_block = sg_last_plane + (sg_output_plane - sg_current_plane);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
120 for (y = 0; y < 8; y++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
121 for (x = 0; x < 8; x++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
122 *sg_output_plane++ = *src_block++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
123 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
124 sg_output_plane += sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
125 src_block += sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
126 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
127
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
128 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
129 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
130 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
131
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
132 #define COPY_FROM_CURRENT() \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
133 motion_offset = current_offset; \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
134 motion_offset += y * sg_stride; \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
135 motion_offset += x; \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
136 if (motion_offset < 0) { \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
137 printf (" Interplay video: motion offset < 0 (%d)\n", motion_offset); \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
138 return -1; \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
139 } else if (motion_offset > sg_upper_motion_limit_offset) { \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
140 printf (" Interplay video: motion offset above limit (%d >= %d)\n", \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
141 motion_offset, sg_upper_motion_limit_offset); \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
142 return -1; \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
143 } \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
144 sg_dsp.put_pixels_tab[0][0](sg_output_plane, \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
145 sg_current_plane + motion_offset, sg_stride, 8);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
146
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
147 #define COPY_FROM_PREVIOUS() \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
148 motion_offset = current_offset; \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
149 motion_offset += y * sg_stride; \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
150 motion_offset += x; \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
151 if (motion_offset < 0) { \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
152 printf (" Interplay video: motion offset < 0 (%d)\n", motion_offset); \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
153 return -1; \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
154 } else if (motion_offset > sg_upper_motion_limit_offset) { \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
155 printf (" Interplay video: motion offset above limit (%d >= %d)\n", \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
156 motion_offset, sg_upper_motion_limit_offset); \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
157 return -1; \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
158 } \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
159 sg_dsp.put_pixels_tab[0][0](sg_output_plane, \
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
160 sg_last_plane + motion_offset, sg_stride, 8);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
161
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
162 static int ipvideo_decode_block_opcode_0x2(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
163 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
164 unsigned char B;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
165 int x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
166 int motion_offset;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
167 int current_offset = sg_output_plane - sg_current_plane;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
168
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
169 /* This is the opcode which claims to copy data from within the same
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
170 * frame at a coordinate which has not been rendered yet. Assume that
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
171 * it is supposed to be copied from the previous frame. */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
172
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
173 /* need 1 more byte for motion */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
174 CHECK_STREAM_PTR(1);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
175 B = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
176
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
177 if (B < 56) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
178 x = 8 + (B % 7);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
179 y = B / 7;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
180 } else {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
181 x = -14 + ((B - 56) % 29);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
182 y = 8 + ((B - 56) / 29);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
183 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
184
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
185 debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
186 COPY_FROM_PREVIOUS();
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
187
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
188 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
189 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
190 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
191
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
192 static int ipvideo_decode_block_opcode_0x3(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
193 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
194 unsigned char B;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
195 int x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
196 int motion_offset;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
197 int current_offset = sg_output_plane - sg_current_plane;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
198
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
199 /* copy 8x8 block from current frame from an up/left block */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
200
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
201 /* need 1 more byte for motion */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
202 CHECK_STREAM_PTR(1);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
203 B = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
204
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
205 if (B < 56) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
206 x = -(8 + (B % 7));
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
207 y = -(B / 7);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
208 } else {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
209 x = -(-14 + ((B - 56) % 29));
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
210 y = -( 8 + ((B - 56) / 29));
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
211 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
212
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
213 debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
214 COPY_FROM_CURRENT();
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
215
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
216 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
217 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
218 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
219
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
220 static int ipvideo_decode_block_opcode_0x4(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
221 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
222 int x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
223 unsigned char B, BL, BH;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
224 int motion_offset;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
225 int current_offset = sg_output_plane - sg_current_plane;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
226
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
227 /* copy a block from the previous frame; need 1 more byte */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
228 CHECK_STREAM_PTR(1);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
229
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
230 B = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
231 BL = B & 0x0F;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
232 BH = (B >> 4) & 0x0F;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
233 x = -8 + BL;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
234 y = -8 + BH;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
235
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
236 debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
237 COPY_FROM_PREVIOUS();
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
238
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
239 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
240 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
241 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
242
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
243 static int ipvideo_decode_block_opcode_0x5(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
244 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
245 signed char x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
246 int motion_offset;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
247 int current_offset = sg_output_plane - sg_current_plane;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
248
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
249 /* copy a block from the previous frame using an expanded range;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
250 * need 2 more bytes */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
251 CHECK_STREAM_PTR(2);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
252
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
253 x = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
254 y = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
255
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
256 debug_interplay (" motion bytes = %d, %d\n", x, y);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
257 COPY_FROM_PREVIOUS();
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
258
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
259 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
260 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
261 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
262
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
263 static int ipvideo_decode_block_opcode_0x6(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
264 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
265 /* mystery opcode? skip multiple blocks? */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
266 printf (" Interplay video: Help! Mystery opcode 0x6 seen\n");
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
267
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
268 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
269 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
270 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
271
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
272 static int ipvideo_decode_block_opcode_0x7(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
273 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
274 int x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
275 unsigned char P0, P1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
276 unsigned char B[8];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
277 unsigned int flags;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
278 int bitmask;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
279
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
280 /* 2-color encoding */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
281 CHECK_STREAM_PTR(2);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
282
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
283 P0 = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
284 P1 = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
285
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
286 if (P0 <= P1) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
287
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
288 /* need 8 more bytes from the stream */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
289 CHECK_STREAM_PTR(8);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
290 for (y = 0; y < 8; y++)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
291 B[y] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
292
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
293 for (y = 0; y < 8; y++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
294 flags = B[y];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
295 for (x = 0x80; x != 0; x >>= 1) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
296 if (flags & x)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
297 *sg_output_plane++ = P1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
298 else
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
299 *sg_output_plane++ = P0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
300 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
301 sg_output_plane += sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
302 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
303
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
304 } else {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
305
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
306 /* need 2 more bytes from the stream */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
307 CHECK_STREAM_PTR(2);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
308 B[0] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
309 B[1] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
310
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
311 flags = (B[0] << 8) | B[1];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
312 bitmask = 0x8000;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
313 for (y = 0; y < 8; y += 2) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
314 for (x = 0; x < 8; x += 2, bitmask >>= 1) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
315 if (flags & bitmask) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
316 *(sg_output_plane + x) = P0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
317 *(sg_output_plane + x + 1) = P0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
318 *(sg_output_plane + sg_stride + x) = P0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
319 *(sg_output_plane + sg_stride + x + 1) = P0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
320 } else {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
321 *(sg_output_plane + x) = P1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
322 *(sg_output_plane + x + 1) = P1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
323 *(sg_output_plane + sg_stride + x) = P1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
324 *(sg_output_plane + sg_stride + x + 1) = P1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
325 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
326 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
327 sg_output_plane += sg_stride * 2;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
328 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
329 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
330
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
331 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
332 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
333 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
334
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
335 static int ipvideo_decode_block_opcode_0x8(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
336 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
337 int x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
338 unsigned char P[8];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
339 unsigned char B[8];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
340 unsigned int flags = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
341 unsigned int bitmask = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
342 unsigned char P0 = 0, P1 = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
343 int lower_half = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
344
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
345 /* 2-color encoding for each 4x4 quadrant, or 2-color encoding on
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
346 * either top and bottom or left and right halves */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
347 CHECK_STREAM_PTR(2);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
348
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
349 P[0] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
350 P[1] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
351
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
352 if (P[0] <= P[1]) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
353
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
354 /* need 12 more bytes */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
355 CHECK_STREAM_PTR(12);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
356 B[0] = *sg_stream_ptr++; B[1] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
357 P[2] = *sg_stream_ptr++; P[3] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
358 B[2] = *sg_stream_ptr++; B[3] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
359 P[4] = *sg_stream_ptr++; P[5] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
360 B[4] = *sg_stream_ptr++; B[5] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
361 P[6] = *sg_stream_ptr++; P[7] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
362 B[6] = *sg_stream_ptr++; B[7] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
363
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
364 for (y = 0; y < 8; y++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
365
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
366 /* time to reload flags? */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
367 if (y == 0) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
368 flags =
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
369 ((B[0] & 0xF0) << 24) | ((B[4] & 0xF0) << 20) |
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
370 ((B[0] & 0x0F) << 20) | ((B[4] & 0x0F) << 16) |
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
371 ((B[1] & 0xF0) << 8) | ((B[5] & 0xF0) << 4) |
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
372 ((B[1] & 0x0F) << 4) | ((B[5] & 0x0F) << 0);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
373 bitmask = 0x80000000;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
374 lower_half = 0; /* still on top half */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
375 } else if (y == 4) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
376 flags =
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
377 ((B[2] & 0xF0) << 24) | ((B[6] & 0xF0) << 20) |
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
378 ((B[2] & 0x0F) << 20) | ((B[6] & 0x0F) << 16) |
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
379 ((B[3] & 0xF0) << 8) | ((B[7] & 0xF0) << 4) |
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
380 ((B[3] & 0x0F) << 4) | ((B[7] & 0x0F) << 0);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
381 bitmask = 0x80000000;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
382 lower_half = 4;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
383 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
384
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
385 for (x = 0; x < 8; x++, bitmask >>= 1) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
386 /* get the pixel values ready for this quadrant */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
387 if (x == 0) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
388 P0 = P[lower_half + 0];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
389 P1 = P[lower_half + 1];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
390 } else if (x == 4) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
391 P0 = P[lower_half + 2];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
392 P1 = P[lower_half + 3];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
393 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
394
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
395 if (flags & bitmask)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
396 *sg_output_plane++ = P1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
397 else
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
398 *sg_output_plane++ = P0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
399 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
400 sg_output_plane += sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
401 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
402
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
403 } else {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
404
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
405 /* need 10 more bytes */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
406 CHECK_STREAM_PTR(10);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
407 B[0] = *sg_stream_ptr++; B[1] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
408 B[2] = *sg_stream_ptr++; B[3] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
409 P[2] = *sg_stream_ptr++; P[3] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
410 B[4] = *sg_stream_ptr++; B[5] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
411 B[6] = *sg_stream_ptr++; B[7] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
412
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
413 if (P[2] <= P[3]) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
414
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
415 /* vertical split; left & right halves are 2-color encoded */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
416
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
417 for (y = 0; y < 8; y++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
418
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
419 /* time to reload flags? */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
420 if (y == 0) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
421 flags =
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
422 ((B[0] & 0xF0) << 24) | ((B[4] & 0xF0) << 20) |
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
423 ((B[0] & 0x0F) << 20) | ((B[4] & 0x0F) << 16) |
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
424 ((B[1] & 0xF0) << 8) | ((B[5] & 0xF0) << 4) |
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
425 ((B[1] & 0x0F) << 4) | ((B[5] & 0x0F) << 0);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
426 bitmask = 0x80000000;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
427 } else if (y == 4) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
428 flags =
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
429 ((B[2] & 0xF0) << 24) | ((B[6] & 0xF0) << 20) |
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
430 ((B[2] & 0x0F) << 20) | ((B[6] & 0x0F) << 16) |
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
431 ((B[3] & 0xF0) << 8) | ((B[7] & 0xF0) << 4) |
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
432 ((B[3] & 0x0F) << 4) | ((B[7] & 0x0F) << 0);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
433 bitmask = 0x80000000;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
434 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
435
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
436 for (x = 0; x < 8; x++, bitmask >>= 1) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
437 /* get the pixel values ready for this half */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
438 if (x == 0) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
439 P0 = P[0];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
440 P1 = P[1];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
441 } else if (x == 4) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
442 P0 = P[2];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
443 P1 = P[3];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
444 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
445
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
446 if (flags & bitmask)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
447 *sg_output_plane++ = P0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
448 else
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
449 *sg_output_plane++ = P1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
450 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
451 sg_output_plane += sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
452 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
453
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
454 } else {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
455
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
456 /* horizontal split; top & bottom halves are 2-color encoded */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
457
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
458 for (y = 0; y < 8; y++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
459
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
460 flags = B[y];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
461 if (y == 0) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
462 P0 = P[0];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
463 P1 = P[1];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
464 } else if (y == 4) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
465 P0 = P[2];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
466 P1 = P[3];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
467 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
468
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
469 for (bitmask = 0x80; bitmask != 0; bitmask >>= 1) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
470
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
471 if (flags & bitmask)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
472 *sg_output_plane++ = P0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
473 else
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
474 *sg_output_plane++ = P1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
475 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
476 sg_output_plane += sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
477 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
478 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
479 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
480
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
481 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
482 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
483 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
484
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
485 static int ipvideo_decode_block_opcode_0x9(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
486 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
487 int x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
488 unsigned char P[4];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
489 unsigned int flags = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
490 int shifter = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
491 unsigned char pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
492
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
493 /* 4-color encoding */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
494 CHECK_STREAM_PTR(4);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
495
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
496 for (y = 0; y < 4; y++)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
497 P[y] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
498
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
499 if ((P[0] <= P[1]) && (P[2] <= P[3])) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
500
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
501 /* 1 of 4 colors for each pixel, need 16 more bytes */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
502 CHECK_STREAM_PTR(16);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
503
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
504 for (y = 0; y < 8; y++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
505 /* get the next set of 8 2-bit flags */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
506 flags = (sg_stream_ptr[0] << 8) | sg_stream_ptr[1];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
507 sg_stream_ptr += 2;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
508 for (x = 0, shifter = 14; x < 8; x++, shifter -= 2) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
509 *sg_output_plane++ = P[(flags >> shifter) & 0x03];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
510 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
511 sg_output_plane += sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
512 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
513
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
514 } else if ((P[0] <= P[1]) && (P[2] > P[3])) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
515
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
516 /* 1 of 4 colors for each 2x2 block, need 4 more bytes */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
517 CHECK_STREAM_PTR(4);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
518
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
519 flags = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
520 flags = (flags << 8) | *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
521 flags = (flags << 8) | *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
522 flags = (flags << 8) | *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
523 flags = (flags << 8) | *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
524 shifter = 30;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
525
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
526 for (y = 0; y < 8; y += 2) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
527 for (x = 0; x < 8; x += 2, shifter -= 2) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
528 pix = P[(flags >> shifter) & 0x03];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
529 *(sg_output_plane + x) = pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
530 *(sg_output_plane + x + 1) = pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
531 *(sg_output_plane + sg_stride + x) = pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
532 *(sg_output_plane + sg_stride + x + 1) = pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
533 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
534 sg_output_plane += sg_stride * 2;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
535 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
536
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
537 } else if ((P[0] > P[1]) && (P[2] <= P[3])) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
538
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
539 /* 1 of 4 colors for each 2x1 block, need 8 more bytes */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
540 CHECK_STREAM_PTR(8);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
541
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
542 for (y = 0; y < 8; y++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
543 /* time to reload flags? */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
544 if ((y == 0) || (y == 4)) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
545 flags = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
546 flags = (flags << 8) | *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
547 flags = (flags << 8) | *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
548 flags = (flags << 8) | *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
549 flags = (flags << 8) | *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
550 shifter = 30;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
551 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
552 for (x = 0; x < 8; x += 2, shifter -= 2) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
553 pix = P[(flags >> shifter) & 0x03];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
554 *(sg_output_plane + x) = pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
555 *(sg_output_plane + x + 1) = pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
556 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
557 sg_output_plane += sg_stride;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
558 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
559
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
560 } else {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
561
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
562 /* 1 of 4 colors for each 1x2 block, need 8 more bytes */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
563 CHECK_STREAM_PTR(8);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
564
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
565 for (y = 0; y < 8; y += 2) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
566 /* time to reload flags? */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
567 if ((y == 0) || (y == 4)) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
568 flags = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
569 flags = (flags << 8) | *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
570 flags = (flags << 8) | *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
571 flags = (flags << 8) | *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
572 flags = (flags << 8) | *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
573 shifter = 30;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
574 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
575 for (x = 0; x < 8; x++, shifter -= 2) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
576 pix = P[(flags >> shifter) & 0x03];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
577 *(sg_output_plane + x) = pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
578 *(sg_output_plane + sg_stride + x) = pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
579 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
580 sg_output_plane += sg_stride * 2;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
581 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
582 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
583
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
584 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
585 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
586 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
587
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
588 static int ipvideo_decode_block_opcode_0xA(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
589 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
590 int x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
591 unsigned char P[16];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
592 unsigned char B[16];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
593 int flags = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
594 int shifter = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
595 int index;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
596 int split;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
597 int lower_half;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
598
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
599 /* 4-color encoding for each 4x4 quadrant, or 4-color encoding on
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
600 * either top and bottom or left and right halves */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
601 CHECK_STREAM_PTR(4);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
602
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
603 for (y = 0; y < 4; y++)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
604 P[y] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
605
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
606 if (P[0] <= P[1]) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
607
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
608 /* 4-color encoding for each quadrant; need 28 more bytes */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
609 CHECK_STREAM_PTR(28);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
610
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
611 for (y = 0; y < 4; y++)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
612 B[y] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
613 for (y = 4; y < 16; y += 4) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
614 for (x = y; x < y + 4; x++)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
615 P[x] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
616 for (x = y; x < y + 4; x++)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
617 B[x] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
618 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
619
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
620 for (y = 0; y < 8; y++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
621
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
622 lower_half = (y >= 4) ? 4 : 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
623 flags = (B[y] << 8) | B[y + 8];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
624
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
625 for (x = 0, shifter = 14; x < 8; x++, shifter -= 2) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
626 split = (x >= 4) ? 8 : 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
627 index = split + lower_half + ((flags >> shifter) & 0x03);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
628 *sg_output_plane++ = P[index];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
629 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
630
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
631 sg_output_plane += sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
632 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
633
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
634 } else {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
635
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
636 /* 4-color encoding for either left and right or top and bottom
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
637 * halves; need 20 more bytes */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
638 CHECK_STREAM_PTR(20);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
639
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
640 for (y = 0; y < 8; y++)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
641 B[y] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
642 for (y = 4; y < 8; y++)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
643 P[y] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
644 for (y = 8; y < 16; y++)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
645 B[y] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
646
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
647 if (P[4] <= P[5]) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
648
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
649 /* block is divided into left and right halves */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
650 for (y = 0; y < 8; y++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
651
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
652 flags = (B[y] << 8) | B[y + 8];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
653 split = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
654
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
655 for (x = 0, shifter = 14; x < 8; x++, shifter -= 2) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
656 if (x == 4)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
657 split = 4;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
658 *sg_output_plane++ = P[split + ((flags >> shifter) & 0x03)];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
659 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
660
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
661 sg_output_plane += sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
662 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
663
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
664 } else {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
665
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
666 /* block is divided into top and bottom halves */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
667 split = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
668 for (y = 0; y < 8; y++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
669
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
670 flags = (B[y * 2] << 8) | B[y * 2 + 1];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
671 if (y == 4)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
672 split = 4;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
673
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
674 for (x = 0, shifter = 14; x < 8; x++, shifter -= 2)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
675 *sg_output_plane++ = P[split + ((flags >> shifter) & 0x03)];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
676
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
677 sg_output_plane += sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
678 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
679 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
680 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
681
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
682 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
683 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
684 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
685
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
686 static int ipvideo_decode_block_opcode_0xB(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
687 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
688 int x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
689
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
690 /* 64-color encoding (each pixel in block is a different color) */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
691 CHECK_STREAM_PTR(64);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
692
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
693 for (y = 0; y < 8; y++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
694 for (x = 0; x < 8; x++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
695 *sg_output_plane++ = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
696 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
697 sg_output_plane += sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
698 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
699
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
700 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
701 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
702 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
703
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
704 static int ipvideo_decode_block_opcode_0xC(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
705 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
706 int x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
707 unsigned char pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
708
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
709 /* 16-color block encoding: each 2x2 block is a different color */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
710 CHECK_STREAM_PTR(16);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
711
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
712 for (y = 0; y < 8; y += 2) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
713 for (x = 0; x < 8; x += 2) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
714 pix = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
715 *(sg_output_plane + x) = pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
716 *(sg_output_plane + x + 1) = pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
717 *(sg_output_plane + sg_stride + x) = pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
718 *(sg_output_plane + sg_stride + x + 1) = pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
719 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
720 sg_output_plane += sg_stride * 2;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
721 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
722
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
723 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
724 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
725 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
726
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
727 static int ipvideo_decode_block_opcode_0xD(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
728 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
729 int x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
730 unsigned char P[4];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
731 unsigned char index = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
732
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
733 /* 4-color block encoding: each 4x4 block is a different color */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
734 CHECK_STREAM_PTR(4);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
735
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
736 for (y = 0; y < 4; y++)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
737 P[y] = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
738
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
739 for (y = 0; y < 8; y++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
740 if (y < 4)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
741 index = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
742 else
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
743 index = 2;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
744
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
745 for (x = 0; x < 8; x++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
746 if (x == 4)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
747 index++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
748 *sg_output_plane++ = P[index];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
749 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
750 sg_output_plane += sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
751 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
752
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
753 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
754 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
755 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
756
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
757 static int ipvideo_decode_block_opcode_0xE(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
758 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
759 int x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
760 unsigned char pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
761
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
762 /* 1-color encoding: the whole block is 1 solid color */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
763 CHECK_STREAM_PTR(1);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
764 pix = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
765
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
766 for (y = 0; y < 8; y++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
767 for (x = 0; x < 8; x++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
768 *sg_output_plane++ = pix;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
769 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
770 sg_output_plane += sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
771 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
772
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
773 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
774 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
775 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
776
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
777 static int ipvideo_decode_block_opcode_0xF(void)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
778 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
779 int x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
780 unsigned char sample0, sample1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
781
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
782 /* dithered encoding */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
783 CHECK_STREAM_PTR(2);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
784 sample0 = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
785 sample1 = *sg_stream_ptr++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
786
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
787 for (y = 0; y < 8; y++) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
788 for (x = 0; x < 8; x += 2) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
789 if (y & 1) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
790 *sg_output_plane++ = sample1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
791 *sg_output_plane++ = sample0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
792 } else {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
793 *sg_output_plane++ = sample0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
794 *sg_output_plane++ = sample1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
795 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
796 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
797 sg_output_plane += sg_line_inc;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
798 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
799
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
800 /* report success */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
801 return 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
802 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
803
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
804 static int (*ipvideo_decode_block[16])(void);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
805
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
806 static void ipvideo_decode_opcodes(IpvideoContext *s)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
807 {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
808 int x, y;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
809 int index = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
810 unsigned char opcode;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
811 int ret;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
812 int code_counts[16];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
813 static int frame = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
814
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
815 debug_interplay("------------------ frame %d\n", frame);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
816 frame++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
817
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
818 for (x = 0; x < 16; x++)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
819 code_counts[x] = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
820
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
821 /* this is PAL8, so make the palette available */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
822 if (s->avctx->pix_fmt == PIX_FMT_PAL8)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
823 memcpy(s->current_frame.data[1], s->palette, PALETTE_COUNT * 4);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
824
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
825 switch (s->avctx->pix_fmt) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
826
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
827 case PIX_FMT_PAL8:
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
828 sg_stride = s->current_frame.linesize[0];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
829 sg_stream_ptr = s->buf + 14; /* data starts 14 bytes in */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
830 sg_stream_end = s->buf + s->size;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
831 sg_line_inc = sg_stride - 8;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
832 sg_current_plane = s->current_frame.data[0];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
833 sg_last_plane = s->last_frame.data[0];
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
834 sg_upper_motion_limit_offset = (s->avctx->height - 8) * sg_stride
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
835 + s->avctx->width - 8;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
836 sg_dsp = s->dsp;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
837
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
838 for (y = 0; y < (sg_stride * s->avctx->height); y += sg_stride * 8) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
839 for (x = y; x < y + s->avctx->width; x += 8) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
840 /* bottom nibble first, then top nibble (which makes it
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
841 * hard to use a GetBitcontext) */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
842 if (index & 1)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
843 opcode = s->decoding_map[index >> 1] >> 4;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
844 else
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
845 opcode = s->decoding_map[index >> 1] & 0xF;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
846 index++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
847
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
848 debug_interplay(" block @ (%3d, %3d): encoding 0x%X, data ptr @ %p\n",
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
849 x - y, y / sg_stride, opcode, sg_stream_ptr);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
850 code_counts[opcode]++;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
851
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
852 sg_output_plane = sg_current_plane + x;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
853 ret = ipvideo_decode_block[opcode]();
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
854 if (ret != 0) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
855 printf(" Interplay video: decode problem on frame %d, @ block (%d, %d)\n",
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
856 frame, x - y, y / sg_stride);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
857 return;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
858 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
859 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
860 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
861 if ((sg_stream_ptr != sg_stream_end) &&
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
862 (sg_stream_ptr + 1 != sg_stream_end)) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
863 printf (" Interplay video: decode finished with %d bytes left over\n",
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
864 sg_stream_end - sg_stream_ptr);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
865 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
866 break;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
867
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
868 default:
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
869 printf ("Interplay video: Unhandled video format\n");
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
870 break;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
871 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
872
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
873 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
874
1439
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
875 static int ipvideo_decode_init(AVCodecContext *avctx)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
876 {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
877 IpvideoContext *s = avctx->priv_data;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
878
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
879 s->avctx = avctx;
1468
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
880
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
881 if (s->avctx->extradata_size != sizeof(AVPaletteControl)) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
882 printf (" Interplay video: expected extradata_size of %d\n",
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
883 sizeof(AVPaletteControl));
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
884 return -1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
885 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
886
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
887 avctx->pix_fmt = PIX_FMT_PAL8;
1439
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
888 avctx->has_b_frames = 0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
889 dsputil_init(&s->dsp, avctx);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
890
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
891 s->first_frame = 1;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
892
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
893 /* decoding map contains 4 bits of information per 8x8 block */
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
894 s->decoding_map_size = avctx->width * avctx->height / (8 * 8 * 2);
1468
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
895
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
896 /* assign block decode functions */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
897 ipvideo_decode_block[0x0] = ipvideo_decode_block_opcode_0x0_0x1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
898 ipvideo_decode_block[0x1] = ipvideo_decode_block_opcode_0x0_0x1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
899 ipvideo_decode_block[0x2] = ipvideo_decode_block_opcode_0x2;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
900 ipvideo_decode_block[0x3] = ipvideo_decode_block_opcode_0x3;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
901 ipvideo_decode_block[0x4] = ipvideo_decode_block_opcode_0x4;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
902 ipvideo_decode_block[0x5] = ipvideo_decode_block_opcode_0x5;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
903 ipvideo_decode_block[0x6] = ipvideo_decode_block_opcode_0x6;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
904 ipvideo_decode_block[0x7] = ipvideo_decode_block_opcode_0x7;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
905 ipvideo_decode_block[0x8] = ipvideo_decode_block_opcode_0x8;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
906 ipvideo_decode_block[0x9] = ipvideo_decode_block_opcode_0x9;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
907 ipvideo_decode_block[0xA] = ipvideo_decode_block_opcode_0xA;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
908 ipvideo_decode_block[0xB] = ipvideo_decode_block_opcode_0xB;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
909 ipvideo_decode_block[0xC] = ipvideo_decode_block_opcode_0xC;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
910 ipvideo_decode_block[0xD] = ipvideo_decode_block_opcode_0xD;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
911 ipvideo_decode_block[0xE] = ipvideo_decode_block_opcode_0xE;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
912 ipvideo_decode_block[0xF] = ipvideo_decode_block_opcode_0xF;
1439
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
913
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
914 return 0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
915 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
916
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
917 static int ipvideo_decode_frame(AVCodecContext *avctx,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
918 void *data, int *data_size,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
919 uint8_t *buf, int buf_size)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
920 {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
921 IpvideoContext *s = avctx->priv_data;
1468
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
922 AVPaletteControl *palette_control = (AVPaletteControl *)avctx->extradata;
1439
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
923
1468
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
924 if (palette_control->palette_changed) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
925 /* load the new palette and reset the palette control */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
926 ipvideo_new_palette(s, palette_control->palette);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
927 palette_control->palette_changed = 0;
1439
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
928 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
929
1468
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
930 s->decoding_map = buf;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
931 s->buf = buf + s->decoding_map_size;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
932 s->size = buf_size - s->decoding_map_size;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
933
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
934 if (avctx->get_buffer(avctx, &s->current_frame)) {
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
935 printf (" Interplay Video: get_buffer() failed\n");
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
936 return -1;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
937 }
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
938
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
939 ipvideo_decode_opcodes(s);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
940
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
941 /* release the last frame if it is allocated */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
942 if (s->first_frame)
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
943 s->first_frame = 0;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
944 else
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
945 avctx->release_buffer(avctx, &s->last_frame);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
946
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
947 /* shuffle frames */
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
948 s->last_frame = s->current_frame;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
949
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
950 *data_size = sizeof(AVFrame);
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
951 *(AVFrame*)data = s->current_frame;
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
952
92c1f24f7754 initial Interplay video decoder
tmmm
parents: 1439
diff changeset
953 /* report that the buffer was completely consumed */
1439
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
954 return buf_size;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
955 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
956
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
957 static int ipvideo_decode_end(AVCodecContext *avctx)
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
958 {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
959 IpvideoContext *s = avctx->priv_data;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
960
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
961 /* release the last frame */
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
962 avctx->release_buffer(avctx, &s->last_frame);
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
963
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
964 return 0;
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
965 }
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
966
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
967 AVCodec interplay_video_decoder = {
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
968 "interplayvideo",
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
969 CODEC_TYPE_VIDEO,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
970 CODEC_ID_INTERPLAY_VIDEO,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
971 sizeof(IpvideoContext),
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
972 ipvideo_decode_init,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
973 NULL,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
974 ipvideo_decode_end,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
975 ipvideo_decode_frame,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
976 CODEC_CAP_DR1,
a4d00b1f0271 initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff changeset
977 };