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

📄 haljpeg.c

📁 车载电子影音系统dvd播放系统原程序代码
💻 C
📖 第 1 页 / 共 5 页
字号:
        //CoCo.newJPEG, do first scaling for 3 buffers to 1 buffer(the final original buffer).
        _JPEGFirstScaling();
#endif

        _JPEGCalculateScaling(VIEW_ZOOM100);
        _JPEGDecodeCmd(HAL_JPEG_DECODE, VIEW_ZOOM100); //Don't fit to full screen. "Clip" command will not be executed.      
    }
    else if (bDecode == HAL_JPEG_STOP_DECODE)
    {
#ifdef SUPPORT_JPEG_C3
		//CoCo1.22, DVD_JPEG just do "reset parser".
		if (!__bDVDROM)
			HAL_Reset(HAL_RESET_AUDIO);
		else
			W99AV_Reset(W99AV_RESET_PARSER);        
#else
        W99AV_Reset(W99AV_RESET_PARSER);
#endif
        // Brian0.87, disable one field
        W99AV_WriteDRAMData(W99AV_DRAM_ONE_FIELD, 0);

        //call "stop decode" macro command to stop decoding.
        //W99AV_Command1(COMMAND_JPEG, CMDARG_JPEG_STOP_DECODE);
        __dwW99AVCmdArg[0]=1;
        __dwW99AVCmdArg[1]=CMDARG_JPEG_STOP_DECODE;
        W99AV_CommandN(COMMAND_JPEG);

        //Do video decode reset
        __dwTemp=W99AV_ReadInternalRegDW(0x42);
        W99AV_WriteInternalRegDW(0x42, LOWORD(__dwTemp|0x20000), HIWORD(__dwTemp|0x20000));
        UTL_DelayTime(COUNT_50_MSEC, FALSE);
        W99AV_WriteInternalRegDW(0x42, LOWORD(__dwTemp), HIWORD(__dwTemp));                           
    }
#endif //NO_PICTURECD
}

//***********************************************************************
//  Function    :   HAL_JPEGParseHeader
//  Description :   Call this funciton to parse JPEG's header.
//  Arguments   :   none.
//  Return      :   none.
//  Note        :   Should set sectors to servo before calling this function.
//  global      :   use _dwHALTemp and _dwHALTemp1.
//  *********************************************************************
void HAL_JPEGParseHeader (void)
{
#ifndef NO_PICTURECD
    //call parse header macro command.
    __dwW99AVCmdArg[0]=2;
    __dwW99AVCmdArg[1]=CMDARG_JPEG_PARSE_HEADER;  
    __dwW99AVCmdArg[2] = __bThumbnailMode; //0:Normal JPEG. 1:thumbnail
    W99AV_CommandN(COMMAND_JPEG);        
#endif //NO_PICTURECD
}

//***********************************************************************
//  Function    :   HAL_JPEGInitial
//  Description :   Call this funciton when decoding the JPEG at first time.
//  Arguments   :   none.
//  Return      :   none.
//  Note        :   This function should be called after downloading ucode.
//  global      :   use _bHALJPEGTemp.
//  *********************************************************************
void HAL_JPEGInitial (void)
{
#ifndef NO_PICTURECD

    __bAudioType = HAL_AUDIO_NONE; //Brain.276p

    //Set A/V buffer
    HAL_SetBuffer(HAL_SETBUFFER_AV, HAL_BUFFERMODE_JPEG);

    //Do jpeg reset
    HAL_JPEGDecode(HAL_JPEG_STOP_DECODE);

    //Set the display buffer width/height
    if (__bDVDROM)
    {
        __wHALJPEGDisplayBufWidth = HAL_DISPLAY_DVD_JPEG_WIDTH;
        __wHALJPEGDisplayBufHeight = HAL_DISPLAY_DVD_JPEG_HEIGHT;
    }
    else
    {
        __wHALJPEGDisplayBufWidth = HAL_DISPLAY_CD_JPEG_WIDTH;
        __wHALJPEGDisplayBufHeight = HAL_DISPLAY_CD_JPEG_HEIGHT;
    }

#endif //NO_PICTURECD
}

//***********************************************************************
//  Function    :   _JPEGRecoverToNormal
//  Description :   Call this function to clip full size.
//  Arguments   :   none.
//  Return      :   none.
//  Note        :   
//  global      :   
//  *********************************************************************
void _JPEGRecoverToNormal (void)
{
#ifndef NO_PICTURECD
    __wHClipStart = 0;
    __wVClipStart = 0;
    __wHClipWidth = __wHALJPEGDisplayBufWidth;
    __wVClipHeight = __wHALJPEGDisplayBufHeight;
#endif
}

