📄 char_subpict.c
字号:
#include "winav.h"#include "ctkav.h"#include "utl.h"#include "infofilter.h"#include "cc.h"#include "hal.h"#include "osd.h"#include "osdnd.h"#include "setup.h"#include "mmanager.h"#include "osdfont.h"#include "parser.h"#include "comutl.h"//Alan1.10, for char-based subpicture#ifdef SUPPORT_CHAR_SUBPICTURE#include "subpict.h"#include "par_sptx.h"#include "char_subpict.h"#include "gdi.h"#include "fontindex.h" //++CoCo2.37P#include "convchar.h"#ifndef CUSTOMER_ASCII#include "OSDString/Ascii_Remapping.txt"#endif#define ONE_LINE_CHAR_NUMBER 64 #define CHAR_NUMBER (ONE_LINE_CHAR_NUMBER * CHAR_SP_MAX_LINE_NUM)// Damon2.56, for Hebrew external subtitle#ifdef ISO_8859_8_FONT#ifndef HEBREW_WORD_INVERSION#define MAX_WORD_LENGTH 20#define MAX_WORD_NUMBER 30#endif#endifDWORD __dwParResult_CharSP;DWORD _dwSPType;DWORD _dwSPStartSector;DWORD _dwSPEndSector;PPARSER_SPTXT_HEADER _pSP_HeaderPt; PPARSER_SPTXT_HEADER _pSP_LastHeaderPt; PARSER_SPTXT_BUF _Char_SP_InputInfo;PARSER_SPTXT_BUF _Char_SP_OutputInfo;PARM_DRAW_STRING _CHAR_SP_StrAttr; PARM_RECT _CHAR_SP_RectAttr;WORD _aString[CHAR_NUMBER];WORD* _aLinePtr[CHAR_SP_MAX_LINE_NUM];//WORD* _pwCurrentLocaleTable; // Current character set in used//WORD* _pwCurrentUnicodeTable; // Current character set in used//WORD* _pwMappingTable;//BYTE _bFontHeightInTable;BOOL _blAlreadyDisplay = FALSE;// Damon2.56, for Hebrew external subtitle #ifdef ISO_8859_8_FONT#ifdef HEBREW_IE_FORMATBYTE _bHebSentenceInfo[CHAR_SP_MAX_LINE_NUM*2]; // Save sentence start position & lengthBYTE _bHebNumberInfo[MAX_WORD_NUMBER*2]; // Save number character start position & lengthBYTE _bHebSentenceIndex;BYTE _bHebNumberIndex;#elif defined(HEBREW_WORD_FORMAT)BYTE _bHebWordInfo[MAX_WORD_NUMBER*2]; // Save word position & lengthBYTE _bHebWordIndex;#endif#endif/*#ifndef CUSTOMER_ASCII#include "OSDString/Ascii_Remapping.txt"#endifWORD _aAsciiMappingTable[][2] = { #include "OSDString/Ascii_Mapping.txt"};#ifdef ISO_8859_15_FONTWORD _a8859_15_MappingTable[][2] = { #include "OSDString/ISO_8859_15_Mapping.txt"};#ifdef SUPPORT_UTF8 WORD _aUni_8859_15_MappingTable[][2] = { #include "OSDString/Uni_8859-15_Mapping.txt"};#endif#endif#ifdef ISO_8859_2_FONTWORD _a8859_2_MappingTable[][2] = { #include "OSDString/ISO_8859_2_Mapping.txt"};#ifdef SUPPORT_UTF8 WORD _aUni_8859_2_MappingTable[][2] = { #include "OSDString/Uni_8859-2_Mapping.txt"};#endif#endif#ifdef ISO_8859_7_FONTWORD _a8859_7_MappingTable[][2] = { #include "OSDString/ISO_8859_7_Mapping.txt"};#ifdef SUPPORT_UTF8 WORD _aUni_8859_7_MappingTable[][2] = { #include "OSDString/Uni_8859-7_Mapping.txt"};#endif#endif// elmer2.51, add Damon's code for Hebrew// Damon2.38a, for Hebrew#ifdef ISO_8859_8_FONTWORD _a8859_8_MappingTable[][2] = { #include "OSDString/ISO_8859_8_Mapping.txt"};#ifdef SUPPORT_UTF8 WORD _aUni_8859_8_MappingTable[][2] = { #include "OSDString/Uni_8859-8_Mapping.txt"};#endif#endif#ifdef ISO_8859_9_FONTWORD _a8859_9_MappingTable[][2] = { #include "OSDString/ISO_8859_9_Mapping.txt"};#ifdef SUPPORT_UTF8 WORD _aUni_8859_9_MappingTable[][2] = { #include "OSDString/Uni_8859-9_Mapping.txt"};#endif#endif#ifdef CP_1250_FONTWORD _aCP_1250_MappingTable[][2] = { #include "OSDString/CP_1250_Mapping.txt"};#endif#ifdef CP_1251_FONTWORD _aCP_1251_MappingTable[][2] = { #include "OSDString/CP_1251_Mapping.txt"};#ifdef SUPPORT_UTF8 WORD _aUni_CP_1251_MappingTable[][2] = { #include "OSDString/Uni_CP-1251_Mapping.txt"};#endif#endif*/extern DWORD __dwTemp;extern BYTE __bTemp;extern BYTE __bOSDDynamicRegion;extern WORD __wFontNum[];BOOL _CHAR_SP_CheckPTS_ExSP(void);#ifdef SUPPORT_UTF8 BOOL _CHAR_SP_CheckPTS_MP4(void);#endifvoid _Convert_Locale_To_CTK_Strings(void);void _Convert_UTF8_To_CTK_Strings(void);void _Convert_Big5_To_Unicode(void);void _Convert_Shift_JIS_To_Unicode(void);void _Convert_UTF8_To_Unicode(void);void _Change_Word_Direction(void);BYTE _SP_Autowrap(void);void _CHAR_SP_InitPalette(void);void _CHAR_SP_InitSPU(void);//void CHAR_SP_ClearRegion(void);void _CHAR_SP_DrawStrings(void);void _CHAR_SP_RecoverFunc(void); void _CHAR_SP_LoadSP(void);#if (FONT_TABLE_METHOD == CREATE_DYNAMICALLY)void _CHAR_SP_UseExSPFontTable(BOOL bUseExSPFontTable);#endif////////////////// Public functions //////////////////////////////////////void CHAR_SP_Initial(void){ __dwParResult_CharSP = PARSER_SPTXT_INVALID_RP; _pSP_HeaderPt = NULL; _pSP_LastHeaderPt = NULL; _CHAR_SP_InitPalette(); _CHAR_SP_StrAttr.bTextColor = CHAR_SP_ENTRY_COLOR_FG; _CHAR_SP_StrAttr.bBackground = CHAR_SP_ENTRY_COLOR_BG; _CHAR_SP_RectAttr.bColor = PAL_ENTRY_COLOR_TRANSPARENT; _CHAR_SP_RectAttr.rect.wLeft = CHAR_SP_REG_LEFT; _CHAR_SP_RectAttr.rect.wRight= CHAR_SP_REG_RIGHT; CHAR_SP_AdjustRegion();/*#if (FONT_TABLE_METHOD != CREATE_DYNAMICALLY) // Shift the index for each character set and only do once // After do it, set _aAsciiMappingTable[0][1] = 0xFFFF if (_aAsciiMappingTable[0][1] != 0xFFFF) {#ifdef ISO_8859_15_FONT for (__bTemp = 1; __bTemp < _a8859_15_MappingTable[0][0]; __bTemp++) _a8859_15_MappingTable[__bTemp][1] += OSD_FONT_NUM; #endif#ifdef ISO_8859_2_FONT for (__bTemp = 1; __bTemp < _a8859_2_MappingTable[0][0]; __bTemp++) _a8859_2_MappingTable[__bTemp][1] += OSD_FONT_NUM;#endif#ifdef ISO_8859_7_FONT for (__bTemp = 1; __bTemp < _a8859_7_MappingTable[0][0]; __bTemp++) _a8859_7_MappingTable[__bTemp][1] += OSD_FONT_NUM; #endif#ifdef ISO_8859_9_FONT for (__bTemp = 1; __bTemp < _a8859_9_MappingTable[0][0]; __bTemp++) _a8859_9_MappingTable[__bTemp][1] += OSD_FONT_NUM;#endif#ifdef CP_1251_FONT for (__bTemp = 1; __bTemp < _aCP_1251_MappingTable[0][0]; __bTemp++) _aCP_1251_MappingTable[__bTemp][1] += OSD_FONT_NUM; #endif _aAsciiMappingTable[0][1] = 0xFFFF; }#endif // #if (FONT_TABLE_METHOD != CREATE_DYNAMICALLY)*/ //CHAR_SP_ReplaceFont(); PARSER_SPTXT_SetFilter(SUPPORT_EX_SUBTITLE_FORMAT); _Char_SP_InputInfo.dwAddr = (DWORD) NULL; _Char_SP_InputInfo.dwLen = 0; _Char_SP_OutputInfo.dwAddr = (DWORD) NULL; _Char_SP_OutputInfo.dwLen = 0;}void CHAR_SP_ReplaceFont(void){/* switch (__SetupInfo.bExSPSTLanguage) {#ifdef ISO_8859_15_FONT case SETUP_LANGUAGE_EX_SP_WESTERN_EUROPEAN: _pwCurrentLocaleTable = (WORD*) (_a8859_15_MappingTable[0]);#ifdef SUPPORT_UTF8 _pwCurrentUnicodeTable = (WORD*) (_aUni_8859_15_MappingTable[0]);#endif OSD_AddFontToTable(FONTTABLE_8859_15); _bFontHeightInTable = ISO_8859_15_FONT_HEIGHT; break;#endif#ifdef ISO_8859_2_FONT case SETUP_LANGUAGE_EX_SP_CENTRAL_EUROPEAN: _pwCurrentLocaleTable = (WORD*) (_a8859_2_MappingTable[0]);#ifdef SUPPORT_UTF8 _pwCurrentUnicodeTable = (WORD*) (_aUni_8859_2_MappingTable[0]);#endif OSD_AddFontToTable(FONTTABLE_8859_2); _bFontHeightInTable = ISO_8859_2_FONT_HEIGHT; break;#endif#ifdef ISO_8859_7_FONT case SETUP_LANGUAGE_EX_SP_GREEK: _pwCurrentLocaleTable = (WORD*) (_a8859_7_MappingTable[0]);#ifdef SUPPORT_UTF8 _pwCurrentUnicodeTable = (WORD*) (_aUni_8859_7_MappingTable[0]);#endif OSD_AddFontToTable(FONTTABLE_8859_7); _bFontHeightInTable = ISO_8859_7_FONT_HEIGHT; break;#endif// elmer2.51, add Damon's code for Hebrew#ifdef ISO_8859_8_FONT case SETUP_LANGUAGE_EX_SP_HEBREW: _pwCurrentLocaleTable = (WORD*) (_a8859_8_MappingTable[0]);#ifdef SUPPORT_UTF8 _pwCurrentUnicodeTable = (WORD*) (_aUni_8859_8_MappingTable[0]);#endif OSD_AddFontToTable(FONTTABLE_8859_8); _bFontHeightInTable = ISO_8859_8_FONT_HEIGHT; break;#endif#ifdef ISO_8859_9_FONT case SETUP_LANGUAGE_EX_SP_TURKISH: _pwCurrentLocaleTable = (WORD*) (_a8859_9_MappingTable[0]);#ifdef SUPPORT_UTF8 _pwCurrentUnicodeTable = (WORD*) (_aUni_8859_9_MappingTable[0]);#endif OSD_AddFontToTable(FONTTABLE_8859_9); _bFontHeightInTable = ISO_8859_9_FONT_HEIGHT; break;#endif#ifdef CP_1250_FONT case SETUP_LANGUAGE_EX_SP_CP1250: _pwCurrentLocaleTable = (WORD*) (_aCP_1250_MappingTable[0]);#ifdef SUPPORT_UTF8 _pwCurrentUnicodeTable = (WORD*) (_aUni_8859_2_MappingTable[0]);#endif OSD_AddFontToTable(FONTTABLE_8859_2); _bFontHeightInTable = ISO_8859_2_FONT_HEIGHT; break;#endif#ifdef CP_1251_FONT case SETUP_LANGUAGE_EX_SP_CYRILLIC: _pwCurrentLocaleTable = (WORD*) (_aCP_1251_MappingTable[0]);#ifdef SUPPORT_UTF8 _pwCurrentUnicodeTable = (WORD*) (_aUni_CP_1251_MappingTable[0]);#endif OSD_AddFontToTable(FONTTABLE_CP_1251); _bFontHeightInTable = CP_1251_FONT_HEIGHT; break;#endif case SETUP_LANGUAGE_EX_SP_ASCII: default: _pwCurrentLocaleTable = (WORD*) (_aAsciiMappingTable[0]);#ifdef SUPPORT_UTF8 _pwCurrentUnicodeTable = (WORD*) (_aAsciiMappingTable[0]);#endif break; }*/}void CHAR_SP_ReloadFromTime(void){ if (! (PARSER_SPTXT_SUCCESS == __dwParResult_CharSP || PARSER_SPTXT_BUFFER_OVERFLOW == __dwParResult_CharSP)) { return; } _pSP_HeaderPt = (PPARSER_SPTXT_HEADER)_Char_SP_OutputInfo.dwAddr; PARSER_Command(0, PARSER_CMD_PAUSE, NULL); // wyc2.53-909P, SrcFilter_Stop(__dwSFStreamID); SrcFilter_ReadSectors(__dwSFStreamID, _dwSPStartSector, _dwSPEndSector); PARSER_SPTXT_initial(); __dwParResult_CharSP = PARSER_SPTXT(&_Char_SP_InputInfo, &_Char_SP_OutputInfo, __dwGoToTime * 90000, _dwSPType);// PARSER_Command(0, PARSER_CMD_RESUME, NULL);}////////////////// Private functions //////////////////////////////////////void _CHAR_SP_RecoverFunc(void){ CHAR_SP_Trigger();}void _CHAR_SP_LoadSP(void){ DWORD dwReadAVSector, dwSPSector, dwTime1; if (PARSER_SPTXT_SUCCESS == __dwParResult_CharSP) return; PARSER_Command(0, PARSER_CMD_PAUSE, NULL); dwTime1 = OS_GetSysTimer(); HAL_REORDER_BARRIER(); while ((OS_GetSysTimer() - dwTime1) < COUNT_2_SEC) { if(PARSER_QueryEvent(0, PARSER_EVENT_COMPLETED, TRUE)) { break; } } // save current read sector dwReadAVSector = PARSER_SPTXT_ReadSector(); dwSPSector = PARSER_SPTXT_SPSector(); SrcFilter_Stop(__dwSFStreamID); SrcFilter_ReadSectors(__dwSFStreamID, dwSPSector, _dwSPEndSector); __dwParResult_CharSP = PARSER_SPTXT(&_Char_SP_InputInfo, &_Char_SP_OutputInfo, 0, _dwSPType); SrcFilter_Stop(__dwSFStreamID); SrcFilter_ReadSectors(__dwSFStreamID, dwReadAVSector, __dwTimeEnd); _pSP_HeaderPt = (PPARSER_SPTXT_HEADER)_Char_SP_OutputInfo.dwAddr; PARSER_Command(0, PARSER_CMD_RESUME, NULL);}void CHAR_SP_Reset(void){#ifndef EX_SP_USE_SPU_BUFFER if (__bOSDDynamicRegion) { CHAR_SP_ClearRegion(); OSD_DeleteDynamicRegion(); }#endif if (PARSER_ESFMT_TEXT_SP_EXT == __SP1.ESFormat) { if (PARSER_SPTXT_SUCCESS == __dwParResult_CharSP || PARSER_SPTXT_BUFFER_OVERFLOW == __dwParResult_CharSP) { _pSP_HeaderPt = (PPARSER_SPTXT_HEADER)_Char_SP_OutputInfo.dwAddr;#ifdef EX_SP_USE_SPU_BUFFER _CHAR_SP_InitSPU();#endif } else { _pSP_HeaderPt = NULL; } } else if (PARSER_ESFMT_TEXT_SP == __SP1.ESFormat) { // Need to implement _pSP_HeaderPt = NULL; } _pSP_LastHeaderPt = NULL;}void CHAR_SP_AdjustRegion(void){#ifndef EX_SP_USE_SPU_BUFFER if (TRUE == __bOSDDynamicRegion)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -