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

📄 mm_file.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 5 页
字号:
//                  - the start sector/ length of each file : _pFMFileTOC
//                  - the playing status of all JPG file : _pFMStatusList
//  Parameters  :   None
//  Return      :
//  Changed     :
//  Side Effect :   Will share __bPool[] buffer
//                  [1] _cSector3: 2048 bytes, ISO9660 parsering -- CDROM decoding
//                      Two buffer will share _cSector3[]:
//                      - __pMMDirNameList:
//                        CT9928AF: 150 directory * (6+1+1) char = 1200 bytes,
//                        CT908   : 150 directory * (8+1+1) char = 1500 bytes
//                      - _pFMStatusList:
//                        CT9928AF/ CT908: 200 file * (3 byte element) = 600 bytes
//                      CT9928AF: 200 file * (6+1+1) char = 1600 bytes;
//                      CT908   : 200 file * (8+1+1) char = 2000 bytes;
//                  [3] _pFMFileTOC: 200 file * (3+2) = 1000 bytes
//                  [4] _pMMDirLoc: 150 directory * (3 bytes) = 450 bytes
//                  [5] __pMMVolumeDirTree : 150 directory * (3 bytes) = 450 bytes
//                  So, max buffer size is: 2048 + 2000 + 1000 + 450 + 450 = 5948 bytes
//  Notice      :   _pFMStatusList[] will use temporal buffer while initialize,
//                  And all data will be always kept in DRAM.
//                  Share _cSector3[] buffer in first stage
//  Globals     :   _dwMMTemp5, _dwMMTemp6, _dwMMTemp7, _bMMIdx, _dwMMTemp2
//#######################################################################
BYTE _MM_PrepareInfo(void)
{
    __wPoolOffset = (WORD)((DWORD)__cSector3 - (DWORD)__bPool);
	
    // Increase 64 bytes because will use when parse dir record during across sector boundary.
    __wPoolOffset+=(M2F1_DATASECTOR+64);  // __cSector3 will be used for ISO9660
    // Check if the remain buffer size is enough for __cSector3 (2048 bytes)
    if( (__wPoolOffset + M2F1_DATASECTOR) > LENGTH_SHAREPOOL)
    {
#ifdef  _DEBUG_INFO
#ifdef  SUPPORT_PRINTF
        DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF,"\n BUFFER OVERFLOW[FMANAGER] for __cSector3[] !!!");
#endif  // #ifdef SUPPORT_PRINTF
#endif  // #ifdef _DEBUG_INFO
        return FALSE;
    }
	
    // [2] Assign buffer for _pMMDirLoc, this buffer is used to record the location of every directory
    // to parse the file information.
    _pMMDirLoc = (PDIR_LOC)(__bPool + __wPoolOffset);
    // Assign same buffer memory to __pMMFilesOfDir, __pMMFilesOfDir use same memory as _pMMDirLoc us
    // because we will set __pMMFilesOfDir value after _pMMDirLoc is used and will not use it anymore.
    __pMMFilesOfDir=(WORD *) _pMMDirLoc;
    // Update the __wPoolOffset by MM_MAX_DIR_NO*DIR_LOC_LENGTH bytes
    __wPoolOffset += (MM_MAX_DIR_NO*DIR_LOC_LENGTH);
	
    if ((__wPoolOffset + (MM_MAX_DIR_NO*DIR_LOC_LENGTH)) > LENGTH_SHAREPOOL)
    {
#ifdef  _DEBUG_INFO
#ifdef  SUPPORT_PRINTF
        DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF,"\n BUFFER OVERFLOW for _pMMDirLoc[] & __pMMFilesOfDir[] !!!");
#endif  // #ifdef  SUPPORT_PRINTF
#endif  // #ifdef  _DEBUG_INFO
        return FALSE;
    }
	
    // [3] Assign the buffer of __pMMVolumeDirTree
    __pMMVolumeDirTree = (PTREE_INFO)(__bPool + __wPoolOffset);
	
    // Update the __wPoolOffset by MM_MAX_DIR_NO*TREE_INFO_LENGTH  bytes
    __wPoolOffset += MM_MAX_DIR_NO*TREE_INFO_LENGTH;
	
    // Check if the remain buffer size is enough for __pMMVolumeDirTree
    if( (__wPoolOffset + MM_MAX_DIR_NO*TREE_INFO_LENGTH) > LENGTH_SHAREPOOL)
    {
#ifdef  _DEBUG_INFO
#ifdef  SUPPORT_PRINTF
        DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF,"\n BUFFER OVERFLOW for __pMMVolumeDirTree[] !!!");
