2 * Copyright (c) 2012 Mans Rullgard <mans@mansr.com>
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "libavutil/avutil.h"
32 # define sample_type int32_t
34 # define sample_type int16_t
38 # define FSUF AV_JOIN(SAMPLE_SIZE, p)
39 # define sample sample_type *
41 # define S(s, c, i) (s[c][i])
43 # define FSUF SAMPLE_SIZE
44 # define sample sample_type
46 # define S(s, c, i) (*s++)
49 #define FUNC(n) AV_JOIN(n ## _, FSUF)
51 static void FUNC(flac_decorrelate_indep_c
)(uint8_t **out
, int32_t **in
,
52 int channels
, int len
, int shift
)
54 sample
*samples
= (sample
*) OUT(out
);
57 for (j
= 0; j
< len
; j
++)
58 for (i
= 0; i
< channels
; i
++)
59 S(samples
, i
, j
) = in
[i
][j
] << shift
;
62 static void FUNC(flac_decorrelate_ls_c
)(uint8_t **out
, int32_t **in
,
63 int channels
, int len
, int shift
)
65 sample
*samples
= (sample
*) OUT(out
);
68 for (i
= 0; i
< len
; i
++) {
71 S(samples
, 0, i
) = a
<< shift
;
72 S(samples
, 1, i
) = (a
- b
) << shift
;
76 static void FUNC(flac_decorrelate_rs_c
)(uint8_t **out
, int32_t **in
,
77 int channels
, int len
, int shift
)
79 sample
*samples
= (sample
*) OUT(out
);
82 for (i
= 0; i
< len
; i
++) {
85 S(samples
, 0, i
) = (a
+ b
) << shift
;
86 S(samples
, 1, i
) = b
<< shift
;
90 static void FUNC(flac_decorrelate_ms_c
)(uint8_t **out
, int32_t **in
,
91 int channels
, int len
, int shift
)
93 sample
*samples
= (sample
*) OUT(out
);
96 for (i
= 0; i
< len
; i
++) {
100 S(samples
, 0, i
) = (a
+ b
) << shift
;
101 S(samples
, 1, i
) = a
<< shift
;