summaryrefslogtreecommitdiff
path: root/libavresample/arm/resample_init.c
blob: 540177ed0bc9cbbd66b03229f60490b4b21aa93a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * Copyright (c) 2014 Peter Meerwald <pmeerw@pmeerw.net>
 *
 * This file is part of Libav.
 *
 * Libav is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Libav is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Libav; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "config.h"

#include "libavutil/cpu.h"
#include "libavutil/arm/cpu.h"
#include "libavutil/internal.h"
#include "libavutil/samplefmt.h"

#include "libavresample/resample.h"

#include "asm-offsets.h"

AV_CHECK_OFFSET(struct ResampleContext, filter_bank,   FILTER_BANK);
AV_CHECK_OFFSET(struct ResampleContext, filter_length, FILTER_LENGTH);
AV_CHECK_OFFSET(struct ResampleContext, src_incr,      SRC_INCR);
AV_CHECK_OFFSET(struct ResampleContext, phase_shift,   PHASE_SHIFT);
AV_CHECK_OFFSET(struct ResampleContext, phase_mask,    PHASE_MASK);

void ff_resample_one_flt_neon(struct ResampleContext *c, void *dst0,
                              int dst_index, const void *src0,
                              unsigned int index, int frac);
void ff_resample_one_s16_neon(struct ResampleContext *c, void *dst0,
                              int dst_index, const void *src0,
                              unsigned int index, int frac);
void ff_resample_one_s32_neon(struct ResampleContext *c, void *dst0,
                              int dst_index, const void *src0,
                              unsigned int index, int frac);

void ff_resample_linear_flt_neon(struct ResampleContext *c, void *dst0,
                                 int dst_index, const void *src0,
                                 unsigned int index, int frac);

av_cold void ff_audio_resample_init_arm(ResampleContext *c,
                                        enum AVSampleFormat sample_fmt)
{
    int cpu_flags = av_get_cpu_flags();
    if (have_neon(cpu_flags)) {
        switch (sample_fmt) {
        case AV_SAMPLE_FMT_FLTP:
            if (c->linear)
                c->resample_one = ff_resample_linear_flt_neon;
            else
                c->resample_one = ff_resample_one_flt_neon;
            break;
        case AV_SAMPLE_FMT_S16P:
            if (!c->linear)
                c->resample_one = ff_resample_one_s16_neon;
            break;
        case AV_SAMPLE_FMT_S32P:
            if (!c->linear)
                c->resample_one = ff_resample_one_s32_neon;
            break;
        }
    }
}