Revision b531e1ab libavcodec/dct.c

View differences:

libavcodec/dct.c
42 42
    int n = 1 << ctx->nbits;
43 43
    int i;
44 44

  
45
        float next = data[n - 1];
46
        float inv_n = 1.0f / n;
45
    float next = data[n - 1];
46
    float inv_n = 1.0f / n;
47 47

  
48
        for (i = n - 2; i >= 2; i -= 2) {
49
            float val1 = data[i    ];
50
            float val2 = data[i - 1] - data[i + 1];
51
            float c = COS(ctx, n, i);
52
            float s = SIN(ctx, n, i);
48
    for (i = n - 2; i >= 2; i -= 2) {
49
        float val1 = data[i    ];
50
        float val2 = data[i - 1] - data[i + 1];
51
        float c = COS(ctx, n, i);
52
        float s = SIN(ctx, n, i);
53 53

  
54
            data[i    ] = c * val1 + s * val2;
55
            data[i + 1] = s * val1 - c * val2;
56
        }
54
        data[i    ] = c * val1 + s * val2;
55
        data[i + 1] = s * val1 - c * val2;
56
    }
57 57

  
58
        data[1] = 2 * next;
58
    data[1] = 2 * next;
59 59

  
60
        ff_rdft_calc(&ctx->rdft, data);
60
    ff_rdft_calc(&ctx->rdft, data);
61 61

  
62
        for (i = 0; i < n / 2; i++) {
63
            float tmp1 = data[i        ] * inv_n;
64
            float tmp2 = data[n - i - 1] * inv_n;
65
            float csc = ctx->csc2[i] * (tmp1 - tmp2);
62
    for (i = 0; i < n / 2; i++) {
63
        float tmp1 = data[i        ] * inv_n;
64
        float tmp2 = data[n - i - 1] * inv_n;
65
        float csc = ctx->csc2[i] * (tmp1 - tmp2);
66 66

  
67
            tmp1 += tmp2;
68
            data[i        ] = tmp1 + csc;
69
            data[n - i - 1] = tmp1 - csc;
70
        }
67
        tmp1 += tmp2;
68
        data[i        ] = tmp1 + csc;
69
        data[n - i - 1] = tmp1 - csc;
70
    }
71 71
}
72 72

  
73 73
static void ff_dct_calc_II_c(DCTContext *ctx, FFTSample *data)
74 74
{
75 75
    int n = 1 << ctx->nbits;
76 76
    int i;
77
        float next;
78
        for (i=0; i < n/2; i++) {
79
            float tmp1 = data[i        ];
80
            float tmp2 = data[n - i - 1];
81
            float s = SIN(ctx, n, 2*i + 1);
77
    float next;
82 78

  
83
            s *= tmp1 - tmp2;
84
            tmp1 = (tmp1 + tmp2) * 0.5f;
79
    for (i=0; i < n/2; i++) {
80
        float tmp1 = data[i        ];
81
        float tmp2 = data[n - i - 1];
82
        float s = SIN(ctx, n, 2*i + 1);
85 83

  
86
            data[i    ] = tmp1 + s;
87
            data[n-i-1] = tmp1 - s;
88
        }
84
        s *= tmp1 - tmp2;
85
        tmp1 = (tmp1 + tmp2) * 0.5f;
89 86

  
90
        ff_rdft_calc(&ctx->rdft, data);
87
        data[i    ] = tmp1 + s;
88
        data[n-i-1] = tmp1 - s;
89
    }
91 90

  
92
        next = data[1] * 0.5;
93
        data[1] *= -1;
91
    ff_rdft_calc(&ctx->rdft, data);
94 92

  
95
        for (i = n - 2; i >= 0; i -= 2) {
96
            float inr = data[i    ];
97
            float ini = data[i + 1];
98
            float c = COS(ctx, n, i);
99
            float s = SIN(ctx, n, i);
93
    next = data[1] * 0.5;
94
    data[1] *= -1;
100 95

  
101
            data[i  ] = c * inr + s * ini;
96
    for (i = n - 2; i >= 0; i -= 2) {
97
        float inr = data[i    ];
98
        float ini = data[i + 1];
99
        float c = COS(ctx, n, i);
100
        float s = SIN(ctx, n, i);
102 101

  
103
            data[i+1] = next;
102
        data[i  ] = c * inr + s * ini;
104 103

  
105
            next +=     s * inr - c * ini;
106
        }
104
        data[i+1] = next;
105

  
106
        next +=     s * inr - c * ini;
107
    }
107 108
}
108 109

  
109 110
void ff_dct_calc(DCTContext *s, FFTSample *data)

Also available in: Unified diff