FFmpeg
flacdsp_init.c
Go to the documentation of this file.
1 /*
2  * Copyright © 2023 Rémi Denis-Courmont.
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 "config.h"
22 
23 #include "libavutil/attributes.h"
24 #include "libavutil/cpu.h"
25 #include "libavutil/riscv/cpu.h"
26 #include "libavcodec/flacdsp.h"
27 
28 void ff_flac_lpc16_rvv(int32_t *decoded, const int coeffs[32],
29  int pred_order, int qlevel, int len);
30 void ff_flac_lpc32_rvv(int32_t *decoded, const int coeffs[32],
31  int pred_order, int qlevel, int len);
32 void ff_flac_lpc32_rvv_simple(int32_t *decoded, const int coeffs[32],
33  int pred_order, int qlevel, int len);
34 void ff_flac_decorrelate_indep2_16_rvv(uint8_t **out, int32_t **in,
35  int channels, int len, int shift);
36 void ff_flac_decorrelate_indep4_16_rvv(uint8_t **out, int32_t **in,
37  int channels, int len, int shift);
38 void ff_flac_decorrelate_indep6_16_rvv(uint8_t **out, int32_t **in,
39  int channels, int len, int shift);
40 void ff_flac_decorrelate_indep8_16_rvv(uint8_t **out, int32_t **in,
41  int channels, int len, int shift);
42 void ff_flac_decorrelate_ls_16_rvv(uint8_t **out, int32_t **in,
43  int channels, int len, int shift);
44 void ff_flac_decorrelate_rs_16_rvv(uint8_t **out, int32_t **in,
45  int channels, int len, int shift);
46 void ff_flac_decorrelate_ms_16_rvv(uint8_t **out, int32_t **in,
47  int channels, int len, int shift);
48 void ff_flac_decorrelate_indep2_32_rvv(uint8_t **out, int32_t **in,
49  int channels, int len, int shift);
50 void ff_flac_decorrelate_indep4_32_rvv(uint8_t **out, int32_t **in,
51  int channels, int len, int shift);
52 void ff_flac_decorrelate_indep6_32_rvv(uint8_t **out, int32_t **in,
53  int channels, int len, int shift);
54 void ff_flac_decorrelate_indep8_32_rvv(uint8_t **out, int32_t **in,
55  int channels, int len, int shift);
56 void ff_flac_decorrelate_ls_32_rvv(uint8_t **out, int32_t **in,
57  int channels, int len, int shift);
58 void ff_flac_decorrelate_rs_32_rvv(uint8_t **out, int32_t **in,
59  int channels, int len, int shift);
60 void ff_flac_decorrelate_ms_32_rvv(uint8_t **out, int32_t **in,
61  int channels, int len, int shift);
62 
64  int channels)
65 {
66 #if HAVE_RVV
67  int flags = av_get_cpu_flags();
68 
70  int vlenb = ff_get_rv_vlenb();
71 
72  if (vlenb >= 16) {
73  c->lpc16 = ff_flac_lpc16_rvv;
74 # if (__riscv_xlen >= 64)
75  if (vlenb > 16)
76  c->lpc32 = ff_flac_lpc32_rvv_simple;
77  else
78  c->lpc32 = ff_flac_lpc32_rvv;
79  }
80 
81  switch (fmt) {
82  case AV_SAMPLE_FMT_S16:
83  switch (channels) {
84  case 2:
85  c->decorrelate[0] = ff_flac_decorrelate_indep2_16_rvv;
86  break;
87  case 4:
88  c->decorrelate[0] = ff_flac_decorrelate_indep4_16_rvv;
89  break;
90  case 6:
91  c->decorrelate[0] = ff_flac_decorrelate_indep6_16_rvv;
92  break;
93  case 8:
94  c->decorrelate[0] = ff_flac_decorrelate_indep8_16_rvv;
95  break;
96  }
97  c->decorrelate[1] = ff_flac_decorrelate_ls_16_rvv;
98  c->decorrelate[2] = ff_flac_decorrelate_rs_16_rvv;
99  c->decorrelate[3] = ff_flac_decorrelate_ms_16_rvv;
100  break;
101  case AV_SAMPLE_FMT_S32:
102  switch (channels) {
103  case 2:
104  c->decorrelate[0] = ff_flac_decorrelate_indep2_32_rvv;
105  break;
106  case 4:
107  c->decorrelate[0] = ff_flac_decorrelate_indep4_32_rvv;
108  break;
109  case 6:
110  c->decorrelate[0] = ff_flac_decorrelate_indep6_32_rvv;
111  break;
112  case 8:
113  c->decorrelate[0] = ff_flac_decorrelate_indep8_32_rvv;
114  break;
115  }
116  c->decorrelate[1] = ff_flac_decorrelate_ls_32_rvv;
117  c->decorrelate[2] = ff_flac_decorrelate_rs_32_rvv;
118  c->decorrelate[3] = ff_flac_decorrelate_ms_32_rvv;
119  break;
120 # endif
121  }
122  }
123 #endif
124 }
out
FILE * out
Definition: movenc.c:54
ff_flac_decorrelate_indep4_32_rvv
void ff_flac_decorrelate_indep4_32_rvv(uint8_t **out, int32_t **in, int channels, int len, int shift)
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:103
flacdsp.h
ff_flac_decorrelate_indep2_32_rvv
void ff_flac_decorrelate_indep2_32_rvv(uint8_t **out, int32_t **in, int channels, int len, int shift)
ff_flac_decorrelate_ls_32_rvv
void ff_flac_decorrelate_ls_32_rvv(uint8_t **out, int32_t **in, int channels, int len, int shift)
ff_flac_decorrelate_indep8_16_rvv
void ff_flac_decorrelate_indep8_16_rvv(uint8_t **out, int32_t **in, int channels, int len, int shift)
av_cold
#define av_cold
Definition: attributes.h:90
cpu.h
channels
channels
Definition: aptx.h:31
AV_CPU_FLAG_RVB_ADDR
#define AV_CPU_FLAG_RVB_ADDR
Address bit-manipulations.
Definition: cpu.h:92
ff_flac_decorrelate_indep6_16_rvv
void ff_flac_decorrelate_indep6_16_rvv(uint8_t **out, int32_t **in, int channels, int len, int shift)
ff_flac_lpc32_rvv
void ff_flac_lpc32_rvv(int32_t *decoded, const int coeffs[32], int pred_order, int qlevel, int len)
ff_flac_decorrelate_ms_32_rvv
void ff_flac_decorrelate_ms_32_rvv(uint8_t **out, int32_t **in, int channels, int len, int shift)
ff_flac_lpc32_rvv_simple
void ff_flac_lpc32_rvv_simple(int32_t *decoded, const int coeffs[32], int pred_order, int qlevel, int len)
ff_flacdsp_init_riscv
av_cold void ff_flacdsp_init_riscv(FLACDSPContext *c, enum AVSampleFormat fmt, int channels)
Definition: flacdsp_init.c:63
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
ff_flac_decorrelate_indep8_32_rvv
void ff_flac_decorrelate_indep8_32_rvv(uint8_t **out, int32_t **in, int channels, int len, int shift)
ff_flac_lpc16_rvv
void ff_flac_lpc16_rvv(int32_t *decoded, const int coeffs[32], int pred_order, int qlevel, int len)
shift
static int shift(int a, int b)
Definition: bonk.c:262
cpu.h
attributes.h
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
AV_CPU_FLAG_RVV_I32
#define AV_CPU_FLAG_RVV_I32
Vectors of 8/16/32-bit int's *‍/.
Definition: cpu.h:87
AV_SAMPLE_FMT_S16
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition: samplefmt.h:58
len
int len
Definition: vorbis_enc_data.h:426
ff_flac_decorrelate_ls_16_rvv
void ff_flac_decorrelate_ls_16_rvv(uint8_t **out, int32_t **in, int channels, int len, int shift)
ff_flac_decorrelate_indep6_32_rvv
void ff_flac_decorrelate_indep6_32_rvv(uint8_t **out, int32_t **in, int channels, int len, int shift)
ff_flac_decorrelate_rs_32_rvv
void ff_flac_decorrelate_rs_32_rvv(uint8_t **out, int32_t **in, int channels, int len, int shift)
ff_flac_decorrelate_indep4_16_rvv
void ff_flac_decorrelate_indep4_16_rvv(uint8_t **out, int32_t **in, int channels, int len, int shift)
ff_flac_decorrelate_rs_16_rvv
void ff_flac_decorrelate_rs_16_rvv(uint8_t **out, int32_t **in, int channels, int len, int shift)
int32_t
int32_t
Definition: audioconvert.c:56
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
AV_SAMPLE_FMT_S32
@ AV_SAMPLE_FMT_S32
signed 32 bits
Definition: samplefmt.h:59
FLACDSPContext
Definition: flacdsp.h:26
ff_flac_decorrelate_ms_16_rvv
void ff_flac_decorrelate_ms_16_rvv(uint8_t **out, int32_t **in, int channels, int len, int shift)
ff_flac_decorrelate_indep2_16_rvv
void ff_flac_decorrelate_indep2_16_rvv(uint8_t **out, int32_t **in, int channels, int len, int shift)