YUVSpatialReductionAdaptor Class Reference

Implementation of Adaptor that applies spatial transformation on YUVFrame objects. <short description="">. More...

#include <YUVSpatialReductionAdaptor.hpp>

Inheritance diagram for YUVSpatialReductionAdaptor:

VideoAdaptor Adaptor List of all members.

Public Member Functions

 YUVSpatialReductionAdaptor (VideoESInfo *pESInfo, u32 *puiWidth, u32 *puiHeight)
 Constructor.
list< Frame * > adapt (Frame *frm)
 YUVFrame frm in - list of YUVFrame objects out.
list< Frame * > close ()
 Flush all buffered YUVFrame objects (if any).
Adaptorclone ()
 Not implemented.
void initialize ()
 Initialize internal data structures.
u32 getTranscodingCosts () const
 returns adaptation costs (CPU only) YUVscaling is expensive, this is an optimized impl., 30% more expensive than decoding

Detailed Description

Implementation of Adaptor that applies spatial transformation on YUVFrame objects. <short description="">.

Currently only downscaling is implemented using nearest neighbor hood search.

Author:
Bernhard Penz
Version:
Id
YUVSpatialReductionAdaptor.hpp,v 1.4 2004/06/14 09:02:46 pschojer Exp

Definition at line 62 of file YUVSpatialReductionAdaptor.hpp.


Constructor & Destructor Documentation

YUVSpatialReductionAdaptor::YUVSpatialReductionAdaptor VideoESInfo *  pESInfo,
u32 *  puiWidth,
u32 *  puiHeight
 

Constructor.

Takes input frame size from pESInfo, and sets output frame size according to puiWidth/puiHeight.

Parameters:
pESInfo Pointer to ESInfo object, containing valid size information about the input YUVFrame objects.
puiWidth Pointer to target width of output YUVFrame objects. Must be divisible by 2!!!!
puiHeight Pointer to target height of output YUVFrame objects. Must be divisible by 2!!!!
Definition at line 49 of file YUVSpatialReductionAdaptor.cpp.

Referenced by clone().

00051 { 00052 es = pESInfo; 00053 initialized = false; 00054 muiTargetWidth = *puiWidth; 00055 muiTargetHeight = *puiHeight; 00056 strcpy(name,"YUVSpatialReductionAdaptor"); 00057 }


Member Function Documentation

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

YUVFrame frm in - list of YUVFrame objects out.

Output list will contain one YUVFrame object only.

Parameters:
frm Pointer to uncompressed YUVFrame object
Returns:
List of YUVFrame objects

Reimplemented from Adaptor.

Definition at line 96 of file YUVSpatialReductionAdaptor.cpp.

References Frame::getAU(), and initialize().

