SoftVPX.h revision 7cfc18e680fc295d1975c8da183f0d9df4cab803
1/* 2 * Copyright (C) 2011 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_VPX_H_ 18 19#define SOFT_VPX_H_ 20 21#include "SoftVideoDecoderOMXComponent.h" 22 23#include "vpx/vpx_decoder.h" 24#include "vpx/vpx_codec.h" 25#include "vpx/vp8dx.h" 26 27namespace android { 28 29struct SoftVPX : public SoftVideoDecoderOMXComponent { 30 SoftVPX(const char *name, 31 const char *componentRole, 32 OMX_VIDEO_CODINGTYPE codingType, 33 const OMX_CALLBACKTYPE *callbacks, 34 OMX_PTR appData, 35 OMX_COMPONENTTYPE **component); 36 37protected: 38 virtual ~SoftVPX(); 39 40 virtual void onQueueFilled(OMX_U32 portIndex); 41 virtual void onPortFlushCompleted(OMX_U32 portIndex); 42 virtual void onReset(); 43 44private: 45 enum { 46 kNumBuffers = 4 47 }; 48 49 enum { 50 MODE_VP8, 51 MODE_VP9 52 } mMode; 53 54 enum { 55 INPUT_DATA_AVAILABLE, // VPX component is ready to decode data. 56 INPUT_EOS_SEEN, // VPX component saw EOS and is flushing On2 decoder. 57 OUTPUT_FRAMES_FLUSHED // VPX component finished flushing On2 decoder. 58 } mEOSStatus; 59 60 void *mCtx; 61 bool mFrameParallelMode; // Frame parallel is only supported by VP9 decoder. 62 OMX_TICKS mTimeStamps[kNumBuffers]; 63 uint8_t mTimeStampIdx; 64 vpx_image_t *mImg; 65 66 status_t initDecoder(); 67 status_t destroyDecoder(); 68 bool outputBuffers(bool flushDecoder, bool display, bool eos, bool *portWillReset); 69 bool outputBufferSafe(OMX_BUFFERHEADERTYPE *outHeader); 70 71 DISALLOW_EVIL_CONSTRUCTORS(SoftVPX); 72}; 73 74} // namespace android 75 76#endif // SOFT_VPX_H_ 77