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

videomux_env.cc

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <assert.h>
00003 #include "videomux_env.h"
00004 
00005 VideoMuxEnv::VideoMuxEnv
00006 (
00007         const Id&                                     n,
00008         In<videomux_args_t>&    muxArguments,   
00009         In<pT_header>&                    seqInfoF,
00010         Out<imagePosition>&     YimgPosF0,
00011         Out<imagePosition>&     UVimgPosF0,
00012         Out<imagePosition>&     YimgPosF1,
00013         Out<imagePosition>&     UVimgPosF1      
00014 )
00015 :       // member initialisation
00016         // process network
00017         Process(n),
00018         // ports
00019   muxArgumentsP(id("muxArgumentsP"),muxArguments),
00020   seqInfoP(id("seqInfoP"),seqInfoF),
00021         YimgPosP0(id("YimgPosP0"),YimgPosF0),   
00022         UVimgPosP0(id("UVimgPosP0"),UVimgPosF0),        
00023         YimgPosP1(id("YimgPosP1"),YimgPosF1),   
00024         UVimgPosP1(id("UVimgPosP1"),UVimgPosF1)
00025 {
00026 }
00027 
00028 void VideoMuxEnv::main()
00029 {
00030         while(true)
00031         {
00032                 const int N = 2;
00033 
00034     pT_header               seqInfo;
00035     pT_color                colorInfo;
00036                 int                           nrImages;
00037                 int                           interlaceFactor;
00038                 videomux_args_t arguments;
00039 
00040                 imagePosition     YimgPos[N];
00041                 imagePosition     UVimgPos[N];
00042                 
00043                 read(muxArgumentsP, arguments);
00044     assert(arguments.NSTRM == N);
00045 
00046                 #ifdef VERBOSE
00047                         printf("%s:\n",fullName());
00048                 #endif
00049         
00050                 for(int i=0; i<N; i++)
00051                 {
00052                         YimgPos[i].x = arguments.hpos[i];
00053                         YimgPos[i].y = arguments.vpos[i];
00054                         YimgPos[i].z = arguments.depth[i];
00055                         YimgPos[i].enabled = true; /*arguments.depth[i];*/
00056                 
00057                         #ifdef VERBOSE
00058                                 printf("    Stream %d position=(%d,%d), depth=%d\n",
00059                                                 i, YimgPos[i].x, YimgPos[i].y, YimgPos[i].z);
00060                         #endif
00061                 }
00062                 #ifdef VERBOSE
00063                         printf("\n");
00064                 #endif
00065         
00066                 read(seqInfoP, seqInfo);
00067                 if (p_is_interlaced(&seqInfo))
00068                         interlaceFactor = 2;
00069                 else
00070                         interlaceFactor = 1;
00071                 colorInfo = p_get_color_format(&seqInfo);
00072                 
00073                 nrImages = interlaceFactor * p_get_num_frames(&seqInfo);
00074                 for (int i=0; i<N; i++)
00075                 {
00076                         YimgPos[i].y = YimgPos[i].y / interlaceFactor;
00077         
00078                         if ((colorInfo == P_COLOR_420) || (colorInfo == P_COLOR_420_PL))
00079                         {
00080                                 UVimgPos[i].x = YimgPos[i].x / 2;
00081                                 UVimgPos[i].y = YimgPos[i].y / 2;
00082                                 UVimgPos[i].z = YimgPos[i].z;
00083                                 UVimgPos[i].enabled = YimgPos[i].enabled;
00084                         }
00085                         else if ((colorInfo == P_COLOR_422) || (colorInfo == P_COLOR_422_PL))
00086                         {
00087                                 UVimgPos[i].x = YimgPos[i].x / 2;
00088                                 UVimgPos[i].y = YimgPos[i].y;
00089                                 UVimgPos[i].z = YimgPos[i].z;
00090                                 UVimgPos[i].enabled = YimgPos[i].enabled;
00091                         } 
00092                         else
00093                         {
00094                                 UVimgPos[i].x = YimgPos[i].x;
00095                                 UVimgPos[i].y = YimgPos[i].y;
00096                                 UVimgPos[i].z = YimgPos[i].z;
00097                                 UVimgPos[i].enabled = YimgPos[i].enabled;
00098                         }
00099                 }
00100         
00101     for (int i=0; i<nrImages; i++)
00102                 {
00103       write(YimgPosP0, YimgPos[0]);
00104       write(UVimgPosP0, UVimgPos[0]);
00105       write(YimgPosP1, YimgPos[1]);
00106       write(UVimgPosP1, UVimgPos[1]);
00107                 }
00108         }
00109 }

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