decoder-oina.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 "common/bt_target.h"
  32. #include <oi_codec_sbc_private.h>
  33. #if (defined(SBC_DEC_INCLUDED) && SBC_DEC_INCLUDED == TRUE)
  34. OI_STATUS OI_CODEC_SBC_DecoderConfigureRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
  35. OI_BOOL enhanced,
  36. OI_UINT8 frequency,
  37. OI_UINT8 mode,
  38. OI_UINT8 subbands,
  39. OI_UINT8 blocks,
  40. OI_UINT8 alloc,
  41. OI_UINT8 maxBitpool)
  42. {
  43. if (frequency > SBC_FREQ_48000) {
  44. return OI_STATUS_INVALID_PARAMETERS;
  45. }
  46. if (enhanced) {
  47. #ifdef SBC_ENHANCED
  48. if (subbands != SBC_SUBBANDS_8) {
  49. return OI_STATUS_INVALID_PARAMETERS;
  50. }
  51. #else
  52. return OI_STATUS_INVALID_PARAMETERS;
  53. #endif
  54. }
  55. if (mode > SBC_JOINT_STEREO) {
  56. return OI_STATUS_INVALID_PARAMETERS;
  57. }
  58. if (subbands > SBC_SUBBANDS_8) {
  59. return OI_STATUS_INVALID_PARAMETERS;
  60. }
  61. if (blocks > SBC_BLOCKS_16) {
  62. return OI_STATUS_INVALID_PARAMETERS;
  63. }
  64. if (alloc > SBC_SNR) {
  65. return OI_STATUS_INVALID_PARAMETERS;
  66. }
  67. #ifdef SBC_ENHANCED
  68. context->common.frameInfo.enhanced = enhanced;
  69. #else
  70. context->common.frameInfo.enhanced = FALSE;
  71. #endif
  72. context->common.frameInfo.freqIndex = frequency;
  73. context->common.frameInfo.mode = mode;
  74. context->common.frameInfo.subbands = subbands;
  75. context->common.frameInfo.blocks = blocks;
  76. context->common.frameInfo.alloc = alloc;
  77. context->common.frameInfo.bitpool = maxBitpool;
  78. OI_SBC_ExpandFrameFields(&context->common.frameInfo);
  79. if (context->common.frameInfo.nrof_channels >= context->common.pcmStride) {
  80. return OI_STATUS_INVALID_PARAMETERS;
  81. }
  82. return OI_OK;
  83. }
  84. OI_STATUS OI_CODEC_SBC_DecodeRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
  85. OI_UINT8 bitpool,
  86. const OI_BYTE **frameData,
  87. OI_UINT32 *frameBytes,
  88. OI_INT16 *pcmData,
  89. OI_UINT32 *pcmBytes)
  90. {
  91. return internal_DecodeRaw(context,
  92. bitpool,
  93. frameData,
  94. frameBytes,
  95. pcmData,
  96. pcmBytes);
  97. }
  98. OI_STATUS OI_CODEC_SBC_DecoderLimit(OI_CODEC_SBC_DECODER_CONTEXT *context,
  99. OI_BOOL enhanced,
  100. OI_UINT8 subbands)
  101. {
  102. if (enhanced) {
  103. #ifdef SBC_ENHANCED
  104. context->enhancedEnabled = TRUE;
  105. #else
  106. context->enhancedEnabled = FALSE;
  107. #endif
  108. } else {
  109. context->enhancedEnabled = FALSE;
  110. }
  111. context->restrictSubbands = subbands;
  112. context->limitFrameFormat = TRUE;
  113. return OI_OK;
  114. }
  115. /**
  116. @}
  117. */
  118. #endif /* #if (defined(SBC_DEC_INCLUDED) && SBC_DEC_INCLUDED == TRUE) */