2 * This file is part of Libav.
4 * Libav is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * Libav is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with Libav; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "libavutil/avutil.h"
29 #define FUNC(n) AV_JOIN(n ## _, SAMPLE_SIZE)
32 # define sum_type int64_t
33 # define MUL(a, b) MUL64(a, b)
34 # define CLIP(x) av_clipl_int32(x)
36 # define sum_type int32_t
37 # define MUL(a, b) ((a) * (b))
42 int c = coefs[(x)-1]; \
48 static av_always_inline
void FUNC(lpc_encode_unrolled
)(int32_t *res
,
49 const int32_t *smp
, int len
, int order
,
50 const int32_t *coefs
, int shift
, int big
)
53 for (i
= order
; i
< len
; i
+= 2) {
55 sum_type p0
= 0, p1
= 0;
103 res
[i
] = smp
[i
] - CLIP(p0
>> shift
);
104 res
[i
+1] = smp
[i
+1] - CLIP(p1
>> shift
);
108 static void FUNC(flac_lpc_encode_c
)(int32_t *res
, const int32_t *smp
, int len
,
109 int order
, const int32_t *coefs
, int shift
)
112 for (i
= 0; i
< order
; i
++)
115 for (i
= order
; i
< len
; i
+= 2) {
118 sum_type p0
= 0, p1
= 0;
119 for (j
= 0; j
< order
; j
++) {
125 res
[i
] = smp
[i
] - CLIP(p0
>> shift
);
126 res
[i
+1] = smp
[i
+1] - CLIP(p1
>> shift
);
130 case 1: FUNC(lpc_encode_unrolled
)(res
, smp
, len
, 1, coefs
, shift
, 0); break;
131 case 2: FUNC(lpc_encode_unrolled
)(res
, smp
, len
, 2, coefs
, shift
, 0); break;
132 case 3: FUNC(lpc_encode_unrolled
)(res
, smp
, len
, 3, coefs
, shift
, 0); break;
133 case 4: FUNC(lpc_encode_unrolled
)(res
, smp
, len
, 4, coefs
, shift
, 0); break;
134 case 5: FUNC(lpc_encode_unrolled
)(res
, smp
, len
, 5, coefs
, shift
, 0); break;
135 case 6: FUNC(lpc_encode_unrolled
)(res
, smp
, len
, 6, coefs
, shift
, 0); break;
136 case 7: FUNC(lpc_encode_unrolled
)(res
, smp
, len
, 7, coefs
, shift
, 0); break;
137 case 8: FUNC(lpc_encode_unrolled
)(res
, smp
, len
, 8, coefs
, shift
, 0); break;
138 default: FUNC(lpc_encode_unrolled
)(res
, smp
, len
, order
, coefs
, shift
, 1); break;