DataDump Class Reference

Adaptor class DataDump stores each passing frame to disk (any IO), but also inserts old frames if one was missing, to adhere to frame dropping adaptation if this automatic insertion feature is not wanted, set the corresponding constructor flag! <short description="">. More...

#include <DataDump.hpp>

Inheritance diagram for DataDump:

Adaptor List of all members.

Public Member Functions

 DataDump (ESInfo *esi, IO *outStream, bool autoFix=true)
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 ()
u32 getTranscodingCosts () const
 returns adaptation costs (CPU only).

Protected Attributes

ESInfoes
IOout
bool autoFix
AU lastAU
u8 * lastPayload
FramedummyFrame
int numFrames

Detailed Description

Adaptor class DataDump stores each passing frame to disk (any IO), but also inserts old frames if one was missing, to adhere to frame dropping adaptation if this automatic insertion feature is not wanted, set the corresponding constructor flag! <short description="">.

Author:
Michael Kropfberger
Version:
Id
DataDump.hpp,v 1.5 2006/01/20 15:37:17 mkropfbe Exp

Definition at line 64 of file DataDump.hpp.


Member Function Documentation

list< Frame * > DataDump::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 83 of file DataDump.cpp.

References Frame::getAU(), VideoFrame::getHeight(), Frame::getMediaTimeScale(), ESInfo::getMediaTimeScale(), IO::getURL(), ESInfo::getVOPTimeIncrement(), VideoFrame::getWidth(), IO::open(), Frame::setAU(), Frame::setMediaTimeScale(), Frame::unsetAU(), and IO::writeFrame().

00083 { 00084 list < Frame * >tmp; 00085 u32 thisCTS; 00086 int thisSec; 00087 int done=0; 00088 00089 //call open on first frame 00090 if (numFrames == 0) 00091 if (!out->open()) { 00092 dprintf_err("DataDump: FATAL: not writing, since another IO class is accessing file %s\n",out->getURL()); 00093 //standard forwarding adaptor behaviour 00094 tmp.push_front(frm); 00095 return tmp; 00096 } 00097 00098 UncompressedVideoFrame *thisFrame = (UncompressedVideoFrame*)frm; 00099 thisCTS = frm->getAU()->cts; 00100 thisSec = (int)floor((double)thisCTS / es->getMediaTimeScale()); 00101 dprintf_full("DataDump::adapt frame %i CTS %i, VOP increment %i\n", numFrames, thisCTS,es->getVOPTimeIncrement()); 00102 00103 //FIXME: assert(isVideoFrame) 00104 00105 //first frame, malloc payload, size is always the same for YUV frames! 00106 if (!lastAU.payload) { 00107 dprintf_full("DataDump::adapt creating initial buffers\n"); 00108 lastPayload = (u8*)malloc(thisFrame->getAU()->size); 00109 lastAU.payload = lastPayload; 00110 lastAU.size = thisFrame->getAU()->size; 00111 dummyFrame = new UncompressedVideoFrame(Frame::NN_VOP, thisFrame->getWidth(), thisFrame->getHeight()); 00112 dummyFrame->setMediaTimeScale(thisFrame->getMediaTimeScale()); 00113 dummyFrame->setAU(&lastAU,false); //disable detectFrameType() for efficiency! 00114 } 00115 00116 while(!done) { 00117 if (numFrames * es->getVOPTimeIncrement() == thisCTS) { //NO FRAME LOSS 00118 out->writeFrame(thisFrame); 00119 done=1; 00120 } else if (autoFix) { //catch up BECAUSE OF FRAME LOSS 00121 dprintf_full("DataDump::adapt %i dummyADAPT!\n",numFrames); 00122 out->writeFrame(dummyFrame); 00123 } 00124 numFrames++; 00125 } 00126 00127 00128 // assert(lastAU.size == thisFrame->getAU()->size); 00129 dummyFrame->unsetAU(); 00130 lastAU = thisFrame->getAU(); 00131 lastAU.payload = lastPayload; 00132 lastAU.size = thisFrame->getAU()->size; 00133 memcpy(lastAU.payload, thisFrame->getAU()->payload, thisFrame->getAU()->size); 00134 dummyFrame->setAU(&lastAU,false); //disable detectFrameType() for efficiency! 00135 00136 //standard forwarding adaptor behaviour 00137 tmp.push_front(frm); 00138 return tmp; 00139 }

Adaptor* DataDump::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 78 of file DataDump.hpp.

00078 { return new DataDump(es, new DevNull(), autoFix); };

list< Frame * > DataDump::close  )  [inline, 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 82 of file DataDump.hpp.

00082 { 00083 list < Frame * >tmp; 00084 return tmp; 00085 };

u32 DataDump::getTranscodingCosts  )  const [inline, virtual]
 

returns adaptation costs (CPU only).

This adaptor causes hd costs, which are currently ignored. as CPU side effect we can only guess but it should depend on the bytes of the video

Implements Adaptor.

Definition at line 99 of file DataDump.hpp.

References ESInfo::getAvgBandwidth().

00099 { 00100 return es->getAvgBandwidth()/8; 00101 }

void DataDump::initialize  )  [virtual]
 

Initialize internal data structures.

Implements Adaptor.

Definition at line 70 of file DataDump.cpp.

00070 { 00071 }

void DataDump::setESInfo ESInfo esi  )  [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 73 of file DataDump.cpp.

00073 { 00074 es = esi; 00075 }


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