2 * ALAC (Apple Lossless Audio Codec) decoder
3 * Copyright (c) 2005 David Hammerton
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "libavutil/attributes.h"
26 static void decorrelate_stereo(int32_t *buffer[2], int nb_samples,
27 int decorr_shift, int decorr_left_weight)
31 for (i = 0; i < nb_samples; i++) {
37 a -= (b * decorr_left_weight) >> decorr_shift;
45 static void append_extra_bits(int32_t *buffer[2], int32_t *extra_bits_buffer[2],
46 int extra_bits, int channels, int nb_samples)
50 for (ch = 0; ch < channels; ch++)
51 for (i = 0; i < nb_samples; i++)
52 buffer[ch][i] = (buffer[ch][i] << extra_bits) | extra_bits_buffer[ch][i];
55 av_cold void ff_alacdsp_init(ALACDSPContext *c)
57 c->decorrelate_stereo = decorrelate_stereo;
58 c->append_extra_bits[0] =
59 c->append_extra_bits[1] = append_extra_bits;
62 ff_alacdsp_init_x86(c);