sbrdsp_template.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * AAC Spectral Band Replication decoding functions
  3. * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
  4. * Copyright (c) 2009-2010 Alex Converse <alex.converse@gmail.com>
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. static void sbr_sum64x5_c(INTFLOAT *z)
  23. {
  24. int k;
  25. for (k = 0; k < 64; k++) {
  26. INTFLOAT f = z[k] + z[k + 64] + z[k + 128] + z[k + 192] + z[k + 256];
  27. z[k] = f;
  28. }
  29. }
  30. static void sbr_qmf_deint_bfly_c(INTFLOAT *v, const INTFLOAT *src0, const INTFLOAT *src1)
  31. {
  32. int i;
  33. for (i = 0; i < 64; i++) {
  34. #if USE_FIXED
  35. v[ i] = (int)(0x10U + src0[i] - src1[63 - i]) >> 5;
  36. v[127 - i] = (int)(0x10U + src0[i] + src1[63 - i]) >> 5;
  37. #else
  38. v[ i] = src0[i] - src1[63 - i];
  39. v[127 - i] = src0[i] + src1[63 - i];
  40. #endif
  41. }
  42. }
  43. static void sbr_hf_apply_noise_0(INTFLOAT (*Y)[2], const AAC_FLOAT *s_m,
  44. const AAC_FLOAT *q_filt, int noise,
  45. int kx, int m_max)
  46. {
  47. sbr_hf_apply_noise(Y, s_m, q_filt, noise, (INTFLOAT)1.0, (INTFLOAT)0.0, m_max);
  48. }
  49. static void sbr_hf_apply_noise_1(INTFLOAT (*Y)[2], const AAC_FLOAT *s_m,
  50. const AAC_FLOAT *q_filt, int noise,
  51. int kx, int m_max)
  52. {
  53. INTFLOAT phi_sign = 1 - 2 * (kx & 1);
  54. sbr_hf_apply_noise(Y, s_m, q_filt, noise, (INTFLOAT)0.0, phi_sign, m_max);
  55. }
  56. static void sbr_hf_apply_noise_2(INTFLOAT (*Y)[2], const AAC_FLOAT *s_m,
  57. const AAC_FLOAT *q_filt, int noise,
  58. int kx, int m_max)
  59. {
  60. sbr_hf_apply_noise(Y, s_m, q_filt, noise, (INTFLOAT)-1.0, (INTFLOAT)0.0, m_max);
  61. }
  62. static void sbr_hf_apply_noise_3(INTFLOAT (*Y)[2], const AAC_FLOAT *s_m,
  63. const AAC_FLOAT *q_filt, int noise,
  64. int kx, int m_max)
  65. {
  66. INTFLOAT phi_sign = 1 - 2 * (kx & 1);
  67. sbr_hf_apply_noise(Y, s_m, q_filt, noise, (INTFLOAT)0.0, -phi_sign, m_max);
  68. }
  69. av_cold void AAC_RENAME(ff_sbrdsp_init)(SBRDSPContext *s)
  70. {
  71. s->sum64x5 = sbr_sum64x5_c;
  72. s->sum_square = sbr_sum_square_c;
  73. s->neg_odd_64 = sbr_neg_odd_64_c;
  74. s->qmf_pre_shuffle = sbr_qmf_pre_shuffle_c;
  75. s->qmf_post_shuffle = sbr_qmf_post_shuffle_c;
  76. s->qmf_deint_neg = sbr_qmf_deint_neg_c;
  77. s->qmf_deint_bfly = sbr_qmf_deint_bfly_c;
  78. s->autocorrelate = sbr_autocorrelate_c;
  79. s->hf_gen = sbr_hf_gen_c;
  80. s->hf_g_filt = sbr_hf_g_filt_c;
  81. s->hf_apply_noise[0] = sbr_hf_apply_noise_0;
  82. s->hf_apply_noise[1] = sbr_hf_apply_noise_1;
  83. s->hf_apply_noise[2] = sbr_hf_apply_noise_2;
  84. s->hf_apply_noise[3] = sbr_hf_apply_noise_3;
  85. #if !USE_FIXED
  86. if (ARCH_ARM)
  87. ff_sbrdsp_init_arm(s);
  88. if (ARCH_AARCH64)
  89. ff_sbrdsp_init_aarch64(s);
  90. if (ARCH_X86)
  91. ff_sbrdsp_init_x86(s);
  92. if (ARCH_MIPS)
  93. ff_sbrdsp_init_mips(s);
  94. #endif /* !USE_FIXED */
  95. }