sbcdsp_init_arm.c 3.9 KB

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