SoftAVC.h revision d94e716af0e49d775f0c0c4f36dd2c136ba5f2b2
10c1bc742181ded4930842b46e9507372f0b1b963James Dong/* 20c1bc742181ded4930842b46e9507372f0b1b963James Dong * Copyright (C) 2011 The Android Open Source Project 30c1bc742181ded4930842b46e9507372f0b1b963James Dong * 40c1bc742181ded4930842b46e9507372f0b1b963James Dong * Licensed under the Apache License, Version 2.0 (the "License"); 50c1bc742181ded4930842b46e9507372f0b1b963James Dong * you may not use this file except in compliance with the License. 60c1bc742181ded4930842b46e9507372f0b1b963James Dong * You may obtain a copy of the License at 70c1bc742181ded4930842b46e9507372f0b1b963James Dong * 80c1bc742181ded4930842b46e9507372f0b1b963James Dong * http://www.apache.org/licenses/LICENSE-2.0 90c1bc742181ded4930842b46e9507372f0b1b963James Dong * 100c1bc742181ded4930842b46e9507372f0b1b963James Dong * Unless required by applicable law or agreed to in writing, software 110c1bc742181ded4930842b46e9507372f0b1b963James Dong * distributed under the License is distributed on an "AS IS" BASIS, 120c1bc742181ded4930842b46e9507372f0b1b963James Dong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130c1bc742181ded4930842b46e9507372f0b1b963James Dong * See the License for the specific language governing permissions and 140c1bc742181ded4930842b46e9507372f0b1b963James Dong * limitations under the License. 150c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 160c1bc742181ded4930842b46e9507372f0b1b963James Dong 170c1bc742181ded4930842b46e9507372f0b1b963James Dong#ifndef SOFT_AVC_H_ 180c1bc742181ded4930842b46e9507372f0b1b963James Dong 190c1bc742181ded4930842b46e9507372f0b1b963James Dong#define SOFT_AVC_H_ 200c1bc742181ded4930842b46e9507372f0b1b963James Dong 210c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "SimpleSoftOMXComponent.h" 220c1bc742181ded4930842b46e9507372f0b1b963James Dong#include <utils/KeyedVector.h> 230c1bc742181ded4930842b46e9507372f0b1b963James Dong 240c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "H264SwDecApi.h" 250c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "basetype.h" 260c1bc742181ded4930842b46e9507372f0b1b963James Dong 270c1bc742181ded4930842b46e9507372f0b1b963James Dongnamespace android { 280c1bc742181ded4930842b46e9507372f0b1b963James Dong 290c1bc742181ded4930842b46e9507372f0b1b963James Dongstruct SoftAVC : public SimpleSoftOMXComponent { 300c1bc742181ded4930842b46e9507372f0b1b963James Dong SoftAVC(const char *name, 310c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_CALLBACKTYPE *callbacks, 320c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_PTR appData, 330c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_COMPONENTTYPE **component); 340c1bc742181ded4930842b46e9507372f0b1b963James Dong 350c1bc742181ded4930842b46e9507372f0b1b963James Dongprotected: 360c1bc742181ded4930842b46e9507372f0b1b963James Dong virtual ~SoftAVC(); 370c1bc742181ded4930842b46e9507372f0b1b963James Dong 380c1bc742181ded4930842b46e9507372f0b1b963James Dong virtual OMX_ERRORTYPE internalGetParameter( 390c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INDEXTYPE index, OMX_PTR params); 400c1bc742181ded4930842b46e9507372f0b1b963James Dong 410c1bc742181ded4930842b46e9507372f0b1b963James Dong virtual OMX_ERRORTYPE internalSetParameter( 420c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INDEXTYPE index, const OMX_PTR params); 430c1bc742181ded4930842b46e9507372f0b1b963James Dong 440c1bc742181ded4930842b46e9507372f0b1b963James Dong virtual OMX_ERRORTYPE getConfig(OMX_INDEXTYPE index, OMX_PTR params); 450c1bc742181ded4930842b46e9507372f0b1b963James Dong 460c1bc742181ded4930842b46e9507372f0b1b963James Dong virtual void onQueueFilled(OMX_U32 portIndex); 470c1bc742181ded4930842b46e9507372f0b1b963James Dong virtual void onPortFlushCompleted(OMX_U32 portIndex); 480c1bc742181ded4930842b46e9507372f0b1b963James Dong virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled); 49d94e716af0e49d775f0c0c4f36dd2c136ba5f2b2Andreas Huber virtual void onReset(); 500c1bc742181ded4930842b46e9507372f0b1b963James Dong 510c1bc742181ded4930842b46e9507372f0b1b963James Dongprivate: 520c1bc742181ded4930842b46e9507372f0b1b963James Dong enum { 530c1bc742181ded4930842b46e9507372f0b1b963James Dong kInputPortIndex = 0, 540c1bc742181ded4930842b46e9507372f0b1b963James Dong kOutputPortIndex = 1, 550c1bc742181ded4930842b46e9507372f0b1b963James Dong kNumInputBuffers = 8, 56486247017e0bfb9db9994a53a28c0dacfebf8567James Dong kNumOutputBuffers = 2, 570c1bc742181ded4930842b46e9507372f0b1b963James Dong }; 580c1bc742181ded4930842b46e9507372f0b1b963James Dong 590c1bc742181ded4930842b46e9507372f0b1b963James Dong enum EOSStatus { 600c1bc742181ded4930842b46e9507372f0b1b963James Dong INPUT_DATA_AVAILABLE, 610c1bc742181ded4930842b46e9507372f0b1b963James Dong INPUT_EOS_SEEN, 620c1bc742181ded4930842b46e9507372f0b1b963James Dong OUTPUT_FRAMES_FLUSHED, 630c1bc742181ded4930842b46e9507372f0b1b963James Dong }; 640c1bc742181ded4930842b46e9507372f0b1b963James Dong 650c1bc742181ded4930842b46e9507372f0b1b963James Dong void *mHandle; 660c1bc742181ded4930842b46e9507372f0b1b963James Dong 670c1bc742181ded4930842b46e9507372f0b1b963James Dong size_t mInputBufferCount; 680c1bc742181ded4930842b46e9507372f0b1b963James Dong 690c1bc742181ded4930842b46e9507372f0b1b963James Dong uint32_t mWidth, mHeight, mPictureSize; 700c1bc742181ded4930842b46e9507372f0b1b963James Dong uint32_t mCropLeft, mCropTop; 71639ffaca514deb9de538bc2dc6e712380db68fd3James Dong uint32_t mCropWidth, mCropHeight; 720c1bc742181ded4930842b46e9507372f0b1b963James Dong 730c1bc742181ded4930842b46e9507372f0b1b963James Dong uint8_t *mFirstPicture; 740c1bc742181ded4930842b46e9507372f0b1b963James Dong int32_t mFirstPictureId; 750c1bc742181ded4930842b46e9507372f0b1b963James Dong 760c1bc742181ded4930842b46e9507372f0b1b963James Dong int32_t mPicId; // Which output picture is for which input buffer? 770c1bc742181ded4930842b46e9507372f0b1b963James Dong 780c1bc742181ded4930842b46e9507372f0b1b963James Dong // OMX_BUFFERHEADERTYPE may be overkill, but it is convenient 790c1bc742181ded4930842b46e9507372f0b1b963James Dong // for tracking the following fields: nFlags, nTimeStamp, etc. 800c1bc742181ded4930842b46e9507372f0b1b963James Dong KeyedVector<int32_t, OMX_BUFFERHEADERTYPE *> mPicToHeaderMap; 810c1bc742181ded4930842b46e9507372f0b1b963James Dong bool mHeadersDecoded; 820c1bc742181ded4930842b46e9507372f0b1b963James Dong 830c1bc742181ded4930842b46e9507372f0b1b963James Dong EOSStatus mEOSStatus; 840c1bc742181ded4930842b46e9507372f0b1b963James Dong 850c1bc742181ded4930842b46e9507372f0b1b963James Dong enum OutputPortSettingChange { 860c1bc742181ded4930842b46e9507372f0b1b963James Dong NONE, 870c1bc742181ded4930842b46e9507372f0b1b963James Dong AWAITING_DISABLED, 880c1bc742181ded4930842b46e9507372f0b1b963James Dong AWAITING_ENABLED 890c1bc742181ded4930842b46e9507372f0b1b963James Dong }; 900c1bc742181ded4930842b46e9507372f0b1b963James Dong OutputPortSettingChange mOutputPortSettingsChange; 910c1bc742181ded4930842b46e9507372f0b1b963James Dong 922961a85f5f00343c115ac8e5dc17de631694fb6eAndreas Huber bool mSignalledError; 932961a85f5f00343c115ac8e5dc17de631694fb6eAndreas Huber 940c1bc742181ded4930842b46e9507372f0b1b963James Dong void initPorts(); 950c1bc742181ded4930842b46e9507372f0b1b963James Dong status_t initDecoder(); 960c1bc742181ded4930842b46e9507372f0b1b963James Dong void updatePortDefinitions(); 970c1bc742181ded4930842b46e9507372f0b1b963James Dong bool drainAllOutputBuffers(); 980c1bc742181ded4930842b46e9507372f0b1b963James Dong void drainOneOutputBuffer(int32_t picId, uint8_t *data); 990c1bc742181ded4930842b46e9507372f0b1b963James Dong void saveFirstOutputBuffer(int32_t pidId, uint8_t *data); 1000c1bc742181ded4930842b46e9507372f0b1b963James Dong bool handleCropRectEvent(const CropParams* crop); 1010c1bc742181ded4930842b46e9507372f0b1b963James Dong bool handlePortSettingChangeEvent(const H264SwDecInfo *info); 1020c1bc742181ded4930842b46e9507372f0b1b963James Dong 1030c1bc742181ded4930842b46e9507372f0b1b963James Dong DISALLOW_EVIL_CONSTRUCTORS(SoftAVC); 1040c1bc742181ded4930842b46e9507372f0b1b963James Dong}; 1050c1bc742181ded4930842b46e9507372f0b1b963James Dong 1060c1bc742181ded4930842b46e9507372f0b1b963James Dong} // namespace android 1070c1bc742181ded4930842b46e9507372f0b1b963James Dong 1080c1bc742181ded4930842b46e9507372f0b1b963James Dong#endif // SOFT_AVC_H_ 1090c1bc742181ded4930842b46e9507372f0b1b963James Dong 110