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

📄 haljpeg.c

📁 车载电子影音系统dvd播放系统原程序代码
💻 C
📖 第 1 页 / 共 5 页
字号:
#include "winav.h"
#include "w99av.h"
#include "cc.h"
#include "hal.h"
#include "utl.h"
#include "thumb.h"
#include "OSD.h"
#include "setup.h"
#include "cdinfo.h"

//#include "HalJPEG.h"
#define JPEG_DEFAULT_BLUR   HAL_JPEG_DECODE_BLUR_2

//float   _fScalingRate;
WORD    _wScalingRate;  //Real scaling rate * 1000
WORD    __wDisplayWidth;
WORD    __wDisplayHeight;
/*--CoCo1.21, for 4M flash
WORD    __wTVDisplayWidth;
WORD    __wTVDisplayHeight;
*/
WORD    __wHStart;                  //global variable for slide show and thumbnail
WORD    __wVStart;                  //global variable for slide show and thumbnail
WORD    __wWidth;                   //global variable for slide show and thumbnail
WORD    __wHeight;                  //global variable for slide show and thumbnail
BYTE    _bJPEGfit;
WORD    _wJPEGRealWidth;            //backup usage for two frame buffers
WORD    _wJPEGRealHeight;           //backup usage for two frame buffers
WORD    _wJPEGWidth;                //backup usage for two frame buffers
WORD    _wJPEGHeight;               //backup usage for two frame buffers
WORD    __wHExtractStart, __wVExtractStart;               //backup usage for two frame buffers

BYTE    __bJPEGEffect;              //The effect of slide transition
BYTE    __bJPEGOperation;           //For the combination of "roate" and "flip"
//float   _fZoomRate;                 //Current rate of zoom.
BYTE    _bZoomRate;                 //Real zoom rate * 100     
BYTE    _bScalingAll;               //Extract "all" image from FOrg or not.
WORD    __wCheckDecodeHang;
BYTE    __bDoJPEGEffect;
#ifdef _DEBUG_INFO
BYTE    __bJPEGFilter = HAL_JPEG_DECODE_BLUR_2;
#endif

WORD    _wHALJPEGTemp, _wHALJPEGTemp1;
BYTE    _bHALJPEGTemp, _bHALJPEGTemp1, _bHALJPEGTemp2;
WORD    __wHClipWidth, __wVClipHeight;  // keep picture hor. & ver. size while clip command
WORD    __wHClipStart, __wVClipStart;
WORD    __wHALJPEGDisplayBufWidth, __wHALJPEGDisplayBufHeight;
WORD    __wHALJPEGFirstScalingWidth, __wHALJPEGFirstScalingHeight;

//use external variables.
extern DWORD   _dwHALTemp;

//***************************************************************************
//  Function    :   _JPEGDisplay
//  Abstract    :   This function will display JPEG in __btActiveFrame.
//  Return		:   none.
//  Side Effect :
//  Notes       :   Please assign __bJPEGEffect before calling this function. (for CT908 only)
//***************************************************************************
void _JPEGDisplay(BYTE bDispAction)
{
#ifndef NO_PICTURECD    
    __dwW99AVCmdArg[0]=4;
    __dwW99AVCmdArg[1]=CMDARG_JPEG_DISPLAY;   // unused command arg  
    if ((bDispAction == HAL_JPEG_NODECODE) || __bThumbnailMode || !__bDoJPEGEffect)
        __dwW99AVCmdArg[2]=MAKELONG(HAL_JPEG_EFFECT_NO_EFFECT, __btActiveFrame); //No effect. for Zoom, rotate, flip and thumbnail
    else
        __dwW99AVCmdArg[2]=MAKELONG(__bJPEGEffect, __btActiveFrame); 

    __dwW99AVCmdArg[3]=0; //Use default value for effect.
    __dwW99AVCmdArg[4] = 1; //Execute the clip command. Should write the "clip" region to DRAM first.
    W99AV_CommandN(COMMAND_JPEG);
#endif  // #ifndef NO_PICTURECD
}

/*--CoCo1.21, for 4M flash
//***********************************************************************
//  Function    :   _JPEGSetTVDisplay
//  Description :   This function will set the width and height for display   
//  Return      :   none.
//  Side Effect :   
//  global      :   Set __wTVDisplayWidth and __wTVDisplayHeight.
//  *********************************************************************
void _JPEGSetTVDisplay (void)
{
#ifndef NO_PICTURECD
    __wTVDisplayWidth = HAL_DISPLAY_JPEG_WIDTH;
    __wTVDisplayHeight = __wHALJPEGDisplayBufHeight;
#endif
}
*/

//***********************************************************************
//  Function    :   _JPEGRealSize
//  Description :   This function get the JPEG's size after down sample by
//              :   DSP.  
//  Arguments   :   none
//  Return      :   none
//  Side Effect :
//  global      :   The result is put in __wPicHsize and __wPicVsize.   
//              :   use _dwHALTemp.
//  *********************************************************************
void _JPEGRealSize (void)
{
#ifndef NO_PICTURECD
    W99AV_ReadDRAMData(W99AV_DRAM_JPEG_SIZE, &_dwHALTemp); 
    _wJPEGRealWidth = HIWORD(_dwHALTemp); //The real width in FOrg.
    _wJPEGRealHeight = LOWORD(_dwHALTemp); //The real height in FOrg.
#endif //NO_PICTURECD
}

