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/******************************************************************************* 21 $Revision: #1 $ 22 ******************************************************************************/ 23 24/** 25@file 26This file exposes OINA-specific interfaces to decoder functions. 27 28@ingroup codec_internal 29*/ 30 31/** 32@addtogroup codec_internal 33@{ 34*/ 35 36#include <oi_codec_sbc_private.h> 37 38OI_STATUS OI_CODEC_SBC_DecoderConfigureRaw( 39 OI_CODEC_SBC_DECODER_CONTEXT* context, OI_BOOL enhanced, uint8_t frequency, 40 uint8_t mode, uint8_t subbands, uint8_t blocks, uint8_t alloc, 41 uint8_t maxBitpool) { 42 if (frequency > SBC_FREQ_48000) { 43 return OI_STATUS_INVALID_PARAMETERS; 44 } 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 56 if (mode > SBC_JOINT_STEREO) { 57 return OI_STATUS_INVALID_PARAMETERS; 58 } 59 60 if (subbands > SBC_SUBBANDS_8) { 61 return OI_STATUS_INVALID_PARAMETERS; 62 } 63 64 if (blocks > SBC_BLOCKS_16) { 65 return OI_STATUS_INVALID_PARAMETERS; 66 } 67 68 if (alloc > SBC_SNR) { 69 return OI_STATUS_INVALID_PARAMETERS; 70 } 71 72#ifdef SBC_ENHANCED 73 context->common.frameInfo.enhanced = enhanced; 74#else 75 context->common.frameInfo.enhanced = FALSE; 76#endif 77 context->common.frameInfo.freqIndex = frequency; 78 context->common.frameInfo.mode = mode; 79 context->common.frameInfo.subbands = subbands; 80 context->common.frameInfo.blocks = blocks; 81 context->common.frameInfo.alloc = alloc; 82 context->common.frameInfo.bitpool = maxBitpool; 83 84 OI_SBC_ExpandFrameFields(&context->common.frameInfo); 85 86 if (context->common.frameInfo.nrof_channels >= context->common.pcmStride) { 87 return OI_STATUS_INVALID_PARAMETERS; 88 } 89 90 return OI_OK; 91} 92 93OI_STATUS OI_CODEC_SBC_DecodeRaw(OI_CODEC_SBC_DECODER_CONTEXT* context, 94 uint8_t bitpool, const OI_BYTE** frameData, 95 uint32_t* frameBytes, int16_t* pcmData, 96 uint32_t* pcmBytes) { 97 return internal_DecodeRaw(context, bitpool, frameData, frameBytes, pcmData, 98 pcmBytes); 99} 100 101OI_STATUS OI_CODEC_SBC_DecoderLimit(OI_CODEC_SBC_DECODER_CONTEXT* context, 102 OI_BOOL enhanced, uint8_t subbands) { 103 if (enhanced) { 104#ifdef SBC_ENHANCED 105 context->enhancedEnabled = TRUE; 106#else 107 context->enhancedEnabled = FALSE; 108#endif 109 } else { 110 context->enhancedEnabled = FALSE; 111 } 112 context->restrictSubbands = subbands; 113 context->limitFrameFormat = TRUE; 114 return OI_OK; 115} 116 117/** 118@} 119*/ 120