FFmpeg
audiodsp.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include <stdint.h>
20 
21 #include "libavutil/attributes.h"
22 #include "libavutil/common.h"
23 #include "audiodsp.h"
24 
25 static void vector_clipf_c(float *dst, const float *src, int len,
26  float min, float max)
27 {
28  for (int i = 0; i < len; i += 8) {
29  float tmp[8];
30 
31  for (int j = 0; j < 8; j++)
32  tmp[j]= av_clipf(src[i + j], min, max);
33  for (int j = 0; j < 8; j++)
34  dst[i + j] = tmp[j];
35  }
36 }
37 
38 static int32_t scalarproduct_int16_c(const int16_t *v1, const int16_t *v2,
39  int order)
40 {
41  unsigned res = 0;
42 
43  while (order--)
44  res += *v1++ **v2++;
45 
46  return res;
47 }
48 
50  int32_t max, unsigned int len)
51 {
52  do {
53  *dst++ = av_clip(*src++, min, max);
54  *dst++ = av_clip(*src++, min, max);
55  *dst++ = av_clip(*src++, min, max);
56  *dst++ = av_clip(*src++, min, max);
57  *dst++ = av_clip(*src++, min, max);
58  *dst++ = av_clip(*src++, min, max);
59  *dst++ = av_clip(*src++, min, max);
60  *dst++ = av_clip(*src++, min, max);
61  len -= 8;
62  } while (len > 0);
63 }
64 
66 {
67  c->scalarproduct_int16 = scalarproduct_int16_c;
68  c->vector_clip_int32 = vector_clip_int32_c;
69  c->vector_clipf = vector_clipf_c;
70 
71 #if ARCH_ARM
73 #elif ARCH_PPC
75 #elif ARCH_RISCV
77 #elif ARCH_X86
79 #endif
80 }
av_clip
#define av_clip
Definition: common.h:100
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
ff_audiodsp_init_x86
void ff_audiodsp_init_x86(AudioDSPContext *c)
Definition: audiodsp_init.c:42
ff_audiodsp_init
av_cold void ff_audiodsp_init(AudioDSPContext *c)
Definition: audiodsp.c:65
max
#define max(a, b)
Definition: cuda_runtime.h:33
ff_audiodsp_init_ppc
av_cold void ff_audiodsp_init_ppc(AudioDSPContext *c)
Definition: audiodsp.c:86
av_cold
#define av_cold
Definition: attributes.h:90
vector_clipf_c
static void vector_clipf_c(float *dst, const float *src, int len, float min, float max)
Definition: audiodsp.c:25
ff_audiodsp_init_arm
av_cold void ff_audiodsp_init_arm(AudioDSPContext *c)
Definition: audiodsp_init_arm.c:27
av_clipf
av_clipf
Definition: af_crystalizer.c:122
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
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
vector_clip_int32_c
static void vector_clip_int32_c(int32_t *dst, const int32_t *src, int32_t min, int32_t max, unsigned int len)
Definition: audiodsp.c:49
attributes.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
common.h
len
int len
Definition: vorbis_enc_data.h:426
scalarproduct_int16_c
static int32_t scalarproduct_int16_c(const int16_t *v1, const int16_t *v2, int order)
Definition: audiodsp.c:38
audiodsp.h
AudioDSPContext
Definition: audiodsp.h:24
int32_t
int32_t
Definition: audioconvert.c:56
ff_audiodsp_init_riscv
void ff_audiodsp_init_riscv(AudioDSPContext *c)
Definition: audiodsp_init.c:32
src
#define src
Definition: vp8dsp.c:248
min
float min
Definition: vorbis_enc_data.h:429