FramePatternDetector Class Reference

Adaptor class FramePatternDetector counts by-passing frames by frame type and detects if a video has a constant frame pattern, how many b-frames are between and how large is the GOP-size <short description="">. More...

#include <FramePatternDetector.hpp>

Inheritance diagram for FramePatternDetector:

Adaptor List of all members.

Public Member Functions

 FramePatternDetector (VideoESInfo *esi, bool updateEsInfoAtClose)
list< Frame * > adapt (Frame *frm)
 Accepts as input a frame, and checks if it can adapt the frame, If the frame is modified, a new Frame object is created and inserted into the return list.
Adaptorclone ()
 Create a shallow copy of the Adaptor.
void initialize ()
 Initialize internal data structures.
list< Frame * > close ()
 Close and destroy an Adaptor.
void setESInfo (ESInfo *esi)
 Sets a reference to an ESInfo object.
ESInfogetESInfo ()
bool hasDecidedOnGopSize () const
 returns if the analyzer has already seen enough GOPs to decide if the GOP pattern is static or not
bool hasDecidedOnBFrames () const
 returns if the analyzer has already seen enough GOPs to decide on the number of b-frames in between
bool isStaticGopSize () const
 returns if all GOPs consists of the same number of frames (not type!)
int getGopSize () const
int getBFramesBetween () const
u32 getTotalSizeOfBFrames () const
 returns the sum of sizes of all b-frames that passed through this adaptor.
u32 getTotalSizeOfFrames () const
 returns the sum of sizes of all frames that passed through this adaptor.
u32 getTranscodingCosts () const
 returns adaptation costs (CPU only)

Protected Attributes

VideoESInfo * es
bool updateESInfo
int bFramesBetween
int bFramesBetweenCounter [FRAMEPATTERNDETECTOR_MAX_BFRAMES_BETWEEN]
int framesSinceIFrame
 including I-frame
u32 lastCTSIFrame
int gopSizesDetected [FRAMEPATTERNDETECTOR_MAX_GOP_ANALYZE]
 pos[i] in the array stores the GOP size from I-frame [i] to (excluding) I-frame[i+1]
int foundBFramesBetween
int foundGopSize
bool staticGopSize
bool staticGopPattern
int currentGOP
Frame::FrameType lastFrame
bool stopBFrames
bool stopGOPSize
u32 bFrameSize
u32 totalVideoSize

Detailed Description

Adaptor class FramePatternDetector counts by-passing frames by frame type and detects if a video has a constant frame pattern, how many b-frames are between and how large is the GOP-size <short description="">.

Author:
Peter Schojer
Version:
Id
FramePatternDetector.hpp,v 1.4 2006/01/20 15:37:17 mkropfbe Exp

Definition at line 66 of file FramePatternDetector.hpp.


Member Function Documentation

list< Frame * > FramePatternDetector::adapt Frame frm  )  [virtual]
 

Accepts as input a frame, and checks if it can adapt the frame, If the frame is modified, a new Frame object is created and inserted into the return list.

This new frame is returned only, if the size of the payload is larger than zero. If the frame was not modified, it is also inserted into the list. For more complex adaptors, it will happen, that the adaptor caches up one complete GOP and returns the full GOP in network order. A caching adaptor has to create deep-copies for each frames. Never directly modify the payload of the input frm, always create copies!!!

Parameters:
frm object to adapt. An Adaptor is never allowed to free the input frame. This has to be done in the caller.
Returns:
List of adapted Frame objects

Reimplemented from Adaptor.

Definition at line 79 of file FramePatternDetector.cpp.

References framesSinceIFrame, Frame::getAU(), and Frame::getType().

00079 { 00080 assert(frm); 00081 list < Frame * >tmp; 00082 u32 thisCTS=0; 00083 00084 totalVideoSize+=frm->getAU()->size; 00085 if(frm->getAU()->frameType==Frame::B_VOP) 00086 bFrameSize+=frm->getAU()->size; 00087 //standard forwarding adaptor behaviour 00088 tmp.push_front(frm); 00089 if(currentGOP>=FRAMEPATTERNDETECTOR_MAX_GOP_ANALYZE) { 00090 // stop analyze 00091 return tmp; 00092 } 00093 00094 thisCTS = frm->getAU()->cts; 00095 00096 if(frm->getType() == Frame::I_VOP && currentGOP<0) { 00097 framesSinceIFrame=1; 00098 bFramesBetween=0; 00099 currentGOP=0; 00100 foundBFramesBetween=0; 00101 foundGopSize=0; 00102 lastCTSIFrame=frm->getAU()->cts; 00103 stopBFrames=false; 00104 } 00105 else { 00106 handleFrameType(frm->getType(),thisCTS); 00107 if(currentGOP>=FRAMEPATTERNDETECTOR_MAX_GOP_ANALYZE) 00108 detectGopSize(); 00109 } 00110 00111 return tmp; 00112 00113 }

Adaptor* FramePatternDetector::clone  )  [inline, virtual]
 

Create a shallow copy of the Adaptor.

Creates an Adaptor with the same setup (without copying the current status).

Returns:
An Adaptor object.

Implements Adaptor.

Definition at line 79 of file FramePatternDetector.hpp.

00079 { return new FramePatternDetector(es,updateESInfo); };

list< Frame * > FramePatternDetector::close  )  [virtual]
 

Close and destroy an Adaptor.

Releases all internally buffered frame objects, and deallocate all allocated memory. The Adaptor must not be used after calling the close method!!!

Returns:
List of adapted Frame objects.

Reimplemented from Adaptor.

Definition at line 229 of file FramePatternDetector.cpp.

00229 { 00230 list < Frame * >tmp; 00231 if(!stopGOPSize) 00232 detectGopSize(); 00233 if(updateESInfo) { 00234 if(stopBFrames) 00235 es->setAvgBFrameSize( ((double)this->bFrameSize)/totalVideoSize); 00236 if(staticGopSize && foundGopSize>0 && stopGOPSize) 00237 es->setGOP_size(foundGopSize); 00238 if(staticGopPattern && foundBFramesBetween>=0 && stopBFrames) 00239 es->setNum_B_frames(foundBFramesBetween); 00240 es->setStaticFramePattern(staticGopPattern); 00241 } 00242 return tmp; 00243 };

u32 FramePatternDetector::getTotalSizeOfBFrames  )  const [inline]
 

returns the sum of sizes of all b-frames that passed through this adaptor.

Be careful when using with network input (frame loss!)Definition at line 115 of file FramePatternDetector.hpp.

00115 { 00116 return bFrameSize; 00117 }

u32 FramePatternDetector::getTotalSizeOfFrames  )  const [inline]
 

returns the sum of sizes of all frames that passed through this adaptor.

Be careful when using with network input (frame loss!)Definition at line 122 of file FramePatternDetector.hpp.

00122 { 00123 return totalVideoSize; 00124 };

void FramePatternDetector::initialize  )  [virtual]
 

Initialize internal data structures.

Implements Adaptor.

Definition at line 72 of file FramePatternDetector.cpp.

00072 { 00073 }

void FramePatternDetector::setESInfo ESInfo esi  )  [inline, virtual]
 

Sets a reference to an ESInfo object.

Adaptors are allowed to change ESInfo objects. If you don't want that, pass an es->clone()

Reimplemented from Adaptor.

Definition at line 89 of file FramePatternDetector.hpp.

00089 {es=(VideoESInfo*)esi;};


The documentation for this class was generated from the following files: