📄 utl.c
字号:
// LLY0.80 create ...// ********************************************************************************// Function : UTL_MovieASTSetting// Description : Do DivX/ Nero Digital/ VOB audio stream relative setting// Argument : bID, specify the desired audio stream index// Return : None// ********************************************************************************void UTL_MovieASTSetting(BYTE bID){ PARSER_ESFMT ESAudio; // Nothing need to do if don't exist any audio stream. if(!__bASTNs) { return; } // LLY1.20, update audio related information while change audio stream _UTL_Update_Movie_AudioInfo(__bAttrPlay, bID); // LLY2.21, collect AVI/ NeroDigital/ VOB audio stream format together if(__bAttrPlay == ATTR_AVI) { ESAudio = pBitsContent->StreamID.AVI.AudioTrack[bID].ESFormat; } else { ESAudio = pBitsContent->StreamID.MPEG.AudioTrack[bID].ESFormat; } // Get corresponding audio stream type base on desired audio stream ID //switch(pBitsContent->StreamID.AVI.AudioTrack[bID].ESFormat) switch(ESAudio) { // LLY0.90, split MP12 & MP3 since OSD will reference it. case PARSER_ESFMT_MP3: __bAudioType=HAL_AUDIO_MP3; break; case PARSER_ESFMT_MP12: __bAudioType=HAL_AUDIO_MPG; break; case PARSER_ESFMT_AC3: __bAudioType=HAL_AUDIO_AC3; break; case PARSER_ESFMT_DTS: __bAudioType=HAL_AUDIO_DTS; break; case PARSER_ESFMT_PCM: // LLY2.21, need set as LPCM for non-AVI file's audio stream // Since, parser all think it as PCM if(__bAttrPlay == ATTR_AVI) __bAudioType=HAL_AUDIO_PCM; else __bAudioType=HAL_AUDIO_LPCM; break; case PARSER_ESFMT_OGG: //??? break; // LLY0.91, Support audio stream is WMA format // Notice: set audio ID as non-exist temporally since DSP code don't support it. case PARSER_ESFMT_WMA_V1: case PARSER_ESFMT_WMA_V2: __bAudioType=HAL_AUDIO_WMA; break; // LLY2.10, new added AAC format for Nero Digital case PARSER_ESFMT_AAC: __bAudioType=HAL_AUDIO_AAC; break; default: // LLY2.55, always set as unknown audio type for un-implement audio type. __bAudioType=HAL_AUDIO_NONE; DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "un-implement audio type: %lx \n", ESAudio); break; } // LLY2.10, don't to do audio setting continue while throw audio stream // Ntoce: __bASTID is ready after _UTL_Update_Movie_AudioInfo() // And, can return this API after __bAudioType is setting (since OSD will reference it) -- LLY2.30 if(__bASTID == HAL_THROW_AUDIO) { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Not do audio setting since skip audio stream\n"); return; } // Do audio type setting for DSP HAL_SetAudioType(__bAudioType); // LLY1.02, enable audio frequency setting flag // Since the sample rate maybe different between DivX title multi-audio channel // Otherwise, the audio output is abnormal for DivX Certification title file 'e08" AST=5 __bCheckAudioType |= CHECK_AUDIO_FREQ; // LLY1.06, must tell DSP to stop after audio frequency detection done // And, F/W will issue start command continue. // Otherwise, we may hear audio frequency wrong while beginning. HAL_WriteAM(HAL_AM_START_DECODE, 0);}// LLY1.01 create ...// ********************************************************************************// Function : UTL_PreScanAction// Description : Issue the pre-scan command for CDROM motion file to get the// necessary information, ex.// [1] DivX/ AVI necessary information, build index table// [2] 1st/ last PTS/ SCR value for VOB/ DAT/ MPG// Arguments : wMode, specfy the desired prescan mode// dwStart, specify the start sector of the desired range// dwEnd, specify the end sector of the desired range// Return : TRUE, issue the command successfully// FALSE, issue the command failure// ********************************************************************************// Need to remove it while parser define this bitstream format// LLY1.20, add MP4 prescan relative procedure, and extend prescan mode unit from BYTE to WORD// LLY1.50. re-adjust the procedure since integrate MP4 prescan action.BYTE UTL_PreScanAction(WORD wMode, DWORD dwStart, DWORD dwEnd){ DWORD dwContent; BYTE bRet; if(wMode==PRESCAN_MOTION_INFO || wMode==PRESCAN_1ST_SCR) {#ifdef DEBUG_PRESCAN DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Do pre-scan\n");#endif // #ifdef DEBUG_PRESCAN } // LLY1.21, reset the playback mode and attribute since pre-scan action maybe affect parser setting // So, following playback setting must be redo. Otherwise, playback maybe fail. // Ex, play JPG first --> try to playback a un-support motion --> playback JPG again. (fail) // Since, playback mode an attribute are same and nothing will be done within UTL_SetPlayMode() __bModePlay=MODE_PLAYUNKNOW; __bAttrPlay=ATTR_NONE; // Step 0: Always stop parser & source before each pre-scan action start -- LLY1.05 // Otherwise, it may cause procedure abnormal while receive any key before pre-scan action done HAL_ControlParser(HAL_PARSER_STOP, FALSE); SrcFilter_Stop(__dwSFStreamID); // Step 1: enable parsing user data PARSER_ActionFilter( 0, PARSER_ENABLE_DATA, TRUE ); // Step 2: Specify the bitstream format for parser base on differnt source if(__bAttrPlayNew==ATTR_AVI) // AVI/ MP4 { // Grievous2.78, preconfig avi buffer earlier to prevent the time // that config sp internal/external buffer mode is later than call parser char sp if(__bUTLSPTextMode == 2) { __bUTLSPTextMode = 1; _UTL_PreConfig_AVIBuffer(); } #ifdef SUPPORT_MP4 if(MM_GetFileType(__MMPlayingItem.wDirID, __wPlayItem)==EXTNAME_MP4) { PARSER_SetDataFmt(0, PARSER_DATAFMT_NOCHANGE,PARSER_BSFMT_MP4); } else#endif // #ifdef SUPPORT_MP4 { PARSER_SetDataFmt(0, PARSER_DATAFMT_NOCHANGE,PARSER_BSFMT_AVI); } } else // Other motion file { // set data format as MUXED for MPG/ VOB/ DAT file PARSER_SetDataFmt(0, PARSER_DATAFMT_NOCHANGE, PARSER_BSFMT_MUXED); } // Step 3: specify the desired parsing type if( wMode == PRESCAN_MOTION_INFO ) // prescan motion file header information {#ifdef DEBUG_PRESCAN DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Pre-scan motion info. \n");#endif // #ifdef DEBUG_PRESCAN // Must initial related information if 1st pre-scan action // LLY2.36, remove container buffer address initial action to UTL_PreConfig_AVIBuffer() // Just the same time while other necessary buffer initial action. // And, it only be done once before pre-scan. if(dwStart == __dwTimeBegin) {#ifdef DEBUG_PRESCAN DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Initial Container prescan \n");#endif // #ifdef DEBUG_PRESCAN#ifdef SUPPORT_MP4 if(MM_GetFileType(__MMPlayingItem.wDirID, __wPlayItem)==EXTNAME_MP4) { PARSER_InitialContainerPrescan(DS_MP4_TMP_INDEX_TBL_ST, DS_MP4_TMP_INDEX_TBL_LEN, DS_MP4_INDEX_TBL_ST, DS_MP4_INDEX_TBL_LEN); } else#endif // #ifdef SUPPORT_MP4 { // LLY2.36, base on current used F/W buffer end address to config AVI index buffer#ifdef SET_AVI_IDX_SP_SERVO_BUFF_RUNTIME PARSER_InitialContainerPrescan(DS_AVI_TMP_INDEX_TBL_ST, DS_AVI_TMP_INDEX_TBL_LEN, __dwMMFWBuffEnd, 0x3000L);#else // #ifdef SET_AVI_IDX_SP_SERVO_BUFF_RUNTIME PARSER_InitialContainerPrescan(DS_AVI_TMP_INDEX_TBL_ST, DS_AVI_TMP_INDEX_TBL_LEN, DS_AVI_INDEX_TBL_ST, DS_AVI_INDEX_TBL_LEN);#endif // #ifdef SET_AVI_IDX_SP_SERVO_BUFF_RUNTIME } } // specify the prescan mode as parsing motion information. dwContent=PARSER_PRESCAN_CONTAINER_INFO; } else if(wMode == PRESCAN_MOTION_IDXTBL) // prescan motion index table {#ifndef SIMP_UTL#ifdef DEBUG_PRESCAN DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Pre-scan motion index table. \n");#endif // #ifdef DEBUG_PRESCAN // [1] Get index table starting sector first __dwTemp = PARSER_GetContainerIndexPosition(dwStart); // LLY0.96, add protect while the index table sector is out-of range // ie. the index table maybe no-exist __bNoDivXIndexTbl=FALSE; if(__dwTemp<dwStart || __dwTemp>=dwEnd) { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Err: Index Table position is out-of range \n"); __bNoDivXIndexTbl=TRUE; // LLY1.05-1, return FALSE while index table un-exist // Then, MM module will go to set playing mode stage directly. return (FALSE); } else { // [2] Give the desired range for source to send data dwStart=__dwTemp; // [3] Specify the pre-scan mode as prescan motion index table dwContent = PARSER_PRESCAN_CONTAINER_INDEX; }#endif // #ifndef SIMP_UTL } else if(wMode & PRESCAN_SCR_VALUE) // prescan VOB/ DAT/ MPG 1st & last SCR value {#ifdef DEBUG_PRESCAN if(wMode == PRESCAN_1ST_SCR) { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Pre-scan 1st SCR value \n"); } else if(wMode == PRESCAN_LAST_SCR) { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Pre-scan last SCR value \n"); }#endif // #ifdef DEBUG_PRESCAN // specify the prescan mode as find SCR dwContent=PARSER_PRESCAN_SCR; // F100CSC_108, for reset the track counter at 1st time if( (dwStart == __dwTimeBegin) && (wMode == PRESCAN_1ST_SCR) ) { dwContent = PARSER_PRESCAN_1STSCR; } } /// LLY2.30, porting Elmer's code for FAT system play frome time#ifdef SUPPORT_FAT_FILE_SYSTEM if ((__bFileSystem == FILE_SYSTEM_FAT12) || (__bFileSystem == FILE_SYSTEM_FAT16) || (__bFileSystem == FILE_SYSTEM_FAT32)) { DWORD dwOffset; FAT_CheckUSBSecNum(&dwStart, &dwEnd, __dwTimeBegin, &dwOffset); __SF_SourceGBL[__dwSFStreamID].dwBlockOffset = dwOffset; }#endif // // Step 5: give the desired range for source to send data SrcFilter_ReadSectors(__dwSFStreamID, dwStart, dwEnd); // Step 6: Issue the pre-scan command bRet=PARSER_Command(0, PARSER_CMD_PRESCAN, &dwContent); if(bRet) { return (TRUE); } else { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "PreScan Action fail: %lx\n", wMode); return (FALSE); }}// LLY2.36 create// ***************************************************************************************// Function : UTL_PreConfig_AVIBuffer// Description : Used to pre-config some AVI buffer, ex AVI index, SP, servo buffer// Since, those buffer must be ready before do pre-scan.// Arguments : None// Return : None// Notice : Only be called before do pre-scan, ex UTL_Init_PlayItem()// ***************************************************************************************void _UTL_PreConfig_AVIBuffer(void){ DWORD dwSPStart, dwSPSize; DWORD dwServoSize; DWORD dwSPOutStart=DS_SP_OSD_ST;#ifdef SET_AVI_IDX_SP_SERVO_BUFF_RUNTIME#if 0 // Step 0: Initial container for pre-scan action.#ifdef DEBUG_PRESCAN DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Initial Container address\n");#endif // #ifdef DEBUG_PRESCAN#ifdef SUPPORT_MP4 if(MM_GetFileType(__MMPlayingItem.wDirID, __wPlayItem)==EXTNAME_MP4) { PARSER_InitialContainerPrescan(DS_MP4_TMP_INDEX_TBL_ST, DS_MP4_TMP_INDEX_TBL_LEN, DS_MP4_INDEX_TBL_ST, DS_MP4_INDEX_TBL_LEN); } else#endif // #ifdef SUPPORT_MP4 { // LLY2.36, base on current used F/W buffer end address to config AVI index buffer#ifdef SET_AVI_IDX_SP_SERVO_BUFF_RUNTIME PARSER_InitialContainerPrescan(DS_AVI_TMP_INDEX_TBL_ST, DS_AVI_TMP_INDEX_TBL_LEN, __dwMMFWBuffEnd, 0x3000L);#else // #ifdef SET_AVI_IDX_SP_SERVO_BUFF_RUNTIME PARSER_InitialContainerPrescan(DS_AVI_TMP_INDEX_TBL_ST, DS_AVI_TMP_INDEX_TBL_LEN, DS_AVI_INDEX_TBL_ST, DS_AVI_INDEX_TBL_LEN);#endif // #ifdef SET_AVI_IDX_SP_SERVO_BUFF_RUNTIME }#endif // #if 0 // [1] If exist internal SP, // Grievous2.78, change an variable to determine internal SP mode // Since __bSPSTNs is not for the usage. // if(__bSPSTNs) if(__bUTLSPTextMode) { // [1-1] always set SP buffer as 13K DW // Notice: index table is near F/W buffer, and size is 3K DW dwSPStart = __dwMMFWBuffEnd + 0x3000L; dwSPSize = 0xD000L; // Grievous2.78, add SMALL_SOURCE_BUFFER case for different buffer address#ifdef SMALL_SOURCE_BUFFER dwServoSize = DS_INPUT_BITBUF_END_AVI_SMALL - DS_INPUT_BITBUF_ST_AVI_SMALL;#else // [1-2] Let servo buffer = total reserved space - F/W used buffer - 3K index table - 13K SP buffer // So, calculate the availabe servo buffer first dwServoSize = DS_INPUT_BITBUF_END_AVI - __dwMMFWBuffEnd - 0x3000L - dwSPSize; dwServoSize = (dwServoSize/SERVO_BUFSIZE_ALIGN_UNIT)*SERVO_BUFSIZE_ALIGN_UNIT; // 1 servo blok = 10 KDW#endif } // [2] If don't exist internal SP, else { // [2-1] Always let servo buffer as 3 block // wyc2.76-909P#ifdef SMALL_SOURCE_BUFFER dwServoSize = DS_INPUT_BITBUF_END_AVI_SMALL - DS_INPUT_BITBUF_ST_AVI_SMALL; // [2-2] Configure SP output buffer as 3K DW (near servo buffer)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -