FrameRateAdjust.cpp

00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: FrameRateAdjust.cpp * 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 #include "FrameRateAdjust.hpp" 00045 #include "UncompressedVideoFrame.hpp" 00046 00047 00048 /***************************************************************/ 00049 FrameRateAdjust::FrameRateAdjust(ESInfo *esi, u32 newTimeIncrement) { 00050 00051 es = esi; 00052 timeInc = newTimeIncrement; 00053 oldTimeInc = es->getVOPTimeIncrement(); 00054 // es->setVOPTimeIncrement(timeInc); 00055 strcpy(name,"FrameRateAdjust"); 00056 currentFrameNumber = 0; 00057 currentTicks = 0; 00058 00059 dprintf_full("FrameRateAdjust (from %i to %i timeInc)\n", oldTimeInc, timeInc); 00060 } 00061 00062 00063 /***************************************************************/ 00064 FrameRateAdjust::~FrameRateAdjust() { 00065 } 00066 00067 00068 /***************************************************************/ 00069 void FrameRateAdjust::initialize() { 00070 } 00071 00072 00073 /***************************************************************/ 00074 list < Frame * > FrameRateAdjust::adapt(Frame * frm) { 00075 list < Frame * >tmp; 00076 u32 thisCTS; 00077 int thisSec; 00078 00079 thisCTS = frm->getAU()->cts; 00080 thisSec = (int)floor((double)thisCTS / es->getMediaTimeScale()); 00081 dprintf_full("FrameRateAdjust::adapt frame CTS %i (dropped until %i), VOP increment %i, playoutSec: %i \n", 00082 thisCTS, currentTicks, oldTimeInc, thisSec ); 00083 00084 currentFrameNumber++; 00085 if (oldTimeInc <= timeInc) { // remove some frames 00086 if (thisCTS >= currentTicks) { 00087 //standard forwarding adaptor behaviour 00088 tmp.push_front(frm); 00089 currentTicks += timeInc; 00090 } else { 00091 //this frame is dropped.... 00092 dprintf_full("FrameRateAdjust::adapt: this frame %p is dropped (will be deleted by AdaptorChain)....\n",frm); 00093 } 00094 } else { // add some frames 00095 dprintf_err("FrameRateAdjust::adapt should add frames now (from %i to %i timeInc)... NOT SUPPORTED!\n", 00096 oldTimeInc,timeInc); 00097 ::exit(1); 00098 } 00099 00100 return tmp; 00101 }