/* LICENSE:
  =========================================================================
    CMPack'04 Source Code Release for OPEN-R SDK 1.1.5-r2 for ERS7
    Copyright (C) 2004 Multirobot Lab [Project Head: Manuela Veloso]
    School of Computer Science, Carnegie Mellon University
    All rights reserved.
  ========================================================================= */

#ifndef INCLUDED_VisionRawPacketDecoder_h
#define INCLUDED_VisionRawPacketDecoder_h

class RobotDataPacket;

#include "../../../agent/Vision/cmv_types.h"
#include "../../../agent/Vision/VisionInterface.h"

#include "PacketDecoder.h"

using namespace VisionInterface;

/*------------------------------------------------------------------
CLASS
  VisionRawPacketDecoder

DESCRIPTION
  Decodes vision raw data into an image.
------------------------------------------------------------------*/
class VisionRawPacketDecoder : public PacketDecoder {
public:
  VisionRawPacketDecoder()
  {}
  
  bool decode(double *angles,RobotDataPacket *packet);
  bool decode(int &width, int &height,
	      RobotDataPacket *packet);
  bool decode(int image_x_size,int image_y_size,
	      CMVision::image_yuv<uchar> *img,RobotDataPacket *packet);
  // Warning: This assumes the buffers are big enough.
  bool decode(int &image_x_size, int &image_y_size, 
	      CMVision::image_yuv<uchar> *img, int max_image_x_size,
	      int max_image_y_size, RobotDataPacket *packet);

  // Fills in buf with the data portion of a PPM file (i.e. a long series
  // of YUV triplets). image_x_size and image_y_size are set to the
  // values extracted from the packet. out_buf is assumed to be at
  // least max_image_x_size*max_image_y_size*3 bytes long (or you're
  // gonna have issues).
  bool decode(int &image_x_size, int &image_y_size, uchar *out_buf,
	      int max_image_x_size, int max_image_y_size,
	      RobotDataPacket *packet);
private:
};

#endif