//CoCo.jpeg
//***********************************************************************
//  Function    :   _JPEGZoom
//  Description :   This function will zoom the JPEG to full screen.
//  Arguments   :   bAction,
//              :   VIEW_NORAML==>fit to TV display.
//              :   VIEW_ZOOM25==>zoom out to 25% of the original image.
//              :   VIEW_ZOOM50==>zoom out to 50% of the original image.
//              :   VIEW_ZOOM100==>The original image size.
//              :   VIEW_ZOOM150==>zoom in to 150% of the original image.
//              :   VIEW_ZOOM200==>zoom in to 200% of the original image.
//              :   VIEW_ZOOM_LEFT==>pan left.
//              :   VIEW_ZOOM_RIGHT==>pan right.
//              :   VIEW_ZOOM_UP==>pan up.
//              :   VIEW_ZOOM_DOWN==>pan down.
//  Return      :   HAL_ZOOM_FAIL, HAL_ZOOM_OK, HAL_ZOOM_REDO
//  Note        :   
//  global      :   
//  *********************************************************************
BYTE _JPEGZoom (BYTE bAction, BYTE bDecodeMode)
{
#ifndef NO_PICTURECD
    if ((bAction == VIEW_ZOOM_LEFT) ||
        (bAction == VIEW_ZOOM_RIGHT) ||
        (bAction == VIEW_ZOOM_UP) ||
        (bAction == VIEW_ZOOM_DOWN))
    {
        if (__bZoomFactor <= VIEW_ZOOM100) //Doesn't need to pan
            return HAL_ZOOM_FAIL;
        
        if (!_bScalingAll) //Extract part of the image from the FOrg.
        {
            bAction = _TransformPanAction(bAction);
            
            //Calculate the pan pixels
            _wHALJPEGTemp1 = (WORD)((DWORD)HAL_JPEG_PAN_PIXELS * (DWORD)_wJPEGWidth / (DWORD)__wDisplayWidth); 
            _ForceTo8Multiple(&_wHALJPEGTemp1);
            
            switch (bAction)
            {
            case VIEW_ZOOM_LEFT:
                if (__wHExtractStart == 0)
                    return HAL_ZOOM_FAIL;
                else if (__wHExtractStart <= _wHALJPEGTemp1)
                    __wHExtractStart = 0;
                else
                    __wHExtractStart -= _wHALJPEGTemp1;
                break;
            case VIEW_ZOOM_RIGHT:
                if (__wHExtractStart == (_wJPEGRealWidth - _wJPEGWidth))
                    return HAL_ZOOM_FAIL;
                else if ((__wHExtractStart + _wJPEGWidth + _wHALJPEGTemp1) >= _wJPEGRealWidth)
                    __wHExtractStart = _wJPEGRealWidth - _wJPEGWidth;
                else
                    __wHExtractStart += _wHALJPEGTemp1;
                break;
            case VIEW_ZOOM_UP:
                if (__wVExtractStart == 0)
                    return HAL_ZOOM_FAIL;
                else if (__wVExtractStart <= _wHALJPEGTemp1)
                    __wVExtractStart = 0;
                else
                    __wVExtractStart -= _wHALJPEGTemp1;
                break;
            case VIEW_ZOOM_DOWN:
                if (__wVExtractStart == (_wJPEGRealHeight - _wJPEGHeight))
                    return HAL_ZOOM_FAIL;
                else if ((__wVExtractStart + _wJPEGHeight + _wHALJPEGTemp1) >= _wJPEGRealHeight)
                    __wVExtractStart = _wJPEGRealHeight - _wJPEGHeight;
                else
                    __wVExtractStart += _wHALJPEGTemp1;
                break;
            default:
                break;
            }
            
            _DoZoomPanDecode();				
        }
        else //Extract all image from FOrg. (zoom mode > _fScalingRate)
        {
            //if (_fScalingRate < 1)
            if (_wScalingRate < 1000)
            {
                //Calculate the pan pixels
                //_wHALJPEGTemp1 = (WORD)(((float)((DWORD)HAL_JPEG_PAN_PIXELS * (DWORD)__wDisplayWidth / (DWORD)__wHALJPEGDisplayBufWidth))/ _fZoomRate);
                _wHALJPEGTemp1 = (WORD)((DWORD)HAL_JPEG_PAN_PIXELS*(DWORD)__wDisplayWidth/(DWORD)__wHALJPEGDisplayBufWidth*100L/(DWORD)_bZoomRate);
                //The "pan pixel" have to be 8's multipe?   
                
                //Don't pan the black region
                //To get the rotating status. Rotating 90 degree==>TRUE. Else==>FALSE.
                _bHALJPEGTemp = _GetJPEGRotateStatus();
                switch (bAction)
                {
                case VIEW_ZOOM_LEFT:
                case VIEW_ZOOM_RIGHT:
                    if (_bHALJPEGTemp)
                    {
                        if (__wHClipWidth >= __wDisplayHeight)
                            return HAL_ZOOM_FAIL;
                    }
                    else
                    {
                        if (__wHClipWidth >= __wDisplayWidth)
                            return HAL_ZOOM_FAIL;
                    }
                case VIEW_ZOOM_UP:
                case VIEW_ZOOM_DOWN:
                    if (_bHALJPEGTemp)
                    {
                        if (__wVClipHeight >= __wDisplayWidth)
                            return HAL_ZOOM_FAIL;
                    }
                    else
                    {
                        if (__wVClipHeight >= __wDisplayHeight)
                            return HAL_ZOOM_FAIL;
                    }
                default:
                    break;
                }
            }
            else                    
                _wHALJPEGTemp1 = HAL_JPEG_PAN_PIXELS * __wHClipWidth / __wHALJPEGDisplayBufWidth;
            
            _wHALJPEGTemp = _JPEGGetPanBoundary(bAction);
            switch (bAction)
            {
            case VIEW_ZOOM_LEFT:
                if (__wHClipStart == _wHALJPEGTemp)
                    return HAL_ZOOM_FAIL;
                else if (__wHClipStart < (_wHALJPEGTemp1 + _wHALJPEGTemp))
                    __wHClipStart = _wHALJPEGTemp;
                else
                    __wHClipStart -= _wHALJPEGTemp1;                        
                break;
            case VIEW_ZOOM_RIGHT:
                if (__wHClipStart == _wHALJPEGTemp)
                    return HAL_ZOOM_FAIL;
                else if ((__wHClipStart + _wHALJPEGTemp1) > _wHALJPEGTemp)
                    __wHClipStart = _wHALJPEGTemp;
                else
                    __wHClipStart += _wHALJPEGTemp1;
                break;
            case VIEW_ZOOM_UP:
                if (__wVClipStart == _wHALJPEGTemp)
                    return HAL_ZOOM_FAIL;
                else if (__wVClipStart < (_wHALJPEGTemp1 + _wHALJPEGTemp))
                    __wVClipStart = _wHALJPEGTemp;
                else
                    __wVClipStart -= _wHALJPEGTemp1;
                break;
            case VIEW_ZOOM_DOWN:
                if (__wVClipStart == _wHALJPEGTemp)
                    return HAL_ZOOM_FAIL;
                else if ((__wVClipStart + _wHALJPEGTemp1) > _wHALJPEGTemp)
                    __wVClipStart = _wHALJPEGTemp;
                else
                    __wVClipStart += _wHALJPEGTemp1;
                break;
            default:
                break;
            } 
            
            W99AV_WriteDRAMData(W99AV_DRAM_JPEG_HCS, (((DWORD)__wHClipStart) << 16));
            W99AV_WriteDRAMData(W99AV_DRAM_JPEG_VCS, (((DWORD)__wVClipStart) << 16));
            W99AV_WriteDRAMData(W99AV_DRAM_JPEG_HCW, (((DWORD)__wHClipWidth) << 16));
            W99AV_WriteDRAMData(W99AV_DRAM_JPEG_VCW, (((DWORD)__wVClipHeight) << 16));

#ifdef SUPPORT_JPEG_3_FRAMES
            _JPEGDisplay(HAL_JPEG_NODECODE);
#else
            _DoZoomPanDecode();				
#endif
        }           
    }
    else
    {
        _bHALJPEGTemp = _JPEGCalculateScaling(bAction);
        _DoZoomPanDecode();				
    }
    
#endif //NO_PICTURECD
    return HAL_ZOOM_OK;


}


