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