FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/alacdsp.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 20 20 100.0%
Functions: 3 3 100.0%
Branches: 6 6 100.0%

Line Branch Exec Source
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 602 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
2/2
✓ Branch 0 taken 2443594 times.
✓ Branch 1 taken 602 times.
2444196 for (i = 0; i < nb_samples; i++) {
32 uint32_t a, b;
33
34 2443594 a = buffer[0][i];
35 2443594 b = buffer[1][i];
36
37 2443594 a -= (int)(b * decorr_left_weight) >> decorr_shift;
38 2443594 b += a;
39
40 2443594 buffer[0][i] = b;
41 2443594 buffer[1][i] = a;
42 }
43 602 }
44
45 1416 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
2/2
✓ Branch 0 taken 2829 times.
✓ Branch 1 taken 1416 times.
4245 for (ch = 0; ch < channels; ch++)
51
2/2
✓ Branch 0 taken 11545372 times.
✓ Branch 1 taken 2829 times.
11548201 for (i = 0; i < nb_samples; i++)
52 11545372 buffer[ch][i] = ((unsigned)buffer[ch][i] << extra_bits) | extra_bits_buffer[ch][i];
53 1416 }
54
55 61 av_cold void ff_alacdsp_init(ALACDSPContext *c)
56 {
57 61 c->decorrelate_stereo = decorrelate_stereo;
58 61 c->append_extra_bits[0] =
59 61 c->append_extra_bits[1] = append_extra_bits;
60
61 #if ARCH_RISCV
62 ff_alacdsp_init_riscv(c);
63 #elif ARCH_X86
64 61 ff_alacdsp_init_x86(c);
65 #endif
66 61 }
67