| @@ -145,38 +145,6 @@ static av_always_inline void lift(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, · 144 unmodified lines |
| 145 | inverse); | 145 | inverse); |
| 146 | } | 146 | } |
| 147 | | 147 | |
| 148 | static av_always_inline void inv_lift(IDWTELEM *dst, IDWTELEM *src, IDWTELEM *ref, | | |
| 149 | int dst_step, int src_step, int ref_step, | | |
| 150 | int width, int mul, int add, int shift, | | |
| 151 | int highpass, int inverse) | | |
| 152 | { | | |
| 153 | const int mirror_left = !highpass; | | |
| 154 | const int mirror_right = (width & 1) ^ highpass; | | |
| 155 | const int w = (width >> 1) - 1 + (highpass & width); | | |
| 156 | int i; | | |
| 157 | | | |
| 158 | #define LIFT(src, ref, inv) ((src) + ((inv) ? -(ref) : +(ref))) | | |
| 159 | if (mirror_left) { | | |
| 160 | dst[0] = LIFT(src[0], ((mul * 2 * ref[0] + add) >> shift), inverse); | | |
| 161 | dst += dst_step; | | |
| 162 | src += src_step; | | |
| 163 | } | | |
| 164 | | | |
| 165 | for (i = 0; i < w; i++) | | |
| 166 | dst[i * dst_step] = LIFT(src[i * src_step], | | |
| 167 | ((mul * (ref[i * ref_step] + | | |
| 168 | ref[(i + 1) * ref_step]) + | | |
| 169 | add) >> shift), | | |
| 170 | inverse); | | |
| 171 | | | |
| 172 | if (mirror_right) { | | |
| 173 | dst[w * dst_step] = LIFT(src[w * src_step], | | |
| 174 | ((mul * 2 * ref[w * ref_step] + add) >> shift), | | |
| 175 | inverse); | | |
| 176 | } | | |
| 177 | } | | |
| 178 | | | |
| 179 | #ifndef liftS | | |
| 180 | static av_always_inline void liftS(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, | 148 | static av_always_inline void liftS(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, |
| 181 | int dst_step, int src_step, int ref_step, | 149 | int dst_step, int src_step, int ref_step, |
| 182 | int width, int mul, int add, int shift, | 150 | int width, int mul, int add, int shift, |
| @@ -210,40 +178,6 @@ static av_always_inline void liftS(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, · 27 unmodified lines |
| 210 | inverse); | 178 | inverse); |
| 211 | } | 179 | } |
| 212 | | 180 | |
| 213 | static av_always_inline void inv_liftS(IDWTELEM *dst, IDWTELEM *src, | | |
| 214 | IDWTELEM *ref, int dst_step, | | |
| 215 | int src_step, int ref_step, | | |
| 216 | int width, int mul, int add, int shift, | | |
| 217 | int highpass, int inverse) | | |
| 218 | { | | |
| 219 | const int mirror_left = !highpass; | | |
| 220 | const int mirror_right = (width & 1) ^ highpass; | | |
| 221 | const int w = (width >> 1) - 1 + (highpass & width); | | |
| 222 | int i; | | |
| 223 | | | |
| 224 | assert(shift == 4); | | |
| 225 | #define LIFTS(src, ref, inv) \ | | |
| 226 | ((inv) ? (src) + (((ref) + 4 * (src)) >> shift) \ | | |
| 227 | : -((-16 * (src) + (ref) + add / \ | | |
| 228 | 4 + 1 + (5 << 25)) / (5 * 4) - (1 << 23))) | | |
| 229 | if (mirror_left) { | | |
| 230 | dst[0] = LIFTS(src[0], mul * 2 * ref[0] + add, inverse); | | |
| 231 | dst += dst_step; | | |
| 232 | src += src_step; | | |
| 233 | } | | |
| 234 | | | |
| 235 | for (i = 0; i < w; i++) | | |
| 236 | dst[i * dst_step] = LIFTS(src[i * src_step], | | |
| 237 | mul * (ref[i * ref_step] + | | |
| 238 | ref[(i + 1) * ref_step]) + add, | | |
| 239 | inverse); | | |
| 240 | | | |
| 241 | if (mirror_right) | | |
| 242 | dst[w * dst_step] = LIFTS(src[w * src_step], | | |
| 243 | mul * 2 * ref[w * ref_step] + add, inverse); | | |
| 244 | } | | |
| 245 | #endif /* ! liftS */ | | |
| 246 | | | |
| 247 | static void horizontal_decompose53i(DWTELEM *b, DWTELEM *temp, int width) | 181 | static void horizontal_decompose53i(DWTELEM *b, DWTELEM *temp, int width) |
| 248 | { | 182 | { |
| 249 | const int width2 = width >> 1; | 183 | const int width2 = width >> 1; |
| @@ -256,41 +190,8 @@ static void horizontal_decompose53i(DWTELEM *b, DWTELEM *temp, int width) · 6 unmodified lines |
| 256 | } | 190 | } |
| 257 | if (width & 1) | 191 | if (width & 1) |
| 258 | temp[x] = b[2 * x]; | 192 | temp[x] = b[2 * x]; |
| 259 | #if 0 | | |
| 260 | { | | |
| 261 | int A1, A2, A3, A4; | | |
| 262 | A2 = temp[1]; | | |
| 263 | A4 = temp[0]; | | |
| 264 | A1 = temp[0 + width2]; | | |
| 265 | A1 -= (A2 + A4) >> 1; | | |
| 266 | A4 += (A1 + 1) >> 1; | | |
| 267 | b[0 + width2] = A1; | | |
| 268 | b[0] = A4; | | |
| 269 | for (x = 1; x + 1 < width2; x += 2) { | | |
| 270 | A3 = temp[x + width2]; | | |
| 271 | A4 = temp[x + 1]; | | |
| 272 | A3 -= (A2 + A4) >> 1; | | |
| 273 | A2 += (A1 + A3 + 2) >> 2; | | |
| 274 | b[x + width2] = A3; | | |
| 275 | b[x] = A2; | | |
| 276 | | | |
| 277 | A1 = temp[x + 1 + width2]; | | |
| 278 | A2 = temp[x + 2]; | | |
| 279 | A1 -= (A2 + A4) >> 1; | | |
| 280 | A4 += (A1 + A3 + 2) >> 2; | | |
| 281 | b[x + 1 + width2] = A1; | | |
| 282 | b[x + 1] = A4; | | |
| 283 | } | | |
| 284 | A3 = temp[width - 1]; | | |
| 285 | A3 -= A2; | | |
| 286 | A2 += (A1 + A3 + 2) >> 2; | | |
| 287 | b[width - 1] = A3; | | |
| 288 | b[width2 - 1] = A2; | | |
| 289 | } | | |
| 290 | #else | | |
| 291 | lift(b + w2, temp + w2, temp, 1, 1, 1, width, -1, 0, 1, 1, 0); | 193 | lift(b + w2, temp + w2, temp, 1, 1, 1, width, -1, 0, 1, 1, 0); |
| 292 | lift(b, temp, b + w2, 1, 1, 1, width, 1, 2, 2, 0, 0); | 194 | lift(b, temp, b + w2, 1, 1, 1, width, 1, 2, 2, 0, 0); |
| 293 | #endif /* 0 */ | | |
| 294 | } | 195 | } |
| 295 | | 196 | |
| 296 | static void vertical_decompose53iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, | 197 | static void vertical_decompose53iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, |
| @@ -371,12 +272,8 @@ static void vertical_decompose97iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, · 74 unmodified lines |
| 371 | int i; | 272 | int i; |
| 372 | | 273 | |
| 373 | for (i = 0; i < width; i++) | 274 | for (i = 0; i < width; i++) |
| 374 | #ifdef liftS | | |
| 375 | b1[i] -= (W_BM * (b0[i] + b2[i]) + W_BO) >> W_BS; | | |
| 376 | #else | | |
| 377 | b1[i] = (16 * 4 * b1[i] - 4 * (b0[i] + b2[i]) + W_BO * 5 + (5 << 27)) / | 275 | b1[i] = (16 * 4 * b1[i] - 4 * (b0[i] + b2[i]) + W_BO * 5 + (5 << 27)) / |
| 378 | (5 * 16) - (1 << 23); | 276 | (5 * 16) - (1 << 23); |
| 379 | #endif | | |
| 380 | } | 277 | } |
| 381 | | 278 | |
| 382 | static void vertical_decompose97iL1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, | 279 | static void vertical_decompose97iL1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, |
| @@ -580,15 +477,8 @@ static void av_unused spatial_compose53i(IDWTELEM *buffer, IDWTELEM *temp, · 197 unmodified lines |
| 580 | void ff_snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width) | 477 | void ff_snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width) |
| 581 | { | 478 | { |
| 582 | const int w2 = (width + 1) >> 1; | 479 | const int w2 = (width + 1) >> 1; |
| 583 | | | |
| 584 | #if 0 //maybe more understadable but slower | | |
| 585 | inv_lift(temp, b, b + w2, 2, 1, 1, width, W_DM, W_DO, W_DS, 0, 1); | | |
| 586 | inv_lift(temp + 1, b + w2, temp, 2, 1, 2, width, W_CM, W_CO, W_CS, 1, 1); | | |
| 587 | | | |
| 588 | inv_liftS(b, temp, temp + 1, 2, 2, 2, width, W_BM, W_BO, W_BS, 0, 1); | | |
| 589 | inv_lift(b + 1, temp + 1, b, 2, 2, 2, width, W_AM, W_AO, W_AS, 1, 0); | | |
| 590 | #else | | |
| 591 | int x; | 480 | int x; |
| | 481 | |
| 592 | temp[0] = b[0] - ((3 * b[w2] + 2) >> 2); | 482 | temp[0] = b[0] - ((3 * b[w2] + 2) >> 2); |
| 593 | for (x = 1; x < (width >> 1); x++) { | 483 | for (x = 1; x < (width >> 1); x++) { |
| 594 | temp[2 * x] = b[x] - ((3 * (b[x + w2 - 1] + b[x + w2]) + 4) >> 3); | 484 | temp[2 * x] = b[x] - ((3 * (b[x + w2 - 1] + b[x + w2]) + 4) >> 3); |
| @@ -610,7 +500,6 @@ void ff_snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width) · 15 unmodified lines |
| 610 | b[x - 1] = temp[x - 1] + ((3 * (b[x - 2] + b[x])) >> 1); | 500 | b[x - 1] = temp[x - 1] + ((3 * (b[x - 2] + b[x])) >> 1); |
| 611 | } else | 501 | } else |
| 612 | b[x - 1] = temp[x - 1] + 3 * b[x - 2]; | 502 | b[x - 1] = temp[x - 1] + 3 * b[x - 2]; |
| 613 | #endif | | |
| 614 | } | 503 | } |
| 615 | | 504 | |
| 616 | static void vertical_compose97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, | 505 | static void vertical_compose97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, |
| @@ -637,11 +526,7 @@ static void vertical_compose97iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, · 20 unmodified lines |
| 637 | int i; | 526 | int i; |
| 638 | | 527 | |
| 639 | for (i = 0; i < width; i++) | 528 | for (i = 0; i < width; i++) |
| 640 | #ifdef liftS | | |
| 641 | b1[i] += (W_BM * (b0[i] + b2[i]) + W_BO) >> W_BS; | | |
| 642 | #else | | |
| 643 | b1[i] += (W_BM * (b0[i] + b2[i]) + 4 * b1[i] + W_BO) >> W_BS; | 529 | b1[i] += (W_BM * (b0[i] + b2[i]) + 4 * b1[i] + W_BO) >> W_BS; |
| 644 | #endif | | |
| 645 | } | 530 | } |
| 646 | | 531 | |
| 647 | static void vertical_compose97iL1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, | 532 | static void vertical_compose97iL1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, |
| @@ -662,11 +547,7 @@ void ff_snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, · 14 unmodified lines |
| 662 | for (i = 0; i < width; i++) { | 547 | for (i = 0; i < width; i++) { |
| 663 | b4[i] -= (W_DM * (b3[i] + b5[i]) + W_DO) >> W_DS; | 548 | b4[i] -= (W_DM * (b3[i] + b5[i]) + W_DO) >> W_DS; |
| 664 | b3[i] -= (W_CM * (b2[i] + b4[i]) + W_CO) >> W_CS; | 549 | b3[i] -= (W_CM * (b2[i] + b4[i]) + W_CO) >> W_CS; |
| 665 | #ifdef liftS | | |
| 666 | b2[i] += (W_BM * (b1[i] + b3[i]) + W_BO) >> W_BS; | | |
| 667 | #else | | |
| 668 | b2[i] += (W_BM * (b1[i] + b3[i]) + 4 * b2[i] + W_BO) >> W_BS; | 550 | b2[i] += (W_BM * (b1[i] + b3[i]) + 4 * b2[i] + W_BO) >> W_BS; |
| 669 | #endif | | |
| 670 | b1[i] += (W_AM * (b0[i] + b2[i]) + W_AO) >> W_AS; | 551 | b1[i] += (W_AM * (b0[i] + b2[i]) + W_AO) >> W_AS; |
| 671 | } | 552 | } |
| 672 | } | 553 | } |