⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wbmp_decoder_api.c

📁 wbmp图像文件解码器的arm版本源代码
💻 C
字号:
/*
*******************************************************************************
*
* FILE NAME:            
*   wbmp_decoder_api.c
*
* DESCRIPTION:
*   Contain all function definitions for WBMP decoder API.
*
* MODULE: 
*   WBMP (Wireless BitMaP) decoder.
* 
*  
*******************************************************************************
*/

/*
*******************************************************************************
* Include files
*******************************************************************************
*/

#include "wbmp_decoder_api.h"
#include "wbmpi_decoder.h"

/*
*******************************************************************************
* Global variables
*******************************************************************************
*/

/* -- Input buffer pointer -- */
static OP_UINT8             *wbmpInputBuffer;

/* -- Output buffer pointer -- */
static OP_UINT8             *wbmpOutputBuffer;

/* -- Input buffer size -- */
static OP_UINT32            wbmpInputBufferSize;

/* -- Image information -- */
static WBMP_IMAGE_INFO      wbmpImageInfo;

/* -- Decoder state -- */
static WBMP_DECODER_STATE   wbmpDecoderState = WBMP_DECODER_STATE_UNINITIALIZED;




/*
*******************************************************************************
* 
* FUNCTION NAME:
*   wbmpDecoderInitialize()
*
* FUNCTION DESCRIPTION:
*   This function initializes the WBMP decoder and sets the image  
*   decoding configurations to default values.
*
* INPUTS:
*   None
*
* OUTPUTS:
*   None
*   
* RETURN:
*   None
*
* GLOBALS ACCESSED/MODIFIED:
*   wbmpInputBuffer, wbmpOutputBuffer, wbmpInputBufferSize, wbmpDecoderState
*   WBMP_DECODER_STATE_INITIALIZED
*
* SPECIAL NOTES:
*
*
*******************************************************************************
*/
void wbmpDecoderInitialize
(
    void
)
{
    /* -- Clear input and output buffer pointers -- */
    wbmpInputBuffer     = OP_NULL;
    wbmpOutputBuffer    = OP_NULL;
    wbmpInputBufferSize = 0;

    /* -- Clear image info structure -- */
    wbmpImageInfo.u16ImageType   = 0;    
    wbmpImageInfo.u16imageHeight = 0;
    wbmpImageInfo.u16imageWidth  = 0;

    /* -- Update decoder state -- */
    wbmpDecoderState = WBMP_DECODER_STATE_INITIALIZED;
}


/*
*******************************************************************************
* 
* FUNCTION NAME:
*   wbmpSetInputBuffer()
*
* FUNCTION DESCRIPTION:
*   This function allows the Decoder Controller to pass the decoder
*   the input buffer pointer and the input buffer size. 
*   wbmpInputBuffer and wbmpInputBufferSize are initialized to the input
*   parameters of this function.
*
* INPUTS:
*   pu8InputBuffer     : input buffer pointer (from decoder controller)
*   u32InputBufferSize : input buffer size (from decoder controller)
*
* OUTPUTS:
*   None
*   
* RETURN:
*   None
*
* GLOBALS ACCESSED/MODIFIED:
*   wbmpInputBuffer, wbmpInputBufferSize, wbmpDecoderState
*   WBMP_DECODER_STATE_INITIALIZED, WBMP_DECODER_STATE_READY
*
* SPECIAL NOTES:
*
*******************************************************************************
*/
void wbmpSetInputBuffer
(
    OP_UINT8    *pu8InputBuffer, 
    OP_UINT32   u32InputBufferSize
)
{

    if(wbmpDecoderState == WBMP_DECODER_STATE_INITIALIZED)
    {
        /* -- Store input buffer info -- */
        wbmpInputBuffer     = pu8InputBuffer;
        wbmpInputBufferSize = u32InputBufferSize;

        /* -- Read header to retrieve input image size and WBMP type --*/
        WBMPI_ReadHeader(&wbmpInputBuffer, 
                         &wbmpImageInfo.u16ImageType,    
                         &wbmpImageInfo.u16imageWidth,
                         &wbmpImageInfo.u16imageHeight);
        
        /* -- Update decoder state -- */
        wbmpDecoderState = WBMP_DECODER_STATE_READY;
    }

}


