/* 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_RGBtoRGBCONVERTERNODE_HPP_
#define _NMM_RGBtoRGBCONVERTERNODE_HPP_

#include "nmm/multimedia/GenericConverterNode.hpp"


#define CLIPPED(x) ((x)>255?255:((x)<0?0:(x)))

namespace NMM {
  /** \class RGBtoRGBConverterNode
   * \ingroup VideoConverter
   * 
   */
  class RGBtoRGBConverterNode : public GenericConverterNode {
    
  public:
    
    RGBtoRGBConverterNode(const char* name = "RGBtoRGBConverterNode");
    virtual ~RGBtoRGBConverterNode() {};
    

  protected:

    /* naming convention for converters:
     * colorspace: RGB, BGR, RGBA, BGRA...
     * bits per pixel: 16, 24, 32...
     * number of bits for each channel
     * endian order: LIT for little and BIG for big
     */
    static  Buffer* BGR16_5_6_5_LIT_to_RGB16_5_6_5_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* RGB16_5_6_5_LIT_to_RGB24_8_8_8_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* BGR16_5_6_5_LIT_to_RGB32_8_8_8_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* RGB16_5_6_5_LIT_to_RGB32_8_8_8_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* RGB24_8_8_8_LIT_to_RGB16_5_6_5_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* RGB24_8_8_8_LIT_to_RGBA32_8_8_8_8_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* RGB24_8_8_8_LIT_to_BGRA32_8_8_8_8_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* BGR24_8_8_8_LIT_to_RGB32_8_8_8_8_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* RGB32_8_8_8_LIT_to_RGB16_5_6_5_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* BGR32_8_8_8_LIT_to_RGB16_5_6_5_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* BGR32_8_8_8_LIT_to_RGB32_8_8_8_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* RGB32_11_11_10_LIT_to_RGB16_5_6_5_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* RGB32_11_11_10_LIT_to_RGB32_8_8_8_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* BGR32_10_11_11_LIT_to_RGB32_8_8_8_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* BGRA32_8_8_8_8_LIT_to_RGB16_5_6_5_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* RGBA32_8_8_8_8_LIT_to_RGB24_8_8_8_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* RGBA32_8_8_8_8_LIT_to_BGR24_8_8_8_LIT(Buffer* in_buffer, const GenericConverterNode* node);
    static  Buffer* dummy(Buffer* in_buffer, const GenericConverterNode* node);

    virtual Result doInitOutput();
    virtual Result doDeinitOutput();

  private:
    void allocate();

  };

}

#endif
