Skip to content

Commit db3f646

Browse files
committed
Merge commit '12655c48049f9a52e5504bde90fe738862b0ff08'
* commit '12655c48049f9a52e5504bde90fe738862b0ff08': libavresample: NEON optimized FIR audio resampling Merged-by: Michael Niedermayer <[email protected]>
2 parents 52a1a55 + 12655c4 commit db3f646

File tree

6 files changed

+470
-2
lines changed

6 files changed

+470
-2
lines changed

libavresample/arm/Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
OBJS += arm/audio_convert_init.o
1+
OBJS += arm/audio_convert_init.o \
2+
arm/resample_init.o
23

34
OBJS-$(CONFIG_NEON_CLOBBER_TEST) += arm/neontest.o
45

5-
NEON-OBJS += arm/audio_convert_neon.o
6+
NEON-OBJS += arm/audio_convert_neon.o \
7+
arm/resample_neon.o

libavresample/arm/asm-offsets.h

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
#ifndef AVRESAMPLE_ARM_ASM_OFFSETS_H
20+
#define AVRESAMPLE_ARM_ASM_OFFSETS_H
21+
22+
/* struct ResampleContext */
23+
#define FILTER_BANK 0x08
24+
#define FILTER_LENGTH 0x0c
25+
#define SRC_INCR 0x20
26+
#define PHASE_SHIFT 0x28
27+
#define PHASE_MASK (PHASE_SHIFT + 0x04)
28+
29+
#endif /* AVRESAMPLE_ARM_ASM_OFFSETS_H */

libavresample/arm/resample_init.c

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (c) 2014 Peter Meerwald <[email protected]>
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/cpu.h"
24+
#include "libavutil/arm/cpu.h"
25+
#include "libavutil/internal.h"
26+
#include "libavutil/samplefmt.h"
27+
28+
#include "libavresample/resample.h"
29+
30+
#include "asm-offsets.h"
31+
32+
AV_CHECK_OFFSET(struct ResampleContext, filter_bank, FILTER_BANK);
33+
AV_CHECK_OFFSET(struct ResampleContext, filter_length, FILTER_LENGTH);
34+
AV_CHECK_OFFSET(struct ResampleContext, src_incr, SRC_INCR);
35+
AV_CHECK_OFFSET(struct ResampleContext, phase_shift, PHASE_SHIFT);
36+
AV_CHECK_OFFSET(struct ResampleContext, phase_mask, PHASE_MASK);
37+
38+
void ff_resample_one_flt_neon(struct ResampleContext *c, void *dst0,
39+
int dst_index, const void *src0,
40+
unsigned int index, int frac);
41+
void ff_resample_one_s16_neon(struct ResampleContext *c, void *dst0,
42+
int dst_index, const void *src0,
43+
unsigned int index, int frac);
44+
void ff_resample_one_s32_neon(struct ResampleContext *c, void *dst0,
45+
int dst_index, const void *src0,
46+
unsigned int index, int frac);
47+
48+
void ff_resample_linear_flt_neon(struct ResampleContext *c, void *dst0,
49+
int dst_index, const void *src0,
50+
unsigned int index, int frac);
51+
52+
av_cold void ff_audio_resample_init_arm(ResampleContext *c,
53+
enum AVSampleFormat sample_fmt)
54+
{
55+
int cpu_flags = av_get_cpu_flags();
56+
if (have_neon(cpu_flags)) {
57+
switch (sample_fmt) {
58+
case AV_SAMPLE_FMT_FLTP:
59+
if (c->linear)
60+
c->resample_one = ff_resample_linear_flt_neon;
61+
else
62+
c->resample_one = ff_resample_one_flt_neon;
63+
break;
64+
case AV_SAMPLE_FMT_S16P:
65+
if (!c->linear)
66+
c->resample_one = ff_resample_one_s16_neon;
67+
break;
68+
case AV_SAMPLE_FMT_S32P:
69+
if (!c->linear)
70+
c->resample_one = ff_resample_one_s32_neon;
71+
break;
72+
}
73+
}
74+
}

0 commit comments

Comments
 (0)