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 <media/stagefright/omx/SoftVideoDecoderOMXComponent.h> 22 23 #include "vpx/vpx_decoder.h" 24 #include "vpx/vpx_codec.h" 25 #include "vpx/vp8dx.h" 26 27 namespace android { 28 29 struct 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 37 protected: 38 virtual ~SoftVPX(); 39 40 virtual void onQueueFilled(OMX_U32 portIndex); 41 virtual void onPortFlushCompleted(OMX_U32 portIndex); 42 virtual void onReset(); 43 virtual bool supportDescribeHdrStaticInfo(); 44 45 private: 46 enum { 47 kNumBuffers = 10 48 }; 49 50 enum { 51 MODE_VP8, 52 MODE_VP9 53 } mMode; 54 55 enum { 56 INPUT_DATA_AVAILABLE, // VPX component is ready to decode data. 57 INPUT_EOS_SEEN, // VPX component saw EOS and is flushing On2 decoder. 58 OUTPUT_FRAMES_FLUSHED // VPX component finished flushing On2 decoder. 59 } mEOSStatus; 60 61 void *mCtx; 62 bool mFrameParallelMode; // Frame parallel is only supported by VP9 decoder. 63 OMX_TICKS mTimeStamps[kNumBuffers]; 64 uint8_t mTimeStampIdx; 65 vpx_image_t *mImg; 66 67 status_t initDecoder(); 68 status_t destroyDecoder(); 69 bool outputBuffers(bool flushDecoder, bool display, bool eos, bool *portWillReset); 70 bool outputBufferSafe(OMX_BUFFERHEADERTYPE *outHeader); 71 72 DISALLOW_EVIL_CONSTRUCTORS(SoftVPX); 73 }; 74 75 } // namespace android 76 77 #endif // SOFT_VPX_H_ 78