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

📄 mm_file.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 5 页
字号:
//////////////////////////////////////////////////////////////
// ****** All necessary including files Area ******
#include    "winav.h"
// wyc0.60-909, include ctkav.h and <cyg/kernel/kapi.h> for thread control.
#include "ctkav.h"
#include    <string.h>
#include    "input.h"
#include    "infofilter.h"
#include    "cc.h"
#include    "osd.h"
#include    "mmanager.h"
#include    "utl.h"
#include    "initial.h" 
#include    "SrcFilter.h"
#include    "monitor.h"
#include    "setup.h"
#include    "chips.h"
#include    "hal.h"
#include    "linear.h"
#include    "panel.h"
#include    "parser.h"
#include    "disp.h"
#include    "disp.h" 
#include    "media.h"

#ifdef SUPPORT_POWERON_MENU
#include "poweronmenu.h"
#endif //SUPPORT_POWERON_MENU

#ifdef SUPPORT_CHAR_SUBPICTURE
#include "char_subpict.h"
#endif

#include    "comutl.h"

#include "debug.h"
#undef PRINTF
#undef printf
// Micky2.17c
#ifdef	APPLICATION_WINDOWS
#define PRINTF		DBG_Printf_Simple
#define printf		DBG_Printf_Simple
#else
#define PRINTF(x, y...)     DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_MM_INFOFTR, x, ## y)
#define printf(x, y...)     DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, x, ## y)
#endif

///////////////////////////////////////////////////////////////////////////
// File Log structure
// [G-19bytes]
FILE_LOG _MMFileLog;
// scping, for parse UDF dir record usage.
FAT_FS_FAT_DIRLOG _MMUDFDirLog;
// wyc1.05-909, for parse FAT dir record usage.
#ifdef SUPPORT_FAT_FILE_SYSTEM
FAT_FS_FAT_DIRLOG _MMFATDirLog;
DWORD *_pMMFATTable;
#endif //
///////////////////////////////////////////////////////////////////////////
PDIRNAMEINFO __pMMDirNameList;
// This variable is used to temp reference dir / file name to do some temp processing. For example, convert dir / file name.
PFILENAMEINFO  _pMMTempNameList; // NULL;
// wyc1.25, add pointer to use FILE_RECORD in SRAM
PFILE_RECORD __pMMFileRecord;
PFILE_RECORD __pMMFileRecordStart;
PFILE_RECORD __pMMFileRecordTemp;
PDIR_LOC _pMMDirLoc;
PMP4SP_RECORD     __pMMMP4SPRecord;
#ifdef SUPPORT_CHAR_SUBPICTURE
PMP4SP_RECORD     __pMMMP4SPRecordStart;
// elmer, record the index of sub-titles in each dir
PMP4SP_INDEX _pMMMP4SPIndex;
#endif //SUPPORT_CHAR_SUBPICTURE
BYTE    __bTotalSRTFiles;
//////////////////////////////////////////////////////////////
DWORD   __dwMMFWBuffEnd;  // LLY2.36, keep current used F/W buffer end address.
///////////////////////////////////////////////////////////////////////////
WORD *__pMMFilesOfDir;
WORD *__pMMFilterFilesOfDir;
BYTE *__pFMComFile;
BYTE __bMMTotalDirs;
WORD __wMMTotalFiles;
PTREE_INFO __pMMVolumeDirTree;
BYTE _bMMParentID;
// Keep the info. while exist "UP_DIR" or not -- LLY0.83b-2
BYTE _bMMExistUpDir;

// wyc2.38a-909s, varoable to record the total files after sort/filter mode.
WORD __wMMTotalFilterFiles;
DWORD _wMMGetRangeIndex;
// used for supporting parsing more files in one directory.
BYTE _bMMDirParseIdx;
///////////////////////////////////////////////////////////////////////////
WORD _wStartDumpAbsID;
WORD _wMMUnDumpFileRecord;
WORD _wNextFileRecord;
BYTE _bMMFirstDumped;
///////////////////////////////////////////////////////////////////////////
BYTE __bMMVolumeSet [1]; // Now use 1 us because only support SERVO media now, correct way need to define by max. support media and need to wait Brian's define.
BYTE __bMMVolumeNum = 1;
///////////////////////////////////////////////////////////////////////////
DWORD   _dwMMTemp; 
DWORD   _dwMMTemp1;
DWORD   _dwMMTemp2;
DWORD   _dwMMTemp3;
DWORD   _dwMMTemp4;
DWORD   _dwMMTemp5;
DWORD   _dwMMTemp6;
DWORD   _dwMMTemp7;
DWORD   _dwMMTemp8;
DWORD   _dwMMTemp9; 
WORD    _wMMTemp;
BYTE    _bMMIdx;
///////////////////////////////////////////////////////////////////////////
BYTE    __bMMUniFile;
///////////////////////////////////////////////////////////////////////////
PFILENAMEINFO    __pMMProgContent;
///////////////////////////////////////////////////////////////////////////
BYTE    __bMMExtFilterMode;
volatile BYTE    __bMMExtFilterModeInMMMode;
BYTE    __bMMSortMethod;
BYTE    __bMMPreExtFilterMode;
WORD    __wMMPreFilterDir;
BYTE    __bMMPreSortMethod;
BYTE    __bMMSortSequence;
BYTE    __bMaxExtNO;
WORD    _wMMExtFirstID[MAX_EXTENSION_NO];
WORD    _wMMExtLastID[MAX_EXTENSION_NO];
WORD    _wSortIndex;
///////////////////////////////////////////////////////////////////////////
DWORD   _dwMMLastRelID, _dwMMLastAbsID;
///////////////////////////////////////////////////////////////////////////