00096 { 00097 list < Frame * >retFrameList; 00098 if (!initialized) 00099 initialize(); 00100 00101 if (!initialized) 00102 return retFrameList; 00103 00104 u32 h, w, hOrig, wOrig; 00105 u8 *pOffsetTarget=NULL; 00106 u8 *pOffsetOrig=NULL; 00107 00108 u8 *origFrame = frm->getAU()->payload; 00109 pOffsetOrig = origFrame; 00110 00111 // u8 *retFrame = new u8[muiTargetWidth * muiTargetHeight * 3 / 2]; 00112 // memset(retFrame, 128, muiTargetWidth * muiTargetHeight * 3 / 2); 00113 u8* retFrame=origFrame; // reuse incoming frame 00114 pOffsetTarget = retFrame; 00115 00116 00117 // Y 00118 for (h = 0; h < muiTargetHeight; h++) { 00119 for (w = 0; w < muiTargetWidth; w++) { 00120 // hOrig = (u32) (((float)h)/mfScaleFactorHeight); 00121 // wOrig = (u32) (((float)w)/mfScaleFactorWidth); 00122 hOrig = (u32) ((h * 1000000) / muiScaleFactorHeight); 00123 wOrig = (u32) ((w * 1000000) / muiScaleFactorWidth); 00124 pOffsetTarget[h * muiTargetWidth + w] = 00125 pOffsetOrig[hOrig * muiWidth + wOrig]; 00126 } 00127 } 00128 // V 00129 pOffsetOrig = pOffsetOrig + muiWidth * muiHeight; 00130 pOffsetTarget = pOffsetTarget + muiTargetWidth * muiTargetHeight; 00131 for (h = 0; h < muiTargetHeight / 2; h++) { 00132 for (w = 0; w < muiTargetWidth / 2; w++) { 00133 // hOrig = (u32) (((float)h)/mfScaleFactorHeight); 00134 // wOrig = (u32) (((float)w)/mfScaleFactorWidth); 00135 hOrig = (u32) ((h * 1000000) / muiScaleFactorHeight); 00136 wOrig = (u32) ((w * 1000000) / muiScaleFactorWidth); 00137 pOffsetTarget[h * muiTargetWidth / 2 + w] = 00138 pOffsetOrig[hOrig * muiWidth / 2 + wOrig]; 00139 } 00140 } 00141 // U 00142 pOffsetOrig = pOffsetOrig + muiWidth * muiHeight / 4; 00143 pOffsetTarget = pOffsetTarget + muiTargetWidth * muiTargetHeight / 4; 00144 for (h = 0; h < muiTargetHeight / 2; h++) { 00145 for (w = 0; w < muiTargetWidth / 2; w++) { 00146 // hOrig = (u32) (((float)h)/mfScaleFactorHeight); 00147 // wOrig = (u32) (((float)w)/mfScaleFactorWidth); 00148 hOrig = (u32) ((h * 1000000) / muiScaleFactorHeight); 00149 wOrig = (u32) ((w * 1000000) / muiScaleFactorWidth); 00150 pOffsetTarget[h * muiTargetWidth / 2 + w] = 00151 pOffsetOrig[hOrig * muiWidth / 2 + wOrig]; 00152 } 00153 } 00154 00155 frm->getAU()->payload = retFrame; 00156 frm->getAU()->size = muiTargetWidth * muiTargetHeight * 3 / 2; // YV12 00157 retFrameList.push_back(frm); 00158 return retFrameList; 00159 }

Adaptor * YUVSpatialReductionAdaptor::clone  )  [virtual]
 

Not implemented.

Returns:
Defaults to NULL.

Implements Adaptor.

Definition at line 169 of file YUVSpatialReductionAdaptor.cpp.

References YUVSpatialReductionAdaptor().

00169 { 00170 u32 w=muiTargetWidth; 00171 u32 h=muiTargetHeight; 00172 return new YUVSpatialReductionAdaptor(es,&w,&h); 00173 }

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

Flush all buffered YUVFrame objects (if any).

Returns:
List of YUVFrame objects

Reimplemented from Adaptor.

Definition at line 162 of file YUVSpatialReductionAdaptor.cpp.

00162 { 00163 list < Frame * >retFrameList; 00164 00165 return retFrameList; 00166 }

void YUVSpatialReductionAdaptor::initialize  )  [virtual]
 

Initialize internal data structures.

Implements Adaptor.

Definition at line 60 of file YUVSpatialReductionAdaptor.cpp.

Referenced by adapt().

00060 { 00061 if(initialized) 00062 return; 00063 00064 muiWidth = es->getWidth(); 00065 muiHeight = es->getHeight(); 00066 00067 if (muiTargetWidth % 2 == 1) 00068 muiTargetWidth += 1; 00069 if (muiTargetHeight % 2 == 1) 00070 muiTargetHeight += 1; 00071 00072 // disable upscaling, let the hw do this when rendering to the screen!!! 00073 // this allows us to reuse the incoming frame, os we don't have to newly 00074 // allocate memory 00075 if(muiTargetWidth>muiWidth) 00076 muiTargetWidth=muiWidth; 00077 if(muiTargetHeight>muiHeight) 00078 muiTargetHeight=muiHeight; 00079 00080 es->setWidth(muiTargetWidth); 00081 es->setHeight(muiTargetHeight); 00082 00083 muiScaleFactorWidth = (u32) ((muiTargetWidth * 1000000) / muiWidth) ; 00084 muiScaleFactorHeight = (u32)((muiTargetHeight* 1000000) / muiHeight) ; 00085 initialized = true; 00086 00087 dprintf_full("Scalefactors [w|h]: [%i|%i]\n", muiScaleFactorWidth, 00088 muiScaleFactorHeight); 00089 }


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