📄 fmanager.c
字号:
// Set the desired JPEG effect mode within __bJPEGEffect
// before calling HAL_JPEGDecode()
// Notice: Must do this action each time
// because __bJPEGEffect maybe changed by another application
// Ex. thumbnail module will set it as no_effect
__bJPEGEffect=aJPEGEffect_List[__bFMEffectIdx];
}
break;
// LLY.275a, merge STAGE_PREDECODE & STAGE_DECODE together
// Because those two stage can't be interrupt
// otherwise, some global variable will be updated
// Ex. use press KEY_ZOOM while in STAGE_PREDECODE
case STAGE_DECODE:
if(__bAttrPlay==ATTR_JPG)
{
#ifdef JPG_DEBUG_INFO
_printf("\n Query parse header"); //CoCo1.22a, for JPEG debug
_FM_DebugInfo(); //CoCo1.22a, for JPEG debug
#endif //JPG_DEBUG_INFO
// LLY.276p-4, Merge following procedure into UTL_SetPlayItemConfig()
// [1] Reset JPEG relative info.
// [2] Read-back JPG flip/ rotate info. from DRAM and set them to DSP
// [3] Set display width/ height to DSP
// [4] Issue parse header command
// LLY.276p-4, porting if parsing header ok, and time-out is 1 sec
// Notice: must make sure if it's the correct item in __bFMJPGStatus
// because this value is get within UTL_SetPlayItemConfig()
__bFMPlayable=HAL_QueryStatus(HAL_JPEG_PARSE_HEADER);
if( (UTL_GetSysTimer()- __dwPreGetTime) < (COUNT_1_SEC) )
{
// Notice: It's unnecessary to continue go while parsing header unfinish,
// And it can't contine go, because check system hang will refer this __dwPreGetTime value
if(__bFMPlayable==HAL_QUERY_RESULT_UNFINISH)
{
if(!__btPlayEnd)
{
UTL_GetCurrentTime ();
if (__dwTimeNow>=__dwTimeEnd)
{
__btPlayEnd = TRUE; //CoCo1.22
// wyc1.05, need to push FIFO to make audio1 have enough data to move to video buffer in JPG decoding. (when file size less 2K)
//CoCo1.00, C3
#ifdef SUPPORT_C3_FOR_CDROM_DATA
for (_bFMTemp2 = 0; _bFMTemp2<6; _bFMTemp2++)
HAL_PushFIFOData( (HAL_PUSHDATA_IFIFO|HAL_WITH_SYNC), 128);
#else
// LLY.276p, merge push data procedure into HAL_PushFIFOData()
HAL_PushFIFOData( (HAL_PUSHDATA_IFIFO|HAL_WITH_SYNC), 68); // 68=(270/4+1) DWORD
#endif // #ifdef SUPPORT_C3_FOR_CDROM_DATA
SERVO_Abort(); //CoCo1.22
}
}
return;
}
else if (__bFMPlayable == HAL_QUERY_RESULT_UNSUPPORT)//CoCo1.22
{
#if defined(JPG_DEBUG_INFO) || defined(_DEBUG_INFO) //CoCo1.22a, for JPEG debug
OSD_OUTPUT_MACRO(MSG_ERRCODE, FM_JPEG_PARSE_HEADER_UNSUPPORT, 0x1);
#endif // #ifdef _DEBUG_INFO
_FM_JPEGChangeToNext();
return;
}
else if (__bFMPlayable == HAL_QUERY_RESULT_FAIL)//CoCo1.22
{
// wyc1.24, every time play new JPG file increase one, if decode & display OK in stage DISPLAY will reset this value.
__wMonitorLackIFD++;
#if defined(JPG_DEBUG_INFO) || defined(_DEBUG_INFO) //CoCo1.22a, for JPEG debug
OSD_OUTPUT_MACRO(MSG_ERRCODE, FM_JPEG_PARSE_HEADER_FAIL, 0x1);
#endif // #ifdef _DEBUG_INFO
_FM_JPEGRedecode();
return;
}
}
//CoCo1.22, modify the JPEG flow
if(__bFMPlayable == HAL_QUERY_RESULT_UNFINISH)
{
// wyc1.24, every time play new JPG file increase one, if decode & display OK in stage DISPLAY will reset this value.
__wMonitorLackIFD++;
#if defined(JPG_DEBUG_INFO) || defined(_DEBUG_INFO) //CoCo1.22a, for JPEG debug
OSD_OUTPUT_MACRO(MSG_ERRCODE, FM_JPEG_PARSE_HEADER_UNFINISH, 0x3);
#endif // #ifdef _DEBUG_INFO
_FM_JPEGChangeToNext();
return;
}
else if (__bFMPlayable == HAL_QUERY_RESULT_FAIL)
{
// wyc1.24, every time play new JPG file increase one, if decode & display OK in stage DISPLAY will reset this value.
__wMonitorLackIFD++;
#if defined(JPG_DEBUG_INFO) || defined(_DEBUG_INFO) //CoCo1.22a, for JPEG debug
OSD_OUTPUT_MACRO(MSG_ERRCODE, FM_JPEG_PARSE_HEADER_FAIL, 0x1);
#endif // #ifdef _DEBUG_INFO
_FM_JPEGRedecode();
return;
}
else
{
// LLY.276p-4, disable video output before clear frame buffer
// And, it's only necessary for single buffer mode
#ifdef JPEG_SINGLE_BUFFER
HAL_Display(HAL_DISPLAY_VIDEO, FALSE);
#endif // #ifdef JPEG_SINGLE_BUFFER
//CoCo1.22, Wait display command OK before setting "decode" command.
W99AV_ReadDRAMData(W99AV_DRAM_JPEG_DISPLAY_OK, &__dwTemp);
if (HIWORD(__dwTemp) == 1)
{
__dwCheckTime=UTL_GetSysTimer();
while( (UTL_GetSysTimer()-__dwCheckTime) < COUNT_500_MSEC)
{
W99AV_ReadDRAMData(0xB0, &__dwTemp);
if (HIWORD(__dwTemp) == 0)
break;
}
}
// Issue decoding command
// LLY.276p-4, the API spec. has updated
HAL_JPEGDecode(HAL_JPEG_DECODE);
// wyc0.90, when picture size is less then 600 x 400, then this picture is called small picture. Small picture can do effect.
// When play from small -> big picture, this big picture also can't do effect. Only big -> big can do effect.
if (!HAL_JPEGCanDoEffect())
{
__bDoJPEGEffect = FALSE;
__bFMLastPicEffect = FALSE;
}
else
{
if (__bFMLastPicEffect)
__bDoJPEGEffect = TRUE;
else
__bDoJPEGEffect = FALSE;
__bFMLastPicEffect = TRUE;
}
#ifdef _DEBUG_TWO_BUFFER
printf("#### Decoding JPEG at %u frame buffer ;\n", __btActiveFrame);
#endif // #ifdef _DEBUG_TWO_BUFFER
// LLY.276p-4, issue display command and enable video display
// only for single buffer mode
#ifdef JPEG_SINGLE_BUFFER
/*--Coco1.21, remove it
#ifdef _DEBUG_DECODING_MODE
printf("#### Decoding mode is %u ;\n", __bDecodeMode);
#endif // #ifdef _DEBUG_DECODEING_MODE
*/
//HAL_Display(HAL_DISPLAY_JPEG, __bDecodeMode);
HAL_Display(HAL_DISPLAY_JPEG, HAL_JPEG_DECODE); //CoCo1.21, remove __bDecodeMode
HAL_Display(HAL_DISPLAY_VIDEO, TRUE);
#endif // #ifdef JPEG_SINGLE_BUFFER
__bFMStage=STAGE_PLAYEND; // LLY.278, STAGE_POLLING_END;
}
}
else // other file format
__bFMStage=STAGE_PLAYEND; //LLY.278, STAGE_POLLING_END;
break;
// LLY.278, STAGE_POLLING_END is unnecessary
// because buffer control is handle by MONITOR.C
// So, jump to STAGE_PLAYEND directly
case STAGE_PLAYEND:
// LLY.278, Check if playing end first, and enable flag (base on Chuan suggestion)
if(!__btPlayEnd)
{
UTL_GetCurrentTime ();
// wyc2.37, when decode OK, also make it go display stage. It fixed when much dummy data after 0xFFD9, then video will stop to decode
// these dummy data and video buffer full. Then CDIF closed and play end condition won't becode TRUE forever.
if (__bAttrPlay == ATTR_JPG)
__bTemp = HAL_QueryStatus(HAL_JPEG_DECODE_STATUS);
else
__bTemp = HAL_QUERY_RESULT_UNFINISH;
if ((__dwTimeNow>=__dwTimeEnd) || (__bTemp == HAL_QUERY_RESULT_OK))
{
__btPlayEnd = TRUE;
dwTimeStamp=0xffffffff;
// wyc2.39, for martking non-playable MP3 file in FM mode.
#ifdef SUPPORT_DISPLAY_INVALID_AUDIO_FILE //CoCo2.39, support displaying invalid audio file.
if (__bAttrPlay == ATTR_MP3)
_FM_MP3CANNOTPLAY();
#endif //
// wyc1.07, push data into IFIFO and push the AC3 sync to make DSP can complete playing bitstream.
#ifdef DOLBY_CERTIFICATION
if (__bAttrPlay == ATTR_AC3)
HAL_PushFIFOData(HAL_PUSHDATA_IFIFO_AC3SYNC|HAL_WITH_SYNC, 255);
#endif //
//Kevin1.22, fix can't play to the end for some bitstreams
// by inserting dummy pattern to IFIFO so that DSP can decode the latest frames
if (__bAttrPlay == ATTR_WMA)
{
//_printf("push dummy\n");
HAL_PushFIFOData(HAL_PUSHDATA_IFIFO|HAL_WITH_SYNC, 255);
}
}
// Kevin1.22, add comment
// Every 1 sec check abuf remainder to do error concealment while not __btPlayEnd
// LLY0.83b-2, alwasy break this switch-case if everything is done
// Because, following checking playing end procedure only need to
// do while __btPlayEnd=TRUE;
// If __btPlayEnd==TRUE, nothing need to do
// So, always break from this case
//if(__btPlayEnd)
break;
}
// LLY.274p-1, add INT_IFSC checking for JPG decoding
if(__bAttrPlay==ATTR_JPG)
{
// Send extra dummy data (sync + 270 zero) into IFIFO to push the last data
// IFIFO --> Parser --> VC --> DSP --> DRAM --> AD FIFO
// Otherwise, DSP can't find the endcode 'FFD9'
// Then, JPEG decoding can't finish !!
// Notice: 270 bytes: submode(4+8), ACFIFO(64), IFIFO(128+1), ADFIFO(64)
if (__btPlayEnd)
{
//CoCo1.00, C3
#ifdef SUPPORT_JPEG_C3
// wyc1.21, CoCo's updated code for C3 retry.
//CoCo, When push fifo for JPEG, we need to add the "C3 identify" for DSP to let it identify the last sector.
for (_bFMTemp2 = 0; _bFMTemp2<6; _bFMTemp2++)
HAL_PushFIFOData( (HAL_PUSHDATA_IFIFO|HAL_WITH_SYNC|HAL_WITH_C3_IDENTIFY), 128);
#else
// LLY.276p, merge push data procedure into HAL_PushFIFOData()
HAL_PushFIFOData( (HAL_PUSHDATA_IFIFO|HAL_WITH_SYNC), 68); // 68=(270/4+1) DWORD
#endif // #ifdef SUPPORT_JPEG_C3
SERVO_Abort(); //CoCo1.22
// LLY.275, prepare to enter display stage
// Because, push IFIFO action only need to do once time
__bFMStage=STAGE_DISPLAY;
#ifdef _DEBUG_PROGRESSIVE_JPEG
printf("Push IFIFO data ok for track : %d !! \n", __wPlayItem);
#endif // #ifdef _DEBUG_PROGRESSIVE_JPEG
}
}
#ifdef SUPPORT_WMA
else if(__bAttrPlay==ATTR_WMA) //Kevin1.08
{
#ifdef WMA_DEBUG //Kevin1.22, DM(dram_error_flag)
W99AV_ReadDM(0xe9c, &__dwTemp);
if (__dwTemp)
_printf("!!!!! WMA intend to write DRAM out of range !!!!!\n", __dwTemp);
#endif
W99AV_ReadDM(W99AV_DM_AUDIO2_REMAIN, &__dwTemp) ;
W99AV_ReadDM(W99AV_DM_WMA_BLOCK_ALIGN, &_dwFMTemp) ;
W99AV_ReadDM(W99AV_DM_WMA_TOTAL_SAMPLES, &dwSample); //Kevin1.22, add
//if (__dwTemp < _dwFMTemp+64)
if ((__dwTemp < _dwFMTemp+64) && (dwSample==dwPreSample) ) //Kevin1.22, also check decoding sample count
{
if (dwTimeStamp == 0xffffffff)
{
#ifdef WMA_DEBUG //Kevin1.22
_printf(" A-Rem2 < FrameSize + 64\n");
#endif
dwTimeStamp=__dwCountSystem;
}
// >= 1 sec force to play end
if ((__dwCountSystem-dwTimeStamp) < COUNT_1_SEC)
//return ERR_ERROR;
return; //CoCo1.21
}
else
{
dwPreSample = dwSample; //Kevin1.22, add
//Kevin1.22, fix can't auto play next file while playing to the end of the file for some patterns
//return ERR_ERROR;
//Every 1 sec check abuf remainder to do error concealment while the above change track condition is not satisfied even when really playing to the end of the file
break;
}
__dwTimeNow= __dwTimeBegin;
__btPlayEnd= TRUE;
__bFMStage=STAGE_NEXT_ITEM;
CHIPS_OpenAudio (FALSE); // VCD_071
}
#endif //#ifdef SUPPORT_WMA
else
{
// wait audio buffer empty
// LLY0.83b-2, splite CT9928AF & CT908 case
// CT9928AF: polling audio buffer remainder
// CT908: polling audio buffer 2 remainder,
// because audio buffer 1 is original RAW data w/o C3 action
// Notice: check if integrate these two case together !!
W99AV_ReadDM(W99AV_DM_AUDIO2_REMAIN, &__dwTemp) ;
// LLY.278, the remaind audio data is 2 frame (360 DW/ frame)
// So, the check value is 360*2=720 DW
// if side information not enough, the main data will be left in buffer
if ( __dwTemp<720
&& !(__bModeCmd==KEY_SCB && __bScanLevel!=0) //Kevin1.24a, fix MP3 SCB(will reset audio) when playing almost to the end of the file => jumps to next file
)
{
if (dwTimeStamp == 0xffffffff)
{
dwTimeStamp=__dwCountSystem;
}
// >= 0.5 sec force to play end
if ((__dwCountSystem-dwTimeStamp) < COUNT_500_MSEC)
//return ERR_ERROR;
return; //CoCo1.21
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -