decoder-oina.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 2014 The Android Open Source Project
  4. * Copyright 2006 Open Interface North America, Inc. All rights reserved.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at:
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. ******************************************************************************/
  19. /**********************************************************************************
  20. $Revision: #1 $
  21. ***********************************************************************************/
  22. /**
  23. @file
  24. This file exposes OINA-specific interfaces to decoder functions.
  25. @ingroup codec_internal
  26. */
  27. /**
  28. @addtogroup codec_internal
  29. @{
  30. */
  31. #include <oi_codec_sbc_private.h>
  32. OI_STATUS OI_CODEC_SBC_DecoderConfigureRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
  33. OI_BOOL enhanced,
  34. OI_UINT8 frequency,
  35. OI_UINT8 mode,
  36. OI_UINT8 subbands,
  37. OI_UINT8 blocks,
  38. OI_UINT8 alloc,
  39. OI_UINT8 maxBitpool)
  40. {
  41. if (frequency > SBC_FREQ_48000) {
  42. return OI_STATUS_INVALID_PARAMETERS;
  43. }
  44. if (enhanced) {
  45. #ifdef SBC_ENHANCED
  46. if (subbands != SBC_SUBBANDS_8) {
  47. return OI_STATUS_INVALID_PARAMETERS;
  48. }
  49. #else
  50. return OI_STATUS_INVALID_PARAMETERS;
  51. #endif
  52. }
  53. if (mode > SBC_JOINT_STEREO) {
  54. return OI_STATUS_INVALID_PARAMETERS;
  55. }
  56. if (subbands > SBC_SUBBANDS_8) {
  57. return OI_STATUS_INVALID_PARAMETERS;
  58. }
  59. if (blocks > SBC_BLOCKS_16) {
  60. return OI_STATUS_INVALID_PARAMETERS;
  61. }
  62. if (alloc > SBC_SNR) {
  63. return OI_STATUS_INVALID_PARAMETERS;
  64. }
  65. #ifdef SBC_ENHANCED
  66. context->common.frameInfo.enhanced = enhanced;
  67. #else
  68. context->common.frameInfo.enhanced = FALSE;
  69. #endif
  70. context->common.frameInfo.freqIndex = frequency;
  71. context->common.frameInfo.mode = mode;
  72. context->common.frameInfo.subbands = subbands;
  73. context->common.frameInfo.blocks = blocks;
  74. context->common.frameInfo.alloc = alloc;
  75. context->common.frameInfo.bitpool = maxBitpool;
  76. OI_SBC_ExpandFrameFields(&context->common.frameInfo);
  77. if (context->common.frameInfo.nrof_channels >= context->common.pcmStride) {
  78. return OI_STATUS_INVALID_PARAMETERS;
  79. }
  80. return OI_OK;
  81. }
  82. OI_STATUS OI_CODEC_SBC_DecodeRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
  83. OI_UINT8 bitpool,
  84. const OI_BYTE **frameData,
  85. OI_UINT32 *frameBytes,
  86. OI_INT16 *pcmData,
  87. OI_UINT32 *pcmBytes)
  88. {
  89. return internal_DecodeRaw(context,
  90. bitpool,
  91. frameData,
  92. frameBytes,
  93. pcmData,
  94. pcmBytes);
  95. }
  96. OI_STATUS OI_CODEC_SBC_DecoderLimit(OI_CODEC_SBC_DECODER_CONTEXT *context,
  97. OI_BOOL enhanced,
  98. OI_UINT8 subbands)
  99. {
  100. if (enhanced)
  101. {
  102. #ifdef SBC_ENHANCED
  103. context->enhancedEnabled = TRUE;
  104. #else
  105. context->enhancedEnabled = FALSE;
  106. #endif
  107. }
  108. else
  109. {
  110. context->enhancedEnabled = FALSE;
  111. }
  112. context->restrictSubbands = subbands;
  113. context->limitFrameFormat = TRUE;
  114. return OI_OK;
  115. }
  116. /**
  117. @}
  118. */