35 #define F_LFTG_ALPHA 1.586134342059924f
36 #define F_LFTG_BETA 0.052980118572961f
37 #define F_LFTG_GAMMA 0.882911075530934f
38 #define F_LFTG_DELTA 0.443506852043971f
39 #define F_LFTG_K 1.230174104914001f
40 #define F_LFTG_X 1.625732422f
47 #define I_LFTG_ALPHA 103949
48 #define I_LFTG_BETA 3472
49 #define I_LFTG_GAMMA 57862
50 #define I_LFTG_DELTA 29066
51 #define I_LFTG_K 80621
52 #define I_LFTG_X 106544
54 static inline void extend53(
int *p,
int i0,
int i1)
56 p[i0 - 1] = p[i0 + 1];
58 p[i0 - 2] = p[i0 + 2];
59 p[i1 + 1] = p[i1 - 3];
66 for (i = 1; i <= 4; i++) {
67 p[i0 - i] = p[i0 + i];
68 p[i1 + i - 1] = p[i1 - i - 1];
76 for (i = 1; i <= 4; i++) {
77 p[i0 - i] = p[i0 + i];
78 p[i1 + i - 1] = p[i1 - i - 1];
82 static void sd_1d53(
int *p,
int i0,
int i1)
91 for (i = (i0+1)/2 - 1; i < (i1+1)/2; i++)
92 p[2*i+1] -= (p[2*i] + p[2*i+2]) >> 1;
93 for (i = (i0+1)/2; i < (i1+1)/2; i++)
94 p[2*i] += (p[2*i-1] + p[2*i+1] + 2) >> 2;
114 for (lp = 0; lp < lv; lp++){
117 for (i = 0; i < lh; i++)
123 for (i = mh; i < lh; i+=2, j++)
125 for (i = 1-mh; i < lh; i+=2, j++)
131 for (lp = 0; lp < lh; lp++) {
134 for (i = 0; i < lv; i++)
140 for (i = mv; i < lv; i+=2, j++)
142 for (i = 1-mv; i < lv; i+=2, j++)
157 for (i = i0/2 - 2; i < i1/2 + 1; i++)
158 p[2*i+1] -= 1.586134 * (p[2*i] + p[2*i+2]);
159 for (i = i0/2 - 1; i < i1/2 + 1; i++)
160 p[2*i] -= 0.052980 * (p[2*i-1] + p[2*i+1]);
161 for (i = i0/2 - 1; i < i1/2; i++)
162 p[2*i+1] += 0.882911 * (p[2*i] + p[2*i+2]);
163 for (i = i0/2; i < i1/2; i++)
164 p[2*i] += 0.443506 * (p[2*i-1] + p[2*i+1]);
184 for (lp = 0; lp < lv; lp++){
187 for (i = 0; i < lh; i++)
193 for (i = mh; i < lh; i+=2, j++)
195 for (i = 1-mh; i < lh; i+=2, j++)
201 for (lp = 0; lp < lh; lp++) {
204 for (i = 0; i < lv; i++)
210 for (i = mv; i < lv; i+=2, j++)
212 for (i = 1-mv; i < lv; i+=2, j++)
228 for (i = i0/2 - 2; i < i1/2 + 1; i++)
229 p[2 * i + 1] -= (
I_LFTG_ALPHA * (p[2 * i] + p[2 * i + 2]) + (1 << 15)) >> 16;
230 for (i = i0/2 - 1; i < i1/2 + 1; i++)
231 p[2 * i] -= (
I_LFTG_BETA * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16;
232 for (i = i0/2 - 1; i < i1/2; i++)
233 p[2 * i + 1] += (
I_LFTG_GAMMA * (p[2 * i] + p[2 * i + 2]) + (1 << 15)) >> 16;
234 for (i = i0/2; i < i1/2; i++)
235 p[2 * i] += (
I_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16;
255 for (lp = 0; lp < lv; lp++){
258 for (i = 0; i < lh; i++)
264 for (i = mh; i < lh; i+=2, j++)
265 t[w*lp + j] = ((l[i] *
I_LFTG_X) + (1 << 16)) >> 17;
266 for (i = 1-mh; i < lh; i+=2, j++)
267 t[w*lp + j] = ((l[i] *
I_LFTG_K) + (1 << 16)) >> 17;
272 for (lp = 0; lp < lh; lp++) {
275 for (i = 0; i < lv; i++)
281 for (i = mv; i < lv; i+=2, j++)
282 t[w*j + lp] = ((l[i] *
I_LFTG_X) + (1 << 16)) >> 17;
283 for (i = 1-mv; i < lv; i+=2, j++)
284 t[w*j + lp] = ((l[i] *
I_LFTG_K) + (1 << 16)) >> 17;
298 for (i = i0 / 2; i < i1 / 2 + 1; i++)
299 p[2 * i] -= (p[2 * i - 1] + p[2 * i + 1] + 2) >> 2;
300 for (i = i0 / 2; i < i1 / 2; i++)
301 p[2 * i + 1] += (p[2 * i] + p[2 * i + 2]) >> 1;
321 for (lp = 0; lp < lv; lp++) {
324 for (i = mh; i < lh; i += 2, j++)
325 l[i] = t[w * lp + j];
326 for (i = 1 - mh; i < lh; i += 2, j++)
327 l[i] = t[w * lp + j];
331 for (i = 0; i < lh; i++)
332 t[w * lp + i] = l[i];
337 for (lp = 0; lp < lh; lp++) {
340 for (i = mv; i < lv; i += 2, j++)
341 l[i] = t[w * j + lp];
342 for (i = 1 - mv; i < lv; i += 2, j++)
343 l[i] = t[w * j + lp];
347 for (i = 0; i < lv; i++)
348 t[w * i + lp] = l[i];
362 for (i = i0 / 2 - 1; i < i1 / 2 + 2; i++)
363 p[2 * i] -=
F_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]);
365 for (i = i0 / 2 - 1; i < i1 / 2 + 1; i++)
366 p[2 * i + 1] -=
F_LFTG_GAMMA * (p[2 * i] + p[2 * i + 2]);
368 for (i = i0 / 2; i < i1 / 2 + 1; i++)
369 p[2 * i] +=
F_LFTG_BETA * (p[2 * i - 1] + p[2 * i + 1]);
371 for (i = i0 / 2; i < i1 / 2; i++)
372 p[2 * i + 1] +=
F_LFTG_ALPHA * (p[2 * i] + p[2 * i + 2]);
393 for (lp = 0; lp < lv; lp++) {
396 for (i = mh; i < lh; i += 2, j++)
398 for (i = 1 - mh; i < lh; i += 2, j++)
403 for (i = 0; i < lh; i++)
404 data[w * lp + i] = l[i];
409 for (lp = 0; lp < lh; lp++) {
412 for (i = mv; i < lv; i += 2, j++)
414 for (i = 1 - mv; i < lv; i += 2, j++)
419 for (i = 0; i < lv; i++)
420 data[w * i + lp] = l[i];
434 for (i = i0 / 2 - 1; i < i1 / 2 + 2; i++)
435 p[2 * i] -= (
I_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16;
437 for (i = i0 / 2 - 1; i < i1 / 2 + 1; i++)
438 p[2 * i + 1] -= (
I_LFTG_GAMMA * (p[2 * i] + p[2 * i + 2]) + (1 << 15)) >> 16;
440 for (i = i0 / 2; i < i1 / 2 + 1; i++)
441 p[2 * i] += (
I_LFTG_BETA * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16;
443 for (i = i0 / 2; i < i1 / 2; i++)
444 p[2 * i + 1] += (
I_LFTG_ALPHA * (p[2 * i] + p[2 * i + 2]) + (1 << 15)) >> 16;
465 for (lp = 0; lp < lv; lp++) {
468 for (i = mh; i < lh; i += 2, j++)
469 l[i] = ((data[w * lp + j] *
I_LFTG_K) + (1 << 15)) >> 16;
470 for (i = 1 - mh; i < lh; i += 2, j++)
471 l[i] = ((data[w * lp + j] *
I_LFTG_X) + (1 << 15)) >> 16;
475 for (i = 0; i < lh; i++)
476 data[w * lp + i] = l[i];
481 for (lp = 0; lp < lh; lp++) {
484 for (i = mv; i < lv; i += 2, j++)
485 l[i] = ((data[w * j + lp] *
I_LFTG_K) + (1 << 15)) >> 16;
486 for (i = 1 - mv; i < lv; i += 2, j++)
487 l[i] = ((data[w * j + lp] *
I_LFTG_X) + (1 << 15)) >> 16;
491 for (i = 0; i < lv; i++)
492 data[w * i + lp] = l[i];
498 int decomp_levels,
int type)
500 int i, j, lev = decomp_levels, maxlen,
506 for (i = 0; i < 2; i++)
507 for (j = 0; j < 2; j++)
508 b[i][j] = border[i][j];
510 maxlen =
FFMAX(b[0][1] - b[0][0],
513 for (i = 0; i < 2; i++) {
514 s->
linelen[lev][i] = b[i][1] - b[i][0];
515 s->
mod[lev][i] = b[i][0] & 1;
516 for (j = 0; j < 2; j++)
517 b[i][j] = (b[i][j] + 1) >> 1;