theonlineoasis

VideoCodec/Modules/RateControl/GOPManager.cpp

#include "GOPManager.h" namespace VideoCodec {    GOPManager::GOPManager() : Module(GOP_MANAGER_MODULE_ID)    {       this->frameCountSinceLastIntraFrame = 0;    }        GOPManager::~GOPManager()    {    }        ConfigurationStatus GOPManager::Configure(ConfigurationElement* configuration)    {       if (configuration != NULL && configuration->GetType() == CONFIGURATION_PAIRS)       {          // Get the maximum number of predictive frames allowed in a GOP.          ConfigurationElement* element;          if ((element = configuration->GetValue(std::string("maxPredictiveFramesInGOP"))) != NULL && element->GetType() == CONFIGURATION_INTEGER)             this->maxPredictiveFramesInGOP = (UnsignedByte)(*element->GetInteger());          else             return MODULE_CONFIGURATION_ERROR;                    return MODULE_CONFIGURATION_OK;       }       return MODULE_CONFIGURATION_ERROR;    }        bool GOPManager::RequireIFrame()    {       // An I-frame is required if there is no previously decoded frame, or if the frame count since       // the last I-frame has exceeded the maximum number of P-frames allowed in a GOP.       return (this->frameCountSinceLastIntraFrame >= this->maxPredictiveFramesInGOP);    }        void GOPManager::Reset()    {       this->frameCountSinceLastIntraFrame = 0;    }        void GOPManager::IncrementInterCount()    {       this->frameCountSinceLastIntraFrame++;    } }