FFmpeg
alacdsp.c
Go to the documentation of this file.
1 /*
2  * ALAC (Apple Lossless Audio Codec) decoder
3  * Copyright (c) 2005 David Hammerton
4  *
5  * This file is part of FFmpeg.
6  *
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.
11  *
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.
16  *
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
20  */
21 
22 #include "libavutil/attributes.h"
23 #include "alacdsp.h"
24 #include "config.h"
25 
26 static void decorrelate_stereo(int32_t *buffer[2], int nb_samples,
27  int decorr_shift, int decorr_left_weight)
28 {
29  int i;
30 
31  for (i = 0; i < nb_samples; i++) {
32  uint32_t a, b;
33 
34  a = buffer[0][i];
35  b = buffer[1][i];
36 
37  a -= (int)(b * decorr_left_weight) >> decorr_shift;
38  b += a;
39 
40  buffer[0][i] = b;
41  buffer[1][i] = a;
42  }
43 }
44 
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)
47 {
48  int i, ch;
49 
50  for (ch = 0; ch < channels; ch++)
51  for (i = 0; i < nb_samples; i++)
52  buffer[ch][i] = ((unsigned)buffer[ch][i] << extra_bits) | extra_bits_buffer[ch][i];
53 }
54 
56 {
57  c->decorrelate_stereo = decorrelate_stereo;
58  c->append_extra_bits[0] =
59  c->append_extra_bits[1] = append_extra_bits;
60 
61 #if ARCH_RISCV
63 #elif ARCH_X86
65 #endif
66 }
ff_alacdsp_init
av_cold void ff_alacdsp_init(ALACDSPContext *c)
Definition: alacdsp.c:55
extra_bits
#define extra_bits(eb)
Definition: intrax8.c:125
b
#define b
Definition: input.c:41
append_extra_bits
static void append_extra_bits(int32_t *buffer[2], int32_t *extra_bits_buffer[2], int extra_bits, int channels, int nb_samples)
Definition: alacdsp.c:45
alacdsp.h
ff_alacdsp_init_riscv
void ff_alacdsp_init_riscv(ALACDSPContext *c)
Definition: alacdsp_init.c:39
av_cold
#define av_cold
Definition: attributes.h:90
channels
channels
Definition: aptx.h:31
decorrelate_stereo
static void decorrelate_stereo(int32_t *buffer[2], int nb_samples, int decorr_shift, int decorr_left_weight)
Definition: alacdsp.c:26
ALACDSPContext
Definition: alacdsp.h:24
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
attributes.h
ff_alacdsp_init_x86
void ff_alacdsp_init_x86(ALACDSPContext *c)
Definition: alacdsp_init.c:31
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
int32_t
int32_t
Definition: audioconvert.c:56
int
int
Definition: ffmpeg_filter.c:368