SoftAAC2.h revision ab7f4182d4d509733107622216db4dd128340185
1/* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef SOFT_AAC_2_H_ 18#define SOFT_AAC_2_H_ 19 20#include "SimpleSoftOMXComponent.h" 21 22#include "aacdecoder_lib.h" 23#include "DrcPresModeWrap.h" 24 25namespace android { 26 27struct SoftAAC2 : public SimpleSoftOMXComponent { 28 SoftAAC2(const char *name, 29 const OMX_CALLBACKTYPE *callbacks, 30 OMX_PTR appData, 31 OMX_COMPONENTTYPE **component); 32 33protected: 34 virtual ~SoftAAC2(); 35 36 virtual OMX_ERRORTYPE internalGetParameter( 37 OMX_INDEXTYPE index, OMX_PTR params); 38 39 virtual OMX_ERRORTYPE internalSetParameter( 40 OMX_INDEXTYPE index, const OMX_PTR params); 41 42 virtual void onQueueFilled(OMX_U32 portIndex); 43 virtual void onPortFlushCompleted(OMX_U32 portIndex); 44 virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled); 45 virtual void onReset(); 46 47private: 48 enum { 49 kNumInputBuffers = 4, 50 kNumOutputBuffers = 4, 51 kNumDelayBlocksMax = 8, 52 }; 53 54 HANDLE_AACDECODER mAACDecoder; 55 CStreamInfo *mStreamInfo; 56 bool mIsADTS; 57 bool mIsFirst; 58 size_t mInputBufferCount; 59 size_t mOutputBufferCount; 60 bool mSignalledError; 61 OMX_BUFFERHEADERTYPE *mLastInHeader; 62 Vector<int32_t> mBufferSizes; 63 Vector<int32_t> mDecodedSizes; 64 Vector<int64_t> mBufferTimestamps; 65 66 CDrcPresModeWrapper mDrcWrap; 67 68 enum { 69 NONE, 70 AWAITING_DISABLED, 71 AWAITING_ENABLED 72 } mOutputPortSettingsChange; 73 74 void initPorts(); 75 status_t initDecoder(); 76 bool isConfigured() const; 77 void configureDownmix() const; 78 void drainDecoder(); 79 80// delay compensation 81 bool mEndOfInput; 82 bool mEndOfOutput; 83 int32_t mOutputDelayCompensated; 84 int32_t mOutputDelayRingBufferSize; 85 short *mOutputDelayRingBuffer; 86 int32_t mOutputDelayRingBufferWritePos; 87 int32_t mOutputDelayRingBufferReadPos; 88 int32_t mOutputDelayRingBufferFilled; 89 bool outputDelayRingBufferPutSamples(INT_PCM *samples, int numSamples); 90 int32_t outputDelayRingBufferGetSamples(INT_PCM *samples, int numSamples); 91 int32_t outputDelayRingBufferSamplesAvailable(); 92 int32_t outputDelayRingBufferSpaceLeft(); 93 94 DISALLOW_EVIL_CONSTRUCTORS(SoftAAC2); 95}; 96 97} // namespace android 98 99#endif // SOFT_AAC_2_H_ 100