/*****************************************************************************/
/* 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.c
    @brief  phStbImage component

@b  Application:  phStbImage

*//*

Rev Date        Author      Comments
--------------------------------------------------------------------------------
  1 20060329    neill       Original
  2 20060405    neill       Update include file name
  3 20070320    neill       Changes after QAC checking
  4 20070927    neill       Add support for video device decoding
  5 20071023    neill       More QAC checking
  6 20080208    batelaan    Update file copyright/license text
--------------------------------------------------------------------------------
    For consistency and standardisation retain the Section Separators.
*/

/***********************************************
* INCLUDE FILES                                *
************************************************/

#include <stdio.h>
#include "phStbImageUtils.h"
#include "phStbImage.h"
#include "phStbBmp.h"
#include "phStbGif.h"
#include "phStbPng.h"
#include "phStbJpg.h"
#include "phStbVideoDevice.h"

/***********************************************
* LOCAL MACROS                                 *
************************************************/

/******************************************************************
* LOCAL TYPEDEFS                                                  *
*******************************************************************/

/******************************************************************
* STATIC FUNCTION PROTOTYPES                  <Module>_<Word>+    *
*******************************************************************/

/******************************************************************
* STATIC DATA                  g[k|p|kp|pk|kpk]<Module>_<Word>+   *
*******************************************************************/

/*********************************************************(((((((**********
* EXPORTED DATA      g[k|p|kp|pk|kpk]ph[<lnx|tm|NONE>]StbTemplate_<Word>+ *
***************************************************************************/

/*******************************************************************************
* FUNCTION IMPLEMENTATION  <Module>[_<Word>+] for static functions             *
*                          tm[<layer>]<Module>[_<Word>+] for exported functions*
********************************************************************************/

phStbImageErrorCode_t phStbImage_GetDimensions( const char* filename, int32_t* pWidth, int32_t* pHeight )
{
    phStbImageFileFormat fileType;

    fileType = phStbImage_getFileType(filename);

    switch(fileType)
    {
        case(phStbBmpFile):
            return phStbBmp_GetDimensions(filename, pWidth, pHeight);
        case(phStbGifFile):
            return phStbGif_GetDimensions(filename, pWidth, pHeight);
        case(phStbPngFile):
            return phStbPng_GetDimensions(filename, pWidth, pHeight);
        case(phStbJpegFile):
            return phStbJpg_GetDimensions(filename, pWidth, pHeight);
        case(phStbVideoDeviceFile):
            return phStbVideoDevice_GetDimensions(filename, pWidth, pHeight);
        default:
            return PH_STB_ERR_FILE_WRONG_FORMAT;
    }
}

phStbImageErrorCode_t phStbImage_Decode( const char* filename, phStbImage_SetupParams_t const * pSetup )
{
    phStbImageFileFormat fileType;

    fileType = phStbImage_getFileType(filename);

    switch(fileType)
    {
        case(phStbBmpFile):
            return phStbBmp_Decode(filename, pSetup);
        case(phStbGifFile):
            return phStbGif_Decode(filename, pSetup);
        case(phStbPngFile):
            return phStbPng_Decode(filename, pSetup);
        case(phStbJpegFile):
            return phStbJpg_Decode(filename, pSetup);
        case(phStbVideoDeviceFile):
            return phStbVideoDevice_Decode(filename, pSetup);
        default:
            return PH_STB_ERR_FILE_WRONG_FORMAT;
    }
}