/*
*******************************************************************************
* 
* FUNCTION NAME:
*   wbmpGetImageInfo() 
*
* FUNCTION DESCRIPTION:
*   This function returns image information to Image Decoder 
*   Controller.   
*
* INPUTS:
*   None.
*
* OUTPUTS:
*   psInfo : pointer to WBMP image info structure
*   
* RETURN:
*   WBMP_DECODER_ERR_NONE if successful, an error code otherwise.
*
* GLOBALS ACCESSED/MODIFIED:
*   wbmpImageInfo, wbmpDecoderState
*   WBMP_DECODER_ERR_INVALID_STATE, WBMP_DECODER_STATE_READY,
*   WBMP_DECODER_ERR_NONE
*
* SPECIAL NOTES:
*
*******************************************************************************
*/
WBMP_DECODER_ERR wbmpGetImageInfo
(
    WBMP_IMAGE_INFO     *psInfo
)
{

    if(wbmpDecoderState == WBMP_DECODER_STATE_READY)
    {
        /* -- Copy image info -- */
        psInfo->u16ImageType   = wbmpImageInfo.u16ImageType;
        psInfo->u16imageWidth  = wbmpImageInfo.u16imageWidth;
        psInfo->u16imageHeight = wbmpImageInfo.u16imageHeight;
        return(WBMP_DECODER_ERR_NONE);
    }
    else
    {
        return(WBMP_DECODER_ERR_INVALID_STATE);
    }

    wbmpDecoderState = WBMP_DECODER_STATE_INITIALIZED;

}



/*
*******************************************************************************
* 
* FUNCTION NAME:
*   wbmpDecodeImage() 
*
* FUNCTION DESCRIPTION:
*   This function decodes the WBMP image.   
*
* INPUTS:
*   pu8OutputBuffer : pointer to output buffer 
*   func            : pointer to callback function
*
* OUTPUTS:
*   pu8OutputBuffer : pointer to output buffer   
*   
* RETURN:
*   WBMP_DECODER_ERR_NONE if successful, an error code otherwise.
*
* GLOBALS ACCESSED/MODIFIED:
*   wbmpInputBuffer, wbmpInputBufferSize, wbmpDecoderState
*   WBMP_DECODER_STATE_READY, WBMP_DECODER_STATE_ACTIVE
*   WBMP_DECODER_ERR_NONE, WBMP_DECODER_ERR_INVALID_STATE
*
* SPECIAL NOTES:
*
*******************************************************************************
*/
WBMP_DECODER_ERR wbmpDecodeImage
(
    OP_UINT8        *pu8OutputBuffer,
    OP_BOOLEAN      func(OP_UINT16 x, OP_UINT16 y)
)
{

    /* -- Check if we are in the right state -- */
    if(wbmpDecoderState == WBMP_DECODER_STATE_READY)
    {

        /* -- Save output buffer pointer -- */
        wbmpOutputBuffer = pu8OutputBuffer;

        /* -- Update decoder state -- */
        wbmpDecoderState = WBMP_DECODER_STATE_ACTIVE;

        /* -- Decode WBMP image -- */
        WBMPI_DecodeBitmap(wbmpInputBuffer, 
                           wbmpImageInfo.u16imageWidth,
                           wbmpImageInfo.u16imageHeight,
                           func,
                           (IMAGE_DECODER_OUTPUT_TYPE *)pu8OutputBuffer);  
        
        return(WBMP_DECODER_ERR_NONE);
    }

    /* -- Decoder is not in a right state -- */
    else
    {
        return(WBMP_DECODER_ERR_INVALID_STATE);
    }

}    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -