YUVinYUVoverlay Class Reference

Adaptor class YUVinYUVoverlay provides a graphical overlaying (destructive multiplexing) from one YUV stream (eg. <short description="">. More...

#include <YUVinYUVoverlay.hpp>

Inheritance diagram for YUVinYUVoverlay:

VideoAdaptor Adaptor List of all members.

Public Member Functions

 YUVinYUVoverlay (VideoESInfo *esi, YUVStreamIO *watermarkStream, int x, int y, bool loopWatermark=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

VideoESInfo * es
YUVStreamIOwaterStream
int posX
int posY
bool loopWatermark
AU lastAU
u8 * lastPayload
UncompressedVideoFramewaterFrame
int numFrames

Detailed Description

Adaptor class YUVinYUVoverlay provides a graphical overlaying (destructive multiplexing) from one YUV stream (eg. <short description="">.

a watermark or a small video preview) into a larger main YUV stream.

NOTE: there is no alpha channel support, yet! but the feature should be fairly easy to add: eg. assume the color black (Y:0,U:0,V:0) to be the alpha, so don't copy it... but this will drastically slow down the whole overlaying process!

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

Definition at line 67 of file YUVinYUVoverlay.hpp.


Member Function Documentation

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

References RawStreamIO::close(), Frame::getAU(), YUVStreamIO::getFrame(), VideoFrame::getHeight(), RawStreamIO::getURL(), VideoFrame::getWidth(), and RawStreamIO::open().

00084 { 00085 list < Frame * >tmp; 00086 u32 thisCTS; 00087 int thisSec; 00088 int inW,inH,waterW,waterH; 00089 u8 *inPay, *waterPay; 00090 UncompressedVideoFrame *inFrame = (UncompressedVideoFrame*)frm; 00091 00092 //call open on first frame 00093 if (numFrames == 0) 00094 if (!waterStream->open()) { 00095 dprintf_err("YUVinYUVoverlay: FATAL: not writing, since another IO class is accessing file %s\n",waterStream->getURL()); 00096 //standard forwarding adaptor behaviour 00097 tmp.push_front(frm); 00098 return tmp; 00099 } 00100 00101 thisCTS = inFrame->getAU()->cts; 00102 thisSec = (int)floor((double)thisCTS / es->getMediaTimeScale()); 00103 dprintf_full("YUVinYUVoverlay::adapt frame %i CTS %i, VOP increment %i\n", numFrames, thisCTS,es->getVOPTimeIncrement()); 00104 00105 //FIXME: assert(isVideoFrame) 00106 00107 waterFrame = (UncompressedVideoFrame*)waterStream->getFrame(); 00108 00109 if (!waterFrame && loopWatermark) { 00110 //loop & reget first frame 00111 // waterStream->setToFrameNumber(0); 00112 waterStream->close(); 00113 waterStream->open(); 00114 waterFrame = (UncompressedVideoFrame*)waterStream->getFrame(); 00115 assert(waterFrame); 00116 } 00117 00118 if (waterFrame) { 00119 inW = inFrame->getWidth(); 00120 inH = inFrame->getHeight(); 00121 waterW = waterFrame->getWidth(); 00122 waterH = waterFrame->getHeight(); 00123 int inCromU = inW*inH; 00124 int waterCromU = waterW*waterH; 00125 int inCromV = inCromU + (inW*inH)/4; 00126 int waterCromV = waterCromU + (waterW*waterH)/4; 00127 00128 inPay = inFrame->getAU()->payload; 00129 waterPay = waterFrame->getAU()->payload; 00130 for (int i=0; i < waterW; i++) 00131 for (int j=0; j < waterH; j++) 00132 memcpy(&inPay[(posY+j)*inW+posX], &waterPay[j*waterW], waterW); 00133 00134 for (int i=0; i < waterW/2; i++) 00135 for (int j=0; j < waterH/2; j++) { 00136 memcpy(&inPay[posX/2+inCromU+(posY/2+j)*(inW/2)], &waterPay[waterCromU+j*(waterW/2)], waterW/2); 00137 memcpy(&inPay[posX/2+inCromV+(posY/2+j)*(inW/2)], &waterPay[waterCromV+j*(waterW/2)], waterW/2); 00138 } 00139 } 00140 00141 //standard forwarding adaptor behaviour 00142 tmp.push_front(frm); 00143 return tmp; 00144 }

Adaptor* YUVinYUVoverlay::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 82 of file YUVinYUVoverlay.hpp.

References YUVStreamIO::clone().

00082 { return new YUVinYUVoverlay(es, (YUVStreamIO*)waterStream->clone(), posX, posY, loopWatermark); };

list< Frame * > YUVinYUVoverlay::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 86 of file YUVinYUVoverlay.hpp.

00086 { 00087 list < Frame * >tmp; 00088 return tmp; 00089 };

u32 YUVinYUVoverlay::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 103 of file YUVinYUVoverlay.hpp.

00103 { 00104 return es->getAvgBandwidth()/8; 00105 }

void YUVinYUVoverlay::initialize  )  [virtual]
 

Initialize internal data structures.

Implements Adaptor.

Definition at line 71 of file YUVinYUVoverlay.cpp.

00071 { 00072 }

void YUVinYUVoverlay::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 74 of file YUVinYUVoverlay.cpp.

00074 { 00075 es = (VideoESInfo*)esi; 00076 }


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