#endif  // #ifdef  SUPPORT_PRINTF
#endif  // #ifdef  _DEBUG_INFO
        return FALSE;
    }
	
    // [4] Assign the buffer of __pMMProgContent
    __pMMProgContent = (PFILENAMEINFO)(__bPool + __wPoolOffset);
	
    // Update the __wPoolOffset by MAX_PROG_ITEM*FILENAMEINFO_LENGTH bytes
    __wPoolOffset += MAX_PROG_ITEM*sizeof(FILENAMEINFO);
	
    // check if buffer overflow
    if ((__wPoolOffset + (MAX_PROG_ITEM * sizeof(FILENAMEINFO)) ) > LENGTH_SHAREPOOL)
    {
#ifdef  _DEBUG_INFO
#ifdef  SUPPORT_PRINTF
        DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF,"\n BUFFER OVERFLOW for __pMMProgContent[] !!!");
#endif  // #ifdef  SUPPORT_PRINTF
#endif  // #ifdef  _DEBUG_INFO
        return FALSE;
    }
    __pMMFilterFilesOfDir = (WORD*)(__bPool + __wPoolOffset);
#ifdef SUPPORT_FAT_FILE_SYSTEM
    // wyc1.05-909, when support FAT, FAT will borrow space of __pMMFilterFilesOfDir for save dir location, dir_loc is 3 bytes. So reserve more for FAT.
    __wPoolOffset += MM_MAX_DIR_NO*3;
#else
    __wPoolOffset += MM_MAX_DIR_NO*2;
#endif //
    if (__wPoolOffset > LENGTH_SHAREPOOL)
        return FALSE;
    // wyc1.00-909, initial the address of pointer
    __pFMComFile = (BYTE*)(__bPool + __wPoolOffset);
    __wPoolOffset += 64; // max file length in each file is 64.
	
#ifdef SUPPORT_FAT_FILE_SYSTEM
    // wyc1.05-909, allocate DRAM size for FAT cache table.
    // wyc1.07-909, to force _pMMFATTable address DWORD alignment to avoid IU error when dumping data into this pointer.
	
    __wPoolOffset += (8 - ((DWORD)__bPool + __wPoolOffset)) & 7;    // 8 bytes alignment
    _pMMFATTable = (DWORD*)((DWORD)__bPool + __wPoolOffset);
	
    // x2 is because one cluster need to use 2 bytes to record in FAT table.
    __wPoolOffset += FAT16_TABLE_CACHE_CLUS_NUM * FAT16_TABLE_OCCUPY_SIZE_PER_CLUS;
	
    if (__wPoolOffset > LENGTH_SHAREPOOL)
        return FALSE;
#endif //SUPPORT_FAT_FILE_SYSTEM
	
    // wyc1.10-909, init the DRAM for DivX SP usage.
#ifdef SUPPORT_CHAR_SUBPICTURE
    // wyc2.76-909P,
    __wPoolOffset += (4 - ((DWORD)__bPool + __wPoolOffset)) & 3;
    __pMMMP4SPRecordStart = (PMP4SP_RECORD)(__bPool + __wPoolOffset);
    __pMMMP4SPRecord = __pMMMP4SPRecordStart;
    __wPoolOffset += (sizeof(MP4SP_RECORD))*MM_MAX_SRT_NUM;
    if (__wPoolOffset > LENGTH_SHAREPOOL)
        return FALSE;
	
	
    __bTotalSRTFiles = 0;
#else
    __pMMMP4SPRecord = 0;
#endif //
	
    // scping, for UDF
    // wyc2.16-909S, add UDF file system supporting.
#ifdef SUPPORT_UDF_FILE_SYSTEM
    __cSectorFE = (char *)(__bPool + __wPoolOffset);
    __wPoolOffset += 200;
    if (__wPoolOffset > LENGTH_SHAREPOOL)
    {
        return FALSE;
    }
