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 MPEG4_ENC_H_INCLUDED 19 #define MPEG4_ENC_H_INCLUDED 20 21 22 #ifndef OSCL_MEM_H_INCLUDED 23 #include "oscl_mem.h" 24 #endif 25 26 #ifndef OMX_Component_h 27 #include "OMX_Component.h" 28 #endif 29 30 #ifndef _MP4ENC_API_H_ 31 #include "mp4enc_api.h" 32 #endif 33 34 #ifndef CCRGB24TOYUV420_H_INCLUDED 35 #include "ccrgb24toyuv420.h" 36 #endif 37 38 #ifndef CCRGB12TOYUV420_H_INCLUDED 39 #include "ccrgb12toyuv420.h" 40 #endif 41 42 #ifndef CCYUV420SEMITOYUV420_H_INCLUDED 43 #include "ccyuv420semitoyuv420.h" 44 #endif 45 46 #ifndef OSCL_INT64_UTILS_H_INCLUDED 47 #include "oscl_int64_utils.h" 48 #endif 49 50 51 const uint32 DEFAULT_VOL_HEADER_LENGTH = 28; 52 53 enum 54 { 55 MODE_H263 = 0, 56 MODE_MPEG4 57 }; 58 59 60 class Mpeg4Encoder_OMX 61 { 62 public: 63 64 Mpeg4Encoder_OMX(); 65 66 OMX_ERRORTYPE Mp4EncInit(OMX_S32 iEncMode, 67 OMX_VIDEO_PORTDEFINITIONTYPE aInputParam, 68 OMX_CONFIG_ROTATIONTYPE aInputOrientationType, 69 OMX_VIDEO_PORTDEFINITIONTYPE aEncodeParam, 70 OMX_VIDEO_PARAM_MPEG4TYPE aEncodeMpeg4Param, 71 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE aErrorCorrection, 72 OMX_VIDEO_PARAM_BITRATETYPE aRateControlType, 73 OMX_VIDEO_PARAM_QUANTIZATIONTYPE aQuantType, 74 OMX_VIDEO_PARAM_MOTIONVECTORTYPE aSearchRange, 75 OMX_VIDEO_PARAM_INTRAREFRESHTYPE aIntraRefresh, 76 OMX_VIDEO_PARAM_H263TYPE aH263Type, 77 OMX_VIDEO_PARAM_PROFILELEVELTYPE* aProfileLevel); 78 79 80 OMX_BOOL Mp4EncodeVideo(OMX_U8* aOutBuffer, 81 OMX_U32* aOutputLength, 82 OMX_BOOL* aBufferOverRun, 83 OMX_U8** aOverBufferPointer, 84 OMX_U8* aInBuffer, 85 OMX_U32 aInBufSize, 86 OMX_TICKS aInTimeStamp, 87 OMX_TICKS* aOutTimeStamp, 88 OMX_BOOL* aSyncFlag); 89 90 OMX_ERRORTYPE Mp4RequestIFrame(); 91 OMX_BOOL Mp4UpdateBitRate(OMX_U32 aEncodedBitRate); 92 OMX_BOOL Mp4UpdateFrameRate(OMX_U32 aEncodeFramerate); 93 94 OMX_ERRORTYPE Mp4EncDeinit(); 95 96 97 98 private: 99 100 void CopyToYUVIn(uint8* YUV, int width, int height, int width_16, int height_16); 101 102 /* RGB->YUV conversion */ 103 ColorConvertBase *ccRGBtoYUV; 104 105 VideoEncControls iEncoderControl; 106 OMX_BOOL iInitialized; 107 OMX_COLOR_FORMATTYPE iVideoFormat; 108 109 int iSrcWidth; 110 int iSrcHeight; 111 int iFrameOrientation; 112 uint32 iSrcFrameRate; 113 uint8* iYUVIn; 114 uint8* iVideoIn; 115 uint8* iVideoOut; 116 OMX_TICKS iNextModTime; 117 MP4HintTrack iHintTrack; 118 MP4EncodingMode ENC_Mode; 119 120 OMX_U8 iVolHeader[DEFAULT_VOL_HEADER_LENGTH]; /** Vol header */ 121 OMX_U32 iVolHeaderSize; 122 OMX_BOOL iVolHeaderFlag; 123 124 125 126 }; 127 128 129 #endif ///#ifndef MPEG4_ENC_H_INCLUDED 130