00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <stdio.h>
00012 #include <stdlib.h>
00013 #include "pfspdfe.h"
00014
00015 pfspdFE::pfspdFE (
00016 const Id& n,
00017 VYAbitPrecision Y_RGB_CVBSoutPrecision,
00018 VYAbitPrecision UVoutPrecision,
00019
00020 In<VYAfileName>& fileNameInF,
00021 In<pT_header>& seqInfoInF,
00022 Out<VYApixel>& Y_R_CVBSoutF,
00023 Out<VYApixel>& U_GoutF,
00024 Out<VYApixel>& V_BoutF,
00025 Out<VYAimageWidth>& Y_RGBimgWidthOutF,
00026 Out<VYAimageHeight>& Y_RGBimgHeightOutF,
00027 Out<VYAimageWidth>& UVimgWidthOutF,
00028 Out<VYAimageHeight>& UVimgHeightOutF,
00029 Out<VYAimageType>& Y_YUV_RGBimgTypeOutF)
00030 :
00031
00032
00033 VYAprocess(n),
00034
00035
00036 fileNameInP(id("fileNameInP"), fileNameInF),
00037 seqInfoInP(id("seqInfoInP"), seqInfoInF),
00038 Y_R_CVBSoutP(id("Y_R_CVBSoutP"), Y_R_CVBSoutF),
00039 U_GoutP(id("U_GoutP"), U_GoutF),
00040 V_BoutP(id("V_BoutP"), V_BoutF),
00041 Y_RGBimgWidthOutP(id("Y_RGBimgWidthOutP"), Y_RGBimgWidthOutF),
00042 Y_RGBimgHeightOutP(id("Y_RGBimgHeightOutP"), Y_RGBimgHeightOutF),
00043 UVimgWidthOutP(id("UVimgWidthOutP"), UVimgWidthOutF),
00044 UVimgHeightOutP(id("UVimgHeightOutP"), UVimgHeightOutF),
00045 Y_YUV_RGBimgTypeOutP(id("Y_YUV_RGBimgTypeOutP"), Y_YUV_RGBimgTypeOutF)
00046 {
00047 Y_RGB_CVBSoutPrec = Y_RGB_CVBSoutPrecision;
00048 UVoutPrec = UVoutPrecision;
00049 };
00050
00051 void pfspdFE::main(void)
00052 {
00053 while(true)
00054 {
00055 pT_status status;
00056 pT_color colorFormat;
00057 pT_header seqInfo, seqInfoIn;
00058 int startFrame, nrOutFrames;
00059 unsigned int startImage, nrInFrames, nrOutImages;
00060 byte *CVBSbuf, *Ybuf, *Ubuf, *Vbuf, *UVbuf, *Rbuf, *Gbuf, *Bbuf;
00061 VYApixel *Y_R_CVBSbuf, *U_Gbuf, *V_Bbuf;
00062 VYAimageWidth Y_RGBframeWidth, UVframeWidth;
00063 VYAimageHeight Y_RGBframeHeight, UVframeHeight;
00064 VYAimageWidth Y_RGBimgWidthOut, UVimgWidthOut;
00065 VYAimageHeight Y_RGBimgHeightOut, UVimgHeightOut;
00066 int Y_RGB_CVBSscaleFactor, UVscaleFactor;
00067 unsigned int img, line, UVline, pix, color;
00068 bool interlaced;
00069
00070
00071 VYAcheckPrecision(fullName(), Y_RGB_CVBSoutPrec, Y_RGB_CVBSoutPrec, 8, 12, false, false);
00072 VYAcheckPrecision(fullName(), UVoutPrec, UVoutPrec, 8, 12, true, true);
00073
00074
00075 Y_RGB_CVBSscaleFactor = Y_RGB_CVBSoutPrec.bits - PFSPD_BITS;
00076 UVscaleFactor = UVoutPrec.bits - PFSPD_BITS;
00077
00078
00079 read(fileNameInP, fileNameIn);
00080 read(seqInfoInP, seqInfoIn);
00081 startFrame = 1;
00082 nrOutFrames = p_get_num_frames(&seqInfoIn);
00083
00084
00085 status=p_read_header(fileNameIn, &seqInfo);
00086 p_fatal_error(status, stderr);
00087
00088
00089 nrInFrames = p_get_num_frames(&seqInfo);
00090 checkSequenceInfo(nrInFrames, nrOutFrames, startFrame);
00091
00092
00093 Y_RGBframeWidth = p_get_frame_width(&seqInfo);
00094 Y_RGBframeHeight = p_get_frame_height(&seqInfo);
00095
00096
00097 interlaced = p_is_interlaced(&seqInfo);
00098 colorFormat = p_get_color_format(&seqInfo);
00099 color = (colorFormat != P_NO_COLOR);
00100
00101
00102 switch(colorFormat) {
00103 case P_COLOR_RGB : UVframeWidth = Y_RGBframeWidth;
00104 UVframeHeight = Y_RGBframeHeight;
00105 break;
00106 case P_COLOR_444_PL : UVframeWidth = Y_RGBframeWidth;
00107 UVframeHeight = Y_RGBframeHeight;
00108 break;
00109 case P_COLOR_422 : UVframeWidth = Y_RGBframeWidth/2;
00110 UVframeHeight = Y_RGBframeHeight;
00111 break;
00112 case P_COLOR_422_PL : UVframeWidth = Y_RGBframeWidth/2;
00113 UVframeHeight = Y_RGBframeHeight;
00114 break;
00115 case P_COLOR_420 : UVframeWidth = Y_RGBframeWidth/2;
00116 UVframeHeight = Y_RGBframeHeight/2;
00117 break;
00118 case P_COLOR_420_PL : UVframeWidth = Y_RGBframeWidth/2;
00119 UVframeHeight = Y_RGBframeHeight/2;
00120 break;
00121 default : printf("%s: color format is not supported, exiting.\n",fullName());
00122 exit(1);
00123 }
00124
00125 #ifdef VERBOSE
00126 printInfo(interlaced, colorFormat, nrOutFrames,
00127 Y_RGBframeWidth, Y_RGBframeHeight,
00128 Y_RGB_CVBSscaleFactor, UVscaleFactor);
00129 #endif
00130
00131
00132 Y_RGBimgWidthOut = Y_RGBframeWidth;
00133 UVimgWidthOut = UVframeWidth;
00134 if (interlaced) {
00135 Y_RGBimgHeightOut = Y_RGBframeHeight/2;
00136 UVimgHeightOut = UVframeHeight/2;
00137 startImage = 2*(startFrame-1);
00138 nrOutImages = 2*nrOutFrames;
00139 }
00140 else {
00141 Y_RGBimgHeightOut = Y_RGBframeHeight;
00142 UVimgHeightOut = UVframeHeight;
00143 startImage = startFrame-1;
00144 nrOutImages = nrOutFrames;
00145 }
00146
00147 createLineBuffers(colorFormat,
00148 Y_RGBimgWidthOut, UVimgWidthOut,
00149 &Y_R_CVBSbuf, &U_Gbuf, &V_Bbuf);
00150
00151 createImageBuffers(colorFormat,
00152 Y_RGBimgWidthOut, Y_RGBimgHeightOut,
00153 UVimgWidthOut, UVimgHeightOut,
00154 &CVBSbuf, &Ybuf, &Ubuf, &Vbuf, &UVbuf, &Rbuf, &Gbuf, &Bbuf);
00155
00156 #ifdef VERBOSE
00157 if (startFrame > 1)
00158 printf("%s: skipping %i frame(s)\n", fullName(), startFrame-1);
00159 #endif
00160
00161
00162 for (img=startImage; img<startImage+nrOutImages; img++) {
00163
00164 if (colorFormat==P_STREAM) {
00165 p_read_frame(fileNameIn, &seqInfo, 1+img, CVBSbuf, UVbuf,
00166 0, Y_RGBimgWidthOut, Y_RGBimgHeightOut, Y_RGBimgWidthOut);
00167 }
00168 else
00169
00170 if ((colorFormat==P_NO_COLOR) || (colorFormat==P_COLOR_422) || (colorFormat==P_COLOR_420)) {
00171 if (interlaced)
00172 p_read_field(fileNameIn, &seqInfo, 1+(img/2), 1+(img%2), Ybuf, UVbuf,
00173 color, Y_RGBimgWidthOut, Y_RGBimgHeightOut, Y_RGBimgWidthOut);
00174 else
00175 p_read_frame(fileNameIn, &seqInfo, 1+img, Ybuf, UVbuf,
00176 color, Y_RGBimgWidthOut, Y_RGBimgHeightOut, Y_RGBimgWidthOut);
00177 }
00178 else
00179
00180 if ((colorFormat==P_COLOR_444_PL) || (colorFormat==P_COLOR_422_PL) || (colorFormat==P_COLOR_420_PL)) {
00181 if (interlaced)
00182 p_read_field_planar(fileNameIn, &seqInfo, 1+(img/2), 1+(img%2), Ybuf, Ubuf, Vbuf,
00183 1, Y_RGBimgWidthOut, Y_RGBimgHeightOut, Y_RGBimgWidthOut, UVimgWidthOut);
00184 else
00185 p_read_frame_planar(fileNameIn, &seqInfo, 1+img, Ybuf, Ubuf, Vbuf,
00186 1, Y_RGBimgWidthOut, Y_RGBimgHeightOut, Y_RGBimgWidthOut, UVimgWidthOut);
00187 }
00188 else
00189
00190 if (colorFormat==P_COLOR_RGB) {
00191 if (interlaced)
00192 p_read_field_planar(fileNameIn, &seqInfo, 1+(img/2), 1+(img%2), Rbuf, Gbuf, Bbuf,
00193 1, Y_RGBimgWidthOut, Y_RGBimgHeightOut, Y_RGBimgWidthOut, 0);
00194 else
00195 p_read_frame_planar(fileNameIn, &seqInfo, 1+img, Rbuf, Gbuf, Bbuf,
00196 1, Y_RGBimgWidthOut, Y_RGBimgHeightOut, Y_RGBimgWidthOut, 0);
00197 }
00198
00199 #ifdef VERBOSE
00200 if (interlaced)
00201 printf("%s: sourcing field (%3i,%i)\n", fullName(),
00202 1+((img-startImage)/2), 1+((img-startImage)%2));
00203 else
00204 printf("%s: sourcing frame %3i\n", fullName(), 1+img-startImage);
00205 #endif
00206
00207
00208 if (colorFormat != P_STREAM) {
00209 write(Y_RGBimgHeightOutP, Y_RGBimgHeightOut);
00210 write(Y_RGBimgWidthOutP, Y_RGBimgWidthOut);
00211 if (colorFormat != P_NO_COLOR) {
00212 write(UVimgHeightOutP, UVimgHeightOut);
00213 write(UVimgWidthOutP, UVimgWidthOut);
00214 }
00215 if (interlaced)
00216 write(Y_YUV_RGBimgTypeOutP, ((img%2)==0) ? VYA_TOP_FIELD : VYA_BOTTOM_FIELD);
00217 else
00218 write(Y_YUV_RGBimgTypeOutP, VYA_FRAME);
00219 }
00220
00221
00222 if (colorFormat==P_STREAM) {
00223 for (line=0; line!=Y_RGBimgHeightOut; line++) {
00224 for (pix=0; pix<Y_RGBimgWidthOut; pix++)
00225 Y_R_CVBSbuf[pix] = (VYApixel)(CVBSbuf[line*Y_RGBimgWidthOut+pix]<<Y_RGB_CVBSscaleFactor);
00226 write(Y_R_CVBSoutP, Y_R_CVBSbuf, Y_RGBimgWidthOut);
00227 }
00228 }
00229 else
00230
00231 if (colorFormat==P_NO_COLOR) {
00232 for (line=0; line!=Y_RGBimgHeightOut; line++) {
00233 for (pix=0; pix<Y_RGBimgWidthOut; pix++)
00234 Y_R_CVBSbuf[pix] = (VYApixel)(Ybuf[line*Y_RGBimgWidthOut+pix]<<Y_RGB_CVBSscaleFactor);
00235 write(Y_R_CVBSoutP, Y_R_CVBSbuf, Y_RGBimgWidthOut);
00236 }
00237 }
00238 else
00239
00240 if ((colorFormat==P_COLOR_444_PL) || (colorFormat==P_COLOR_422_PL) || (colorFormat==P_COLOR_420_PL)) {
00241 for (line=0; line<Y_RGBimgHeightOut; line++) {
00242
00243 for (pix=0; pix<Y_RGBimgWidthOut; pix++)
00244 Y_R_CVBSbuf[pix] = (VYApixel)(Ybuf[line*Y_RGBimgWidthOut+pix]<<Y_RGB_CVBSscaleFactor);
00245 write(Y_R_CVBSoutP, Y_R_CVBSbuf, Y_RGBimgWidthOut);
00246
00247 if (line%(Y_RGBimgHeightOut/UVimgHeightOut) == 0) {
00248 UVline = line/(Y_RGBimgHeightOut/UVimgHeightOut);
00249
00250 for (pix=0; pix<UVimgWidthOut; pix++)
00251 U_Gbuf[pix] = (VYApixel)((Ubuf[UVline*UVimgWidthOut+pix]-UV_OFFSET)<<UVscaleFactor);
00252 write(U_GoutP, U_Gbuf, UVimgWidthOut);
00253
00254 for (pix=0; pix<UVimgWidthOut; pix++)
00255 V_Bbuf[pix] = (VYApixel)((Vbuf[UVline*UVimgWidthOut+pix]-UV_OFFSET)<<UVscaleFactor);
00256 write(V_BoutP, V_Bbuf, UVimgWidthOut);
00257 }
00258 }
00259 }
00260 else
00261
00262 if ((colorFormat==P_COLOR_422) || (colorFormat==P_COLOR_420)) {
00263 for (line=0; line<Y_RGBimgHeightOut; line++) {
00264
00265 for (pix=0; pix<Y_RGBimgWidthOut; pix++)
00266 Y_R_CVBSbuf[pix] = (VYApixel)(Ybuf[line*Y_RGBimgWidthOut+pix]<<Y_RGB_CVBSscaleFactor);
00267 write(Y_R_CVBSoutP, Y_R_CVBSbuf, Y_RGBimgWidthOut);
00268
00269 if (line%(Y_RGBimgHeightOut/UVimgHeightOut) == 0) {
00270 UVline = line/(Y_RGBimgHeightOut/UVimgHeightOut);
00271
00272 for (pix=0; pix<UVimgWidthOut; pix++)
00273 U_Gbuf[pix] = (VYApixel)((UVbuf[2*(UVline*UVimgWidthOut+pix)]-UV_OFFSET)<<UVscaleFactor);
00274 write(U_GoutP, U_Gbuf, UVimgWidthOut);
00275
00276 for (pix=0; pix<UVimgWidthOut; pix++)
00277 V_Bbuf[pix] = (VYApixel)((UVbuf[2*(UVline*UVimgWidthOut+pix)+1]-UV_OFFSET)<<UVscaleFactor);
00278 write(V_BoutP, V_Bbuf, UVimgWidthOut);
00279 }
00280 }
00281 }
00282 else
00283
00284 if (colorFormat==P_COLOR_RGB) {
00285 for (line=0; line<Y_RGBimgHeightOut; line++) {
00286
00287 for (pix=0; pix<Y_RGBimgWidthOut; pix++)
00288 Y_R_CVBSbuf[pix] = (VYApixel)(Rbuf[line*Y_RGBimgWidthOut+pix]<<Y_RGB_CVBSscaleFactor);
00289 write(Y_R_CVBSoutP, Y_R_CVBSbuf, Y_RGBimgWidthOut);
00290
00291 for (pix=0; pix<Y_RGBimgWidthOut; pix++)
00292 U_Gbuf[pix] = (VYApixel)(Gbuf[line*Y_RGBimgWidthOut+pix]<<Y_RGB_CVBSscaleFactor);
00293 write(U_GoutP, U_Gbuf, Y_RGBimgWidthOut);
00294
00295 for (pix=0; pix<Y_RGBimgWidthOut; pix++)
00296 V_Bbuf[pix] = (VYApixel)(Bbuf[line*Y_RGBimgWidthOut+pix]<<Y_RGB_CVBSscaleFactor);
00297 write(V_BoutP, V_Bbuf, Y_RGBimgWidthOut);
00298 }
00299 }
00300 }
00301
00302 deleteImageBuffers(colorFormat, &CVBSbuf, &Ybuf, &Ubuf, &Vbuf, &UVbuf, &Rbuf, &Gbuf, &Bbuf);
00303
00304 deleteLineBuffers(colorFormat, &Y_R_CVBSbuf, &U_Gbuf, &V_Bbuf);
00305
00306 p_close_file(fileNameIn);
00307 #ifdef VERBOSE
00308 printf("%s: finished reading input file.\n", fullName());
00309 #endif
00310 }
00311 }
00312
00313 void pfspdFE::checkSequenceInfo(int nrInFrames, int nrOutFrames, int startFrame)
00314 {
00315 if ((startFrame <= 0) || (startFrame > nrInFrames)) {
00316 printf("%s: error: illegal startFrame = %i; must be between 1 and %i\n",
00317 fullName(), startFrame, nrInFrames);
00318 exit(1);
00319 }
00320 if ((nrOutFrames <= 0) || (nrOutFrames > nrInFrames-startFrame+1)) {
00321 printf("%s error: illegal nrOutFrames = %i\n", fullName(), nrOutFrames);
00322 printf(" Must be between 1 and %i (nrInFrames-startFrame+1)\n",
00323 nrInFrames-startFrame+1);
00324 printf(" nrInFrames = %i (#frames in input file %s)\n", nrInFrames,(const char*)fileNameIn);
00325 printf(" startFrame = %i\n", startFrame);
00326 exit(1);
00327 }
00328 }
00329
00330 void pfspdFE::printInfo(bool interlaced, pT_color colorFormat, int nrOutFrames,
00331 int Y_RGBframeWidth, int Y_RGBframeHeight,
00332 int Y_RGB_CVBSscaleFactor, int UVscaleFactor)
00333 {
00334 printf("\n");
00335 printf("%s:\n", fullName());
00336 printf(" reading %i frame(s) from file : %s\n", nrOutFrames,(const char*)fileNameIn);
00337 printf(" frame size: %i pixels x %i lines\n", Y_RGBframeWidth, Y_RGBframeHeight);
00338 if (interlaced)
00339 printf(" input is interlaced; ");
00340 else
00341 printf(" input is progressive; ");
00342 switch(colorFormat) {
00343 case P_STREAM : printf(" format is CVBS\n"); break;
00344 case P_NO_COLOR : printf(" format is Y\n"); break;
00345 case P_COLOR_444_PL : printf(" color format is YUV 4:4:4 planar\n"); break;
00346 case P_COLOR_422 : printf(" color format is YUV 4:2:2 muxed\n"); break;
00347 case P_COLOR_422_PL : printf(" color format is YUV 4:2:2 planar\n"); break;
00348 case P_COLOR_420 : printf(" color format is YUV 4:2:0 muxed\n"); break;
00349 case P_COLOR_420_PL : printf(" color format is YUV 4:2:0 planar\n"); break;
00350 case P_COLOR_RGB : printf(" color format is RGB\n"); break;
00351 default : printf(" color format is not supported, exiting.\n");
00352 exit(1);
00353 }
00354 if (colorFormat==P_STREAM) {
00355 if (Y_RGB_CVBSscaleFactor != 0)
00356 printf(" CBVS-data is scaled from %i to %i bits\n",
00357 PFSPD_BITS, Y_RGB_CVBSoutPrec.bits);
00358 }
00359 else
00360 if (colorFormat!=P_COLOR_RGB) {
00361 if (Y_RGB_CVBSscaleFactor != 0)
00362 printf(" Y-data is scaled from %i to %i bits\n",
00363 PFSPD_BITS, Y_RGB_CVBSoutPrec.bits);
00364 if (colorFormat!=P_NO_COLOR) {
00365 if (UVscaleFactor != 0)
00366 printf(" UV-data is scaled from %i to %i bits\n",
00367 PFSPD_BITS, UVoutPrec.bits);
00368 }
00369 }
00370 else {
00371 if (Y_RGB_CVBSscaleFactor != 0)
00372 printf(" RGB-data is scaled from %i to %i bits\n",
00373 PFSPD_BITS, Y_RGB_CVBSoutPrec.bits);
00374 }
00375 printf("\n");
00376 }
00377
00378 void pfspdFE::createLineBuffers(pT_color colorFormat,
00379 int Y_RGBimgWidth, int UVimgWidth,
00380 VYApixel **Y_R_CVBSbuf, VYApixel **U_Gbuf, VYApixel **V_Bbuf)
00381 {
00382 *Y_R_CVBSbuf = new VYApixel[Y_RGBimgWidth];
00383 if (!(*Y_R_CVBSbuf)) {
00384 printf("%s: error : memory allocation failed on line buffer Y_R_CVBSbuf\n", fullName());
00385 exit(1);
00386 }
00387 if (!((colorFormat == P_STREAM) || (colorFormat == P_NO_COLOR) || (colorFormat == P_COLOR_RGB))) {
00388 *U_Gbuf = new VYApixel[UVimgWidth];
00389 if (!(*U_Gbuf)) {
00390 printf("%s: error : memory allocation failed on line buffer U_Gbuf\n", fullName());
00391 exit(1);
00392 }
00393 *V_Bbuf = new VYApixel[UVimgWidth];
00394 if (!(*V_Bbuf)) {
00395 printf("%s: error : memory allocation failed on line buffer V_Bbuf\n", fullName());
00396 exit(1);
00397 }
00398 }
00399 else
00400 if (colorFormat==P_COLOR_RGB) {
00401 *U_Gbuf = new VYApixel[Y_RGBimgWidth];
00402 if (!(*U_Gbuf)) {
00403 printf("%s: error : memory allocation failed on line buffer U_Gbuf\n", fullName());
00404 exit(1);
00405 }
00406 *V_Bbuf = new VYApixel[Y_RGBimgWidth];
00407 if (!(*V_Bbuf)) {
00408 printf("%s: error : memory allocation failed on line buffer V_Bbuf\n", fullName());
00409 exit(1);
00410 }
00411 }
00412 }
00413
00414 void pfspdFE::createImageBuffers(pT_color colorFormat,
00415 int Y_RGBimgWidth, int Y_RGBimgHeight,
00416 int UVimgWidth, int UVimgHeight,
00417 byte **CVBSbuf,
00418 byte **Ybuf, byte **Ubuf, byte **Vbuf, byte **UVbuf,
00419 byte **Rbuf, byte **Gbuf, byte **Bbuf)
00420 {
00421 if (colorFormat==P_STREAM) {
00422 *CVBSbuf = new byte[Y_RGBimgWidth*Y_RGBimgHeight];
00423 if (!(*CVBSbuf)) {
00424 printf("%s: error : memory allocation failed on image buffer CVBSbuf\n", fullName());
00425 exit(1);
00426 }
00427 }
00428 else
00429 if (colorFormat!=P_COLOR_RGB) {
00430 *Ybuf = new byte[Y_RGBimgWidth*Y_RGBimgHeight];
00431 if (!(*Ybuf)) {
00432 printf("%s: error : memory allocation failed on image buffer Ybuf\n", fullName());
00433 exit(1);
00434 }
00435 }
00436 if ((colorFormat==P_COLOR_444_PL) || (colorFormat==P_COLOR_422_PL) || (colorFormat==P_COLOR_420_PL)) {
00437 *Ubuf = new byte[UVimgWidth*UVimgHeight];
00438 if (!(*Ubuf)) {
00439 printf("%s: error : memory allocation failed on image buffer Ubuf\n", fullName());
00440 exit(1);
00441 }
00442 *Vbuf = new byte[UVimgWidth*UVimgHeight];
00443 if (!(*Vbuf)) {
00444 printf("%s: error : memory allocation failed on image buffer Vbuf\n", fullName());
00445 exit(1);
00446 }
00447 }
00448 else
00449 if ((colorFormat==P_COLOR_422) || (colorFormat==P_COLOR_420)) {
00450 *UVbuf= new byte[2*UVimgWidth*UVimgHeight];
00451 if (!(*UVbuf)) {
00452 printf("%s: error : memory allocation failed on image buffer UVbuf\n", fullName());
00453 exit(1);
00454 }
00455 }
00456 else
00457 if (colorFormat==P_COLOR_RGB) {
00458 *Rbuf = new byte[Y_RGBimgWidth*Y_RGBimgHeight];
00459 if (!(*Rbuf)) {
00460 printf("%s: error : memory allocation failed on image buffer Rbuf\n", fullName());
00461 exit(1);
00462 }
00463 *Gbuf = new byte[Y_RGBimgWidth*Y_RGBimgHeight];
00464 if (!(*Gbuf)) {
00465 printf("%s: error : memory allocation failed on image buffer Gbuf\n", fullName());
00466 exit(1);
00467 }
00468 *Bbuf = new byte[Y_RGBimgWidth*Y_RGBimgHeight];
00469 if (!(*Bbuf)) {
00470 printf("%s: error : memory allocation failed on image buffer Bbuf\n", fullName());
00471 exit(1);
00472 }
00473 }
00474 }
00475
00476 void pfspdFE::deleteLineBuffers(pT_color colorFormat,
00477 VYApixel **Y_R_CVBSbuf, VYApixel **U_Gbuf, VYApixel **V_Bbuf)
00478 {
00479 delete [] *Y_R_CVBSbuf;
00480 if (!((colorFormat==P_STREAM) || (colorFormat==P_NO_COLOR))) {
00481 delete [] *U_Gbuf;
00482 delete [] *V_Bbuf;
00483 }
00484 }
00485
00486 void pfspdFE::deleteImageBuffers(pT_color colorFormat,
00487 byte **CVBSbuf,
00488 byte **Ybuf, byte **Ubuf, byte **Vbuf, byte **UVbuf,
00489 byte **Rbuf, byte **Gbuf, byte **Bbuf)
00490 {
00491 if (colorFormat==P_STREAM)
00492 delete [] *CVBSbuf;
00493 else
00494 if (colorFormat!=P_COLOR_RGB)
00495 delete [] *Ybuf;
00496 if ((colorFormat==P_COLOR_444_PL) || (colorFormat==P_COLOR_422_PL) || (colorFormat==P_COLOR_420_PL)) {
00497 delete [] *Ubuf;
00498 delete [] *Vbuf;
00499 }
00500 else
00501 if ((colorFormat==P_COLOR_422) || (colorFormat==P_COLOR_420))
00502 delete [] *UVbuf;
00503 else
00504 if (colorFormat==P_COLOR_RGB) {
00505 delete [] *Rbuf;
00506 delete [] *Gbuf;
00507 delete [] *Bbuf;
00508 }
00509
00510 }