AuxSubtitlesCommonPrivate.h
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:16k
源码类别:
DVD
开发平台:
Others
- /*******************************************************************
- * AuxSubtitlesCommonPrivate.h
- *******************************************************************
- * Description:
- * ============
- * Private definitions for auxSubtitles.c and auxSubtitlesFormats.c
- *******************************************************************
- *
- *
- ******************************************************************/
- #include "Config.h" // Global Configuration - do not remove!
- #ifdef USE_AUX_SUBTITLES
- #ifndef __AUXSUBTITLESCOMMONPRIVATE_H_
- #define __AUXSUBTITLESCOMMONPRIVATE_H_
- #include "PlaycoreNav_ClipsClip_Impl.h"
- #define STORAGE_INTERFACE_BUFFER_SIZE 16 // size in words
- #define LAST_SUBTITLE_MARKER 0xffffffffUL
- #define SUBTITLES_SCLK_MULTIPLIER 90000UL
- #define SUBTITLES_SCLK_MULTIPLIER_MIL 90
- // Robin_0527_2004_A
- #if defined(SDRAM_2X16MBITS) && !defined(NEW_2X16M_MAPPING)
- #define SUBTITLES_MEMORY_SIZE 73728UL // 72KB
- #else
- #define SUBTITLES_MEMORY_SIZE 204800UL //200KB
- #endif
- //#define SUBTITLES_MEMORY_ADDRESS 0x90400UL
- //#define AUX_SUBTITLE_EARLY_DISPLAY_OFFSET 80000UL
- #define AUX_SUBTITLE_EARLY_DISPLAY_OFFSET 400UL
- #define SUBTITLE_INDEX_ENTRIES 8
- #ifdef SUPPORT_SAMI_SUBTITLE
- #define SF_NUMBER_OF_FORMATS (8+1)
- #else
- #define SF_NUMBER_OF_FORMATS (7+1)
- #endif
- #define SF_MICRODVD_PROBE_LIMIT 50
- #define FORMAT_NEW_LINE 'n'
- #define FRAME_TO_TIME(frame, scale, rate) ((((100000UL*(scale))/(rate))*(frame))/(100UL)) // Robin_0531_2004_A
- // typedefs
- // ======================================================
- // Commented references to this enum are throughout the AuxSubtitles code. It's not really necessary
- // when opening a subtitle file for use, since passing the parse function is enough. If anyone wants
- // to determine exact subtitle format type without using the file, uncomment these references.
- /* typedef enum { SF_MICRODVD, SF_SUBRIP, SF_SAMI, SF_SUBVIEWER1, SF_SUBVIEWER2, SF_UNKNOWN } SubtitlesFormatID; */
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Type : SubtitleProbingFuncPtr
- // Purpose : Check if the beginning of a file is compatible with a specific format
- // Input Parameters : dwSubtitlesFileAddress - location of the file on disc
- // dwSubtitlesFileSize - file size
- // Return type : TRUE if the file's beginning looks compatible, FALSE otherwise or on error.
- // Description : Functions of this type should be implemented for any subtitles format which
- // uses filename extension that other formats also use. The function will
- // scan a small section of the file (mostly its beginning) and attempt
- // to find tokens that distinguish this format from the other formats that
- // use the same extension.
- // Any impelementation should consider the other recongnized types and avoid
- // using identifying marks which the other formats use. When adding a new
- // format it might be necessary to change or implement the probing functions
- // for the existing formats, if there's a risk of confusing between the formats.
- /////////////////////////////////////////////////////////////////////////////////////////////
- typedef BOOL (*SubtitleProbingFuncPtr)(DWORD dwSubtitlesFileAddress, DWORD dwSubtitlesFileSize);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Type : SubtitleParsingFuncPtr
- // Purpose : Parse the subtitle file according to the specific format, and store its
- // contents using the proprietary format.
- // Input Parameters : dwSubtitlesFileAddress - location of the file on disc
- // dwSubtitlesFileSize - file size
- // dwScale, dwRate - dwScale/dwRate is the number of seconds
- // per video frame in the associated clip
- // Return type : TRUE if parsing was successful, FALSE on error.
- // Description : A function of this type must be implemented for every subtitle format.
- // The function will read the file, extract subtitles test, timing information,
- // and possibly language information and formatting information.
- // It will then store this data for use during playback, using only the
- // interface functions available in this file.
- /////////////////////////////////////////////////////////////////////////////////////////////
- typedef BOOL (*SubtitleParsingFuncPtr)(DWORD dwSubtitlesFileAddress, DWORD dwSubtitlesFileSize ,
- DWORD dwScale, DWORD dwRate);
- typedef struct SubtitleFormatAttrTAG {
- /* SubtitlesFormatID sfFormatID; */
- // Robin_1003_2004_E
- // LPCWSTR *aFormatValidExtensions;
- SubtitleProbingFuncPtr pfProbe;
- SubtitleParsingFuncPtr pfParse;
- } SubtitleFormatAttr;
- typedef struct SubtitleStorageInterfaceTAG {
- DWORD dwCurrentStorageOffset;
- BYTE baBuffer[STORAGE_INTERFACE_BUFFER_SIZE];
- WORD wBufferPos;
- #ifdef _DEBUG
- DWORD dwByteCount;
- DWORD dwEntryCount;
- WORD wMaxEntryLength;
- WORD wCurrentEntryLength;
- WORD wCurrentLineLength;
- WORD wMaxLineLength;
- #endif // _DEBUG
- } SubtitleStorageInterface;
- typedef struct SubtitleStorageIndexEntryTAG {
- DWORD dwStartTime;
- DWORD dwAddress;
- } SubtitleStorageIndexEntry;
- typedef struct SubtitleStorageIndexTAG {
- SubtitleStorageIndexEntry entry[SUBTITLE_INDEX_ENTRIES];
- WORD wSubtitlesModulu;
- WORD wInterval;
- BYTE bIndexPosition;
- } SubtitleStorageIndex;
- // externals
- extern CONST SubtitleFormatAttr availableSubtitleFormats[SF_NUMBER_OF_FORMATS];
- extern SubtitleStorageInterface* g_pSubtitleStorage;
- //*******************************************************************************************
- // Subtitle storage interface functions
- //*******************************************************************************************
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageInitWriting
- // Purpose : Initializes the interface to the subtitles storage
- // Return type : TRUE on success, FALSE on error
- // Description :
- /////////////////////////////////////////////////////////////////////////////////////////////
- void subtitleStorageInitWriting(void);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageMarkLastEntry
- // Purpose : to be used after the last subtitle was parsed.
- // Return type : TRUE - on success. FALSE when out of subtitle storage memory
- // Description : writes LAST_SUBTITLE_MARKER to the next position in the subtitle
- // storage.
- /////////////////////////////////////////////////////////////////////////////////////////////
- BOOL subtitleStorageMarkLastEntry(void);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageStartEntry
- // Purpose : Opens a new subtitle entry
- // Input Parameters : dwStartSCLK - Display starting time (SCLK)
- // Return type : TRUE - on success. FALSE when out of subtitle storage memory
- // Description : writes the SCLK DWORD, followed by a null byte
- /////////////////////////////////////////////////////////////////////////////////////////////
- BOOL subtitleStorageStartEntry(DWORD dwStartSCLK);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageEndEntry
- // Purpose : Closes a subtitle entry
- // Input Parameters : dwEndSCLK - Display starting time (SCLK)
- // Return type : TRUE - on success. FALSE when out of subtitle storage memory
- // Description : writes a null byte, followed by the SCLK DWORD.
- /////////////////////////////////////////////////////////////////////////////////////////////
- BOOL subtitleStorageEndEntry(DWORD dwEndSCLK);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageWriteByte
- // Purpose : Writes a byte to the subtitle storage memory
- // Input Parameters : b - the byte to be stored
- // Return type : TRUE - on success. FALSE when out of subtitle storage memory
- // Description : writes the byte to the internal buffer. when full - writes the buffer
- // to the subtitle storage memory
- /////////////////////////////////////////////////////////////////////////////////////////////
- BOOL subtitleStorageWriteByte(BYTE b);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageWriteDWORD
- // Purpose : Writes a double word to the subtitle storage memory
- // Input Parameters : dw - the dword to be stored
- // Return type : TRUE - on success. FALSE when out of subtitle storage memory
- // Description : writes the word to the internal buffer, byte by byte. when
- // the internal buffer is full - writes the buffer
- // to the subtitle storage memory
- /////////////////////////////////////////////////////////////////////////////////////////////
- BOOL subtitleStorageWriteDWORD(DWORD dw);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageCommitBuffer
- // Purpose : Internal Write the internal buffer to memory
- // Return type : void
- // Description : uses sc_SetBytes to write the buffer to subtitle memory. resets wBufferPos
- /////////////////////////////////////////////////////////////////////////////////////////////
- void subtitleStorageCommitBuffer(void);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageGetSubtitle
- // Purpose : Get a subtitle string and the end sclk count
- // Output Parameters: dwEndSCLK - The time for stopping the display of this subtitle in SCLK count
- // Return type : TRUE on success, FALSE if string is too long to fit in buffer
- // Description : Copies the subtitle string from subtitles storage memory to
- // the scratch pad. The string is copied as it was in the subtitles file,
- // except for conversion of formatting symbols. Conversion to Unicode or any
- // other format the OSD module requires, is likely to be language-dependant,
- // and should be performed by the calling function if necessary.
- // The time for displaying the returned subtitle should be determined beforehand,
- // and this function should be called when this time is reached. The end time is
- // returned by this function.
- /////////////////////////////////////////////////////////////////////////////////////////////
- BOOL subtitleStorageGetSubtitle(DWORD *dwEndSCLK);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageGetStartTime
- // Purpose : Get the start SCLK count of the current subtitle
- // Output Parameters: dwStartSCLK - Start display time, as SCLK count
- // Return type : FALSE if there are no more subtitles. TRUE otherwise
- // Description : Reads the start SCLK count for this subtitle. If there are no more subtitle,
- // FALSE is returned, and also the value of dwStartSCLK is LAST_SUBTITLE_MARKER
- // which is set to be the max possible value of the SCLK
- /////////////////////////////////////////////////////////////////////////////////////////////
- BOOL subtitleStorageGetStartTime(DWORD *dwStartSCLK);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageRewind
- // Purpose : Set the current subtitle pointer to the previous subtitle
- // Input Parameters : storage - handle to a storage struct
- // Output Parameters: dwStartSCLK - Start display time of the previous subtitle, as SCLK count
- // dwEndSCLK - End display time of the previous subtitle, as SCLK count
- // Return type : FALSE if the current subtitle is already the first. TRUE otherwise.
- // Description : The function searches for the previous subtitle in the subtitles memory,
- // makes it the current subtitle, and returns its start and end time.
- // This function is used for backwards navigation in the subtitles memory
- /////////////////////////////////////////////////////////////////////////////////////////////
- //BOOL subtitleStorageRewind(SubtitleStorageInterface *storage, DWORD *dwStartSCLK, DWORD *dwEndSCLK);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageFillBuffer
- // Purpose : Internal function for reading from the subtitles memory in to the internal buffer
- // Input Parameters : storage - handle to a storage struct
- // Return type : void
- // Description : uses sc_GetBytes to write the buffer to subtitle memory. resets wBufferPos
- /////////////////////////////////////////////////////////////////////////////////////////////
- void subtitleStorageFillBuffer(void);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageReadByte
- // Purpose : Reads a byte to the subtitle storage memory
- // Input Parameters : b - place to store the byte
- // Return type : void
- // Description : Reads the byte from the internal buffer. when empty - fills the buffer
- /////////////////////////////////////////////////////////////////////////////////////////////
- void subtitleStorageReadByte(BYTE *b);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageReadDWORD
- // Purpose : Reads a byte to the subtitle storage memory
- // Input Parameters : b - place to store the DWOR
- // Return type : void
- // Description : Reads the DWORD byte by byte using subtitleStorageReadByte
- /////////////////////////////////////////////////////////////////////////////////////////////
- void subtitleStorageReadDWORD(DWORD *dw);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageInitReading
- // Purpose : Initializes the interface to the subtitles storage
- // Return type : void
- // Description :
- /////////////////////////////////////////////////////////////////////////////////////////////
- void subtitleStorageInitReading(void);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleStorageRewindBytes
- // Purpose : Rewinds the subtitles storage pointer
- // Input Parameters: count - number of bytes to rewind
- // Return type : FALSE when attempting to rewind beyond the start of the subtitles storage
- // TRUE otherwise.
- // Description : Checks if the requested position is currently in the buffer, and updates
- // internal pointers if so. Otherwise, reads required data from the SDRAM
- /////////////////////////////////////////////////////////////////////////////////////////////
- BOOL subtitleStorageRewindBytes(WORD count);
- void updateSubtitlesIndex(DWORD dwAddress, DWORD dwStartSCLK);
- /////////////////////////////////////////////////////////////////////////////////////////////
- // Function Name : subtitleGoToTime
- // Purpose : Jump to a new time in the subtitle storage
- // Input parameters: dwCurrentTime - the new time
- // Return type : void
- // Description : After FF/FB/Goto, this function is used to set the next subtitle to be
- // the 1 right before the new time.
- /////////////////////////////////////////////////////////////////////////////////////////////
- void subtitleGoToTime(DWORD dwCurrentTime);
- void switchBytesInWString(LPSTR str);
- #endif // __AUXSUBTITLESCOMMONPRIVATE_H_
- #endif // USE_AUX_SUBTITLES