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