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

matrix.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 "matrix.h"
00012 #include <stdio.h>
00013 
00014 /* Ensure number is >=0 and <=255        */
00015 #define Saturate(n) ((n) > 0 ? ((n) < 255 ? (n) : 255) : 0)
00016 
00017 Matrix::Matrix (
00018     const Id&          n,
00019     In<VYApixel>&      Ci1F,
00020     In<VYApixel>&      Ci2F,
00021     In<VYApixel>&      Ci3F,
00022     Out<VYApixel>&     Co1F,
00023     Out<VYApixel>&     Co2F,
00024     Out<VYApixel>&     Co3F)
00025 :
00026     // member initialisation
00027     // process network
00028     Process(n),
00029 
00030     // ports
00031     Ci1P(id("Ci1"), Ci1F),
00032     Ci2P(id("Ci2"), Ci2F),
00033     Ci3P(id("Ci3"), Ci3F),
00034     Co1P(id("G_Y"), Co1F),
00035     Co2P(id("Co2"), Co2F),
00036     Co3P(id("Co3"), Co3F)
00037 {
00038 };
00039 
00040 void Matrix::main(void)
00041 {
00042   VYApixel Ci1,Ci2,Ci3;
00043   VYApixel Co1,Co2,Co3;
00044   
00045       int   y,cb,cr;
00046       int   rcb, rcr;
00047       int r,g,b;
00048 
00049   while(true)
00050   {
00051     read(Ci1P, Ci1);
00052     read(Ci2P, Ci2);
00053     read(Ci3P, Ci3);
00054 
00055     y = Ci1;
00056     cb = Ci2;
00057     cr = Ci3;
00058 
00059     rcb = cb-128;
00060     rcr = cr-128;
00061 
00062     r = y + ((359*rcr)>>8);
00063     g = y - ((11*rcb)>>5) - ((183*rcr)>>8);
00064     b = y + ((227*rcb)>>7);
00065 
00066     Co1 = Saturate(r);
00067     Co2 = Saturate(g);
00068     Co3 = Saturate(b);
00069 
00070     write(Co1P, Co1);
00071     write(Co2P, Co2);
00072     write(Co3P, Co3);
00073   }
00074 }

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