sbcdsp.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 basic "building bricks"
  29. */
  30. #ifndef AVCODEC_SBCDSP_H
  31. #define AVCODEC_SBCDSP_H
  32. #include "sbc.h"
  33. #include "sbcdsp_data.h"
  34. #define SCALE_OUT_BITS 15
  35. #define SBC_X_BUFFER_SIZE 328
  36. typedef struct sbc_dsp_context SBCDSPContext;
  37. struct sbc_dsp_context {
  38. int position;
  39. /* Number of consecutive blocks handled by the encoder */
  40. uint8_t increment;
  41. DECLARE_ALIGNED(SBC_ALIGN, int16_t, X)[2][SBC_X_BUFFER_SIZE];
  42. void (*sbc_analyze_4)(const int16_t *in, int32_t *out, const int16_t *consts);
  43. void (*sbc_analyze_8)(const int16_t *in, int32_t *out, const int16_t *consts);
  44. /* Polyphase analysis filter for 4 subbands configuration,
  45. * it handles "increment" blocks at once */
  46. void (*sbc_analyze_4s)(SBCDSPContext *s,
  47. int16_t *x, int32_t *out, int out_stride);
  48. /* Polyphase analysis filter for 8 subbands configuration,
  49. * it handles "increment" blocks at once */
  50. void (*sbc_analyze_8s)(SBCDSPContext *s,
  51. int16_t *x, int32_t *out, int out_stride);
  52. /* Process input data (deinterleave, endian conversion, reordering),
  53. * depending on the number of subbands and input data byte order */
  54. int (*sbc_enc_process_input_4s)(int position, const uint8_t *pcm,
  55. int16_t X[2][SBC_X_BUFFER_SIZE],
  56. int nsamples, int nchannels);
  57. int (*sbc_enc_process_input_8s)(int position, const uint8_t *pcm,
  58. int16_t X[2][SBC_X_BUFFER_SIZE],
  59. int nsamples, int nchannels);
  60. /* Scale factors calculation */
  61. void (*sbc_calc_scalefactors)(int32_t sb_sample_f[16][2][8],
  62. uint32_t scale_factor[2][8],
  63. int blocks, int channels, int subbands);
  64. /* Scale factors calculation with joint stereo support */
  65. int (*sbc_calc_scalefactors_j)(int32_t sb_sample_f[16][2][8],
  66. uint32_t scale_factor[2][8],
  67. int blocks, int subbands);
  68. };
  69. /*
  70. * Initialize pointers to the functions which are the basic "building bricks"
  71. * of SBC codec. Best implementation is selected based on target CPU
  72. * capabilities.
  73. */
  74. void ff_sbcdsp_init(SBCDSPContext *s);
  75. void ff_sbcdsp_init_arm(SBCDSPContext *s);
  76. void ff_sbcdsp_init_x86(SBCDSPContext *s);
  77. #endif /* AVCODEC_SBCDSP_H */