FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libswresample
arm
resample_init.c
Go to the documentation of this file.
1
/*
2
* Audio resampling
3
*
4
* Copyright (c) 2004-2012 Michael Niedermayer <michaelni@gmx.at>
5
*
6
* This file is part of FFmpeg.
7
*
8
* FFmpeg is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License as published by the Free Software Foundation; either
11
* version 2.1 of the License, or (at your option) any later version.
12
*
13
* FFmpeg is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
17
*
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with FFmpeg; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
*/
22
23
#include "
config.h
"
24
25
#include "
libavutil/cpu.h
"
26
#include "
libavutil/avassert.h
"
27
28
#include "
libavutil/arm/cpu.h
"
29
#include "
libswresample/resample.h
"
30
31
#define DECLARE_RESAMPLE_COMMON_TEMPLATE(TYPE, DELEM, FELEM, FELEM2, OUT) \
32
\
33
void ff_resample_common_apply_filter_x4_##TYPE##_neon(FELEM2 *acc, const DELEM *src, \
34
const FELEM *filter, int length); \
35
\
36
void ff_resample_common_apply_filter_x8_##TYPE##_neon(FELEM2 *acc, const DELEM *src, \
37
const FELEM *filter, int length); \
38
\
39
static int ff_resample_common_##TYPE##_neon(ResampleContext *c, void *dest, const void *source, \
40
int n, int update_ctx) \
41
{ \
42
DELEM *dst = dest; \
43
const DELEM *src = source; \
44
int dst_index; \
45
int index = c->index; \
46
int frac = c->frac; \
47
int sample_index = 0; \
48
int x4_aligned_filter_length = c->filter_length & ~3; \
49
int x8_aligned_filter_length = c->filter_length & ~7; \
50
\
51
while (index >= c->phase_count) { \
52
sample_index++; \
53
index -= c->phase_count; \
54
} \
55
\
56
for (dst_index = 0; dst_index < n; dst_index++) { \
57
FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index; \
58
\
59
FELEM2 val = 0; \
60
int i = 0; \
61
if (x8_aligned_filter_length >= 8) { \
62
ff_resample_common_apply_filter_x8_##TYPE##_neon(&val, &src[sample_index], \
63
filter, x8_aligned_filter_length); \
64
i += x8_aligned_filter_length; \
65
\
66
} else if (x4_aligned_filter_length >= 4) { \
67
ff_resample_common_apply_filter_x4_##TYPE##_neon(&val, &src[sample_index], \
68
filter, x4_aligned_filter_length); \
69
i += x4_aligned_filter_length; \
70
} \
71
for (; i < c->filter_length; i++) { \
72
val += src[sample_index + i] * (FELEM2)filter[i]; \
73
} \
74
OUT(dst[dst_index], val); \
75
\
76
frac += c->dst_incr_mod; \
77
index += c->dst_incr_div; \
78
if (frac >= c->src_incr) { \
79
frac -= c->src_incr; \
80
index++; \
81
} \
82
\
83
while (index >= c->phase_count) { \
84
sample_index++; \
85
index -= c->phase_count; \
86
} \
87
} \
88
\
89
if (update_ctx) { \
90
c->frac = frac; \
91
c->index = index; \
92
} \
93
\
94
return sample_index; \
95
} \
96
97
#define OUT(d, v) d = v
98
DECLARE_RESAMPLE_COMMON_TEMPLATE
(
float
,
float
,
float
,
float
,
OUT
)
99
#undef OUT
100
101
#define OUT(d, v) (v) = ((v) + (1<<(14)))>>15; (d) = av_clip_int16(v)
102
DECLARE_RESAMPLE_COMMON_TEMPLATE
(s16, int16_t, int16_t,
int32_t
,
OUT
)
103
#undef OUT
104
105
av_cold
void
swri_resample_dsp_arm_init
(
ResampleContext
*
c
)
106
{
107
int
cpu_flags
=
av_get_cpu_flags
();
108
109
if
(!
have_neon
(cpu_flags))
110
return
;
111
112
switch
(c->
format
) {
113
case
AV_SAMPLE_FMT_FLTP
:
114
c->
dsp
.
resample_common
= ff_resample_common_float_neon;
115
break
;
116
case
AV_SAMPLE_FMT_S16P
:
117
c->
dsp
.
resample_common
= ff_resample_common_s16_neon;
118
break
;
119
}
120
}
AV_SAMPLE_FMT_FLTP
float, planar
Definition:
samplefmt.h:69
cpu_flags
static atomic_int cpu_flags
Definition:
cpu.c:50
OUT
#define OUT(d, v)
Definition:
resample_init.c:101
ResampleContext
Definition:
af_resample.c:38
ResampleContext::dsp
struct ResampleContext::@256 dsp
swri_resample_dsp_arm_init
av_cold void swri_resample_dsp_arm_init(ResampleContext *c)
Definition:
resample_init.c:105
ResampleContext::format
enum AVSampleFormat format
Definition:
resample.h:48
config.h
av_cold
#define av_cold
Definition:
attributes.h:82
avassert.h
simple assert() macros that are a bit more flexible than ISO C assert().
have_neon
#define have_neon(flags)
Definition:
cpu.h:27
int32_t
int32_t
Definition:
audio_convert.c:194
cpu.h
cpu.h
ResampleContext::resample_common
int(* resample_common)(struct ResampleContext *c, void *dst, const void *src, int n, int update_ctx)
Definition:
resample.h:56
resample.h
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition:
cpu.c:92
c
static double c[64]
Definition:
vsrc_mptestsrc.c:87
AV_SAMPLE_FMT_S16P
signed 16 bits, planar
Definition:
samplefmt.h:67
DECLARE_RESAMPLE_COMMON_TEMPLATE
#define DECLARE_RESAMPLE_COMMON_TEMPLATE(TYPE, DELEM, FELEM, FELEM2, OUT)
Definition:
resample_init.c:31
Generated on Fri Jan 12 2018 01:48:05 for FFmpeg by
1.8.6