1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 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 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 #ifndef PVMF_OMX_VIDEODEC_NODE_H_INCLUDED 19 #define PVMF_OMX_VIDEODEC_NODE_H_INCLUDED 20 21 #ifndef PVMF_VIDEO_H_INCLUDED 22 #include "pvmf_video.h" 23 #endif 24 25 #ifndef PVMF_OMX_BASEDEC_NODE_H_INCLUDED 26 #include "pvmf_omx_basedec_node.h" 27 #endif 28 29 #ifndef PVMF_OMX_VIDEODEC_PORT_H_INCLUDED 30 #include "pvmf_omx_basedec_port.h" 31 #endif 32 33 #define PVMFOMXVIDEODECNODE_NUM_CMD_IN_POOL 8 34 #define PVOMXVIDEODECMAXNUMDPBFRAMESPLUS1 17 35 36 #define PVOMX_VIDEO_DECODER_H264 "video_decoder.avc" 37 #define PVOMX_VIDEO_DECODER_MPEG4 "video_decoder.mpeg4" 38 #define PVOMX_VIDEO_DECODER_H263 "video_decoder.h263" 39 #define PVOMX_VIDEO_DECODER_WMV "video_decoder.wmv" 40 41 #define PVOMXVIDEODECNODECONFIG_KEYSTRING_SIZE 128 42 43 // Key string info at the base level ("x-pvmf/video/decoder") 44 #define PVOMXVIDEODECNODECONFIG_BASE_NUMKEYS 6 45 const PVOMXBaseDecNodeKeyStringData PVOMXVideoDecNodeConfigBaseKeys[PVOMXVIDEODECNODECONFIG_BASE_NUMKEYS] = 46 { 47 {"postproc_enable", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}, 48 {"postproc_type", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BITARRAY32}, 49 {"dropframe_enable", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}, 50 {"h263", PVMI_KVPTYPE_AGGREGATE, PVMI_KVPVALTYPE_KSV}, 51 {"m4v", PVMI_KVPTYPE_AGGREGATE, PVMI_KVPVALTYPE_KSV}, 52 {"format-type", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR} 53 }; 54 55 // Key string info at the h263 level ("x-pvmf/video/decoder/h263") 56 #define PVOMXVIDEODECNODECONFIG_H263_NUMKEYS 2 57 const PVOMXBaseDecNodeKeyStringData PVOMXVideoDecNodeConfigH263Keys[PVOMXVIDEODECNODECONFIG_H263_NUMKEYS] = 58 { 59 {"maxbitstreamframesize", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}, 60 {"maxdimension", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_RANGE_UINT32} 61 }; 62 63 // Key string info at the m4v level ("x-pvmf/video/decoder/m4v") 64 #define PVOMXVIDEODECNODECONFIG_M4V_NUMKEYS 2 65 const PVOMXBaseDecNodeKeyStringData PVOMXVideoDecNodeConfigM4VKeys[PVOMXVIDEODECNODECONFIG_M4V_NUMKEYS] = 66 { 67 {"maxbitstreamframesize", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}, 68 {"maxdimension", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_RANGE_UINT32} 69 }; 70 71 // Key string info at the render level ("x-pvmf/video/render") 72 #define PVOMXVIDEODECNODECONFIG_RENDER_NUMKEYS 2 73 const PVOMXBaseDecNodeKeyStringData PVOMXVideoDecNodeConfigRenderKeys[PVOMXVIDEODECNODECONFIG_RENDER_NUMKEYS] = 74 { 75 {"width", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}, 76 {"height", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32} 77 }; 78 79 80 typedef enum 81 { 82 PV_MPEG_VIDEO_SIMPLE_PROFILE = 0, 83 PV_MPEG_VIDEO_SIMPLE_SCALABLE_PROFILE, 84 PV_MPEG_VIDEO_CORE_PROFILE, 85 PV_MPEG_VIDEO_MAIN_PROFILE, 86 PV_MPEG_VIDEO_N_BIT_PROFILE, 87 PV_MPEG_VIDEO_SCALABLE_TEXTURE_PROFILE, 88 PV_MPEG_VIDEO_SIMPLE_FACE_ANIMATION_PROFILE, 89 PV_MPEG_VIDEO_SIMPLE_FBA_PROFILE, 90 PV_MPEG_VIDEO_BASIC_ANIMATED_TEXTURE_PROFILE, 91 PV_MPEG_VIDEO_HYBRID_PROFILE, 92 PV_MPEG_VIDEO_ADVANCE_REAL_TIME_SIMPLE_PROFILE, 93 PV_MPEG_VIDEO_CORE_SCALABLE_PROFILE, 94 PV_MPEG_VIDEO_ADVANCE_CODING_EFFICIENCY_PROFILE, 95 PV_MPEG_VIDEO_ADVANCE_CORE_PROFILE, 96 PV_MPEG_VIDEO_ADVANCE_SCALABLE_TEXTURE_PROFILE, 97 PV_MPEG_VIDEO_SIMPLE_STUDIO_PROFILE, 98 PV_MPEG_VIDEO_CORE_STUDIO_PROFILE, 99 PV_MPEG_VIDEO_ADVANCE_SIMPLE_PROFILE, 100 PV_MPEG_VIDEO_FINE_GRANUALITY_SCALABLE_PROFILE, 101 PV_MPEG_VIDEO_RESERVED_PROFILE 102 } PVMF_MPEGVideoProfileType; 103 104 typedef enum 105 { 106 PV_MPEG_VIDEO_LEVEL0 = 0, 107 PV_MPEG_VIDEO_LEVEL1, 108 PV_MPEG_VIDEO_LEVEL2, 109 PV_MPEG_VIDEO_LEVEL3, 110 PV_MPEG_VIDEO_LEVEL4, 111 PV_MPEG_VIDEO_LEVEL5, 112 PV_MPEG_VIDEO_LEVEL_UNKNOWN 113 114 } PVMF_MPEGVideoLevelType; 115 116 ///////////////////////////////////////////////////////////////////////////////////////// 117 118 119 120 121 122 //Mimetypes for the custom interface 123 #define PVMF_OMX_VIDEO_DEC_NODE_MIMETYPE "pvxxx/OMXVideoDecNode" 124 #define PVMF_BASEMIMETYPE "pvxxx" 125 126 class PVMFOMXVideoDecNode 127 : public PVMFOMXBaseDecNode 128 { 129 public: 130 PVMFOMXVideoDecNode(int32 aPriority, bool aHwAccelerated); 131 ~PVMFOMXVideoDecNode(); 132 133 // From PVMFNodeInterface 134 PVMFStatus ThreadLogon(); 135 136 //**********begin PVMFMetadataExtensionInterface 137 uint32 GetNumMetadataKeys(char* query_key = NULL); 138 uint32 GetNumMetadataValues(PVMFMetadataList& aKeyList); 139 //**********End PVMFMetadataExtensionInterface 140 141 142 //============================================================================== 143 144 OMX_ERRORTYPE EventHandlerProcessing(OMX_OUT OMX_HANDLETYPE aComponent, 145 OMX_OUT OMX_PTR aAppData, 146 OMX_OUT OMX_EVENTTYPE aEvent, 147 OMX_OUT OMX_U32 aData1, 148 OMX_OUT OMX_U32 aData2, 149 OMX_OUT OMX_PTR aEventData); 150 151 // for WMV params 152 bool VerifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements); 153 private: 154 155 void DoQueryUuid(PVMFOMXBaseDecNodeCommand&); 156 void DoRequestPort(PVMFOMXBaseDecNodeCommand&); 157 void DoReleasePort(PVMFOMXBaseDecNodeCommand&); 158 PVMFStatus DoGetNodeMetadataKey(PVMFOMXBaseDecNodeCommand&); 159 PVMFStatus DoGetNodeMetadataValue(PVMFOMXBaseDecNodeCommand&); 160 PVMFStatus HandlePortReEnable(); 161 162 bool InitDecoder(PVMFSharedMediaDataPtr&); 163 164 bool NegotiateComponentParameters(OMX_PTR aOutputParameters); 165 bool GetSetCodecSpecificInfo(); 166 bool QueueOutputBuffer(OsclSharedPtr<PVMFMediaDataImpl> &mediadataimplout, uint32 aDataLen); 167 168 bool ReleaseAllPorts(); 169 // Capability And Config Helper Methods 170 PVMFStatus DoCapConfigGetParametersSync(PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext); 171 PVMFStatus DoCapConfigReleaseParameters(PvmiKvp* aParameters, int aNumElements); 172 void DoCapConfigSetParameters(PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP); 173 PVMFStatus DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements); 174 PVMFStatus DoGetVideoDecNodeParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr); 175 PVMFStatus DoGetH263DecoderParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr); 176 PVMFStatus DoGetM4VDecoderParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr); 177 PVMFStatus DoVerifyAndSetVideoDecNodeParameter(PvmiKvp& aParameter, bool aSetParam); 178 PVMFStatus DoVerifyAndSetH263DecoderParameter(PvmiKvp& aParameter, bool aSetParam); 179 PVMFStatus DoVerifyAndSetM4VDecoderParameter(PvmiKvp& aParameter, bool aSetParam); 180 181 PVMFStatus GetProfileAndLevel(PVMF_MPEGVideoProfileType& aProfile, PVMF_MPEGVideoLevelType& aLevel); 182 int32 GetNAL_OMXNode(uint8** bitstream, int* size); 183 184 OMX_COLOR_FORMATTYPE iOMXVideoColorFormat; 185 OMX_VIDEO_CODINGTYPE iOMXVideoCompressionFormat; 186 PVMFFormatType iYUVFormat; 187 // Width of decoded frame 188 int32 iYUVWidth; 189 // Height of decoded frame 190 int32 iYUVHeight; 191 // Last stored value of width 192 int32 iLastYUVWidth; 193 // Last stored value of hight 194 int32 iLastYUVHeight; 195 196 uint32 iH263MaxBitstreamFrameSize; 197 uint32 iH263MaxWidth; 198 uint32 iH263MaxHeight; 199 uint32 iM4VMaxBitstreamFrameSize; 200 uint32 iM4VMaxWidth; 201 uint32 iM4VMaxHeight; 202 uint32 iStride; 203 uint32 iSliceHeight; 204 205 uint32 iNewWidth , iNewHeight; 206 207 }; 208 209 210 #endif // PVMF_OMXVIDEODEC_NODE_H_INCLUDED 211 212