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