Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members
MP4Encoder.hpp
00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: MP4Encoder.hpp * 00006 * * 00007 * * 00008 * * 00009 * ITEC institute of the University of Klagenfurt (Austria) * 00010 * http://www.itec.uni-klu.ac.at * 00011 * * 00012 * * 00013 * For more information visit the ViTooKi homepage: * 00014 * http://ViTooKi.sourceforge.net * 00015 * vitooki-user@lists.sourceforge.net * 00016 * vitooki-devel@lists.sourceforge.net * 00017 * * 00018 * This file is part of ViTooKi, a free video toolkit. * 00019 * ViTooKi is free software; you can redistribute it and/or * 00020 * modify it under the terms of the GNU General Public License * 00021 * as published by the Free Software Foundation; either version 2 * 00022 * of the License, or (at your option) any later version. * 00023 * * 00024 * This program is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU General Public License * 00030 * along with this program; if not, write to the Free Software * 00031 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00032 * MA 02111-1307, USA. * 00033 * * 00034 ***********************************************************************/ 00035 00036 /*********************************************************************** 00037 * * 00038 * REVISION HISTORY: * 00039 * * 00040 * * 00041 * * 00042 ***********************************************************************/ 00043 00044 #ifndef AFX_MP4ENCODER_HPP 00045 #define AFX_MP4ENCODER_HPP 00046 00047 #if _MSC_VER > 1000 00048 #pragma once 00049 #endif // _MSC_VER > 1000 00050 00051 #include "VideoAdaptor.hpp" 00052 #include "UncompressedVideoFrame.hpp" 00053 #include "VideoESInfo.hpp" 00054 #include "MP4Decoder.hpp" 00055 00067 class MP4Encoder:public VideoAdaptor { 00068 public: 00080 MP4Encoder(VideoESInfo * pESInfo, 00081 u32 targetBitRate, 00082 u32 frameRate, 00083 u32 uiKeyFrameInterval = 300, 00084 u32 numBFrames = 0, 00085 UncompressedVideoFrame::ColorSpace colorSpace = UncompressedVideoFrame::ColorSpaceI420, 00086 #ifdef ENABLE_FFMPEG 00087 MP4Decoder::eCoderType coderType = MP4Decoder::FFMPEG, 00088 #else 00089 MP4Decoder::eCoderType coderType = MP4Decoder::XVID, 00090 #endif 00091 enum CodecID outputFormat=CODEC_ID_MPEG4, 00092 char* mp4EncoderConfig=NULL); 00093 00095 virtual ~ MP4Encoder(); 00096 00106 list < Frame * >adapt(Frame * frm); 00107 00112 list < Frame * >close(); 00113 00117 Adaptor *clone(); 00118 00119 void initialize(); 00120 00121 void setCoderType(MP4Decoder::eCoderType ct); 00122 00130 static ffmpegColorSpace mapToFFMPEGColorspace(UncompressedVideoFrame::ColorSpace colorSpace); 00131 00135 u32 getTranscodingCosts() const; 00136 00137 static u8* createNewHeader(VideoESInfo* vid,u32 targetBitRate,u32 width, u32 height, 00138 u32 uiKeyFrameInterval, int framerate, u32* headerSize); 00139 00140 private: 00141 MP4Decoder::eCoderType meCoder; 00142 00143 int EncoderInit( char **pEncoderHandle, unsigned int iWidth, unsigned int iHeight, 00144 int iBitrate, int iFramerate, int numBFrames, int keyFrameInterval, VideoESInfo * es); 00145 00146 void EncoderClose(char **pEncoderHandle); 00147 00148 int EncodeFrame(char *pEncoderHandle, char *pYUVFrame, 00149 char *pCompressed, UncompressedVideoFrame::ColorSpace eColorSpace, int forceIFrame); 00150 00152 char *mpEncoderHandle; 00153 00155 UncompressedVideoFrame::ColorSpace mColorSpace; 00156 00158 u32 mFrameSize; 00159 00161 char mpOutBuf[MAX_BUFFER_SIZE]; 00162 00164 u32 muiFrameNumber; 00165 00166 00168 u32 muiTargetBitrate; 00169 00170 /* Key Frame Interval. */ 00171 u32 muiKeyFrameInterval; 00172 00173 u32 numBFrames; 00174 00175 u32 frameRate; 00176 00177 enum CodecID outputFormat; 00178 }; 00179 00180 #endif 00181