OMXVideoDecoderBase.h revision 315fcbb35ef1f355db2f761408c0a22e47ca8222
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 30static constexpr const char* VA_VED_RAW_MIME_TYPE = "video/x-raw-vaved"; 31static const uint32_t VA_VED_COLOR_FORMAT = 0x20; 32 33 34class OMXVideoDecoderBase : public OMXComponentCodecBase { 35public: 36 OMXVideoDecoderBase(); 37 virtual ~OMXVideoDecoderBase(); 38 39protected: 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_ISV 84 DECLARE_HANDLER(OMXVideoDecoderBase, DecoderVppBufferNum); 85#endif 86 DECLARE_HANDLER(OMXVideoDecoderBase, StoreMetaDataMode); 87 DECLARE_HANDLER(OMXVideoDecoderBase, ErrorReportMode); 88 DECLARE_HANDLER(OMXVideoDecoderBase, CodecPriority); 89 DECLARE_HANDLER(OMXVideoDecoderBase, DecoderOperatingRate); 90 91private: 92 enum { 93 // OMX_PARAM_PORTDEFINITIONTYPE 94 INPORT_MIN_BUFFER_COUNT = 1, 95 INPORT_ACTUAL_BUFFER_COUNT = 256, 96 INPORT_BUFFER_SIZE = 1382400, 97 98 // OMX_PARAM_PORTDEFINITIONTYPE 99 OUTPORT_MIN_BUFFER_COUNT = 1, 100 OUTPORT_ACTUAL_BUFFER_COUNT = 4, 101 OUTPORT_BUFFER_SIZE = 1382400, 102 103 OUTPORT_NATIVE_BUFFER_COUNT = 10, 104 }; 105 106 struct GraphicBufferParam { 107 uint32_t graphicBufferStride; 108 uint32_t graphicBufferWidth; 109 uint32_t graphicBufferHeight; 110 uint32_t graphicBufferColorFormat; 111 }; 112 uint32_t mRotationDegrees; 113#ifdef TARGET_HAS_ISV 114 uint32_t mVppBufferNum; 115#endif 116 117 // Codec priority. Higher value means lower priority 118 // Currently, only two levels are supported: 119 // 0: realtime priority - This will only be used by 120 // media playback, capture, and possibly by realtime 121 // communication scenarios if best effort performance is not suitable. 122 // 1: non-realtime priority (best effort). This is the default value. 123 uint32_t mCodecPriority; 124 125 uint32_t mOperatingRate; 126 127protected: 128 IVideoDecoder *mVideoDecoder; 129 int mNativeBufferCount; 130 enum WorkingMode { 131 GRAPHICBUFFER_MODE, 132 RAWDATA_MODE, 133 }; 134 WorkingMode mWorkingMode; 135 bool mErrorReportEnabled; 136 GraphicBufferParam mGraphicBufferParam; 137 uint32_t mOMXBufferHeaderTypePtrNum; 138 OMX_BUFFERHEADERTYPE *mOMXBufferHeaderTypePtrArray[MAX_GRAPHIC_BUFFER_NUM]; 139 140 enum AdaptivePlaybackMode { 141 METADATA_MODE, 142 LEGACY_MODE, 143 }; 144 AdaptivePlaybackMode mAPMode; 145 uint32_t mMetaDataBuffersNum; 146 bool mFormatChanged; 147 uint32_t getStride(uint32_t format, uint32_t width); 148}; 149 150#endif /* OMX_VIDEO_DECODER_BASE_H_ */ 151