FFmpeg
Loading...
Searching...
No Matches
flacdsp_init.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 James Almer
3 *
4 * This file is part of FFmpeg.
5 *
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.
10 *
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.
15 *
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
19 */
20
22#include "libavcodec/flacdsp.h"
23#include "libavutil/x86/cpu.h"
24#include "config.h"
25
26void ff_flac_lpc_16_sse4(int32_t *samples, const int coeffs[32], int order,
27 int qlevel, int len);
28void ff_flac_lpc_32_sse4(int32_t *samples, const int coeffs[32], int order,
29 int qlevel, int len);
30void ff_flac_lpc_32_xop(int32_t *samples, const int coeffs[32], int order,
31 int qlevel, int len);
32
33void ff_flac_wasted_32_sse2(int32_t *decoded, int wasted, int len);
34void ff_flac_wasted_33_sse4(int64_t *decoded, const int32_t *residual, int wasted, int len);
35
36#define DECORRELATE_FUNCS(fmt, opt) \
37void ff_flac_decorrelate_ls_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
38 int len, int shift); \
39void ff_flac_decorrelate_rs_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
40 int len, int shift); \
41void ff_flac_decorrelate_ms_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
42 int len, int shift)
43
44#define DECORRELATE_IFUNCS(fmt, opt) \
45void ff_flac_decorrelate_indep2_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
46 int len, int shift); \
47void ff_flac_decorrelate_indep4_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
48 int len, int shift); \
49void ff_flac_decorrelate_indep6_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
50 int len, int shift); \
51void ff_flac_decorrelate_indep8_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
52 int len, int shift)
53
62
64{
66
68 c->wasted32 = ff_flac_wasted_32_sse2;
69 if (fmt == AV_SAMPLE_FMT_S16) {
70 c->decorrelate[1] = ff_flac_decorrelate_ls_16_sse2;
71 c->decorrelate[2] = ff_flac_decorrelate_rs_16_sse2;
72 c->decorrelate[3] = ff_flac_decorrelate_ms_16_sse2;
73 } else if (fmt == AV_SAMPLE_FMT_S32) {
74 c->decorrelate[1] = ff_flac_decorrelate_ls_32_sse2;
75 c->decorrelate[2] = ff_flac_decorrelate_rs_32_sse2;
76 c->decorrelate[3] = ff_flac_decorrelate_ms_32_sse2;
77 }
78 }
80 if (fmt == AV_SAMPLE_FMT_S16) {
81 if (channels == 2)
82 c->decorrelate[0] = ff_flac_decorrelate_indep2_16_ssse3;
83 else if (channels == 4)
84 c->decorrelate[0] = ff_flac_decorrelate_indep4_16_ssse3;
85 else if (channels == 6)
86 c->decorrelate[0] = ff_flac_decorrelate_indep6_16_ssse3;
87#if ARCH_X86_64
88 else if (channels == 8)
89 c->decorrelate[0] = ff_flac_decorrelate_indep8_16_ssse3;
90#endif
91 } else if (fmt == AV_SAMPLE_FMT_S32) {
92 if (channels == 2)
93 c->decorrelate[0] = ff_flac_decorrelate_indep2_32_ssse3;
94 else if (channels == 4)
95 c->decorrelate[0] = ff_flac_decorrelate_indep4_32_ssse3;
96 else if (channels == 6)
97 c->decorrelate[0] = ff_flac_decorrelate_indep6_32_ssse3;
98#if ARCH_X86_64
99 else if (channels == 8)
100 c->decorrelate[0] = ff_flac_decorrelate_indep8_32_ssse3;
101#endif
102 }
103 }
105 c->lpc16 = ff_flac_lpc_16_sse4;
106 c->lpc32 = ff_flac_lpc_32_sse4;
107 c->wasted33 = ff_flac_wasted_33_sse4;
108 }
109 if (EXTERNAL_AVX(cpu_flags)) {
110 if (fmt == AV_SAMPLE_FMT_S16) {
111#if ARCH_X86_64
112 if (channels == 8)
113 c->decorrelate[0] = ff_flac_decorrelate_indep8_16_avx;
114#endif
115 } else if (fmt == AV_SAMPLE_FMT_S32) {
116 if (channels == 4)
117 c->decorrelate[0] = ff_flac_decorrelate_indep4_32_avx;
118 else if (channels == 6)
119 c->decorrelate[0] = ff_flac_decorrelate_indep6_32_avx;
120#if ARCH_X86_64
121 else if (channels == 8)
122 c->decorrelate[0] = ff_flac_decorrelate_indep8_32_avx;
123#endif
124 }
125 }
126 if (EXTERNAL_XOP(cpu_flags)) {
127 c->lpc32 = ff_flac_lpc_32_xop;
128 }
129}
channels
Definition aptx.h:31
int32_t
long long int64_t
Definition coverity.c:34
AVSampleFormat
Audio sample formats.
Definition samplefmt.h:55
@ AV_SAMPLE_FMT_S32
signed 32 bits
Definition samplefmt.h:59
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition samplefmt.h:58
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
static atomic_int cpu_flags
Definition cpu.c:56
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition cpu.c:109
#define EXTERNAL_AVX(flags)
Definition cpu.h:64
#define EXTERNAL_SSSE3(flags)
Definition cpu.h:59
#define EXTERNAL_XOP(flags)
Definition cpu.h:67
#define EXTERNAL_SSE4(flags)
Definition cpu.h:62
#define EXTERNAL_SSE2(flags)
Definition cpu.h:53
int len
static double c[64]
void ff_flac_wasted_33_sse4(int64_t *decoded, const int32_t *residual, int wasted, int len)
void ff_flac_wasted_32_sse2(int32_t *decoded, int wasted, int len)
#define DECORRELATE_FUNCS(fmt, opt)
av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int channels)
void ff_flac_lpc_16_sse4(int32_t *samples, const int coeffs[32], int order, int qlevel, int len)
void ff_flac_lpc_32_sse4(int32_t *samples, const int coeffs[32], int order, int qlevel, int len)
#define DECORRELATE_IFUNCS(fmt, opt)
void ff_flac_lpc_32_xop(int32_t *samples, const int coeffs[32], int order, int qlevel, int len)