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