annotate indeo3.c @ 1190:60bd91a6e218 libavcodec

native Indeo3 decoder implementation
author tmmm
date Tue, 15 Apr 2003 10:12:38 +0000
parents
children cae31b22b14e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1190
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1 /*
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
2 * Intel Indeo 3 (IV31, IV32, etc.) video decoder for ffmpeg
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
3 * written, produced, and directed by Alan Smithee
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
4 *
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
9 *
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
13 * Lesser General Public License for more details.
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
14 *
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
18 */
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
19
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
20 #include <stdio.h>
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
21 #include <stdlib.h>
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
22 #include <string.h>
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
23 #include <unistd.h>
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
24
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
25 #include "common.h"
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
26 #include "avcodec.h"
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
27 #include "dsputil.h"
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
28 #include "mpegvideo.h"
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
29 #include "bswap.h"
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
30
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
31 #include "indeo3data.h"
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
32
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
33 typedef struct
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
34 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
35 unsigned char *Ybuf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
36 unsigned char *Ubuf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
37 unsigned char *Vbuf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
38 unsigned char *the_buf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
39 unsigned int the_buf_size;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
40 unsigned short y_w, y_h;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
41 unsigned short uv_w, uv_h;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
42 } YUVBufs;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
43
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
44 typedef struct Indeo3DecodeContext {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
45 AVCodecContext *avctx;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
46 int width, height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
47 AVFrame frame;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
48
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
49 YUVBufs iv_frame[2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
50 YUVBufs *cur_frame;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
51 YUVBufs *ref_frame;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
52
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
53 unsigned char *ModPred;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
54 unsigned short *corrector_type;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
55 } Indeo3DecodeContext;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
56
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
57 static int corrector_type_0[24] = {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
58 195, 159, 133, 115, 101, 93, 87, 77,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
59 195, 159, 133, 115, 101, 93, 87, 77,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
60 128, 79, 79, 79, 79, 79, 79, 79
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
61 };
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
62
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
63 static int corrector_type_2[8] = { 9, 7, 6, 8, 5, 4, 3, 2 };
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
64
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
65 static void build_modpred(Indeo3DecodeContext *s)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
66 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
67 int i, j;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
68
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
69 s->ModPred = (unsigned char *) av_malloc (8 * 128);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
70
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
71 for (i=0; i < 128; ++i) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
72 s->ModPred[i+0*128] = (i > 126) ? 254 : 2*((i + 1) - ((i + 1) % 2));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
73 s->ModPred[i+1*128] = (i == 7) ? 20 : ((i == 119 || i == 120)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
74 ? 236 : 2*((i + 2) - ((i + 1) % 3)));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
75 s->ModPred[i+2*128] = (i > 125) ? 248 : 2*((i + 2) - ((i + 2) % 4));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
76 s->ModPred[i+3*128] = 2*((i + 1) - ((i - 3) % 5));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
77 s->ModPred[i+4*128] = (i == 8) ? 20 : 2*((i + 1) - ((i - 3) % 6));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
78 s->ModPred[i+5*128] = 2*((i + 4) - ((i + 3) % 7));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
79 s->ModPred[i+6*128] = (i > 123) ? 240 : 2*((i + 4) - ((i + 4) % 8));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
80 s->ModPred[i+7*128] = 2*((i + 5) - ((i + 4) % 9));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
81 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
82
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
83 s->corrector_type = (unsigned short *) av_malloc (24 * 256 * sizeof(unsigned short));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
84
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
85 for (i=0; i < 24; ++i) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
86 for (j=0; j < 256; ++j) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
87 s->corrector_type[i*256+j] = (j < corrector_type_0[i])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
88 ? 1 : ((j < 248 || (i == 16 && j == 248))
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
89 ? 0 : corrector_type_2[j - 248]);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
90 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
91 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
92 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
93
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
94 static void iv_Decode_Chunk(Indeo3DecodeContext *s, unsigned char *cur,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
95 unsigned char *ref, int width, int height, unsigned char *buf1,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
96 long fflags2, unsigned char *hdr,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
97 unsigned char *buf2, int min_width_160);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
98
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
99 #define min(a,b) ((a) < (b) ? (a) : (b))
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
100
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
101 /* ---------------------------------------------------------------------- */
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
102 static void iv_alloc_frames(Indeo3DecodeContext *s)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
103 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
104 int luma_width, luma_height, luma_pixels, chroma_width, chroma_height,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
105 chroma_pixels, bufsize, i;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
106
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
107 luma_width = (s->width + 15) & -0x10;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
108 luma_height = (s->height + 15) & -0x10;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
109
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
110 s->iv_frame[0].y_w = s->iv_frame[0].y_h =
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
111 s->iv_frame[0].the_buf_size = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
112 s->iv_frame[1].y_w = s->iv_frame[1].y_h =
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
113 s->iv_frame[1].the_buf_size = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
114 s->iv_frame[1].the_buf = NULL;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
115
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
116 chroma_width = luma_width >> 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
117 chroma_height = luma_height >> 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
118 luma_pixels = luma_width * luma_height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
119 chroma_pixels = chroma_width * chroma_height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
120
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
121 bufsize = luma_pixels * 2 + luma_width * 3 +
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
122 (chroma_pixels + chroma_width) * 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
123
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
124 if((s->iv_frame[0].the_buf =
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
125 (s->iv_frame[0].the_buf_size == 0 ? av_malloc(bufsize) :
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
126 av_realloc(s->iv_frame[0].the_buf, bufsize))) == NULL)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
127 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
128 s->iv_frame[0].y_w = s->iv_frame[1].y_w = luma_width;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
129 s->iv_frame[0].y_h = s->iv_frame[1].y_h = luma_height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
130 s->iv_frame[0].uv_w = s->iv_frame[1].uv_w = chroma_width;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
131 s->iv_frame[0].uv_h = s->iv_frame[1].uv_h = chroma_height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
132 s->iv_frame[0].the_buf_size = bufsize;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
133
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
134 s->iv_frame[0].Ybuf = s->iv_frame[0].the_buf + luma_width;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
135 i = luma_pixels + luma_width * 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
136 s->iv_frame[1].Ybuf = s->iv_frame[0].the_buf + i;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
137 i += (luma_pixels + luma_width);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
138 s->iv_frame[0].Ubuf = s->iv_frame[0].the_buf + i;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
139 i += (chroma_pixels + chroma_width);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
140 s->iv_frame[1].Ubuf = s->iv_frame[0].the_buf + i;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
141 i += (chroma_pixels + chroma_width);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
142 s->iv_frame[0].Vbuf = s->iv_frame[0].the_buf + i;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
143 i += (chroma_pixels + chroma_width);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
144 s->iv_frame[1].Vbuf = s->iv_frame[0].the_buf + i;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
145
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
146 for(i = 1; i <= luma_width; i++)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
147 s->iv_frame[0].Ybuf[-i] = s->iv_frame[1].Ybuf[-i] =
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
148 s->iv_frame[0].Ubuf[-i] = 0x80;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
149
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
150 for(i = 1; i <= chroma_width; i++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
151 s->iv_frame[1].Ubuf[-i] = 0x80;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
152 s->iv_frame[0].Vbuf[-i] = 0x80;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
153 s->iv_frame[1].Vbuf[-i] = 0x80;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
154 s->iv_frame[1].Vbuf[chroma_pixels+i-1] = 0x80;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
155 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
156 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
157
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
158 /* ---------------------------------------------------------------------- */
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
159 static void iv_free_func(Indeo3DecodeContext *s)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
160 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
161 int i;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
162
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
163 for(i = 0 ; i < 2 ; i++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
164 if(s->iv_frame[i].the_buf != NULL)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
165 av_free(s->iv_frame[i].the_buf);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
166 s->iv_frame[i].Ybuf = s->iv_frame[i].Ubuf =
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
167 s->iv_frame[i].Vbuf = NULL;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
168 s->iv_frame[i].the_buf = NULL;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
169 s->iv_frame[i].the_buf_size = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
170 s->iv_frame[i].y_w = s->iv_frame[i].y_h = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
171 s->iv_frame[i].uv_w = s->iv_frame[i].uv_h = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
172 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
173
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
174 av_free(s->ModPred);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
175 av_free(s->corrector_type);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
176 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
177
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
178 /* ---------------------------------------------------------------------- */
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
179 static unsigned long iv_decode_frame(Indeo3DecodeContext *s,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
180 unsigned char *buf, int buf_size)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
181 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
182 unsigned int hdr_width, hdr_height,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
183 chroma_width, chroma_height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
184 unsigned long fflags1, fflags2, fflags3, offs1, offs2, offs3, offs;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
185 unsigned char *hdr_pos, *buf_pos;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
186
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
187 buf_pos = buf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
188 buf_pos += 18;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
189
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
190 fflags1 = le2me_16(*(uint16_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
191 buf_pos += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
192 fflags3 = le2me_32(*(uint32_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
193 buf_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
194 fflags2 = *buf_pos++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
195 buf_pos += 3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
196 hdr_height = le2me_16(*(uint16_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
197 buf_pos += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
198 hdr_width = le2me_16(*(uint16_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
199 buf_pos += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
200 chroma_height = ((hdr_height >> 2) + 3) & 0x7ffc;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
201 chroma_width = ((hdr_width >> 2) + 3) & 0x7ffc;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
202 offs1 = le2me_32(*(uint32_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
203 buf_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
204 offs2 = le2me_32(*(uint32_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
205 buf_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
206 offs3 = le2me_32(*(uint32_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
207 buf_pos += 8;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
208 hdr_pos = buf_pos;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
209 if(fflags3 == 0x80) return 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
210
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
211 if(fflags1 & 0x200) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
212 s->cur_frame = s->iv_frame + 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
213 s->ref_frame = s->iv_frame;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
214 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
215 s->cur_frame = s->iv_frame;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
216 s->ref_frame = s->iv_frame + 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
217 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
218
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
219 buf_pos = buf + 16 + offs1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
220 offs = le2me_32(*(uint32_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
221 buf_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
222
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
223 iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, hdr_width,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
224 hdr_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
225 min(hdr_width, 160));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
226
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
227 buf_pos = buf + 16 + offs2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
228 offs = le2me_32(*(uint32_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
229 buf_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
230
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
231 iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
232 chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
233 min(chroma_width, 40));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
234
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
235 buf_pos = buf + 16 + offs3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
236 offs = le2me_32(*(uint32_t *)buf_pos);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
237 buf_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
238
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
239 iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
240 chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
241 min(chroma_width, 40));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
242
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
243 return 8;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
244 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
245
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
246 typedef struct {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
247 long xpos;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
248 long ypos;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
249 long width;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
250 long height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
251 long split_flag;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
252 long split_direction;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
253 long usl7;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
254 } ustr_t;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
255
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
256 /* ---------------------------------------------------------------------- */
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
257
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
258 static void iv_Decode_Chunk(Indeo3DecodeContext *s,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
259 unsigned char *cur, unsigned char *ref, int width, int height,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
260 unsigned char *buf1, long fflags2, unsigned char *hdr,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
261 unsigned char *buf2, int min_width_160)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
262 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
263 unsigned char bit_buf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
264 unsigned long bit_pos, lv, lv1, lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
265 long *width_tbl, width_tbl_arr[10];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
266 char *ref_vectors;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
267 unsigned char *cur_frm_pos, *ref_frm_pos, *cp, *cp2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
268 unsigned long *cur_lp, *ref_lp, *correction_lp[2], *correctionloworder_lp[2],
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
269 *correctionhighorder_lp[2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
270 unsigned short *correction_type_sp[2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
271 ustr_t xustr[20], *ptr_ustr;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
272 int i, j, k, lp1, lp2, flag1, cmd, blks_width, blks_height, region_160_width,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
273 rle_v1, rle_v2, rle_v3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
274
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
275 bit_buf = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
276 ref_vectors = NULL;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
277
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
278 width_tbl = width_tbl_arr + 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
279 i = (width < 0 ? width + 3 : width)/4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
280 for(j = -1; j < 8; j++)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
281 width_tbl[j] = i * j;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
282
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
283 ptr_ustr = xustr;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
284
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
285 for(region_160_width = 0; region_160_width < (width - min_width_160); region_160_width += min_width_160);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
286
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
287 ptr_ustr->ypos = ptr_ustr->xpos = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
288 for(ptr_ustr->width = min_width_160; width > ptr_ustr->width; ptr_ustr->width *= 2);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
289 ptr_ustr->height = height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
290 ptr_ustr->split_direction = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
291 ptr_ustr->split_flag = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
292 ptr_ustr->usl7 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
293
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
294 bit_pos = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
295
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
296 rle_v1 = rle_v2 = rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
297
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
298 while(ptr_ustr >= xustr) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
299 if(bit_pos <= 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
300 bit_pos = 8;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
301 bit_buf = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
302 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
303
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
304 bit_pos -= 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
305 cmd = (bit_buf >> bit_pos) & 0x03;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
306
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
307 if(cmd == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
308 ptr_ustr++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
309 memcpy(ptr_ustr, ptr_ustr-1, sizeof(ustr_t));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
310 ptr_ustr->split_flag = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
311 ptr_ustr->split_direction = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
312 ptr_ustr->height = (ptr_ustr->height > 8 ? ((ptr_ustr->height+8)>>4)<<3 : 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
313 continue;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
314 } else if(cmd == 1) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
315 ptr_ustr++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
316 memcpy(ptr_ustr, ptr_ustr-1, sizeof(ustr_t));
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
317 ptr_ustr->split_flag = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
318 ptr_ustr->split_direction = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
319 ptr_ustr->width = (ptr_ustr->width > 8 ? ((ptr_ustr->width+8)>>4)<<3 : 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
320 continue;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
321 } else if(cmd == 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
322 if(ptr_ustr->usl7 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
323 ptr_ustr->usl7 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
324 ref_vectors = NULL;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
325 continue;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
326 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
327 } else if(cmd == 3) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
328 if(ptr_ustr->usl7 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
329 ptr_ustr->usl7 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
330 ref_vectors = buf2 + (*buf1 * 2);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
331 buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
332 continue;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
333 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
334 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
335
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
336 cur_frm_pos = cur + width * ptr_ustr->ypos + ptr_ustr->xpos;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
337
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
338 if((blks_width = ptr_ustr->width) < 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
339 blks_width += 3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
340 blks_width >>= 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
341 blks_height = ptr_ustr->height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
342
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
343 if(ref_vectors != NULL) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
344 ref_frm_pos = ref + (ref_vectors[0] + ptr_ustr->ypos) * width +
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
345 ref_vectors[1] + ptr_ustr->xpos;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
346 } else
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
347 ref_frm_pos = cur_frm_pos - width_tbl[4];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
348
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
349 if(cmd == 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
350 if(bit_pos <= 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
351 bit_pos = 8;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
352 bit_buf = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
353 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
354
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
355 bit_pos -= 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
356 cmd = (bit_buf >> bit_pos) & 0x03;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
357
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
358 if(cmd == 0 || ref_vectors != NULL) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
359 for(lp1 = 0; lp1 < blks_width; lp1++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
360 for(i = 0, j = 0; i < blks_height; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
361 ((unsigned long *)cur_frm_pos)[j] = ((unsigned long *)ref_frm_pos)[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
362 cur_frm_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
363 ref_frm_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
364 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
365 } else if(cmd != 1)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
366 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
367 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
368 k = *buf1 >> 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
369 j = *buf1 & 0x0f;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
370 buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
371 lv = j + fflags2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
372
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
373 if((lv - 8) <= 7 && (k == 0 || k == 3 || k == 10)) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
374 cp2 = s->ModPred + ((lv - 8) << 7);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
375 cp = ref_frm_pos;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
376 for(i = 0; i < blks_width << 2; i++) { *(cp++) = cp2[*cp >> 1]; }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
377 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
378
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
379 if(k == 1 || k == 4) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
380 lv = (hdr[j] & 0xf) + fflags2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
381 correction_type_sp[0] = s->corrector_type + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
382 correction_lp[0] = correction + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
383 lv = (hdr[j] >> 4) + fflags2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
384 correction_lp[1] = correction + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
385 correction_type_sp[1] = s->corrector_type + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
386 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
387 correctionloworder_lp[0] = correctionloworder_lp[1] = correctionloworder + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
388 correctionhighorder_lp[0] = correctionhighorder_lp[1] = correctionhighorder + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
389 correction_type_sp[0] = correction_type_sp[1] = s->corrector_type + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
390 correction_lp[0] = correction_lp[1] = correction + (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
391 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
392
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
393 switch(k) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
394 case 1:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
395 case 0: /********** CASE 0 **********/
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
396 for( ; blks_height > 0; blks_height -= 4) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
397 for(lp1 = 0; lp1 < blks_width; lp1++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
398 for(lp2 = 0; lp2 < 4; ) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
399 k = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
400 cur_lp = ((unsigned long *)cur_frm_pos) + width_tbl[lp2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
401 ref_lp = ((unsigned long *)ref_frm_pos) + width_tbl[lp2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
402
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
403 switch(correction_type_sp[0][k]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
404 case 0:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
405 *cur_lp = ((*ref_lp >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
406 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
407 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
408 case 1:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
409 ((unsigned short *)cur_lp)[0] = ((((unsigned short *)(ref_lp))[0] >> 1)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
410 + correction_lp[lp2 & 0x01][*buf1++]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
411 ((unsigned short *)cur_lp)[1] = ((((unsigned short *)(ref_lp))[1] >> 1)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
412 + correction_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
413 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
414 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
415 case 2:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
416 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
417 for(i = 0, j = 0; i < 2; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
418 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
419 lp2 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
420 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
421 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
422 case 3:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
423 if(lp2 < 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
424 for(i = 0, j = 0; i < (3 - lp2); i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
425 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
426 lp2 = 3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
427 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
428 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
429 case 8:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
430 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
431 if(rle_v3 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
432 rle_v2 = *buf1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
433 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
434 if(rle_v2 > 32) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
435 rle_v2 -= 32;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
436 rle_v1 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
437 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
438 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
439 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
440 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
441
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
442 if(rle_v1 == 1 || ref_vectors != NULL) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
443 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
444 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
445 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
446
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
447 rle_v2--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
448 if(rle_v2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
449 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
450 buf1 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
451 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
452 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
453 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
454 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
455 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
456 rle_v2 = *buf1 - 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
457 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
458 case 5:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
459 if(lp2 == 0 && rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
460 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
461 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
462 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
463 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
464 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
465 case 4:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
466 for(i = 0, j = 0; i < (4 - lp2); i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
467 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
468 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
469 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
470
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
471 case 7:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
472 if(rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
473 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
474 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
475 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
476 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
477 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
478 case 6:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
479 if(ref_vectors != NULL) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
480 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
481 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
482 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
483 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
484 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
485
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
486 case 9:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
487 lv1 = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
488 lv = (lv1 & 0x7F) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
489 lv += (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
490 lv += (lv << 16);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
491 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
492 cur_lp[j] = lv;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
493
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
494 if((lv1 & 0x80) != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
495 if(rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
496 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
497 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
498 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
499 buf1 -= 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
500 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
501 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
502 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
503 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
504 default:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
505 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
506 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
507 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
508
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
509 cur_frm_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
510 ref_frm_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
511 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
512
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
513 cur_frm_pos += ((width - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
514 ref_frm_pos += ((width - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
515 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
516 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
517
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
518 case 4:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
519 case 3: /********** CASE 3 **********/
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
520 if(ref_vectors != NULL)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
521 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
522 flag1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
523
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
524 for( ; blks_height > 0; blks_height -= 8) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
525 for(lp1 = 0; lp1 < blks_width; lp1++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
526 for(lp2 = 0; lp2 < 4; ) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
527 k = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
528
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
529 cur_lp = ((unsigned long *)cur_frm_pos) + width_tbl[lp2 * 2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
530 ref_lp = ((unsigned long *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
531
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
532 switch(correction_type_sp[lp2 & 0x01][k]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
533 case 0:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
534 cur_lp[width_tbl[1]] = ((*ref_lp >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
535 if(lp2 > 0 || flag1 == 0 || ptr_ustr->ypos != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
536 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
537 else
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
538 cur_lp[0] = ((*ref_lp >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
539 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
540 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
541
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
542 case 1:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
543 ((unsigned short *)cur_lp)[width_tbl[2]] =
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
544 ((((unsigned short *)ref_lp)[0] >> 1) + correction_lp[lp2 & 0x01][*buf1++]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
545 ((unsigned short *)cur_lp)[width_tbl[2]+1] =
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
546 ((((unsigned short *)ref_lp)[1] >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
547 if(lp2 > 0 || flag1 == 0 || ptr_ustr->ypos != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
548 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
549 else
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
550 cur_lp[0] = cur_lp[width_tbl[1]];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
551 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
552 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
553
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
554 case 2:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
555 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
556 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
557 cur_lp[j] = *ref_lp;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
558 lp2 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
559 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
560 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
561
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
562 case 3:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
563 if(lp2 < 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
564 for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
565 cur_lp[j] = *ref_lp;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
566 lp2 = 3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
567 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
568 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
569
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
570 case 6:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
571 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
572 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
573
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
574 case 7:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
575 if(rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
576 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
577 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
578 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
579 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
580 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
581 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
582 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
583
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
584 case 8:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
585 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
586 if(rle_v3 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
587 rle_v2 = *buf1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
588 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
589 if(rle_v2 > 32) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
590 rle_v2 -= 32;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
591 rle_v1 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
592 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
593 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
594 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
595 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
596
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
597 if(rle_v1 == 1) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
598 for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
599 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
600 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
601
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
602 rle_v2--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
603 if(rle_v2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
604 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
605 buf1 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
606 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
607 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
608 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
609 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
610 rle_v2 = (*buf1) - 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
611 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
612 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
613 case 5:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
614 if(lp2 == 0 && rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
615 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
616 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
617 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
618 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
619 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
620 case 4:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
621 for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
622 cur_lp[j] = *ref_lp;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
623 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
624 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
625
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
626 case 9:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
627 fprintf(stderr, "UNTESTED.\n");
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
628 lv1 = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
629 lv = (lv1 & 0x7F) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
630 lv += (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
631 lv += (lv << 16);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
632
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
633 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
634 cur_lp[j] = lv;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
635
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
636 if((lv1 & 0x80) != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
637 if(rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
638 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
639 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
640 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
641 buf1 -= 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
642 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
643 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
644 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
645 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
646
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
647 default:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
648 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
649 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
650 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
651
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
652 cur_frm_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
653 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
654
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
655 cur_frm_pos += (((width * 2) - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
656 flag1 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
657 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
658 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
659
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
660 case 10: /********** CASE 10 **********/
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
661 if(ref_vectors == NULL) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
662 flag1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
663
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
664 for( ; blks_height > 0; blks_height -= 8) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
665 for(lp1 = 0; lp1 < blks_width; lp1 += 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
666 for(lp2 = 0; lp2 < 4; ) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
667 k = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
668 cur_lp = ((unsigned long *)cur_frm_pos) + width_tbl[lp2 * 2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
669 ref_lp = ((unsigned long *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
670 lv1 = ref_lp[0];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
671 lv2 = ref_lp[1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
672 if(lp2 == 0 && flag1 != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
673 lv1 = lv1 & 0x00FF00FF;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
674 lv1 = (lv1 << 8) | lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
675 lv2 = lv2 & 0x00FF00FF;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
676 lv2 = (lv2 << 8) | lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
677 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
678
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
679 switch(correction_type_sp[lp2 & 0x01][k]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
680 case 0:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
681 cur_lp[width_tbl[1]] = ((lv1 >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
682 cur_lp[width_tbl[1]+1] = ((lv2 >> 1) + correctionhighorder_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
683 if(lp2 > 0 || ptr_ustr->ypos != 0 || flag1 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
684 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
685 cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
686 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
687 cur_lp[0] = cur_lp[width_tbl[1]];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
688 cur_lp[1] = cur_lp[width_tbl[1]+1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
689 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
690 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
691 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
692
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
693 case 1:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
694 cur_lp[width_tbl[1]] = ((lv1 >> 1) + correctionloworder_lp[lp2 & 0x01][*buf1++]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
695 cur_lp[width_tbl[1]+1] = ((lv2 >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
696 if(lp2 > 0 || ptr_ustr->ypos != 0 || flag1 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
697 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
698 cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
699 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
700 cur_lp[0] = cur_lp[width_tbl[1]];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
701 cur_lp[1] = cur_lp[width_tbl[1]+1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
702 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
703 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
704 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
705
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
706 case 2:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
707 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
708 if(flag1 != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
709 for(i = 0, j = width_tbl[1]; i < 3; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
710 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
711 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
712 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
713 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
714 cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
715 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
716 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
717 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
718 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
719 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
720 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
721 lp2 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
722 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
723 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
724
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
725 case 3:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
726 if(lp2 < 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
727 if(lp2 == 0 && flag1 != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
728 for(i = 0, j = width_tbl[1]; i < 5; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
729 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
730 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
731 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
732 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
733 cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
734 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
735 for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
736 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
737 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
738 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
739 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
740 lp2 = 3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
741 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
742 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
743
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
744 case 8:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
745 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
746 if(rle_v3 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
747 rle_v2 = *buf1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
748 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
749 if(rle_v2 > 32) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
750 rle_v2 -= 32;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
751 rle_v1 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
752 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
753 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
754 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
755 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
756 if(rle_v1 == 1) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
757 if(flag1 != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
758 for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
759 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
760 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
761 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
762 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
763 cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
764 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
765 for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
766 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
767 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
768 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
769 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
770 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
771 rle_v2--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
772 if(rle_v2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
773 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
774 buf1 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
775 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
776 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
777 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
778 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
779 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
780 rle_v2 = (*buf1) - 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
781 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
782 case 5:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
783 if(lp2 == 0 && rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
784 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
785 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
786 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
787 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
788 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
789 case 4:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
790 if(lp2 == 0 && flag1 != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
791 for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
792 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
793 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
794 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
795 cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
796 cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
797 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
798 for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
799 cur_lp[j] = lv1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
800 cur_lp[j+1] = lv2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
801 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
802 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
803 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
804 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
805
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
806 case 6:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
807 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
808 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
809
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
810 case 7:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
811 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
812 if(rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
813 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
814 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
815 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
816 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
817 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
818 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
819 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
820 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
821
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
822 case 9:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
823 fprintf(stderr, "UNTESTED.\n");
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
824 lv1 = *buf1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
825 lv = (lv1 & 0x7F) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
826 lv += (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
827 lv += (lv << 16);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
828 for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
829 cur_lp[j] = lv;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
830 if((lv1 & 0x80) != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
831 if(rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
832 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
833 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
834 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
835 buf1 -= 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
836 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
837 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
838 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
839 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
840
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
841 default:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
842 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
843 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
844 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
845
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
846 cur_frm_pos += 8;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
847 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
848
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
849 cur_frm_pos += (((width * 2) - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
850 flag1 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
851 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
852 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
853 for( ; blks_height > 0; blks_height -= 8) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
854 for(lp1 = 0; lp1 < blks_width; lp1 += 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
855 for(lp2 = 0; lp2 < 4; ) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
856 k = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
857 cur_lp = ((unsigned long *)cur_frm_pos) + width_tbl[lp2 * 2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
858 ref_lp = ((unsigned long *)ref_frm_pos) + width_tbl[lp2 * 2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
859
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
860 switch(correction_type_sp[lp2 & 0x01][k]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
861 case 0:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
862 lv1 = correctionloworder_lp[lp2 & 0x01][k];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
863 lv2 = correctionhighorder_lp[lp2 & 0x01][k];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
864 cur_lp[0] = ((ref_lp[0] >> 1) + lv1) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
865 cur_lp[1] = ((ref_lp[1] >> 1) + lv2) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
866 cur_lp[width_tbl[1]] = ((ref_lp[width_tbl[1]] >> 1) + lv1) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
867 cur_lp[width_tbl[1]+1] = ((ref_lp[width_tbl[1]+1] >> 1) + lv2) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
868 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
869 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
870
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
871 case 1:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
872 lv1 = correctionloworder_lp[lp2 & 0x01][*buf1++];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
873 lv2 = correctionloworder_lp[lp2 & 0x01][k];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
874 cur_lp[0] = ((ref_lp[0] >> 1) + lv1) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
875 cur_lp[1] = ((ref_lp[1] >> 1) + lv2) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
876 cur_lp[width_tbl[1]] = ((ref_lp[width_tbl[1]] >> 1) + lv1) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
877 cur_lp[width_tbl[1]+1] = ((ref_lp[width_tbl[1]+1] >> 1) + lv2) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
878 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
879 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
880
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
881 case 2:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
882 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
883 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
884 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
885 cur_lp[j+1] = ref_lp[j+1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
886 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
887 lp2 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
888 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
889 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
890
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
891 case 3:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
892 if(lp2 < 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
893 for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
894 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
895 cur_lp[j+1] = ref_lp[j+1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
896 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
897 lp2 = 3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
898 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
899 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
900
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
901 case 8:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
902 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
903 if(rle_v3 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
904 rle_v2 = *buf1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
905 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
906 if(rle_v2 > 32) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
907 rle_v2 -= 32;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
908 rle_v1 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
909 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
910 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
911 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
912 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
913 for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
914 ((unsigned long *)cur_frm_pos)[j] = ((unsigned long *)ref_frm_pos)[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
915 ((unsigned long *)cur_frm_pos)[j+1] = ((unsigned long *)ref_frm_pos)[j+1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
916 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
917 rle_v2--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
918 if(rle_v2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
919 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
920 buf1 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
921 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
922 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
923 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
924 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
925 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
926 rle_v2 = (*buf1) - 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
927 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
928 case 5:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
929 case 7:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
930 if(lp2 == 0 && rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
931 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
932 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
933 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
934 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
935 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
936 case 6:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
937 case 4:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
938 for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
939 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
940 cur_lp[j+1] = ref_lp[j+1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
941 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
942 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
943 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
944
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
945 case 9:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
946 fprintf(stderr, "UNTESTED.\n");
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
947 lv1 = *buf1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
948 lv = (lv1 & 0x7F) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
949 lv += (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
950 lv += (lv << 16);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
951 for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
952 ((unsigned long *)cur_frm_pos)[j] = ((unsigned long *)cur_frm_pos)[j+1] = lv;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
953 if((lv1 & 0x80) != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
954 if(rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
955 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
956 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
957 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
958 buf1 -= 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
959 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
960 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
961 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
962 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
963
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
964 default:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
965 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
966 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
967 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
968
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
969 cur_frm_pos += 8;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
970 ref_frm_pos += 8;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
971 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
972
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
973 cur_frm_pos += (((width * 2) - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
974 ref_frm_pos += (((width * 2) - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
975 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
976 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
977 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
978
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
979 case 11: /********** CASE 11 **********/
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
980 if(ref_vectors == NULL)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
981 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
982
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
983 for( ; blks_height > 0; blks_height -= 8) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
984 for(lp1 = 0; lp1 < blks_width; lp1++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
985 for(lp2 = 0; lp2 < 4; ) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
986 k = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
987 cur_lp = ((unsigned long *)cur_frm_pos) + width_tbl[lp2 * 2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
988 ref_lp = ((unsigned long *)ref_frm_pos) + width_tbl[lp2 * 2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
989
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
990 switch(correction_type_sp[lp2 & 0x01][k]) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
991 case 0:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
992 cur_lp[0] = ((*ref_lp >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
993 cur_lp[width_tbl[1]] = ((ref_lp[width_tbl[1]] >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
994 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
995 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
996
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
997 case 1:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
998 lv1 = (unsigned short)(correction_lp[lp2 & 0x01][*buf1++]);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
999 lv2 = (unsigned short)(correction_lp[lp2 & 0x01][k]);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1000 ((unsigned short *)cur_lp)[0] = ((((unsigned short *)ref_lp)[0] >> 1) + lv1) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1001 ((unsigned short *)cur_lp)[1] = ((((unsigned short *)ref_lp)[1] >> 1) + lv2) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1002 ((unsigned short *)cur_lp)[width_tbl[2]] = ((((unsigned short *)ref_lp)[width_tbl[2]] >> 1) + lv1) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1003 ((unsigned short *)cur_lp)[width_tbl[2]+1] = ((((unsigned short *)ref_lp)[width_tbl[2]+1] >> 1) + lv2) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1004 lp2++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1005 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1006
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1007 case 2:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1008 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1009 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1010 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1011 lp2 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1012 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1013 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1014
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1015 case 3:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1016 if(lp2 < 2) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1017 for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1018 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1019 lp2 = 3;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1020 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1021 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1022
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1023 case 8:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1024 if(lp2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1025 if(rle_v3 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1026 rle_v2 = *buf1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1027 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1028 if(rle_v2 > 32) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1029 rle_v2 -= 32;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1030 rle_v1 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1031 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1032 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1033 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1034 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1035
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1036 for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1037 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1038
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1039 rle_v2--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1040 if(rle_v2 == 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1041 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1042 buf1 += 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1043 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1044 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1045 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1046 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1047 rle_v1 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1048 rle_v2 = (*buf1) - 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1049 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1050 case 5:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1051 case 7:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1052 if(lp2 == 0 && rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1053 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1054 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1055 buf1--;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1056 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1057 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1058 case 4:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1059 case 6:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1060 for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1061 cur_lp[j] = ref_lp[j];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1062 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1063 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1064
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1065 case 9:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1066 fprintf(stderr, "UNTESTED.\n");
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1067 lv1 = *buf1++;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1068 lv = (lv1 & 0x7F) << 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1069 lv += (lv << 8);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1070 lv += (lv << 16);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1071 for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1072 cur_lp[j] = lv;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1073 if((lv1 & 0x80) != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1074 if(rle_v3 != 0)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1075 rle_v3 = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1076 else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1077 rle_v3 = 1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1078 buf1 -= 2;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1079 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1080 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1081 lp2 = 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1082 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1083
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1084 default:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1085 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1086 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1087 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1088
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1089 cur_frm_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1090 ref_frm_pos += 4;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1091 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1092
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1093 cur_frm_pos += (((width * 2) - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1094 ref_frm_pos += (((width * 2) - blks_width) * 4);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1095 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1096 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1097
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1098 default:
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1099 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1100 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1101 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1102
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1103 if(ptr_ustr < xustr)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1104 return;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1105
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1106 for( ; ptr_ustr >= xustr; ptr_ustr--) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1107 if(ptr_ustr->split_flag != 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1108 ptr_ustr->split_flag = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1109 ptr_ustr->usl7 = (ptr_ustr-1)->usl7;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1110
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1111 if(ptr_ustr->split_direction) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1112 ptr_ustr->xpos += ptr_ustr->width;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1113 ptr_ustr->width = (ptr_ustr-1)->width - ptr_ustr->width;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1114 if(region_160_width <= ptr_ustr->xpos && width < ptr_ustr->width + ptr_ustr->xpos)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1115 ptr_ustr->width = width - ptr_ustr->xpos;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1116 } else {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1117 ptr_ustr->ypos += ptr_ustr->height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1118 ptr_ustr->height = (ptr_ustr-1)->height - ptr_ustr->height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1119 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1120 break;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1121 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1122 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1123 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1124 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1125
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1126 static int indeo3_decode_init(AVCodecContext *avctx)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1127 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1128 Indeo3DecodeContext *s = avctx->priv_data;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1129
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1130 s->avctx = avctx;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1131 s->width = avctx->width;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1132 s->height = avctx->height;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1133 avctx->pix_fmt = PIX_FMT_YUV410P;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1134 avctx->has_b_frames = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1135
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1136 build_modpred(s);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1137 iv_alloc_frames(s);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1138
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1139 return 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1140 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1141
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1142 static int indeo3_decode_frame(AVCodecContext *avctx,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1143 void *data, int *data_size,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1144 unsigned char *buf, int buf_size)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1145 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1146 Indeo3DecodeContext *s=avctx->priv_data;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1147 unsigned char *src, *dest;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1148 int y;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1149
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1150 iv_decode_frame(s, buf, buf_size);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1151
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1152 s->frame.reference = 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1153 if(avctx->get_buffer(avctx, &s->frame) < 0) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1154 fprintf(stderr, "get_buffer() failed\n");
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1155 return -1;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1156 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1157
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1158 src = s->cur_frame->Ybuf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1159 dest = s->frame.data[0];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1160 for (y = 0; y < s->height; y++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1161 memcpy(dest, src, s->cur_frame->y_w);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1162 src += s->cur_frame->y_w;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1163 dest += s->frame.linesize[0];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1164 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1165
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1166 src = s->cur_frame->Ubuf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1167 dest = s->frame.data[1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1168 for (y = 0; y < s->height / 4; y++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1169 memcpy(dest, src, s->cur_frame->uv_w);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1170 src += s->cur_frame->uv_w;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1171 dest += s->frame.linesize[1];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1172 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1173
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1174 src = s->cur_frame->Vbuf;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1175 dest = s->frame.data[2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1176 for (y = 0; y < s->height / 4; y++) {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1177 memcpy(dest, src, s->cur_frame->uv_w);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1178 src += s->cur_frame->uv_w;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1179 dest += s->frame.linesize[2];
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1180 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1181
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1182 *data_size=sizeof(AVFrame);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1183 *(AVFrame*)data= s->frame;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1184
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1185 avctx->release_buffer(avctx, &s->frame);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1186
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1187 return buf_size;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1188 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1189
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1190 static int indeo3_decode_end(AVCodecContext *avctx)
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1191 {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1192 Indeo3DecodeContext *s = avctx->priv_data;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1193
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1194 iv_free_func(s);
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1195
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1196 return 0;
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1197 }
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1198
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1199 AVCodec indeo3_decoder = {
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1200 "indeo3",
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1201 CODEC_TYPE_VIDEO,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1202 CODEC_ID_INDEO3,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1203 sizeof(Indeo3DecodeContext),
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1204 indeo3_decode_init,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1205 NULL,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1206 indeo3_decode_end,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1207 indeo3_decode_frame,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1208 0,
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1209 NULL
60bd91a6e218 native Indeo3 decoder implementation
tmmm
parents:
diff changeset
1210 };