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 217f616d3cc5366a4b8af20d3d0c768e3de1df0666Lajos Molnar#include "SoftVideoDecoderOMXComponent.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 297f616d3cc5366a4b8af20d3d0c768e3de1df0666Lajos Molnarstruct SoftAVC : public SoftVideoDecoderOMXComponent { 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 void onQueueFilled(OMX_U32 portIndex); 390c1bc742181ded4930842b46e9507372f0b1b963James Dong virtual void onPortFlushCompleted(OMX_U32 portIndex); 40d94e716af0e49d775f0c0c4f36dd2c136ba5f2b2Andreas Huber virtual void onReset(); 410c1bc742181ded4930842b46e9507372f0b1b963James Dong 420c1bc742181ded4930842b46e9507372f0b1b963James Dongprivate: 430c1bc742181ded4930842b46e9507372f0b1b963James Dong enum { 440c1bc742181ded4930842b46e9507372f0b1b963James Dong kNumInputBuffers = 8, 45486247017e0bfb9db9994a53a28c0dacfebf8567James Dong kNumOutputBuffers = 2, 460c1bc742181ded4930842b46e9507372f0b1b963James Dong }; 470c1bc742181ded4930842b46e9507372f0b1b963James Dong 480c1bc742181ded4930842b46e9507372f0b1b963James Dong enum EOSStatus { 490c1bc742181ded4930842b46e9507372f0b1b963James Dong INPUT_DATA_AVAILABLE, 500c1bc742181ded4930842b46e9507372f0b1b963James Dong INPUT_EOS_SEEN, 510c1bc742181ded4930842b46e9507372f0b1b963James Dong OUTPUT_FRAMES_FLUSHED, 520c1bc742181ded4930842b46e9507372f0b1b963James Dong }; 530c1bc742181ded4930842b46e9507372f0b1b963James Dong 540c1bc742181ded4930842b46e9507372f0b1b963James Dong void *mHandle; 550c1bc742181ded4930842b46e9507372f0b1b963James Dong 560c1bc742181ded4930842b46e9507372f0b1b963James Dong size_t mInputBufferCount; 570c1bc742181ded4930842b46e9507372f0b1b963James Dong 580c1bc742181ded4930842b46e9507372f0b1b963James Dong uint8_t *mFirstPicture; 590c1bc742181ded4930842b46e9507372f0b1b963James Dong int32_t mFirstPictureId; 600c1bc742181ded4930842b46e9507372f0b1b963James Dong 610c1bc742181ded4930842b46e9507372f0b1b963James Dong int32_t mPicId; // Which output picture is for which input buffer? 620c1bc742181ded4930842b46e9507372f0b1b963James Dong 630c1bc742181ded4930842b46e9507372f0b1b963James Dong // OMX_BUFFERHEADERTYPE may be overkill, but it is convenient 640c1bc742181ded4930842b46e9507372f0b1b963James Dong // for tracking the following fields: nFlags, nTimeStamp, etc. 650c1bc742181ded4930842b46e9507372f0b1b963James Dong KeyedVector<int32_t, OMX_BUFFERHEADERTYPE *> mPicToHeaderMap; 660c1bc742181ded4930842b46e9507372f0b1b963James Dong bool mHeadersDecoded; 670c1bc742181ded4930842b46e9507372f0b1b963James Dong 680c1bc742181ded4930842b46e9507372f0b1b963James Dong EOSStatus mEOSStatus; 690c1bc742181ded4930842b46e9507372f0b1b963James Dong 702961a85f5f00343c115ac8e5dc17de631694fb6eAndreas Huber bool mSignalledError; 712961a85f5f00343c115ac8e5dc17de631694fb6eAndreas Huber 720c1bc742181ded4930842b46e9507372f0b1b963James Dong status_t initDecoder(); 732309d1a1ff016a31d9aa68272bcb471e64a26cfaAndreas Huber void drainAllOutputBuffers(bool eos); 740c1bc742181ded4930842b46e9507372f0b1b963James Dong void drainOneOutputBuffer(int32_t picId, uint8_t *data); 750c1bc742181ded4930842b46e9507372f0b1b963James Dong void saveFirstOutputBuffer(int32_t pidId, uint8_t *data); 76d5a2f55034022f2d0425fa0701894d0c4787b726Ronghua Wu CropSettingsMode handleCropParams(const H264SwDecInfo& decInfo); 770c1bc742181ded4930842b46e9507372f0b1b963James Dong 780c1bc742181ded4930842b46e9507372f0b1b963James Dong DISALLOW_EVIL_CONSTRUCTORS(SoftAVC); 790c1bc742181ded4930842b46e9507372f0b1b963James Dong}; 800c1bc742181ded4930842b46e9507372f0b1b963James Dong 810c1bc742181ded4930842b46e9507372f0b1b963James Dong} // namespace android 820c1bc742181ded4930842b46e9507372f0b1b963James Dong 830c1bc742181ded4930842b46e9507372f0b1b963James Dong#endif // SOFT_AVC_H_ 840c1bc742181ded4930842b46e9507372f0b1b963James Dong 85