//***********************************************************************
//  Function    :   HAL_GetZoomFactor
//  Description :   Call this function to get next zoom factor
//  Arguments   :   none.
//  Return      :   return the zoom factor. 
//  Note        :   
//  global      :   use __bZoomFactor as current zoom factor.
//              :   use __wJPEGScaling to judge the scaling rate of slide show.
//  *********************************************************************
BYTE HAL_GetZoomFactor (void)
{
#ifndef NO_PICTURECD
    if ((__bZoomFactor+1) > VIEW_ZOOM200)
        return VIEW_ZOOM25;
    else
        return (__bZoomFactor+1);
#endif //NO_PICTURECD

    return VIEW_NORMAL;
}

//***********************************************************************
//  Function    :   _JPEGGetPanBoundary
//  Description :   call this function to get left, right, up and down boundary.
//  Arguments   :   bAction, 
//              :   VIEW_ZOOM_RIGHT ==> get right boundary
//              :   VIEW_ZOOM_LEFT ==> get left boundary
//              :   VIEW_ZOOM_UP ==> get up boundary
//              :   VIEW_ZOOM_DOWN ==> get down boundary
//  Return      :   x or y position.
//  Note        :   
//  global      :   use _wHALJPEGTemp as the return value.
//              :   use _bJPEGfit to judge we have to fit width or height.
//              :   use __wHStart and __wVStart to know the starting position of display region.
//              :   use __wPicHsize and __wPicVsize to know the real size.
//              :   use __iDigestHor and __iDigestVer to know the display size.
//  *********************************************************************
WORD _JPEGGetPanBoundary (BYTE bAction)
{
#ifndef NO_PICTURECD

    //To get the rotating status. Rotating 90 degree==>TRUE. Else==>FALSE.
    _bHALJPEGTemp = _GetJPEGRotateStatus();

    switch (bAction)
    {
    case VIEW_ZOOM_LEFT:
        if (!_bScalingAll || (_bScalingAll &&!_bHALJPEGTemp)) //Extract part of the image from the FOrg || not rotate
        {
            if (_bScalingAll && (__wHClipWidth >= __wDisplayWidth))
            {
                _wHALJPEGTemp = __wHClipStart;
            }
            else
            {
                _wHALJPEGTemp = __wHALJPEGDisplayBufWidth - __wDisplayWidth;
                _wHALJPEGTemp >>= 1;
            }
        }
        else
		{
			if (__wHClipWidth >= __wDisplayHeight)
				_wHALJPEGTemp = __wHClipStart;
			else
			{
				_wHALJPEGTemp = __wHALJPEGDisplayBufWidth - __wDisplayHeight;
				_wHALJPEGTemp >>= 1;
			}
		}
        break;
    case VIEW_ZOOM_RIGHT:
        if (!_bScalingAll || (_bScalingAll &&!_bHALJPEGTemp)) //Extract part of the image from the FOrg.
        {
            if (_bScalingAll && (__wHClipWidth >= __wDisplayWidth))
            {
                _wHALJPEGTemp = __wHClipStart;
            }
            else
            {
                _wHALJPEGTemp = __wHALJPEGDisplayBufWidth - __wDisplayWidth;
                _wHALJPEGTemp >>= 1;
                _wHALJPEGTemp = _wHALJPEGTemp + __wDisplayWidth - __wHClipWidth;
            }
        }
        else
        {
            if (__wHClipWidth >= __wDisplayHeight)
                _wHALJPEGTemp = __wHClipStart;
            else
            {
                _wHALJPEGTemp = __wHALJPEGDisplayBufWidth - __wDisplayHeight;
                _wHALJPEGTemp >>= 1;
                _wHALJPEGTemp = _wHALJPEGTemp + __wDisplayHeight - __wHClipWidth;
            }
        }
        break;
    case VIEW_ZOOM_UP:
        if (!_bScalingAll || (_bScalingAll &&!_bHALJPEGTemp)) //Extract part of the image from the FOrg.
        {
            if (_bScalingAll && (__wVClipHeight >= __wDisplayHeight))
            {
                _wHALJPEGTemp = __wVClipStart;
            }
            else
            {
                _wHALJPEGTemp = __wHALJPEGDisplayBufHeight - __wDisplayHeight;
                _wHALJPEGTemp >>= 1;
            }
        }
        else 
		{
			if (__wVClipHeight >= __wDisplayWidth)
				_wHALJPEGTemp = __wVClipStart;
			else
			{
				_wHALJPEGTemp = __wHALJPEGDisplayBufHeight - __wDisplayWidth;
				_wHALJPEGTemp >>= 1;
			}
		}            
        break;
    case VIEW_ZOOM_DOWN:
        if (!_bScalingAll || (_bScalingAll &&!_bHALJPEGTemp)) //Extract part of the image from the FOrg.
        {
            if (_bScalingAll && (__wVClipHeight >= __wDisplayHeight))
            {
                _wHALJPEGTemp = __wVClipStart;
            }
            else
            {
                _wHALJPEGTemp = __wHALJPEGDisplayBufHeight - __wDisplayHeight;
                _wHALJPEGTemp >>= 1;
                _wHALJPEGTemp = _wHALJPEGTemp + __wDisplayHeight - __wVClipHeight;
            }
        }
        else
		{
			if (__wVClipHeight >= __wDisplayWidth)
				_wHALJPEGTemp = __wVClipStart;
			else
			{
				_wHALJPEGTemp = __wHALJPEGDisplayBufHeight - __wDisplayWidth;
				_wHALJPEGTemp >>= 1;
				_wHALJPEGTemp = _wHALJPEGTemp + __wDisplayWidth - __wVClipHeight;
			}
		}
        break;
    }
#endif //NO_PICTURECD

    return _wHALJPEGTemp;
}

