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

scaling_env.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 "scaling_env.h"
00012 
00013 ScalingEnv::ScalingEnv (
00014   const Id&             n,
00015   In<pT_header>&        seqInfo,
00016   In<scaling_args_t>&   scaleArguments,
00017   Out<VYAimageWidth>&   YimageWidth,
00018   Out<VYAimageHeight>&  YimageHeight,
00019   Out<VYAimageWidth>&   UVimageWidth,
00020   Out<VYAimageHeight>&  UVimageHeight)
00021 :
00022   Process(n),
00023   seqInfoP(       id("seqInfoP"),       seqInfo),
00024   scaleArgumentsP(id("scaleArgumentsP"),scaleArguments),
00025   YimageWidthP(   id("YimageWidthP"),   YimageWidth),
00026   YimageHeightP(  id("YimageHeightP"),  YimageHeight),
00027   UVimageWidthP(  id("UVimageWidthP"),  UVimageWidth),
00028   UVimageHeightP( id("UVimageHeightP"), UVimageHeight)
00029 { }
00030 
00031 void ScalingEnv::main()
00032 {
00033   while(true)
00034   {
00035     pT_header       seqInfo;
00036     pT_color        colorInfo;
00037     scaling_args_t  arguments;
00038 
00039     int             nrImages;
00040     int             interlaceFactor;
00041     
00042     VYAimageWidth   YimageWidth;
00043     VYAimageHeight  YimageHeight;
00044 
00045     VYAimageWidth   UVimageWidth;
00046     VYAimageHeight  UVimageHeight;
00047 
00048     read(seqInfoP, seqInfo);
00049     interlaceFactor = (p_is_interlaced(&seqInfo) ? 2 : 1);
00050     colorInfo = p_get_color_format(&seqInfo);
00051 
00052     read(scaleArgumentsP, arguments);
00053    
00054     #ifdef VERBOSE
00055       printf("\n%s:\n   Resizing frames to size %d pixels x %d lines\n\n",
00056         fullName(), arguments.hsize, arguments.vsize);
00057     #endif
00058 
00059     nrImages     = interlaceFactor * p_get_num_frames(&seqInfo);
00060     YimageWidth  = arguments.hsize;
00061     YimageHeight = arguments.vsize / interlaceFactor;
00062        
00063     if ((colorInfo == P_COLOR_420) || (colorInfo == P_COLOR_420_PL))
00064     {
00065       UVimageWidth = YimageWidth / 2;
00066       UVimageHeight = YimageHeight / 2;
00067     } 
00068     else if ((colorInfo == P_COLOR_422) || (colorInfo == P_COLOR_422_PL))
00069     {
00070       UVimageWidth = YimageWidth / 2;
00071       UVimageHeight = YimageHeight;
00072     }
00073     else if ((colorInfo == P_COLOR_RGB) || (colorInfo == P_COLOR_444_PL))
00074     {
00075       UVimageWidth = YimageWidth;
00076       UVimageHeight = YimageHeight;
00077     }
00078 
00079     for (int i=0; i<nrImages; i++)
00080     {
00081       write(YimageWidthP, YimageWidth);
00082       write(YimageHeightP, YimageHeight);
00083       if (colorInfo != P_NO_COLOR)
00084       {
00085         write(UVimageWidthP, UVimageWidth);
00086         write(UVimageHeightP, UVimageHeight);
00087       }
00088     }
00089   }
00090 }

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