FFmpeg  4.4.9
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 
21 #include "libavcodec/flacdsp.h"
22 #include "libavutil/x86/cpu.h"
23 #include "config.h"
24 
25 void ff_flac_lpc_32_sse4(int32_t *samples, const int coeffs[32], int order,
26  int qlevel, int len);
27 void ff_flac_lpc_32_xop(int32_t *samples, const int coeffs[32], int order,
28  int qlevel, int len);
29 
30 void ff_flac_enc_lpc_16_sse4(int32_t *, const int32_t *, int, int, const int32_t *,int);
31 
32 #define DECORRELATE_FUNCS(fmt, opt) \
33 void ff_flac_decorrelate_ls_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
34  int len, int shift); \
35 void ff_flac_decorrelate_rs_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
36  int len, int shift); \
37 void ff_flac_decorrelate_ms_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
38  int len, int shift);
39 
40 #define DECORRELATE_IFUNCS(fmt, opt) \
41 void ff_flac_decorrelate_indep2_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
42  int len, int shift); \
43 void ff_flac_decorrelate_indep4_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
44  int len, int shift); \
45 void ff_flac_decorrelate_indep6_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
46  int len, int shift); \
47 void ff_flac_decorrelate_indep8_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
48  int len, int shift)
49 
54 DECORRELATE_IFUNCS(16, ssse3);
56 DECORRELATE_IFUNCS(32, ssse3);
58 
60  int bps)
61 {
62 #if HAVE_X86ASM
64 
65 #if CONFIG_FLAC_DECODER
66  if (EXTERNAL_SSE2(cpu_flags)) {
67  if (fmt == AV_SAMPLE_FMT_S16) {
68  c->decorrelate[1] = ff_flac_decorrelate_ls_16_sse2;
69  c->decorrelate[2] = ff_flac_decorrelate_rs_16_sse2;
70  c->decorrelate[3] = ff_flac_decorrelate_ms_16_sse2;
71  } else if (fmt == AV_SAMPLE_FMT_S32) {
72  c->decorrelate[1] = ff_flac_decorrelate_ls_32_sse2;
73  c->decorrelate[2] = ff_flac_decorrelate_rs_32_sse2;
74  c->decorrelate[3] = ff_flac_decorrelate_ms_32_sse2;
75  }
76  }
78  if (fmt == AV_SAMPLE_FMT_S16) {
79  if (channels == 2)
80  c->decorrelate[0] = ff_flac_decorrelate_indep2_16_ssse3;
81  else if (channels == 4)
82  c->decorrelate[0] = ff_flac_decorrelate_indep4_16_ssse3;
83  else if (channels == 6)
84  c->decorrelate[0] = ff_flac_decorrelate_indep6_16_ssse3;
85  else if (ARCH_X86_64 && channels == 8)
86  c->decorrelate[0] = ff_flac_decorrelate_indep8_16_ssse3;
87  } else if (fmt == AV_SAMPLE_FMT_S32) {
88  if (channels == 2)
89  c->decorrelate[0] = ff_flac_decorrelate_indep2_32_ssse3;
90  else if (channels == 4)
91  c->decorrelate[0] = ff_flac_decorrelate_indep4_32_ssse3;
92  else if (channels == 6)
93  c->decorrelate[0] = ff_flac_decorrelate_indep6_32_ssse3;
94  else if (ARCH_X86_64 && channels == 8)
95  c->decorrelate[0] = ff_flac_decorrelate_indep8_32_ssse3;
96  }
97  }
98  if (EXTERNAL_SSE4(cpu_flags)) {
99  c->lpc32 = ff_flac_lpc_32_sse4;
100  }
101  if (EXTERNAL_AVX(cpu_flags)) {
102  if (fmt == AV_SAMPLE_FMT_S16) {
103  if (ARCH_X86_64 && channels == 8)
104  c->decorrelate[0] = ff_flac_decorrelate_indep8_16_avx;
105  } else if (fmt == AV_SAMPLE_FMT_S32) {
106  if (channels == 4)
107  c->decorrelate[0] = ff_flac_decorrelate_indep4_32_avx;
108  else if (channels == 6)
109  c->decorrelate[0] = ff_flac_decorrelate_indep6_32_avx;
110  else if (ARCH_X86_64 && channels == 8)
111  c->decorrelate[0] = ff_flac_decorrelate_indep8_32_avx;
112  }
113  }
114  if (EXTERNAL_XOP(cpu_flags)) {
115  c->lpc32 = ff_flac_lpc_32_xop;
116  }
117 #endif
118 
119 #if CONFIG_FLAC_ENCODER
120  if (EXTERNAL_SSE4(cpu_flags)) {
121  if (CONFIG_GPL)
122  c->lpc16_encode = ff_flac_enc_lpc_16_sse4;
123  }
124 #endif
125 #endif /* HAVE_X86ASM */
126 }
channels
Definition: aptx.h:33
#define av_cold
Definition: attributes.h:88
int32_t
#define CONFIG_GPL
Definition: config.h:569
#define ARCH_X86_64
Definition: config.h:41
static atomic_int cpu_flags
Definition: cpu.c:50
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:95
av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int channels, int bps)
Definition: flacdsp_init.c:59
void ff_flac_enc_lpc_16_sse4(int32_t *, const int32_t *, int, int, const int32_t *, int)
#define DECORRELATE_FUNCS(fmt, opt)
Definition: flacdsp_init.c:32
void ff_flac_lpc_32_sse4(int32_t *samples, const int coeffs[32], int order, int qlevel, int len)
#define DECORRELATE_IFUNCS(fmt, opt)
Definition: flacdsp_init.c:40
void ff_flac_lpc_32_xop(int32_t *samples, const int coeffs[32], int order, int qlevel, int len)
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
@ AV_SAMPLE_FMT_S32
signed 32 bits
Definition: samplefmt.h:62
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition: samplefmt.h:61
unsigned bps
Definition: movenc.c:1612
int len
static double c[64]
#define EXTERNAL_AVX(flags)
Definition: cpu.h:70
#define EXTERNAL_SSSE3(flags)
Definition: cpu.h:65
#define EXTERNAL_XOP(flags)
Definition: cpu.h:73
#define EXTERNAL_SSE4(flags)
Definition: cpu.h:68
#define EXTERNAL_SSE2(flags)
Definition: cpu.h:59