Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | |
2 | # define RENAME(N) N ## _double |
||
3 | # define DELEM double |
||
4 | # define CLIP(v) |
||
5 | |||
6 | |||
7 | # define RENAME(N) N ## _float |
||
8 | # define DELEM float |
||
9 | # define CLIP(v) |
||
10 | |||
11 | |||
12 | # define RENAME(N) N ## _int32 |
||
13 | # define DELEM int32_t |
||
14 | # define CLIP(v) v = FFMAX(FFMIN(v, INT32_MAX), INT32_MIN) |
||
15 | |||
16 | |||
17 | # define RENAME(N) N ## _int16 |
||
18 | # define DELEM int16_t |
||
19 | # define CLIP(v) v = FFMAX(FFMIN(v, INT16_MAX), INT16_MIN) |
||
20 | |||
21 | |||
22 | ERROR |
||
23 | #endif |
||
24 | |||
25 | |||
26 | int pos = s->dither.ns_pos; |
||
27 | int i, j, ch; |
||
28 | int taps = s->dither.ns_taps; |
||
29 | float S = s->dither.ns_scale; |
||
30 | float S_1 = s->dither.ns_scale_1; |
||
31 | |||
32 | |||
33 | av_assert2((taps&3) != 3 || s->dither.ns_coeffs[taps] == 0); |
||
34 | |||
35 | |||
36 | const float *noise = ((const float *)noises->ch[ch]) + s->dither.noise_pos; |
||
37 | const DELEM *src = (const DELEM*)srcs->ch[ch]; |
||
38 | DELEM *dst = (DELEM*)dsts->ch[ch]; |
||
39 | float *ns_errors = s->dither.ns_errors[ch]; |
||
40 | const float *ns_coeffs = s->dither.ns_coeffs; |
||
41 | pos = s->dither.ns_pos; |
||
42 | for (i=0; i |
||
43 | double d1, d = src[i]*S_1; |
||
44 | for(j=0; j |
||
45 | d -= ns_coeffs[j ] * ns_errors[pos + j ] |
||
46 | +ns_coeffs[j + 1] * ns_errors[pos + j + 1] |
||
47 | +ns_coeffs[j + 2] * ns_errors[pos + j + 2] |
||
48 | +ns_coeffs[j + 3] * ns_errors[pos + j + 3]; |
||
49 | } |
||
50 | if(j < taps) |
||
51 | d -= ns_coeffs[j] * ns_errors[pos + j]; |
||
52 | pos = pos ? pos - 1 : taps - 1; |
||
53 | d1 = rint(d + noise[i]); |
||
54 | ns_errors[pos + taps] = ns_errors[pos] = d1 - d; |
||
55 | d1 *= S; |
||
56 | CLIP(d1); |
||
57 | dst[i] = d1; |
||
58 | } |
||
59 | } |
||
60 | |||
61 | |||
62 | } |
||
63 | |||
64 | |||
65 | #undef DELEM |
||
66 | #undef CLIP> |
||
67 |