//#######################################################################
//  Function    :   MM_CheckPlayableCDROM
//  Description :   This function check if the disc contain playable files
//                  and will prepare all necessary information of these files
//  Parameters  :   None.
//              :
//  Return      :   TRUE,   a playable CDROM disc
//              :   FALSE,  not a playable CDROM disc
//  Changed     :
//  Side Effect :
//#######################################################################
BYTE MM_CheckPlayableCDROM(void)
{
    // wyc1.07, extern these variables for detect if CDROM detecting error.
    BYTE   *__bFMBuf;
	// the following information will be available
	// 1. __pMMDirNameList      // each directory name list
	// 3. _pFMFileTOC           // each file starting sector and length
	// 4. _bAblum1stID          // 1st song ID of each album
	// 5. __pMMFilesOfDir       // total songs of each album
	
    // wyc1.07, detect if CDROM detecting error, if error use ISO mode to re-try again.
    if ( !_MM_PrepareInfo() )
    {
        if (__SF_SourceGBL[__dwSFStreamID].bSourceIndex == SOURCE_DISC)
        {
            SrcFilter_Stop(__dwSFStreamID);
            INFOFILTER_GetFileSystem();
            __bFMBuf= (BYTE * ) __cSector3;
            _dwSectorMPath= ((DWORD)( __bFMBuf [148] )<<24);
            _dwSectorMPath+= ((DWORD)( __bFMBuf [149] )<<16);
            _dwSectorMPath+= ((DWORD)( __bFMBuf [150] )<<8);
            _dwSectorMPath+= (DWORD)( __bFMBuf [151] );
            //__bFileSystem = FILE_SYSTEM_ISO9660;
            if ( !_MM_PrepareInfo() )
                return FALSE;
        }
        else
            return FALSE;
    }
	
    return TRUE;
}

