/* 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_VIDEOSCALER_HPP_
#define _NMM_VIDEOSCALER_HPP_

#include "nmm/nmm_prefix.hpp"

#include "scaler.h"

#include "visibility_VideoScalerNode.hpp"
namespace NMM {
  
  class DLLEXPORT VideoScaler {
    
  public:
    enum {
      FORMAT_RGB,
      FORMAT_RGBA,
      FORMAT_YV12,
      FORMAT_YV12A
    };
    
    enum {
      MAX_PLANES = 6
    };
    
  private:
    
    // format info
    int format;
    int in_width;
    int in_height;
    int out_width;
    int out_height;
    bool filtering;
    
    // internal format info
    bool planar;
    int num_planes;
    ImagePlane in_planes[MAX_PLANES];
    ImagePlane out_planes[MAX_PLANES];
    
    void initPlanes();
    void initPlanes(int w, int h, ImagePlane* planes);
    
  public:
    VideoScaler();
    
    int getFormat() const { return format; }
    int getInputWidth() const { return in_width; }
    int getInputHeight() const { return in_height; }
    int getOutputWidth() const { return out_width; }
    int getOutputHeight() const { return out_height; }
    bool getFiltering() const { return filtering; }
    void setFormat(int format);
    void setInputSize(int width, int height);
    void setOutputSize(int width, int height);
    void setFiltering(bool filtering) { this->filtering = filtering; }
    
    void processData(char* out_data, const char* in_data);
    
  private:
    static void processPlane(char* out_data, int out_width, int out_height, int out_pitch,
			     const char* in_data, int in_pitch,
			     int in_delta_x, int in_delta_y);
    static void processPlaneFiltering(char* out_data, int out_width, int out_height, int out_pitch,
				      const char* in_data, int in_pitch,
				      int in_delta_x, int in_delta_y);
  };
}

#include "nmm/nmm_suffix.hpp"

#endif //_NMM_VIDEOSCALER_HPP_
