/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *  
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *  
 * This file is part of NMM. 
 * 
 * NMM is free software; you can redistribute it and/or modify it    
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; only version 2 of the License.      
 * 
 * NMM is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 
 * License for more details.  
 * 
 * You should have received a copy of the GNU General Public License 
 * along with NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */


#ifndef _NMM_RGBtoYV12CONVERTERNODE_HPP_
#define _NMM_RGBtoYV12CONVERTERNODE_HPP_

#include "nmm/nmm_prefix.hpp"

#include "nmm/multimedia/GenericProcessorNode.hpp"
#include "visibility_RGBtoYV12ConverterNode.hpp"
namespace NMM {
class DLLEXPORT RGBtoYV12ConverterNode :  public GenericProcessorNode
{

private:
    int width;
    int height;
    bool hasmmx;

    void rgb2yuv( unsigned char R, unsigned char G, unsigned char B, double *Y, double *U, double *V );
    void rgb32_to_YV12( unsigned char *rgb_image, unsigned char *yuv_image );
    void rgb24_to_YV12( unsigned char *rgb_image, unsigned char *yuv_image );
    void rgb565_to_YV12( unsigned char *rgb_image, unsigned char *yuv_image );

protected:
   virtual Message* processBuffer(Buffer* in_buffer);
    
  virtual Result doInit();
  virtual Result doInitOutput();
  virtual Result doActivate();

  virtual Result doSetFormat(const Format& format);

public:
  enum { RGB32, RGB24, RGB565 } __format;
  RGBtoYV12ConverterNode( const char * = "RGBtoYV12ConverterNode", StreamQueue::Mode = StreamQueue::MODE_SUSPEND, int = 20);
  ~RGBtoYV12ConverterNode() {};

};

}

#include "nmm/nmm_suffix.hpp"

#endif //_NMM_RGBtoYV12CONVERTERNODE_HPP_