#endif //
	
    // wyc2.22-909s, because the audio buffer is same as user data buffer, so change to video buffer.
    INFOFILTER_SetTempBuff(DS_AD0BUF_ST);
    // elmer2.33
    _pMMMP4SPIndex = (PMP4SP_INDEX)_dwIFTempBuffAddr;
	
    // wyc0.62-909, modify code for CT909 mode.
    // Chuan0.85, Use the definition of CTKAV.H
    __pMMDirNameList = (PDIRNAMEINFO)(DS_FW_BUFFER_ST_MM);
    __pMMFileRecord = (PFILE_RECORD)(DS_FW_BUFFER_ST_MM+(MM_MAX_DIR_NO*sizeof(DIRNAMEINFO)));
    __pMMFileRecordStart = (PFILE_RECORD)(__pMMFileRecord);
    // wyc1.07-909, initial it for cdinfo to reference.
    __bMaxExtNO = MAX_EXTENSION_NO;
	
    // Step 2: Assign the necessary member value of _MMFileLog structure
    // Because, we want to call CD_GetTotalEntriesbyPath(& _MMFileLog);
    // And, get all directory relative information
	
    // LLY2.80, Specify the max string length & gap while parsing directory
    // LLY2.81-2, re-define the spec. of bMaxStringLen : don't include '\0'
    _MMFileLog. bMaxStringLen= MM_MAX_DIRNAME_LENGTH; // don't include "\0"
    _MMFileLog. bGapbyString= sizeof(DIRNAMEINFO);
    _MMFileLog. wMaxNO= MM_MAX_DIR_NO;
    _MMFileLog. wStartNO= 0;  // Who use it ??? It's unnecessary now ??
    _MMFileLog. wAttrFilter= 0xFFFF;
    // The attr of directory can temp use __pMMFileRecord to access because of __pMMFileRecord will not use now.
    _MMFileLog. pAttr= (WORD *)__pMMFileRecord;
    _MMFileLog. pTree= (BYTE *)__pMMVolumeDirTree;
	
	
    _MMFileLog. pName= (char* )__pMMDirNameList;
    _MMFileLog. ptrVoid= (void*) _pMMDirLoc;  // give a buffer point used to save directory location
    // wyc2.37-909s, replace to NO_DISC_MODE define
