yading@11
|
1 /*
|
yading@11
|
2 * This file is part of libswresample.
|
yading@11
|
3 *
|
yading@11
|
4 * libswresample is free software; you can redistribute it and/or
|
yading@11
|
5 * modify it under the terms of the GNU Lesser General Public
|
yading@11
|
6 * License as published by the Free Software Foundation; either
|
yading@11
|
7 * version 2.1 of the License, or (at your option) any later version.
|
yading@11
|
8 *
|
yading@11
|
9 * libswresample is distributed in the hope that it will be useful,
|
yading@11
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@11
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@11
|
12 * Lesser General Public License for more details.
|
yading@11
|
13 *
|
yading@11
|
14 * You should have received a copy of the GNU Lesser General Public
|
yading@11
|
15 * License along with libswresample; if not, write to the Free Software
|
yading@11
|
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@11
|
17 */
|
yading@11
|
18
|
yading@11
|
19 #include <stdint.h>
|
yading@11
|
20
|
yading@11
|
21 #include "config.h"
|
yading@11
|
22 #include "libavutil/attributes.h"
|
yading@11
|
23 #include "libavutil/cpu.h"
|
yading@11
|
24 #include "libavutil/arm/cpu.h"
|
yading@11
|
25 #include "libavutil/samplefmt.h"
|
yading@11
|
26 #include "libswresample/swresample_internal.h"
|
yading@11
|
27 #include "libswresample/audioconvert.h"
|
yading@11
|
28
|
yading@11
|
29 void swri_oldapi_conv_flt_to_s16_neon(int16_t *dst, const float *src, int len);
|
yading@11
|
30 void swri_oldapi_conv_fltp_to_s16_2ch_neon(int16_t *dst, float *const *src, int len, int channels);
|
yading@11
|
31 void swri_oldapi_conv_fltp_to_s16_nch_neon(int16_t *dst, float *const *src, int len, int channels);
|
yading@11
|
32
|
yading@11
|
33 static void conv_flt_to_s16_neon(uint8_t **dst, const uint8_t **src, int len){
|
yading@11
|
34 swri_oldapi_conv_flt_to_s16_neon((int16_t*)*dst, (const float*)*src, len);
|
yading@11
|
35 }
|
yading@11
|
36
|
yading@11
|
37 static void conv_fltp_to_s16_2ch_neon(uint8_t **dst, const uint8_t **src, int len){
|
yading@11
|
38 swri_oldapi_conv_fltp_to_s16_2ch_neon((int16_t*)*dst, (float *const*)src, len, 2);
|
yading@11
|
39 }
|
yading@11
|
40
|
yading@11
|
41 static void conv_fltp_to_s16_nch_neon(uint8_t **dst, const uint8_t **src, int len){
|
yading@11
|
42 int channels;
|
yading@11
|
43 for(channels=3; channels<SWR_CH_MAX && src[channels]; channels++)
|
yading@11
|
44 ;
|
yading@11
|
45 swri_oldapi_conv_fltp_to_s16_nch_neon((int16_t*)*dst, (float *const*)src, len, channels);
|
yading@11
|
46 }
|
yading@11
|
47
|
yading@11
|
48 av_cold void swri_audio_convert_init_arm(struct AudioConvert *ac,
|
yading@11
|
49 enum AVSampleFormat out_fmt,
|
yading@11
|
50 enum AVSampleFormat in_fmt,
|
yading@11
|
51 int channels)
|
yading@11
|
52 {
|
yading@11
|
53 int cpu_flags = av_get_cpu_flags();
|
yading@11
|
54
|
yading@11
|
55 ac->simd_f= NULL;
|
yading@11
|
56
|
yading@11
|
57 if (have_neon(cpu_flags)) {
|
yading@11
|
58 if(out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP)
|
yading@11
|
59 ac->simd_f = conv_flt_to_s16_neon;
|
yading@11
|
60 if(out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLTP && channels == 2)
|
yading@11
|
61 ac->simd_f = conv_fltp_to_s16_2ch_neon;
|
yading@11
|
62 if(out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLTP && channels > 2)
|
yading@11
|
63 ac->simd_f = conv_fltp_to_s16_nch_neon;
|
yading@11
|
64 if(ac->simd_f)
|
yading@11
|
65 ac->in_simd_align_mask = ac->out_simd_align_mask = 15;
|
yading@11
|
66 }
|
yading@11
|
67 }
|