#if !defined(__PHSTBIMAGE_H)
#define __PHSTBIMAGE_H


/*****************************************************************************/
/* Copyright (c) 2008 NXP B.V.                                               */
/*                                                                           */
/* This program 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, using version 2 of the License.             */
/*                                                                           */
/* This program 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 this program; if not, write to the Free Software               */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307       */
/* USA.                                                                      */
/*                                                                           */
/*****************************************************************************/
/**
    @file   phStbImage.h
    @brief  phStbImage

@b  Application:  phStbImage component

*//*

Rev Date        Author      Comments
--------------------------------------------------------------------------------
  1 20060329    neill       Original
  2 20060406    neill       Make phStbImage_getFileType() accessible
  3 20061117    neill       Add callback events
  4 20061117    neill       Changes after crosscheck
  5 20070320    neill       Changes after QAC checking
  6 20070927    neill       Add support for video device decoding
  7 20071026    neill       Fix QAC errors
  8 20080208    batelaan    Update file copyright/license text
  9 20081219    neill       Add support for multiple graphics modes
 10 20090116    neill       Add support for YUV format output
--------------------------------------------------------------------------------
    For consistency and standardisation retain the Section Separators.
*/

/*******************
* INCLUDE FILES    *
********************/
#include <stdint.h>
#include <stdbool.h>

/*******************
* EXPORTED MACROS  *
********************/

/*********************
* EXPORTED TYPEDEFS  *
**********************/

#ifdef __cplusplus
extern "C"
{
#endif

typedef enum {
    phStbImage_frameEvent,
    phStbImage_eofEvent
}phStbImage_eventType;

typedef int (*phStbImage_callback)(phStbImage_eventType event);

typedef uint32_t (*phStbImage_cmapFunction)(uint32_t pixel);

typedef enum phStbImage_GfxMode
{
    phStbImage_GfxMode_Clut256,
    phStbImage_GfxMode_RGB565,
    phStbImage_GfxMode_ARGB1555,
    phStbImage_GfxMode_ARGB4444,
    phStbImage_GfxMode_ARGB8888,
    phStbImage_GfxMode_YUV
}phStbImage_GfxMode_t;

typedef struct _setupParams_t 
{
      bool                     bScalingEnabled;       /* True if scaling is enabled */
      bool                     bFastScalingEnabled;   /* True if fast/losy scaling is enabled */
      uint8_t                 *pInBuffer;             /* Input decode buffer */
      uint8_t                 *pInBuffer2;            /* Input decode buffer (UV buffer) */
      int32_t                  InBufferHeight;        /* Input decode buffer dimensions */
      int32_t                  InBufferWidth;
      int32_t                  OutImageOffsetX;       /* Output image position */
      int32_t                  OutImageOffsetY;
      int32_t                  OutImageHeight;        /* Output image dimensions */
      int32_t                  OutImageWidth;
      phStbImage_GfxMode_t     gfxMode;
      phStbImage_cmapFunction  colourMapFunction;
      phStbImage_callback      Callback;
} phStbImage_SetupParams_t;


typedef int phStbImageErrorCode_t;


typedef enum { 
    phStbBmpFile, 
    phStbGifFile, 
    phStbPngFile, 
    phStbJpegFile, 
    phStbVideoDeviceFile, 
    phStbUnknownFile } phStbImageFileFormat;

#define PH_STB_OK                     0
#define PH_STB_ERR_FILE_WRONG_FORMAT -1
#define PH_STB_ERR_FILE_NOT_OPEN     -2
#define PH_STB_ERR_FILE_TRUNCATED    -3
#define PH_STB_ERR_OUT_OF_MEMORY     -4
#define PH_STB_ERR_NULL_PARAMETER    -5
#define PH_STB_ERR_MEM_MAP           -6
#define PH_STB_ERR_NULL_MEM_PTR      -7
#define PH_STB_ERR_FILE_NOT_CLOSED   -8

#define DBG_PRINT(a)

/*******************
* EXPORTED DATA    *
********************/

/********************************
* EXPORTED FUNCTIONS PROTOTYPES *
*********************************/

/**
*   @brief Function used to return the file type of a given file
*
*   @param  filename      I     File to be checked
*
*   @retval Type of file
*/  
extern phStbImageFileFormat phStbImage_getFileType(const char* filename);

/**
*   @brief Gets dimensions of a bitmap supplied in BMP/GIF/PNG/JPEG format.
*
*   @param  filename      I     File to be checked
*   @param  pWidth        O     Width of Image
*   @param  pHeight       O     Height of Image
* 
*   @retval PH_STB_OK if successful - else error
*/  
extern phStbImageErrorCode_t phStbImage_GetDimensions( const char* filename, int32_t * pWidth, int32_t * pHeight );

/**
*   @brief Decodes a bitmap supplied in BMP/GIF/PNG/JPEG format..
*
*   @param  filename      I     File to be checked
*   @param  pSetup        I     Pointer to set up information - holding decode 
*                               information
* 
*   @retval PH_STB_OK if successful - else error
*/  
extern phStbImageErrorCode_t phStbImage_Decode( const char* filename, phStbImage_SetupParams_t const * pSetup);

/**
*   @brief Converts pixels from ARGB8888 to the requested mode.
*
*   @param  inPixel            I     Pixel to be converted
*   @param  mode               I     Graphics mode to convert to
*   @param  pColourMapFunction I     Pointer to CLUT conversion function
* 
*   @retval PH_STB_OK if successful - else error
*/
extern uint32_t phStbImage_convertPixel(uint32_t inPixel, phStbImage_GfxMode_t mode, phStbImage_cmapFunction pColourMapFunction);

#ifdef __cplusplus
}
#endif

#endif /* __PHSTBIMAGE_H      Do not add any thing below this line */