//***********************************************************************
//  Function    :   HAL_JPEGDecode
//  Description :   Call this funciton to decode JPEG. This function
//              :   should be called after HAL_JPEGSetStatus.
//  Arguments   :   bFullScreen, 
//              :   bDecode, 
//              :   HAL_JPEG_DECODE ==> normal decoding.
//              :   HAL_JPEG_STOP_DECODE ==> stop decoding the image.
//  Return      :   none.
//  Note        :   1. should wait IFSC after calling this function
//              :   2. Should set __wHStart, __wVStart, __wWidth and __wHeight for
//              :      displaying region before calling this function. 
//  global      :   __wHStart, __wVStart, __wWidth, __wHeight and __bThumbnailMode 
//              :   are referred.
//  *********************************************************************
void HAL_JPEGDecode (BYTE bDecode)
{
#ifndef NO_PICTURECD
    if (bDecode == HAL_JPEG_DECODE)
    {
		/*--CoCo1.21, for 4M flash
        //Set the display size according to TV type
        _JPEGSetTVDisplay();
		*/
        
        //CT9928AF Get the real size after down sample from DSP
        //CT908 can get the real size of JPEG after parsing header.
        _JPEGRealSize();        
  
#ifndef  SUPPORT_JPEG_LARGE_BUFFER        

⌨️ 快捷键说明

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