//#######################################################################
//  Function    :   MM_GetRange
//  Description :   This function will return the play range for each file
//  Parameters  :   wIndex, the file index to get play range, from '1'
//  Return      :
//  Changed     :   __dwTimeBegin,  the starting sector
//              :   __dwTimeEnd,    the ending sector
//  Side Effect :
//#######################################################################
void MM_GetRange(WORD wDirID, WORD wIndex, PDWORD pdwStart, PDWORD pdwEnd)
{
    DWORD   dwTimeBegin, dwTimeEnd;
    WORD wIndex1;
	
    // 1. Get current file's starting sector to __dwTimeBegin
    // 2. Get current file's length
    // 3. __dwTimeEnd=__dwTimeBegin + file length
    // 4. __dwTimeEnd=temp - GAP
	
    // LLY.274p-2, decrease wIndex by 1, because the array index is from '0'
    wIndex--;
	
    // LLY0.83b-2, calculate the corresponding index by "disc view"
    // Because, disc file's TOC is stored into DRAM together in "disc view"
    // wyc0.71, wIndex is the offset in MM buffer, so don't need to
    _wMMGetRangeIndex=MM_ID_RelativeToAbsolute(wDirID, wIndex);
    wIndex1=MM_ID_RelativeToAbsolute(wDirID, wIndex);
    wIndex=MM_ID_RelativeToAbsolute(wDirID, wIndex);
    printf("\nGet Range: Ori:%x, New:%x, local new:%x",wIndex,_wMMGetRangeIndex,wIndex1);
	
    // Get __dwTimeBegin and __dwTimeEnd
    // wyc1.07-909, use 4 BYTES to record file range.
    dwTimeBegin = 0;
    dwTimeBegin |= __pMMFileRecordStart[_wMMGetRangeIndex].FileRange.cS[0];
    dwTimeBegin <<=24;
    dwTimeBegin |= ((WORD)__pMMFileRecordStart[_wMMGetRangeIndex].FileRange.cS[1])<<16;
    dwTimeBegin |= ((WORD)__pMMFileRecordStart[_wMMGetRangeIndex].FileRange.cS[2])<<8;
    dwTimeBegin |= __pMMFileRecordStart[_wMMGetRangeIndex].FileRange.cS[3];
    // wyc1.10, change wLen to dwLen because of structure have change from WORD to DWORD.
    dwTimeEnd = dwTimeBegin + __pMMFileRecordStart[_wMMGetRangeIndex].FileRange.dwLen-1;
    // wyc1.01-909, when FAT file system we need to transfer cluster unit to sector unit when want to play from USB source.
    // wyc1.01-909, FAT need to do some transfer for get correct sector in FAT file system.
#ifdef SUPPORT_FAT_FILE_SYSTEM
    if ((__bFileSystem == FILE_SYSTEM_FAT12) || (__bFileSystem == FILE_SYSTEM_FAT16) || (__bFileSystem == FILE_SYSTEM_FAT32))
    {
        // wyc1.01a, need to sent more than the real file size or equal, can't less than file size. Otherwise JPG can't find 0xFFD9 and will decode failed.
        // Begin is USB sector location, size is parser sector unit, end is pesudo to compute and just for checking all data are parsed in.
        dwTimeBegin = __wDataStartSec + (dwTimeBegin - FAT_START_CLUS_NUM)*FAT_GetFATInfo(FAT_INFO_SECTOR_PER_CLUSTER);
        dwTimeEnd = dwTimeBegin + (__pMMFileRecordStart[_wMMGetRangeIndex].FileRange.dwLen/PARSER_SECTOR_SIZE);
    }
#endif //
	
    *pdwStart = dwTimeBegin;
    *pdwEnd = dwTimeEnd;
	
#ifdef  DEBUG_MESSAGE
    DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF,"Item=%lx, Start=%lx, End=%lx, Sectors=%lx\n",
        wIndex, *pdwStart, *pdwEnd, (*pdwEnd-*pdwStart+1));
#endif  // #ifdef DEBUG_MESSAGE
	
}


//  ********************************************************************
//  Function    :   MM_GetFileType
//  Description :   Get the desired item's file type, ex MP3/ JPG
//  Arguments   :   The desired playing item, index from '1'
//  Return      :   File extension ID
//  Side Effect :
//  ********************************************************************
BYTE MM_GetFileType(WORD wDirID, WORD wIndex)
{
    // wyc1.10-3, add protection to avoid non-CDROM titles get wrong information in this function.
    if (__wDiscType & CDROM_M1)
    {
        // Decrease wIndex by 1, because the array index is from '0'
        wIndex--;
        // wyc0.72, use new filter/sort link mechansim to get data
        return __pMMFileRecordStart[MM_ID_RelativeToAbsolute(wDirID, wIndex)].FileName.bExtID;
    }
    return  FALSE;
}

//#######################################################################
//  Function    :   _MM_GetDir1stID
//  Description :   Get the 1st file ID within the desired directory
//  Parameters  :   bDirIdx, specify the desired directory ID, index from '0'
//  Return      :   the 1st file ID within the desired directory
//  Changed     :
//  Side Effect :
//  Global      :   _dwMMTemp2, _dwMMTemp5
//#######################################################################
WORD _MM_GetDir1stID(BYTE bDirIdx)
{
    // LLY2.81, always return total files number (index from '0')
    // if input number is out-of total directory
    if(bDirIdx >= __bMMTotalDirs)
    {
        return __wMMTotalFiles;
    }
	
    // Otherwise, go following procedure to do calculation
    _dwMMTemp2=0;
    for(_dwMMTemp5=0; _dwMMTemp5<bDirIdx; _dwMMTemp5++)
    {
        _dwMMTemp2+=__pMMFilesOfDir[_dwMMTemp5];
    }
    return _dwMMTemp2;
}

// **************************************************************************
//  Function    :   MM_IndexConvert
//  Description :   Convert desired index between different two coordinate
//                  - directory: always '0' for each directory's 1st file
//                  - disc: index is '0' only 1st directory's 1st file
//                          others are continue
//                  - absolute: absolute cursor index within the display window
//                              ex. it includes sub-direcory NO + file NO
//                  - relative: real directory/ file index,
//                             ex. 1st item: '0'; 2nd item: '1'; ....
//  Arguments   :   bMode, specify the convert mode

⌨️ 快捷键说明

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