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

hs.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 "hs.h"
00012 
00013 using namespace std;
00014 
00015 HS::HS(
00016   const Id&           n, 
00017   In<VYApixel>&       Cin,
00018   In<VYAlineLength>&  inLineLengthIn,
00019   In<VYAlineLength>&  outLineLengthIn,
00020   Out<VYApixel>&      Cout)
00021 :
00022   Process(n),
00023   CinP(             id("CinP"),             Cin),
00024   inLineLengthInP(  id("inLineLengthInP"),  inLineLengthIn),
00025   outLineLengthInP( id("outLineLengthInP"), outLineLengthIn),
00026   CoutP(            id("CoutP"),            Cout)
00027 { 
00028 }
00029 
00030 void HS::main()
00031 {
00032   while (true)
00033   {
00034     VYApixel pixel;
00035     VYAlineLength inLineLength;
00036     VYAlineLength outLineLength;
00037     double index;
00038     double scaleFactor;
00039     
00040     read(inLineLengthInP, inLineLength);
00041     read(outLineLengthInP, outLineLength);
00042     
00043     index = 0;
00044     scaleFactor = (double)outLineLength / (double)inLineLength;
00045 
00046     if (scaleFactor <= 1) /* compress */
00047     {
00048       for (unsigned int i=0; i<inLineLength; i++)
00049       {
00050         read(CinP, pixel);
00051         if (index <= i)
00052         {
00053           write(CoutP, pixel);
00054           index += 1/scaleFactor;
00055         }
00056       }
00057     }
00058     else /* expand */
00059     {
00060       for (unsigned int i=0; i<outLineLength; i++)
00061       {
00062         if (index <= i)
00063         {
00064           read(CinP, pixel);
00065           index += scaleFactor;
00066         }     
00067         write(CoutP, pixel);
00068       }
00069     }
00070   }
00071 }

Generated on Wed Feb 15 14:52:44 2006 for scaling by doxygen 1.3.2