#ifndef NO_DISC_MODE //++CoCo2.37p
    if ((__bFileSystem == FILE_SYSTEM_ISO9660) || (__bFileSystem == FILE_SYSTEM_ISOJOLIET))
    {
		
        // Step 3: Call CD_GetTotalEntriesbyPath() to get all directory by path table
        // Notice: all necessary member of _MMFileLog must be ready !!
        CD_GetTotalEntriesbyPath(&_MMFileLog);
		
        // Step 4: Keep the final directory number after parsing ok !!
        __bMMTotalDirs= (BYTE) _MMFileLog.wActualNO;
		
        // Step 5: Find the root directory, and give the name as "ROOT"
        //           Because there is no name for root directory
        for(_bMMIdx=0; _bMMIdx<__bMMTotalDirs; _bMMIdx++)
        {
            if(_MMFileLog.pAttr[_bMMIdx] & FILE_FLAG_ROOT)
            {
                strncpy(__pMMDirNameList[_bMMIdx].cName, "ROOT", 4);
                __pMMDirNameList[_bMMIdx].cName[4]=0; // end of string
                break;
            }
        }
		
        // Step 7: Initialize total file number first
        // And, we will start to get total files of each directory
        __wMMTotalFiles=0;
        _MMFileLog.wTotalNO = __wMMTotalFiles;
		
        // Step 8: Specify the necessary element of _MMFileLog structure
        // Before calling CD_GetTotalEntriesbyDir()
        // (1) specify to search FILE only within each directory
        _MMFileLog. wAttrFilter= FILE_FLAG_FILE;
        // (2) give extension name order -- LLY.274p-2
				
        // (3) Specify the max string length & gap for parsing file
        // LLY2.81-2, re-define the spec. of bMaxStringLen : don't include '\0'
        _MMFileLog. bMaxStringLen= MM_MAX_FILENAME_LENGTH;  // don't include "\0"
        // wyc1.25, use FILE_RECORD_LENGTH to replace FILENAMEINFO_LENGTH
        _MMFileLog. bGapbyString= sizeof(FILE_RECORD);
		
        // elmer
        __bMP4SPFileCnt = 0;
        __bAVIFileCnt = 0;
		
        // Get all files within all directory
        // Notice: can't exceed 200 files !!
        for(_bMMIdx=0; _bMMIdx< __bMMTotalDirs; _bMMIdx++)
        {
            // elmer2.33
            _pMMMP4SPIndex[_bMMIdx].wMMSPRecordEntry = 0xFFFF;
            _pMMMP4SPIndex[_bMMIdx].wMMSPRecordEnd = 0xFFFF;
			
            _dwMMTemp9 = __bMP4SPFileCnt;
            // LLY0.62, using general abort mainflow API instead of checking POWER/ OPEN_CLOSE key
            if( UTL_QueryCapability(QUERY_ABORT_MAINFLOW))
                return FALSE;
						
            // Step 9: Specify directory location
            // wyc1.07-909, update to 4 bytes for FAT32 need 4 bytes to record information.
            _dwMMTemp8=((DWORD)_pMMDirLoc[_bMMIdx].bSector[0]) << 24;
            _dwMMTemp8|=((WORD)_pMMDirLoc[_bMMIdx].bSector[1]) << 16;
            _dwMMTemp8|=((WORD)_pMMDirLoc[_bMMIdx].bSector[2]) << 8;
            _dwMMTemp8|=_pMMDirLoc[_bMMIdx].bSector[3];
            CD_SetDirectoryLocation(_dwMMTemp8);
            // wyc0.87, record the current parsing dir for CDINFO to add correct index dir files attribute. Also need to parse the pointer
            // address for CDINFO.
            _MMFileLog.bDirIndex = _bMMIdx;
            // compute the end sectors of parsing file in directory. Protect to avoid over parsing another directory's files.
            _dwMMTemp8=((DWORD)_pMMDirLoc[_bMMIdx+1].bSector[0]) << 24;
            _dwMMTemp8=((DWORD)_pMMDirLoc[_bMMIdx+1].bSector[1]) << 16;
            _dwMMTemp8|=((WORD)_pMMDirLoc[_bMMIdx+1].bSector[2]) << 8;
            _dwMMTemp8|=_pMMDirLoc[_bMMIdx+1].bSector[3];
            // wyc2.36-909S, when parse to last dir, can't use next dir to check the dir sector ID because no next dir now.
            if (((_bMMIdx+1) == __bMMTotalDirs) || ((_dwMMTemp8 - __dwSectorDir) > MM_MAX_PARSE_DIR_SECTORS))
                _MMFileLog.bDirSectorNum = MM_MAX_PARSE_DIR_SECTORS;
            else
                _MMFileLog.bDirSectorNum = _dwMMTemp8 - __dwSectorDir;
			
            // Step 10: Continue to specify the member of _MMFileLog, before call CD_GetTotalEntriesbyDir()
            _MMFileLog.wMaxNO=(MM_MAX_FILE_NO_ONE_TITLE-__wMMTotalFiles);
			
            // LLY2.80, always use full buffer if F/W will save file info. into DRAM
            _MMFileLog.pFileRecord=(PFILE_RECORD) __pMMFileRecord;
			
            //can't record the attribute, or cause MP3 name/song length wrong???
            _MMFileLog.pAttr=NULL;    // don't record Attribute
			
            // Step 11: Get necessary files information within the desired directory
            // max doing 30 times to parse the data in directory when dir files more than our SRAM boundary,
            __pMMFilesOfDir[_bMMIdx] = 0;
			
#ifdef SUPPORT_CHAR_SUBPICTURE
            _MMFileLog.pMP4SPRecord = (PMP4SP_RECORD)__pMMMP4SPRecord;
#endif
			
            for (_bMMDirParseIdx = 0; _bMMDirParseIdx < 30; _bMMDirParseIdx++)
            {
                // wyc1.10-909, init the pointer for CDINFO to use.
                _MMFileLog.wStartNO=_bMMDirParseIdx;
                _dwMMTemp8 = sizeof(FILE_RECORD);
                // wyc1.07, when CDINFO return FALSE to represent can't getting any data from disc, then we should break the for loop to enter next dir parsing.
                if (!CD_GetTotalEntriesbyDir( & _MMFileLog ))
                {
                    // wyc2.60-909P, modify the mechod for link mechanism
                    __pMMDirNameList[_bMMIdx].bMMLinkStatus &= ~MM_SORT_FILTER_LINK_READY;
                    break;
                }
				
                // Step 12: Update total files within the directory
                __pMMFilesOfDir[_bMMIdx] += _MMFileLog.wActualNO;
				
                // Step 13: Convert the unknown file name into MP3XXX/ JPGXXX
#ifdef  CONVERT_UNKNOWN_NAME
                for(_dwMMTemp2=0; _dwMMTemp2<_MMFileLog.wActualNO; _dwMMTemp2++)
                {
                    // Specify the desired buffer address that stored directory name first
                    // Because, _MM_ConvertName() will use "_pMMTempNameList" for reference
                    _pMMTempNameList=&__pMMFileRecord[_dwMMTemp2].FileName;
                    __bMMUniFile = __pMMFileRecord[_dwMMTemp2].bFileAttr & IF_UNICODE_FILE_TAG;

⌨️ 快捷键说明

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