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 /** 19 * @file pvmp4h263encextension.h 20 */ 21 22 #ifndef PV_MP4_H263_ENC_EXTENSION_H_INCLUDED 23 #define PV_MP4_H263_ENC_EXTENSION_H_INCLUDED 24 25 #ifndef OSCL_BASE_H_INCLUDED 26 #include "oscl_base.h" 27 #endif 28 #ifndef OSCL_STRING_H_INCLUDED 29 #include "oscl_string.h" 30 #endif 31 #ifndef OSCL_REFCOUNTER_MEMFRAG_H_INCLUDED 32 #include "oscl_refcounter_memfrag.h" 33 #endif 34 #ifndef PV_UUID_H_INCLUDED 35 #include "pv_uuid.h" 36 #endif 37 #ifndef PV_INTERFACE_H_INCLUDED 38 #include "pv_interface.h" 39 #endif 40 41 // Forward declaration 42 template <class T> class OsclSharedPtr; 43 44 #define PVMp4H263EncExtensionUUID PVUuid(0xc4737ade,0xa002,0x4632,0x95,0x1a,0x9c,0xa7,0xd6,0x3a,0xcd,0x2b) 45 46 /** 47 * TODO: 48 * Move the enum to another header file that may be 49 * shared by all the video codecs. 50 * 51 * Enumerated list of supported rate control types 52 * The types assume the same value as those defined 53 * in OpenMAX standard. 54 */ 55 typedef enum 56 { 57 PVMFVEN_RATE_CONTROL_CONSTANT_Q, 58 PVMFVEN_RATE_CONTROL_VBR, 59 PVMFVEN_RATE_CONTROL_CBR, 60 PVMFVEN_RATE_CONTROL_VBR_FRAME_SKIPPING, 61 PVMFVEN_RATE_CONTROL_CBR_FRAME_SKIPPING 62 } PVMFVENRateControlType; 63 64 //////////////////////////////////////////////////////////////////////////// 65 class PVMp4H263EncExtensionInterface : public PVInterface 66 { 67 public: 68 /** Increment reference counter for this interface. */ 69 virtual void addRef() = 0; 70 71 /** Decrement reference counter for this interface. */ 72 virtual void removeRef() = 0; 73 74 /** 75 * Query for a pointer to an instance of the interface specified by the UUID. 76 * 77 * @param uuid UUID of the interface to be queried. 78 * @param iface Output parameter where a pointer to an instance of the requested 79 * interface is stored if the interface is supported. 80 * @return True if successful, else false. 81 */ 82 virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0; 83 84 /** 85 * Sets the number of layers in encoded output. 86 * @param aNumLayers Number of layers. 87 * @return True if successful, else false. 88 */ 89 virtual bool SetNumLayers(uint32 aNumLayers) = 0; 90 91 /** 92 * Sets the bitrate of encoded output for the specified layer. 93 * @param aLayer Layer ID 94 * @param aBitRate Bitrate for the specified layer in bits per second. 95 * @return True if successful, else false. 96 */ 97 virtual bool SetOutputBitRate(uint32 aLayer, uint32 aBitRate) = 0; 98 99 /** 100 * Sets the frame size of encoded output for the specified layer. 101 * @param aLayer Layer ID 102 * @param aWidth Width for the specified layer in pixels. 103 * @param aHeight Height for the specified layer in pixels. 104 * @return True if successful, else false. 105 */ 106 virtual bool SetOutputFrameSize(uint32 aLayer, uint32 aWidth, uint32 aHeight) = 0; 107 108 /** 109 * Sets the frame rate of encoded output for the specified layer. 110 * @param aLayer Layer ID 111 * @param aFrameRate Frame rate for the specified layer in frames per second. 112 * @return True if successful, else false. 113 */ 114 virtual bool SetOutputFrameRate(uint32 aLayer, OsclFloat aFrameRate) = 0; 115 116 /** 117 * Sets the segment size of encoded output for the specified layer 118 * @param aLayer Layer ID 119 * @param aSizeBytes Segment size in bytes. 120 * @return True if successful, else false. 121 */ 122 virtual bool SetSegmentTargetSize(uint32 aLayer, uint32 aSizeBytes) = 0; 123 124 /** 125 * Sets the rate control type to be used by encoder for the specified layer. 126 * @param aLayer Layer ID 127 * @param aRateControl Type of rate control to be used by encoder. 128 * @return True if successful, else false. 129 */ 130 virtual bool SetRateControlType(uint32 aLayer, PVMFVENRateControlType aRateControl) = 0; 131 132 /** 133 * Enable or disable data partitioning in the encoded MPEG4 output. 134 * This menthod is valid only when the codec type is set to PVMFVEN_CODEC_M4V. 135 * 136 * @param aDataPartitioning Set to true to enable data partitioning, set to false 137 * to disable data partitioning. 138 * @return True if successful, else false 139 */ 140 virtual bool SetDataPartitioning(bool aDataPartitioning) = 0; 141 142 /** 143 * Enable or disable reversible VLC in the encoded MPEG4 output. 144 * This menthod is valid only when the codec type is set to PVMFVEN_CODEC_M4V. 145 * 146 * @param aRVLC Set to true to enable RVLC, set to false to disable 147 * @return True if successful, else false 148 */ 149 virtual bool SetRVLC(bool aRVLC) = 0; 150 151 /** 152 * Sets the I-Frame refresh rate of the encoded output. 153 * 154 * @param aIFrameInterval I-Frame rate in seconds per I-Frame 155 * @return True if successful, else false 156 */ 157 virtual bool SetIFrameInterval(uint32 aIFrameInterval) = 0; 158 159 160 /** 161 * Sets the automatic I-frame mode for scene change detection. 162 * 163 * @param aSCD Set to true to enable scene detection 164 * @return True is successful, else false. 165 */ 166 virtual bool SetSceneDetection(bool aSCD) = 0; 167 168 /** 169 * Retrieves VOL header for the M4V bitstream. 170 * 171 * This method is valid only when codec type is set to PVMFVEN_CODEC_M4V. This method 172 * would retrieve the VOL header for the M4V bitstream using encoder parameters 173 * specified at the time of the method call. The VOL header is stored in the 174 * memory fragment provided by the caller. 175 * 176 * @param aVolHeader Memory fragment to store the VOL header 177 * @return True if VOL header is successfully retrieved, else false. 178 */ 179 virtual bool GetVolHeader(OsclRefCounterMemFrag& aVolHeader) = 0; 180 181 /** 182 * Requests the encoder to encode the next frame as an I-Frame. This menthod is valid 183 * only when the node is in EPVMFNodeStarted state. If successful, the next encoded 184 * frame will be an I-Frame. 185 * 186 * @return True for success, else false 187 */ 188 virtual bool RequestIFrame() = 0; 189 190 /** 191 * Sets the type of encoder use. 192 * 193 * @param aCodec Codec type. 194 * @return True for success, else false 195 */ SetCodec(PVMFFormatType aCodec)196 virtual bool SetCodec(PVMFFormatType aCodec) 197 { 198 OSCL_UNUSED_ARG(aCodec); 199 return false; 200 } 201 202 /** 203 * Set FSI buff to encoding param 204 * 205 * @param aFSIBuff FSI Buffer 206 * @param aFSIBuffLength Length of FSI Buffer 207 * @return True for success, else false 208 */ 209 virtual bool SetFSIParam(uint8* aFSIBuff, int aFSIBuffLength) = 0; 210 211 212 213 }; 214 #endif // PV_MP4_H263_ENC_EXTENSION_H_INCLUDED 215 216 217 218 219 220