Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members
FramePatternDetector.hpp
00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: FramePatternDetector.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 _PS_VITOOKI_FRAMEPATTERNDETECTOR_HPP 00045 #define _PS_VITOOKI_FRAMEPATTERNDETECTOR_HPP 00046 #include "Adaptor.hpp" 00047 #include "Frame.hpp" 00048 #include "VideoESInfo.hpp" 00049 00050 #define FRAMEPATTERNDETECTOR_MAX_BFRAMES_BETWEEN 10 00051 #define FRAMEPATTERNDETECTOR_MAX_GOP_ANALYZE 10 00052 #define FRAMEPATTERNDETECTOR_BFRAME_THRESHOLD 0.9 00053 #define FRAMEPATTERNDETECTOR_GOP_THRESHOLD 0.8 00054 00066 class FramePatternDetector : public Adaptor { 00067 public: 00068 00069 /* Constructor: @param updateEsInfoAtClose set to true if you want the adaptor to 00070 * automatically overwrite the values in @param esi, when the adaptor is closed (and at least one 00071 * complete GOP was analyzed!) 00072 */ 00073 FramePatternDetector(VideoESInfo* esi, bool updateEsInfoAtClose); 00074 00075 virtual ~FramePatternDetector(); 00076 00077 list < Frame * >adapt(Frame * frm); 00078 00079 Adaptor *clone() { return new FramePatternDetector(es,updateESInfo); }; 00080 00081 void initialize(); 00082 00083 list < Frame * >close(); 00084 00089 void setESInfo(ESInfo * esi) {es=(VideoESInfo*)esi;}; 00090 ESInfo * getESInfo() { return (ESInfo*)es;} 00094 bool hasDecidedOnGopSize() const { return stopGOPSize;}; 00098 bool hasDecidedOnBFrames() const { return stopBFrames;}; 00099 00101 bool isStaticGopSize() const { 00102 return staticGopSize; 00103 } 00104 00105 int getGopSize() const { 00106 return foundGopSize; 00107 } 00108 00109 int getBFramesBetween() const { 00110 return foundBFramesBetween; 00111 } 00115 u32 getTotalSizeOfBFrames() const { 00116 return bFrameSize; 00117 } 00118 00122 u32 getTotalSizeOfFrames() const { 00123 return totalVideoSize; 00124 }; 00126 u32 getTranscodingCosts() const{ 00127 return 5000u; 00128 } 00129 private: 00130 void handleFrameType(Frame::FrameType current,u32 ctsCur); 00131 void analyzeBFramePattern(); 00132 void detectGopSize(); 00133 00134 protected: 00135 VideoESInfo* es; 00136 bool updateESInfo; 00137 int bFramesBetween; 00138 int bFramesBetweenCounter[FRAMEPATTERNDETECTOR_MAX_BFRAMES_BETWEEN]; 00140 int framesSinceIFrame; 00141 u32 lastCTSIFrame; 00143 int gopSizesDetected[FRAMEPATTERNDETECTOR_MAX_GOP_ANALYZE]; 00144 int foundBFramesBetween; 00145 int foundGopSize; 00146 bool staticGopSize; 00147 bool staticGopPattern; 00148 int currentGOP; 00149 Frame::FrameType lastFrame; 00150 bool stopBFrames; 00151 bool stopGOPSize; 00152 u32 bFrameSize; 00153 u32 totalVideoSize; 00154 }; 00155 #endif 00156