//***********************************************************************
//  Function    :   _JPEGGetFitWidthOrHeight
//  Description :   Calculate the picture should fit width or height.
//  Arguments   :   none.
//  Return      :   none.
//  Note        :   
//  global      :   Save the result to _bJPEGfit.
//  *********************************************************************
void _JPEGGetFitWidthOrHeight (void)
{
#ifndef NO_PICTURECD
    _bHALJPEGTemp = _GetJPEGRotateStatus();
    if (_bHALJPEGTemp) //rotate 90 degree
    {
        // if (_wJPEGRealWidth/_wJPEGRealHeight > DisplayHeight/DisplayWidth)==>fit height
        //fit width
        if ((DWORD)((DWORD)_wJPEGRealWidth * (DWORD)__wWidth) >
            (DWORD)((DWORD)_wJPEGRealHeight * (DWORD)__wHeight))
        {
            _bJPEGfit =  HAL_JPEG_DISPLAY_FIT_HEIGHT;
        }
        else //fit width
        {
            _bJPEGfit =  HAL_JPEG_DISPLAY_FIT_WIDTH;
        }
    }
    else
    {
        // if (_wJPEGRealWidth/_wJPEGRealHeight < DisplayWidth/DisplayHeight)==>fit height
        //fit height
        if ((DWORD)((DWORD)_wJPEGRealWidth * (DWORD)__wHeight) <
            (DWORD)((DWORD)_wJPEGRealHeight * (DWORD)__wWidth))
        {
            _bJPEGfit = HAL_JPEG_DISPLAY_FIT_HEIGHT;
            
        }
        else //fit width
        {
            _bJPEGfit = HAL_JPEG_DISPLAY_FIT_WIDTH;
        }
    }
#endif //NO_PICTURECD
}

//***************************************************************************
//  Function    :   _JPEGCalculateScaling
//  Abstract    :   Calculate the scaling according to the zoom mode.
//  Arguments   :   bZoomMode ==> The paramter of zoom mode.
//  Return      :   HAL_JPEG_SCALING_RESULT_CLIP_ONLY ==> Use clip command to do zoom only.
//				:	HAL_JPEG_SCALING_RESULT_REDECODE ==> Need to do decode command after scaling.
//  Side Effect :   none.
//  Notes       :   __wWidth ==> The displaying width
//              :   __wHeight ==> The displaying height
//              :   __wDisplayWidth ==> The width after scaling. (numerator)
//              :   __wDisplayHeight ==> The Height after scaling. (numerator)            
//              :   __wHExtractStart ==> The horizontal starting position to extract the image from the FOrg.
//              :   __wVExtractStart ==> The vertical starting position to extract the image from the FOrg.
//              :   _wJPEGWidth ==> The width to extract from the FOrg.
//              :   _wJPEGHeight ==> The height to extract from the FOrg.
//***************************************************************************
BYTE _JPEGCalculateScaling(BYTE bZoomMode)
{
#ifndef NO_PICTURECD

    _bScalingAll = TRUE; //Extract all image from FOrg.

    //To get the rotating status. Rotating 90 degree==>TRUE. Else==>FALSE.
    _bHALJPEGTemp = _GetJPEGRotateStatus();

    _JPEGGetFitWidthOrHeight();

⌨️ 快捷键说明

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