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

downscale.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 "downscale.h"
00012 
00013 /* The number of bits coefficients are scaled up before 2-D IDCT: */
00014 const unsigned int S_BITS = 3;
00015 
00016 inline
00017 VYApixel DESCALE(VYApixel x, unsigned int n) 
00018 {
00019   return  (x + (1 << (n-1)) - (x < 0)) >> n;
00020 }
00021 
00022 DownScale::DownScale(
00023   const Id&     n, 
00024   In<VYApixel>&     cin, 
00025   Out<VYApixel>&    cout)
00026 :
00027         Process(n),
00028         Cin(  id("Cin"),  cin),
00029         Cout( id("Cout"), cout)
00030 {
00031 }
00032 
00033 void DownScale::main()
00034 {
00035       VYApixel  pixelIn;
00036   VYApixel  pixelOut;
00037 
00038       while (true)
00039   {
00040     read(Cin, pixelIn);
00041   
00042                 pixelOut = 128 + DESCALE(pixelIn, S_BITS+3);
00043                 // Clip to 8 bits unsigned
00044     pixelOut = pixelOut > 0 ? (pixelOut < 255 ? pixelOut : 255) : 0;
00045 
00046     write(Cout, pixelOut);
00047   }
00048 }

Generated on Wed Feb 15 14:52:45 2006 for jpegdec by doxygen 1.3.2