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