1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * Bluetooth low-complexity, subband codec (SBC) 3cabdff1aSopenharmony_ci * 4cabdff1aSopenharmony_ci * Copyright (C) 2017 Aurelien Jacobs <aurel@gnuage.org> 5cabdff1aSopenharmony_ci * Copyright (C) 2008-2010 Nokia Corporation 6cabdff1aSopenharmony_ci * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> 7cabdff1aSopenharmony_ci * Copyright (C) 2004-2005 Henryk Ploetz <henryk@ploetzli.ch> 8cabdff1aSopenharmony_ci * Copyright (C) 2005-2006 Brad Midgley <bmidgley@xmission.com> 9cabdff1aSopenharmony_ci * 10cabdff1aSopenharmony_ci * This file is part of FFmpeg. 11cabdff1aSopenharmony_ci * 12cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 13cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 14cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 15cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 16cabdff1aSopenharmony_ci * 17cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 18cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 19cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20cabdff1aSopenharmony_ci * Lesser General Public License for more details. 21cabdff1aSopenharmony_ci * 22cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 23cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 24cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25cabdff1aSopenharmony_ci */ 26cabdff1aSopenharmony_ci 27cabdff1aSopenharmony_ci/** 28cabdff1aSopenharmony_ci * @file 29cabdff1aSopenharmony_ci * SBC ARMv6 optimization for some basic "building bricks" 30cabdff1aSopenharmony_ci */ 31cabdff1aSopenharmony_ci 32cabdff1aSopenharmony_ci#include "libavutil/attributes.h" 33cabdff1aSopenharmony_ci#include "libavutil/cpu.h" 34cabdff1aSopenharmony_ci#include "libavutil/mem_internal.h" 35cabdff1aSopenharmony_ci#include "libavutil/arm/cpu.h" 36cabdff1aSopenharmony_ci#include "libavcodec/sbcdsp.h" 37cabdff1aSopenharmony_ci 38cabdff1aSopenharmony_civoid ff_sbc_analyze_4_armv6(const int16_t *in, int32_t *out, const int16_t *consts); 39cabdff1aSopenharmony_civoid ff_sbc_analyze_8_armv6(const int16_t *in, int32_t *out, const int16_t *consts); 40cabdff1aSopenharmony_ci 41cabdff1aSopenharmony_civoid ff_sbc_analyze_4_neon(const int16_t *in, int32_t *out, const int16_t *consts); 42cabdff1aSopenharmony_civoid ff_sbc_analyze_8_neon(const int16_t *in, int32_t *out, const int16_t *consts); 43cabdff1aSopenharmony_civoid ff_sbc_calc_scalefactors_neon(int32_t sb_sample_f[16][2][8], 44cabdff1aSopenharmony_ci uint32_t scale_factor[2][8], 45cabdff1aSopenharmony_ci int blocks, int channels, int subbands); 46cabdff1aSopenharmony_ciint ff_sbc_calc_scalefactors_j_neon(int32_t sb_sample_f[16][2][8], 47cabdff1aSopenharmony_ci uint32_t scale_factor[2][8], 48cabdff1aSopenharmony_ci int blocks, int subbands); 49cabdff1aSopenharmony_ciint ff_sbc_enc_process_input_4s_neon(int position, const uint8_t *pcm, 50cabdff1aSopenharmony_ci int16_t X[2][SBC_X_BUFFER_SIZE], 51cabdff1aSopenharmony_ci int nsamples, int nchannels); 52cabdff1aSopenharmony_ciint ff_sbc_enc_process_input_8s_neon(int position, const uint8_t *pcm, 53cabdff1aSopenharmony_ci int16_t X[2][SBC_X_BUFFER_SIZE], 54cabdff1aSopenharmony_ci int nsamples, int nchannels); 55cabdff1aSopenharmony_ci 56cabdff1aSopenharmony_ciDECLARE_ALIGNED(SBC_ALIGN, int32_t, ff_sbcdsp_joint_bits_mask)[8] = { 57cabdff1aSopenharmony_ci 8, 4, 2, 1, 128, 64, 32, 16 58cabdff1aSopenharmony_ci}; 59cabdff1aSopenharmony_ci 60cabdff1aSopenharmony_ci#if HAVE_BIGENDIAN 61cabdff1aSopenharmony_ci#define PERM(a, b, c, d) { \ 62cabdff1aSopenharmony_ci (a * 2) + 1, (a * 2) + 0, \ 63cabdff1aSopenharmony_ci (b * 2) + 1, (b * 2) + 0, \ 64cabdff1aSopenharmony_ci (c * 2) + 1, (c * 2) + 0, \ 65cabdff1aSopenharmony_ci (d * 2) + 1, (d * 2) + 0 \ 66cabdff1aSopenharmony_ci } 67cabdff1aSopenharmony_ci#else 68cabdff1aSopenharmony_ci#define PERM(a, b, c, d) { \ 69cabdff1aSopenharmony_ci (a * 2) + 0, (a * 2) + 1, \ 70cabdff1aSopenharmony_ci (b * 2) + 0, (b * 2) + 1, \ 71cabdff1aSopenharmony_ci (c * 2) + 0, (c * 2) + 1, \ 72cabdff1aSopenharmony_ci (d * 2) + 0, (d * 2) + 1 \ 73cabdff1aSopenharmony_ci } 74cabdff1aSopenharmony_ci#endif 75cabdff1aSopenharmony_ci 76cabdff1aSopenharmony_ciDECLARE_ALIGNED(SBC_ALIGN, uint8_t, ff_sbc_input_perm_4)[2][8] = { 77cabdff1aSopenharmony_ci PERM(7, 3, 6, 4), 78cabdff1aSopenharmony_ci PERM(0, 2, 1, 5) 79cabdff1aSopenharmony_ci}; 80cabdff1aSopenharmony_ci 81cabdff1aSopenharmony_ciDECLARE_ALIGNED(SBC_ALIGN, uint8_t, ff_sbc_input_perm_8)[4][8] = { 82cabdff1aSopenharmony_ci PERM(15, 7, 14, 8), 83cabdff1aSopenharmony_ci PERM(13, 9, 12, 10), 84cabdff1aSopenharmony_ci PERM(11, 3, 6, 0), 85cabdff1aSopenharmony_ci PERM( 5, 1, 4, 2) 86cabdff1aSopenharmony_ci}; 87cabdff1aSopenharmony_ci 88cabdff1aSopenharmony_ciav_cold void ff_sbcdsp_init_arm(SBCDSPContext *s) 89cabdff1aSopenharmony_ci{ 90cabdff1aSopenharmony_ci int cpu_flags = av_get_cpu_flags(); 91cabdff1aSopenharmony_ci 92cabdff1aSopenharmony_ci if (have_armv6(cpu_flags)) { 93cabdff1aSopenharmony_ci s->sbc_analyze_4 = ff_sbc_analyze_4_armv6; 94cabdff1aSopenharmony_ci s->sbc_analyze_8 = ff_sbc_analyze_8_armv6; 95cabdff1aSopenharmony_ci } 96cabdff1aSopenharmony_ci 97cabdff1aSopenharmony_ci if (have_neon(cpu_flags)) { 98cabdff1aSopenharmony_ci s->sbc_analyze_4 = ff_sbc_analyze_4_neon; 99cabdff1aSopenharmony_ci s->sbc_analyze_8 = ff_sbc_analyze_8_neon; 100cabdff1aSopenharmony_ci s->sbc_calc_scalefactors = ff_sbc_calc_scalefactors_neon; 101cabdff1aSopenharmony_ci s->sbc_calc_scalefactors_j = ff_sbc_calc_scalefactors_j_neon; 102cabdff1aSopenharmony_ci if (s->increment != 1) { 103cabdff1aSopenharmony_ci s->sbc_enc_process_input_4s = ff_sbc_enc_process_input_4s_neon; 104cabdff1aSopenharmony_ci s->sbc_enc_process_input_8s = ff_sbc_enc_process_input_8s_neon; 105cabdff1aSopenharmony_ci } 106cabdff1aSopenharmony_ci } 107cabdff1aSopenharmony_ci} 108