1 /* 2 * Copyright (c) 2009-2011 Intel Corporation. All rights reserved. 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 18 #ifndef OMX_VIDEO_DECODER_BASE_H_ 19 #define OMX_VIDEO_DECODER_BASE_H_ 20 21 22 #include "OMXComponentCodecBase.h" 23 #include "VideoDecoderInterface.h" 24 #include "VideoDecoderHost.h" 25 26 #ifdef USE_GEN_HW 27 #include "graphics.h" 28 #endif 29 30 static const char* VA_VED_RAW_MIME_TYPE = "video/x-raw-vaved"; 31 static const uint32_t VA_VED_COLOR_FORMAT = 0x20; 32 33 34 class OMXVideoDecoderBase : public OMXComponentCodecBase { 35 public: 36 OMXVideoDecoderBase(); 37 virtual ~OMXVideoDecoderBase(); 38 39 protected: 40 virtual OMX_ERRORTYPE InitInputPort(void); 41 virtual OMX_ERRORTYPE InitOutputPort(void); 42 virtual OMX_ERRORTYPE InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *input) = 0; 43 virtual OMX_ERRORTYPE InitOutputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *output); 44 45 virtual OMX_ERRORTYPE ProcessorInit(void); 46 virtual OMX_ERRORTYPE ProcessorDeinit(void); 47 virtual OMX_ERRORTYPE ProcessorStart(void); 48 virtual OMX_ERRORTYPE ProcessorStop(void); 49 virtual OMX_ERRORTYPE ProcessorPause(void); 50 virtual OMX_ERRORTYPE ProcessorResume(void); 51 virtual OMX_ERRORTYPE ProcessorFlush(OMX_U32 portIndex); 52 virtual OMX_ERRORTYPE ProcessorProcess( 53 OMX_BUFFERHEADERTYPE ***pBuffers, 54 buffer_retain_t *retains, 55 OMX_U32 numberBuffers); 56 virtual OMX_ERRORTYPE ProcessorReset(void); 57 virtual bool IsAllBufferAvailable(void); 58 virtual OMX_ERRORTYPE SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITIONTYPE *p); 59 virtual OMX_ERRORTYPE ProcessorPreFillBuffer(OMX_BUFFERHEADERTYPE* buffer); 60 virtual OMX_ERRORTYPE ProcessorPreFreeBuffer(OMX_U32 nPortIndex,OMX_BUFFERHEADERTYPE * pBuffer); 61 virtual OMX_ERRORTYPE PrepareConfigBuffer(VideoConfigBuffer *p); 62 virtual OMX_ERRORTYPE PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p); 63 virtual OMX_ERRORTYPE FillRenderBuffer(OMX_BUFFERHEADERTYPE **pBuffer, buffer_retain_t *retain, 64 OMX_U32 inportBufferFlags, OMX_BOOL *isResolutionChange); 65 virtual OMX_ERRORTYPE HandleFormatChange(void); 66 virtual OMX_ERRORTYPE TranslateDecodeStatus(Decode_Status status); 67 virtual OMX_COLOR_FORMATTYPE GetOutputColorFormat(int width); 68 virtual OMX_ERRORTYPE BuildHandlerList(void); 69 virtual OMX_ERRORTYPE SetDecoderOutputCropSpecific(OMX_PTR pStructure); 70 virtual OMX_ERRORTYPE GetDecoderOutputCropSpecific(OMX_PTR pStructure); 71 virtual OMX_ERRORTYPE GetNativeBufferUsageSpecific(OMX_PTR pStructure); 72 virtual OMX_ERRORTYPE SetNativeBufferUsageSpecific(OMX_PTR pStructure); 73 virtual OMX_ERRORTYPE SetNativeBufferModeSpecific(OMX_PTR pStructure); 74 virtual OMX_ERRORTYPE GetNativeBufferModeSpecific(OMX_PTR pStructure); 75 76 DECLARE_HANDLER(OMXVideoDecoderBase, ParamVideoPortFormat); 77 DECLARE_HANDLER(OMXVideoDecoderBase, CapabilityFlags); 78 DECLARE_HANDLER(OMXVideoDecoderBase, NativeBufferUsage); 79 DECLARE_HANDLER(OMXVideoDecoderBase, NativeBuffer); 80 DECLARE_HANDLER(OMXVideoDecoderBase, NativeBufferMode); 81 DECLARE_HANDLER(OMXVideoDecoderBase, DecoderRotation); 82 DECLARE_HANDLER(OMXVideoDecoderBase, DecoderOutputCrop); 83 #ifdef TARGET_HAS_VPP 84 DECLARE_HANDLER(OMXVideoDecoderBase, DecoderVppBufferNum); 85 #endif 86 DECLARE_HANDLER(OMXVideoDecoderBase, ErrorReportMode); 87 88 private: 89 enum { 90 // OMX_PARAM_PORTDEFINITIONTYPE 91 INPORT_MIN_BUFFER_COUNT = 1, 92 INPORT_ACTUAL_BUFFER_COUNT = 256, 93 INPORT_BUFFER_SIZE = 1382400, 94 95 // OMX_PARAM_PORTDEFINITIONTYPE 96 OUTPORT_MIN_BUFFER_COUNT = 1, 97 OUTPORT_ACTUAL_BUFFER_COUNT = 4, 98 OUTPORT_BUFFER_SIZE = 1382400, 99 100 OUTPORT_NATIVE_BUFFER_COUNT = 10, 101 }; 102 103 struct GraphicBufferParam { 104 uint32_t graphicBufferStride; 105 uint32_t graphicBufferWidth; 106 uint32_t graphicBufferHeight; 107 uint32_t graphicBufferColorFormat; 108 }; 109 uint32_t mRotationDegrees; 110 #ifdef TARGET_HAS_VPP 111 uint32_t mVppBufferNum; 112 #endif 113 114 protected: 115 IVideoDecoder *mVideoDecoder; 116 int mNativeBufferCount; 117 enum WorkingMode { 118 GRAPHICBUFFER_MODE, 119 RAWDATA_MODE, 120 }; 121 WorkingMode mWorkingMode; 122 bool mErrorReportEnabled; 123 GraphicBufferParam mGraphicBufferParam; 124 uint32_t mOMXBufferHeaderTypePtrNum; 125 OMX_BUFFERHEADERTYPE *mOMXBufferHeaderTypePtrArray[MAX_GRAPHIC_BUFFER_NUM]; 126 }; 127 128 #endif /* OMX_VIDEO_DECODER_BASE_H_ */ 129