Main Page | Namespace List | Compound List | File List | Compound Members | File Members

pfspdbe.cc

Go to the documentation of this file.
00001 /*--------------------------------------------------------------------
00002  *
00003  * (C) Copyright Koninklijke Philips Electronics NV 2006. 
00004  * All rights reserved. This software is licensed under the terms of
00005  * version 2.1 of the GNU Lesser General Public License as published 
00006  * by the Free Software Foundation. For licensing and warranty
00007  * information, see the file COPYING in the main directory.
00008  *
00009  *------------------------------------------------------------------*/
00010 
00011 #include <stdio.h>
00012 #include <stdlib.h>
00013 #include "pfspdbe.h"
00014 
00015 pfspdBE::pfspdBE (
00016     const Id&              n,
00017     VYAbitPrecision        Y_RGB_CVBSinPrecision,
00018     VYAbitPrecision        UVinPrecision,
00019 
00020     In<VYAfileName>&       fileNameInF,
00021     In<pT_header>&         seqInfoInF,
00022     In<VYApixel>&          Y_R_CVBSinF,
00023     In<VYApixel>&          U_GinF,
00024     In<VYApixel>&          V_BinF,
00025     In<VYAimageWidth>&     Y_RGBimgWidthInF,
00026     In<VYAimageHeight>&    Y_RGBimgHeightInF,
00027     In<VYAimageWidth>&     UVimgWidthInF,
00028     In<VYAimageHeight>&    UVimgHeightInF,
00029     In<VYAimageType>&      Y_YUV_RGBimgTypeInF)
00030 :
00031     // member initialisation
00032 
00033     // process network
00034     VYAprocess(n),
00035 
00036     // bind fifo's to ports
00037     fileNameInP(id("fileNameInP"), fileNameInF),
00038     seqInfoInP(id("seqInfoInP"), seqInfoInF),
00039     Y_R_CVBSinP(id("Y_R_CVBSinP"), Y_R_CVBSinF),
00040     U_GinP(id("U_GinP"), U_GinF),
00041     V_BinP(id("V_BinP"), V_BinF),
00042     Y_RGBimgWidthInP(id("Y_RGBimgWidthInP"), Y_RGBimgWidthInF),
00043     Y_RGBimgHeightInP(id("Y_RGBimgHeightInP"), Y_RGBimgHeightInF),
00044     UVimgWidthInP(id("UVimgWidthInP"), UVimgWidthInF),
00045     UVimgHeightInP(id("UVimgHeightInP"), UVimgHeightInF),
00046     Y_YUV_RGBimgTypeInP(id("Y_YUV_RGBimgTypeInP"), Y_YUV_RGBimgTypeInF)
00047 {
00048     Y_RGB_CVBSinPrec = Y_RGB_CVBSinPrecision;
00049     UVinPrec         = UVinPrecision;
00050 };
00051 
00052 void pfspdBE::main(void)
00053 {
00054   while(true)
00055   {
00056       pT_status         status;
00057       pT_color          colorFormat;
00058       pT_header         seqInfo;
00059       unsigned int      nrOutFrames, 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_RGBimgWidthIn, UVimgWidthIn;
00065       VYAimageHeight    Y_RGBimgHeightIn, UVimgHeightIn;
00066       VYAimageWidth     Y_RGBimgWidth, UVimgWidth;
00067       VYAimageHeight    Y_RGBimgHeight, UVimgHeight;
00068       VYAimageType      Y_YUV_RGBimgTypeIn;
00069       int               Y_RGB_CVBSscaleFactor, UVscaleFactor;
00070       unsigned int      img, line, UVline, pix, color, sample;
00071       bool              interlaced;
00072 
00073       // check bit precision
00074       VYAcheckPrecision(fullName(), Y_RGB_CVBSinPrec, Y_RGB_CVBSinPrec, 8, 12, false, false);
00075       VYAcheckPrecision(fullName(), UVinPrec,         UVinPrec,         8, 12, true,  true);
00076 
00077       // set scale factors
00078       Y_RGB_CVBSscaleFactor = Y_RGB_CVBSinPrec.bits - PFSPD_BITS;
00079       UVscaleFactor         = UVinPrec.bits - PFSPD_BITS;
00080 
00081       // read input file info
00082       read(fileNameInP, fileNameIn);
00083       read(seqInfoInP, seqInfo);
00084  
00085       // open output file
00086       status=p_write_header(fileNameIn, &seqInfo);
00087       p_fatal_error(status, stderr);
00088 
00089       // read length of output sequence
00090       nrOutFrames = p_get_num_frames(&seqInfo);
00091 
00092       // define Y and RGB frame sizes
00093       Y_RGBframeWidth  = p_get_frame_width(&seqInfo);
00094       Y_RGBframeHeight = p_get_frame_height(&seqInfo);
00095 
00096       // set format control parameters
00097       interlaced  = p_is_interlaced(&seqInfo);
00098       colorFormat = p_get_color_format(&seqInfo);
00099       color       = (colorFormat != P_NO_COLOR);
00100 
00101       // define UV frame sizes
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       // define image sizes
00132       Y_RGBimgWidth = Y_RGBframeWidth;
00133       UVimgWidth    = UVframeWidth;
00134       if (interlaced) {
00135           Y_RGBimgHeight = Y_RGBframeHeight/2;
00136           UVimgHeight    = UVframeHeight/2;
00137           nrOutImages    = 2*nrOutFrames;
00138       }
00139       else {
00140           Y_RGBimgHeight = Y_RGBframeHeight;
00141           UVimgHeight    = UVframeHeight;
00142           nrOutImages    = nrOutFrames;
00143       }
00144 
00145       createLineBuffers(colorFormat,
00146                         Y_RGBimgWidth, UVimgWidth,
00147                         &Y_R_CVBSbuf, &U_Gbuf, &V_Bbuf);
00148 
00149       createImageBuffers(colorFormat,
00150                          Y_RGBimgWidth, Y_RGBimgHeight,
00151                          UVimgWidth, UVimgHeight,
00152                          &CVBSbuf, &Ybuf, &Ubuf, &Vbuf, &UVbuf, &Rbuf, &Gbuf, &Bbuf);
00153 
00154       // read nrOutImages output images from video ports
00155       for (img=0; img<nrOutImages; img++) {
00156           #ifdef VERBOSE
00157               if (interlaced)
00158                   printf("%s:  sinking field  (%3i,%i)\n", fullName(), 1+(img/2), 1+(img%2));
00159               else
00160                   printf("%s:  sinking frame  %3i\n", fullName(), 1+img);
00161           #endif
00162 
00163           // read and check image info
00164           if (colorFormat != P_STREAM) {
00165               read(Y_RGBimgWidthInP, Y_RGBimgWidthIn);
00166               checkParameter(Y_RGBimgWidthIn, Y_RGBimgWidth, "Y_RGBimgWidth");
00167               read(Y_RGBimgHeightInP, Y_RGBimgHeightIn);
00168               checkParameter(Y_RGBimgHeightIn, Y_RGBimgHeight, "Y_RGBimgHeight");
00169               if (colorFormat != P_NO_COLOR) {
00170                   read(UVimgWidthInP,  UVimgWidthIn);
00171                   checkParameter(UVimgWidthIn, UVimgWidth, "UVimgWidth");
00172                   read(UVimgHeightInP, UVimgHeightIn);
00173                   checkParameter(UVimgHeightIn, UVimgHeight, "UVimgHeight");
00174               }
00175               read(Y_YUV_RGBimgTypeInP, Y_YUV_RGBimgTypeIn);
00176           }
00177 
00178           // read CVBS image from port
00179           if (colorFormat==P_STREAM) {
00180               for(line=0; line!=Y_RGBimgHeight; line++) {
00181                   read(Y_R_CVBSinP, Y_R_CVBSbuf, Y_RGBimgWidth);
00182                   for(pix=0; pix<Y_RGBimgWidth; pix++) {
00183                       sample = (int)Y_R_CVBSbuf[pix];
00184                       sample = VYAroundNorm(sample, Y_RGB_CVBSscaleFactor);
00185                       sample = VYAclip(sample, Y_RGB_CVBS_MIN, Y_RGB_CVBS_MAX);
00186                       CVBSbuf[line*Y_RGBimgWidth+pix] = (byte)sample;
00187                   }
00188               }
00189           }
00190           else
00191           // read Y image from port
00192           if (colorFormat==P_NO_COLOR) {
00193               for(line=0; line!=Y_RGBimgHeight; line++) {
00194                   read(Y_R_CVBSinP, Y_R_CVBSbuf, Y_RGBimgWidth);
00195                   for(pix=0; pix<Y_RGBimgWidth; pix++) {
00196                       sample = (int)Y_R_CVBSbuf[pix];
00197                       sample = VYAroundNorm(sample, Y_RGB_CVBSscaleFactor);
00198                       sample = VYAclip(sample, Y_RGB_CVBS_MIN, Y_RGB_CVBS_MAX);
00199                       Ybuf[line*Y_RGBimgWidth+pix] = (byte)sample;
00200                   }
00201               }
00202           }
00203           else
00204           // read YUV-422 (muxed) or YUV-420 (muxed) image from port
00205           if ((colorFormat==P_COLOR_422) || (colorFormat==P_COLOR_420)) {
00206               for (line=0; line<Y_RGBimgHeight; line++) {
00207                   // read Y-line
00208                   read(Y_R_CVBSinP, Y_R_CVBSbuf, Y_RGBimgWidth);
00209                   for(pix=0; pix<Y_RGBimgWidth; pix++) {
00210                       sample = (int)Y_R_CVBSbuf[pix];
00211                       sample = VYAroundNorm(sample, Y_RGB_CVBSscaleFactor);
00212                       sample = VYAclip(sample, Y_RGB_CVBS_MIN, Y_RGB_CVBS_MAX);
00213                       Ybuf[line*Y_RGBimgWidth+pix] = (byte)sample;
00214                   }
00215                   // read U-line and V-line
00216                   if (line%(Y_RGBimgHeight/UVimgHeight) == 0) {
00217                       UVline = line/(Y_RGBimgHeight/UVimgHeight);
00218                       read(U_GinP, U_Gbuf, UVimgWidth);
00219                       read(V_BinP, V_Bbuf, UVimgWidth);
00220                       for(pix=0; pix<UVimgWidth; pix++) {
00221                           sample = (int)U_Gbuf[pix];
00222                           sample = VYAroundNorm(sample, UVscaleFactor);
00223                           sample = VYAclip(sample, UV_MIN, UV_MAX);
00224                           UVbuf[UVline*2*UVimgWidth+2*pix]   = (byte)(sample + UV_OFFSET);
00225                           sample = (int)V_Bbuf[pix];
00226                           sample = VYAroundNorm(sample, UVscaleFactor);
00227                           sample = VYAclip(sample, UV_MIN, UV_MAX);
00228                           UVbuf[UVline*2*UVimgWidth+2*pix+1] = (byte)(sample + UV_OFFSET);
00229                       }
00230                   }
00231               }
00232           }
00233           else
00234           // read YUV-444 (planar) or YUV-422 (planar) or YUV-420 (planar) image from port
00235           if ((colorFormat==P_COLOR_444_PL) || (colorFormat==P_COLOR_422_PL) || (colorFormat==P_COLOR_420_PL)) {
00236               for (line=0; line<Y_RGBimgHeight; line++) {
00237                   // read Y-line
00238                   read(Y_R_CVBSinP, Y_R_CVBSbuf, Y_RGBimgWidth);
00239                   for(pix=0; pix<Y_RGBimgWidth; pix++) {
00240                       sample = (int)Y_R_CVBSbuf[pix];
00241                       sample = VYAroundNorm(sample, Y_RGB_CVBSscaleFactor);
00242                       sample = VYAclip(sample, Y_RGB_CVBS_MIN, Y_RGB_CVBS_MAX);
00243                       Ybuf[line*Y_RGBimgWidth+pix] = (byte)sample;
00244                   }
00245                   // read U-line and V-line
00246                   if (line%(Y_RGBimgHeight/UVimgHeight) == 0) {
00247                       read(U_GinP, U_Gbuf, UVimgWidth);
00248                       read(V_BinP, V_Bbuf, UVimgWidth);
00249                       UVline = line/(Y_RGBimgHeight/UVimgHeight);
00250                       for(pix=0; pix<UVimgWidth; pix++) {
00251                           sample = (int)U_Gbuf[pix];
00252                           sample = VYAroundNorm(sample, UVscaleFactor);
00253                           sample = VYAclip(sample, UV_MIN, UV_MAX);
00254                           Ubuf[UVline*UVimgWidth+pix]   = (byte)(sample + UV_OFFSET);
00255                           sample = (int)V_Bbuf[pix];
00256                           sample = VYAroundNorm(sample, UVscaleFactor);
00257                           sample = VYAclip(sample, UV_MIN, UV_MAX);
00258                           Vbuf[UVline*UVimgWidth+pix]   = (byte)(sample + UV_OFFSET);
00259                       }
00260                   }
00261               }
00262           }
00263           else
00264           // read RGB image from port
00265           if (colorFormat==P_COLOR_RGB) {
00266               for(line=0; line<Y_RGBimgHeight; line++) {
00267                   // read R-line and G-line and B-line
00268                   read(Y_R_CVBSinP, Y_R_CVBSbuf, Y_RGBimgWidth);
00269                   read(U_GinP,      U_Gbuf,      Y_RGBimgWidth);
00270                   read(V_BinP,      V_Bbuf,      Y_RGBimgWidth);
00271                   for(pix=0; pix<Y_RGBimgWidth; pix++) {
00272                       sample = (int)Y_R_CVBSbuf[pix];
00273                       sample = VYAroundNorm(sample, Y_RGB_CVBSscaleFactor);
00274                       sample = VYAclip(sample, Y_RGB_CVBS_MIN, Y_RGB_CVBS_MAX);
00275                       Rbuf[line*Y_RGBimgWidth+pix] = (byte)sample;
00276                       sample = (int)U_Gbuf[pix];
00277                       sample = VYAroundNorm(sample, Y_RGB_CVBSscaleFactor);
00278                       sample = VYAclip(sample, Y_RGB_CVBS_MIN, Y_RGB_CVBS_MAX);
00279                       Gbuf[line*Y_RGBimgWidth+pix] = (byte)sample;
00280                       sample = (int)V_Bbuf[pix];
00281                       sample = VYAroundNorm(sample, Y_RGB_CVBSscaleFactor);
00282                       sample = VYAclip(sample, Y_RGB_CVBS_MIN, Y_RGB_CVBS_MAX);
00283                       Bbuf[line*Y_RGBimgWidth+pix] = (byte)sample;
00284                   }
00285               }
00286           }
00287 
00288           // write CVBS image to file
00289           if (colorFormat==P_STREAM) {
00290               p_write_frame(fileNameIn, &seqInfo, 1+img, CVBSbuf, UVbuf,
00291                             Y_RGBimgWidth, Y_RGBimgHeight, Y_RGBimgWidth);
00292           }
00293           else
00294           // write Y or YUV-422 (muxed) or YUV-420 (muxed) image to file
00295           if ((colorFormat==P_NO_COLOR) || (colorFormat==P_COLOR_422) || (colorFormat==P_COLOR_420)) {
00296               if (interlaced)
00297                   p_write_field(fileNameIn, &seqInfo, 1+(img/2), 1+(img%2), Ybuf, UVbuf,
00298                                 Y_RGBimgWidth, Y_RGBimgHeight, Y_RGBimgWidth);
00299               else
00300                   p_write_frame(fileNameIn, &seqInfo, 1+img, Ybuf, UVbuf,
00301                                 Y_RGBimgWidth, Y_RGBimgHeight, Y_RGBimgWidth);
00302           }
00303           else
00304           // write YUV-444 (planar) or YUV-422 (planar) or YUV-420 (planar) image to file
00305           if ((colorFormat==P_COLOR_444_PL) || (colorFormat==P_COLOR_422_PL) || (colorFormat==P_COLOR_420_PL)) {
00306               if (interlaced)
00307                   p_write_field_planar(fileNameIn, &seqInfo, 1+(img/2), 1+(img%2), Ybuf, Ubuf, Vbuf,
00308                                        Y_RGBimgWidth, Y_RGBimgHeight, Y_RGBimgWidth, UVimgWidth);
00309               else
00310                   p_write_frame_planar(fileNameIn, &seqInfo, 1+img, Ybuf, Ubuf, Vbuf,
00311                                        Y_RGBimgWidth, Y_RGBimgHeight, Y_RGBimgWidth, UVimgWidth);
00312           }
00313           else
00314           // write RGB image to file
00315           if (colorFormat==P_COLOR_RGB) {
00316               if (interlaced)
00317                   p_write_field_planar(fileNameIn, &seqInfo, 1+(img/2), 1+(img%2), Rbuf, Gbuf, Bbuf,
00318                                        Y_RGBimgWidth, Y_RGBimgHeight, Y_RGBimgWidth, 0);
00319               else
00320                   p_write_frame_planar(fileNameIn, &seqInfo, 1+img, Rbuf, Gbuf, Bbuf,
00321                                        Y_RGBimgWidth, Y_RGBimgHeight, Y_RGBimgWidth, 0);
00322           }
00323       }
00324 
00325       deleteImageBuffers(colorFormat, &CVBSbuf, &Ybuf, &Ubuf, &Vbuf, &UVbuf, &Rbuf, &Gbuf, &Bbuf);
00326 
00327       deleteLineBuffers(colorFormat, &Y_R_CVBSbuf, &U_Gbuf, &V_Bbuf);
00328 
00329       p_close_file(fileNameIn);
00330  
00331       #ifdef VERBOSE
00332           printf("%s:  finished writing output file.\n", fullName());
00333       #endif
00334   }
00335   printf("%s: ***\n", fullName());
00336 } // main
00337 
00338 void pfspdBE::printInfo(bool interlaced, pT_color colorFormat, int nrOutFrames,
00339                             int Y_RGBframeWidth, int Y_RGBframeHeight,
00340                             int Y_RGB_CVBSscaleFactor, int UVscaleFactor)
00341 {
00342     printf("\n");
00343     printf("%s:\n", fullName());
00344     printf("   writing %i frame(s) to file : %s\n", nrOutFrames,(const char*)fileNameIn);
00345     printf("   frame size: %i pixels x %i lines\n", Y_RGBframeWidth, Y_RGBframeHeight);
00346     if (interlaced)
00347         printf("   output is interlaced; ");
00348     else
00349         printf("   output is progressive; ");
00350     switch(colorFormat) {
00351         case P_STREAM       : printf(" format is CVBS\n");  break;
00352         case P_NO_COLOR     : printf(" format is Y\n");  break;
00353         case P_COLOR_444_PL : printf(" color format is YUV 4:4:4 planar\n"); break;
00354         case P_COLOR_422    : printf(" color format is YUV 4:2:2 muxed\n"); break;
00355         case P_COLOR_422_PL : printf(" color format is YUV 4:2:2 planar\n"); break;
00356         case P_COLOR_420    : printf(" color format is YUV 4:2:0 muxed\n"); break;
00357         case P_COLOR_420_PL : printf(" color format is YUV 4:2:0 planar\n"); break;
00358         case P_COLOR_RGB    : printf(" color format is RGB\n"); break;
00359         default             : printf(" color format is not supported, exiting.\n");
00360                               exit(1);
00361     }
00362     if (colorFormat==P_STREAM) {
00363         if (Y_RGB_CVBSscaleFactor != 0)
00364             printf("   CBVS-data is scaled from %i to %i bits\n",
00365                    Y_RGB_CVBSinPrec.bits, PFSPD_BITS);
00366     }
00367     else
00368     if (colorFormat!=P_COLOR_RGB) {
00369         if (Y_RGB_CVBSscaleFactor != 0)
00370             printf("   Y-data is scaled from %i to %i bits\n",
00371                    Y_RGB_CVBSinPrec.bits, PFSPD_BITS);
00372         if (colorFormat!=P_NO_COLOR) {
00373             if (UVscaleFactor != 0)
00374                 printf("   UV-data is scaled from %i to %i bits\n",
00375                        UVinPrec.bits, PFSPD_BITS);
00376         }
00377     }
00378     else {
00379         if (Y_RGB_CVBSscaleFactor != 0)
00380             printf("   RGB-data is scaled from %i to %i bits\n",
00381                    Y_RGB_CVBSinPrec.bits, PFSPD_BITS);
00382     }
00383     printf("\n");
00384 } // printInfo
00385 
00386 void pfspdBE::checkParameter(int parameterIn, int parameter, char *name)
00387 {
00388     if (parameterIn != parameter) {
00389         printf("%s: error: %sIn (%i) does not equal %s (%i)\n",
00390                fullName(), name, parameterIn, name, parameter);
00391         exit(1);
00392     }
00393 } // checkParameter
00394 
00395 
00396 void pfspdBE::createLineBuffers(pT_color colorFormat,
00397                                     int Y_RGBimgWidth, int UVimgWidth,
00398                                     VYApixel **Y_R_CVBSbuf, VYApixel **U_Gbuf, VYApixel **V_Bbuf)
00399 {
00400     *Y_R_CVBSbuf = new VYApixel[Y_RGBimgWidth];
00401     if (!(*Y_R_CVBSbuf)) {
00402         printf("%s: error : memory allocation failed on line buffer Y_R_CVBSbuf\n", fullName());
00403         exit(1);
00404     }
00405     if (!((colorFormat == P_STREAM) || (colorFormat == P_NO_COLOR) || (colorFormat == P_COLOR_RGB))) {
00406         *U_Gbuf = new VYApixel[UVimgWidth];
00407         if (!(*U_Gbuf)) {
00408             printf("%s: error : memory allocation failed on line buffer U_Gbuf\n", fullName());
00409             exit(1);
00410         }
00411         *V_Bbuf = new VYApixel[UVimgWidth];
00412         if (!(*V_Bbuf)) {
00413             printf("%s: error : memory allocation failed on line buffer V_Bbuf\n", fullName());
00414             exit(1);
00415         }
00416     }
00417     else
00418     if (colorFormat==P_COLOR_RGB) {
00419         *U_Gbuf = new VYApixel[Y_RGBimgWidth];
00420         if (!(*U_Gbuf)) {
00421             printf("%s: error : memory allocation failed on line buffer U_Gbuf\n", fullName());
00422             exit(1);
00423         }
00424         *V_Bbuf = new VYApixel[Y_RGBimgWidth];
00425         if (!(*V_Bbuf)) {
00426             printf("%s: error : memory allocation failed on line buffer V_Bbuf\n", fullName());
00427             exit(1);
00428         }
00429     }
00430 } // createLineBuffers
00431 
00432 void pfspdBE::createImageBuffers(pT_color colorFormat,
00433                                      int Y_RGBimgWidth, int Y_RGBimgHeight,
00434                                      int UVimgWidth, int UVimgHeight,
00435                                      byte **CVBSbuf,
00436                                      byte **Ybuf, byte **Ubuf, byte **Vbuf, byte **UVbuf,
00437                                      byte **Rbuf, byte **Gbuf, byte **Bbuf)
00438 {
00439     if (colorFormat==P_STREAM) {
00440             *CVBSbuf = new byte[Y_RGBimgWidth*Y_RGBimgHeight];
00441             if (!(*CVBSbuf)) {
00442                 printf("%s: error : memory allocation failed on image buffer CVBSbuf\n", fullName());
00443                 exit(1);
00444             }
00445     }
00446     else
00447     if (colorFormat!=P_COLOR_RGB) {
00448             *Ybuf = new byte[Y_RGBimgWidth*Y_RGBimgHeight];
00449             if (!(*Ybuf)) {
00450                 printf("%s: error : memory allocation failed on image buffer Ybuf\n", fullName());
00451                 exit(1);
00452             }
00453     }
00454     if ((colorFormat==P_COLOR_444_PL) || (colorFormat==P_COLOR_422_PL) || (colorFormat==P_COLOR_420_PL)) {
00455             *Ubuf = new byte[UVimgWidth*UVimgHeight];
00456             if (!(*Ubuf)) {
00457                 printf("%s: error : memory allocation failed on image buffer Ubuf\n", fullName());
00458                 exit(1);
00459             }
00460             *Vbuf = new byte[UVimgWidth*UVimgHeight];
00461             if (!(*Vbuf)) {
00462                 printf("%s: error : memory allocation failed on image buffer Vbuf\n", fullName());
00463                 exit(1);
00464             }
00465     }
00466     else
00467     if ((colorFormat==P_COLOR_422) || (colorFormat==P_COLOR_420)) {
00468         *UVbuf= new byte[2*UVimgWidth*UVimgHeight];
00469         if (!(*UVbuf)) {
00470             printf("%s: error : memory allocation failed on image buffer UVbuf\n", fullName());
00471             exit(1);
00472         }
00473     }
00474     else
00475     if (colorFormat==P_COLOR_RGB) {
00476         *Rbuf = new byte[Y_RGBimgWidth*Y_RGBimgHeight];
00477         if (!(*Rbuf)) {
00478             printf("%s: error : memory allocation failed on image buffer Rbuf\n", fullName());
00479             exit(1);
00480         }
00481         *Gbuf = new byte[Y_RGBimgWidth*Y_RGBimgHeight];
00482         if (!(*Gbuf)) {
00483             printf("%s: error : memory allocation failed on image buffer Gbuf\n", fullName());
00484             exit(1);
00485         }
00486         *Bbuf = new byte[Y_RGBimgWidth*Y_RGBimgHeight];
00487         if (!(*Bbuf)) {
00488             printf("%s: error : memory allocation failed on image buffer Bbuf\n", fullName());
00489             exit(1);
00490         }
00491     }
00492 } // createImageBuffers
00493 
00494 void pfspdBE::deleteLineBuffers(pT_color colorFormat,
00495                                     VYApixel **Y_R_CVBSbuf, VYApixel **U_Gbuf, VYApixel **V_Bbuf)
00496 {
00497     delete [] *Y_R_CVBSbuf;
00498     if (!((colorFormat==P_STREAM) || (colorFormat==P_NO_COLOR))) {
00499             delete [] *U_Gbuf;
00500             delete [] *V_Bbuf;
00501     }
00502 } // deleteLineBuffers
00503 
00504 void pfspdBE::deleteImageBuffers(pT_color colorFormat,
00505                                      byte **CVBSbuf,
00506                                      byte **Ybuf, byte **Ubuf, byte **Vbuf, byte **UVbuf,
00507                                      byte **Rbuf, byte **Gbuf, byte **Bbuf)
00508 {
00509     if (colorFormat==P_STREAM)
00510         delete [] *CVBSbuf;
00511     else
00512     if (colorFormat!=P_COLOR_RGB)
00513         delete [] *Ybuf;
00514     if ((colorFormat==P_COLOR_444_PL) || (colorFormat==P_COLOR_422_PL) || (colorFormat==P_COLOR_420_PL)) {
00515         delete [] *Ubuf;
00516         delete [] *Vbuf;
00517     }
00518     else
00519     if ((colorFormat==P_COLOR_422) || (colorFormat==P_COLOR_420))
00520         delete [] *UVbuf;
00521     else
00522     if (colorFormat==P_COLOR_RGB) {
00523         delete [] *Rbuf;
00524         delete [] *Gbuf;
00525         delete [] *Bbuf;
00526     }
00527 
00528 } // deleteImageBuffers

Generated on Wed Feb 15 14:52:43 2006 for pfspdfebe by doxygen 1.3.2