00001
00017 #include "vetPlainFrameGenerator.h"
00018
00025 vetPlainFrameGenerator::vetPlainFrameGenerator(float fps) : vetInput(fps)
00026 {
00027 INFO("vetPlainFrameGenerator::vetPlainFrameGenerator(float fps) : vetInput(fps) [CONTRUCTOR]")
00028 reset();
00029 }
00030
00038 vetPlainFrameGenerator::vetPlainFrameGenerator(PixelRGB96& background, float fps) : vetInput(fps)
00039 {
00040 DEBUGMSG("vetPlainFrameGenerator::vetPlainFrameGenerator(PixelRGB96& background, float fps) : vetInput(fps) [CONTRUCTOR]", background)
00041 reset();
00042
00043 }
00044
00052 vetPlainFrameGenerator::vetPlainFrameGenerator(PixelGrey& background, float fps) : vetInput(fps)
00053 {
00054 DEBUGMSG("vetPlainFrameGenerator::vetPlainFrameGenerator(PixelGrey& background, float fps) : vetInput(fps) [CONTRUCTOR]", background)
00055 reset();
00056
00057 }
00058
00059
00060 vetPlainFrameGenerator::~vetPlainFrameGenerator()
00061 {
00062 releaseBuffers();
00063 }
00064
00065
00066
00067 VETRESULT vetPlainFrameGenerator::reset()
00068 {
00069 releaseBuffers();
00070
00071
00072
00073
00074
00075
00076 return VETRET_OK;
00077 }
00078
00079
00080
00084 void vetPlainFrameGenerator::releaseBuffers()
00085 {
00086 if (bufferYUV != NULL)
00087 delete bufferYUV;
00088
00089 if (bufferRGB != NULL)
00090 delete bufferRGB;
00091
00092 if (bufferTuC != NULL)
00093 delete bufferTuC;
00094
00095 bufferYUV = NULL;
00096 bufferRGB = NULL;
00097 bufferTuC = NULL;
00098
00099 };
00100
00101
00107 void vetPlainFrameGenerator::useBufferYUV(unsigned int width, unsigned int height)
00108 {
00109 if ( bufferYUV == NULL )
00110 bufferYUV = new vetFrameYUV420(width, height);
00111 else if ( bufferYUV->width != width || bufferYUV->height != height )
00112 bufferYUV->reAllocCanvas(width, height);
00113
00114 if ( bufferRGB != NULL )
00115 {
00116 delete bufferRGB;
00117 bufferRGB = NULL;
00118 }
00119 if ( bufferTuC != NULL )
00120 {
00121 delete bufferTuC;
00122 bufferTuC = NULL;
00123 }
00124 };
00125
00131 void vetPlainFrameGenerator::useBufferRGB(unsigned int width, unsigned int height)
00132 {
00133 if ( bufferRGB == NULL )
00134 bufferRGB = new vetFrameRGB24(width, height);
00135 else if ( bufferRGB->width != width || bufferRGB->height != height )
00136 bufferRGB->reAllocCanvas(width, height);
00137
00138 if ( bufferYUV != NULL )
00139 {
00140 delete bufferYUV;
00141 bufferYUV = NULL;
00142 }
00143 if ( bufferTuC != NULL )
00144 {
00145 delete bufferTuC;
00146 bufferTuC = NULL;
00147 }
00148 };
00149
00155 void vetPlainFrameGenerator::useBufferTuC(unsigned int width, unsigned int height, vetFrame::VETFRAME_PROFILE profile)
00156 {
00157 if ( bufferTuC == NULL )
00158 bufferTuC = new vetFrameT<unsigned char>(width, height, profile);
00159 else if ( bufferTuC->width != width || bufferTuC->height != height )
00160 bufferTuC->reAllocCanvas(width, height);
00161
00162 if ( bufferYUV != NULL )
00163 {
00164 delete bufferYUV;
00165 bufferYUV = NULL;
00166 }
00167 if ( bufferRGB != NULL )
00168 {
00169 delete bufferRGB;
00170 bufferRGB = NULL;
00171 }
00172 };
00173
00174
00180 VETRESULT vetPlainFrameGenerator::setHeight(unsigned int value)
00181 {
00182 if (bufferYUV != NULL)
00183 {
00184 bufferYUV->reAllocCanvas(bufferYUV->width, value);
00185 return VETRET_OK;
00186 }
00187 else if (bufferRGB != NULL)
00188 {
00189 bufferRGB->reAllocCanvas(bufferRGB->width, value);
00190 return VETRET_OK;
00191 }
00192 else if (bufferTuC != NULL)
00193 {
00194 bufferTuC->reAllocCanvas(bufferTuC->width, value);
00195 return VETRET_OK;
00196 }
00197
00198 return VETRET_NOT_IMPLEMENTED;
00199 };
00200
00206 VETRESULT vetPlainFrameGenerator::setWidth(unsigned int value)
00207 {
00208 if (bufferYUV != NULL)
00209 {
00210 bufferYUV->reAllocCanvas(value, bufferYUV->height);
00211 return VETRET_OK;
00212 }
00213 else if (bufferRGB != NULL)
00214 {
00215 bufferRGB->reAllocCanvas(value, bufferRGB->height);
00216 return VETRET_OK;
00217 }
00218 else if (bufferTuC != NULL)
00219 {
00220 bufferTuC->reAllocCanvas(value, bufferTuC->height);
00221 return VETRET_OK;
00222 }
00223
00224 return VETRET_NOT_IMPLEMENTED;
00225 };
00226
00232 unsigned int vetPlainFrameGenerator::getWidth() const
00233 {
00234 if (bufferYUV != NULL)
00235 return bufferYUV->width;
00236
00237 else if (bufferRGB != NULL)
00238 return bufferRGB->width;
00239
00240 else if (bufferTuC != NULL)
00241 return bufferTuC->width;
00242
00243 return 0;
00244 };
00245
00251 unsigned int vetPlainFrameGenerator::getHeight() const
00252 {
00253 if (bufferYUV != NULL)
00254 return bufferYUV->height;
00255
00256 else if (bufferRGB != NULL)
00257 return bufferRGB->height;
00258
00259 else if (bufferTuC != NULL)
00260 return bufferTuC->height;
00261
00262 return 0;
00263 };
00264
00265
00266
00267
00268
00269
00281 VETRESULT vetPlainFrameGenerator::extractTo(vetFrameYUV420& img)
00282 {
00283 INFO("VETRESULT vetPlainFrameGenerator::extractTo(vetFrameYUV420& img) [pushing data]")
00284
00285 if ( !isBufferYUV() )
00286 return VETRET_ILLEGAL_USE;
00287
00288 img = *bufferYUV;
00289
00290 return VETRET_OK;
00291 };
00292
00293
00305 VETRESULT vetPlainFrameGenerator::extractTo(vetFrameRGB24& img)
00306 {
00307 INFO("VETRESULT vetPlainFrameGenerator::extractTo(vetFrameRGB24& img) [pushing data]")
00308
00309 if ( !isBufferRGB() )
00310 return VETRET_ILLEGAL_USE;
00311
00312 img = *bufferRGB;
00313
00314 return VETRET_OK;
00315 };
00316
00317
00329 VETRESULT vetPlainFrameGenerator::extractTo(vetFrameT<unsigned char>& img)
00330 {
00331 INFO("VETRESULT vetPlainFrameGenerator::extractTo(vetFrameT<unsigned char>& img) [pushing data]")
00332
00333 if ( !isBufferTuC() )
00334 return VETRET_ILLEGAL_USE;
00335
00336 img = *bufferTuC;
00337
00338 return VETRET_OK;
00339 };
00340
00341
00342