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