arm_dct4_init_f32.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_dct4_init_f32.c
  4. * Description: Initialization function of DCT-4 & IDCT4 F32
  5. *
  6. * $Date: 23 April 2021
  7. * $Revision: V1.9.0
  8. *
  9. * Target Processor: Cortex-M and Cortex-A cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
  13. *
  14. * SPDX-License-Identifier: Apache-2.0
  15. *
  16. * Licensed under the Apache License, Version 2.0 (the License); you may
  17. * not use this file except in compliance with the License.
  18. * You may obtain a copy of the License at
  19. *
  20. * www.apache.org/licenses/LICENSE-2.0
  21. *
  22. * Unless required by applicable law or agreed to in writing, software
  23. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  24. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  25. * See the License for the specific language governing permissions and
  26. * limitations under the License.
  27. */
  28. #include "dsp/transform_functions.h"
  29. #include "arm_common_tables.h"
  30. /**
  31. * @defgroup DCT4F32 DCT4 F32
  32. */
  33. /**
  34. @ingroup DCT4_IDCT4
  35. */
  36. /**
  37. @addtogroup DCT4F32
  38. @{
  39. */
  40. /**
  41. @brief Initialization function for the floating-point DCT4/IDCT4.
  42. @deprecated Do not use this function. It is using a deprecated version of the RFFT.
  43. @param[in,out] S points to an instance of floating-point DCT4/IDCT4 structure
  44. @param[in] S_RFFT points to an instance of floating-point RFFT/RIFFT structure
  45. @param[in] S_CFFT points to an instance of floating-point CFFT/CIFFT structure
  46. @param[in] N length of the DCT4
  47. @param[in] Nby2 half of the length of the DCT4
  48. @param[in] normalize normalizing factor.
  49. @return execution status
  50. - \ref ARM_MATH_SUCCESS : Operation successful
  51. - \ref ARM_MATH_ARGUMENT_ERROR : <code>N</code> is not a supported transform length
  52. @par Normalizing factor
  53. The normalizing factor is <code>sqrt(2/N)</code>, which depends on the size of transform <code>N</code>.
  54. Floating-point normalizing factors are mentioned in the table below for different DCT sizes:
  55. | DCT Size | Normalizing factor value |
  56. | --------: | ------------------------: |
  57. | 2048 | 0.03125 |
  58. | 512 | 0.0625 |
  59. | 128 | 0.125 |
  60. */
  61. arm_status arm_dct4_init_f32(
  62. arm_dct4_instance_f32 * S,
  63. arm_rfft_instance_f32 * S_RFFT,
  64. arm_cfft_radix4_instance_f32 * S_CFFT,
  65. uint16_t N,
  66. uint16_t Nby2,
  67. float32_t normalize)
  68. {
  69. /* Initialize the default arm status */
  70. arm_status status = ARM_MATH_SUCCESS;
  71. /* Initialize the DCT4 length */
  72. S->N = N;
  73. /* Initialize the half of DCT4 length */
  74. S->Nby2 = Nby2;
  75. /* Initialize the DCT4 Normalizing factor */
  76. S->normalize = normalize;
  77. /* Initialize Real FFT Instance */
  78. S->pRfft = S_RFFT;
  79. /* Initialize Complex FFT Instance */
  80. S->pCfft = S_CFFT;
  81. switch (N)
  82. {
  83. /* Initialize the table modifier values */
  84. case 8192U:
  85. S->pTwiddle = Weights_8192;
  86. S->pCosFactor = cos_factors_8192;
  87. break;
  88. case 2048U:
  89. S->pTwiddle = Weights_2048;
  90. S->pCosFactor = cos_factors_2048;
  91. break;
  92. case 512U:
  93. S->pTwiddle = Weights_512;
  94. S->pCosFactor = cos_factors_512;
  95. break;
  96. case 128U:
  97. S->pTwiddle = Weights_128;
  98. S->pCosFactor = cos_factors_128;
  99. break;
  100. default:
  101. status = ARM_MATH_ARGUMENT_ERROR;
  102. }
  103. /* Initialize the RFFT/RIFFT Function */
  104. arm_rfft_init_f32(S->pRfft, S->pCfft, S->N, 0U, 1U);
  105. /* return the status of DCT4 Init function */
  106. return (status);
  107. }
  108. /**
  109. @} end of DCT4F32 group
  110. */