From: longinus Date: Wed, 26 Jan 2011 02:41:26 +0000 (+0000) Subject: commit local dev ver X-Git-Url: http://git.osdn.net/view?p=rec10%2Frec10-git.git;a=commitdiff_plain;h=ee8ada2fa379bbb14427a790c1731ad9f00447d0 commit local dev ver git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@815 4e526526-5e11-4fc0-8910-f8fd03428081 --- diff --git a/epgdump/Makefile b/epgdump/Makefile index ab2ce18..8f2d778 100644 --- a/epgdump/Makefile +++ b/epgdump/Makefile @@ -1,11 +1,16 @@ PREFIX = /usr/local TARGETS = epgdump -OBJ_TARGETS = epgdump.o aribstr.o eit.o ts.o util.o sdt.o -HEDDERDEPEND = eit.h sdt.h aribstr.h ts.h util.h +OBJ_TARGETS = epgdump.o aribstr.o eit.o ts.o util.o psi.o sdt.o cdt.o sdtt.o dsmcc.o tot.o clt2png.o +HEDDERDEPEND = eit.h psi.h sdt.h cdt.h sdtt.h dsmcc.h tot.h clt2png.h aribstr.h ts.h util.h LANG = C CC = gcc -CFLAGS = -std=c99 -O2 -Wall -g + +#CFLAGS = -std=c99 -O2 -Wall -g +CFLAGS = -std=c99 -O0 -Wall -ggdb +#CFLAGS = -std=c99 -O2 -Wall -ggdb +#CFLAGS = -std=c99 -O2 -Wall -ggdb -lefence + LIBS = .c.o: ${CC} ${CFLAGS} -c $< diff --git a/epgdump/aribstr.c b/epgdump/aribstr.c index 1e736ea..44c62bf 100755 --- a/epgdump/aribstr.c +++ b/epgdump/aribstr.c @@ -6,7 +6,7 @@ #include "aribstr.h" -#define CODE_UNKNOWN 0 // ÉÔÌÀ¤Ê¥°¥é¥Õ¥£¥Ã¥¯¥»¥Ã¥È(ÈóÂбþ) +#define CODE_UNKNOWN 0 // 不明なグラフィックセット(非対応) #define CODE_KANJI 1 // Kanji #define CODE_ALPHANUMERIC 2 // Alphanumeric #define CODE_HIRAGANA 3 // Hiragana @@ -50,6 +50,7 @@ static const DWORD ProcessCharCode(TCHAR *lpszDst, const WORD wCode, const CODE_ static const DWORD PutKanjiChar(TCHAR *lpszDst, const WORD wCode); static const DWORD PutAlphanumericChar(TCHAR *lpszDst, const WORD wCode); +//static const DWORD PutAlphanumericHankakuChar(TCHAR *lpszDst, const WORD wCode); static const DWORD PutHiraganaChar(TCHAR *lpszDst, const WORD wCode); static const DWORD PutKatakanaChar(TCHAR *lpszDst, const WORD wCode); static const DWORD PutJisKatakanaChar(TCHAR *lpszDst, const WORD wCode); @@ -64,11 +65,9 @@ static void SingleShiftGL(const BYTE byIndexG); static const bool DesignationGSET(const BYTE byIndexG, const BYTE byCode); static const bool DesignationDRCS(const BYTE byIndexG, const BYTE byCode); -static WORD convertjis(DWORD); - static const bool abCharSizeTable[] = { - false, // CODE_UNKNOWN ÉÔÌÀ¤Ê¥°¥é¥Õ¥£¥Ã¥¯¥»¥Ã¥È(ÈóÂбþ) + false, // CODE_UNKNOWN 不明なグラフィックセット(非対応) true, // CODE_KANJI Kanji false, // CODE_ALPHANUMERIC Alphanumeric false, // CODE_HIRAGANA Hiragana @@ -86,6 +85,57 @@ static const bool abCharSizeTable[] = true // CODE_ADDITIONAL_SYMBOLS Additional symbols }; +typedef enum{ + STR_SMALL = 0, //SSZ + STR_MEDIUM, //MSZ + STR_NORMAL, //NSZ + STR_MICRO, //SZX 0x60 + STR_HIGH_W, //SZX 0x41 + STR_WIDTH_W, //SZX 0x44 + STR_W, //SZX 0x45 + STR_SPECIAL_1, //SZX 0x6B + STR_SPECIAL_2, //SZX 0x64 +} STRING_SIZE; + +STRING_SIZE m_emStrSize; + +bool IsSmallCharMode(void) +{ + bool bRet = false; + switch(m_emStrSize){ + case STR_SMALL: + bRet = true; + break; + case STR_MEDIUM: + bRet = true; + break; + case STR_NORMAL: + bRet = false; + break; + case STR_MICRO: + bRet = true; + break; + case STR_HIGH_W: + bRet = false; + break; + case STR_WIDTH_W: + bRet = false; + break; + case STR_W: + bRet = false; + break; + case STR_SPECIAL_1: + bRet = false; + break; + case STR_SPECIAL_2: + bRet = false; + break; + default: + break; + } + return bRet; +} + int AribToString( char *lpszDst, const char *pSrcData, @@ -104,7 +154,7 @@ const DWORD AribToStringInternal(TCHAR *lpszDst, DWORD dwDstLen = 0UL; int dwSrcData; - // ¾õÂÖ½é´üÀßÄê + // 状態初期設定 m_byEscSeqCount = 0U; m_pSingleGL = NULL; @@ -116,70 +166,82 @@ const DWORD AribToStringInternal(TCHAR *lpszDst, m_pLockingGL = &m_CodeG[0]; m_pLockingGR = &m_CodeG[2]; + m_emStrSize = STR_NORMAL; while(dwSrcPos < dwSrcLen){ dwSrcData = pSrcData[dwSrcPos] & 0xFF; + //printf("Arib:pos%d:%d:%s\n",dwSrcPos,dwSrcData,lpszDst); if(!m_byEscSeqCount){ - // GL/GRÎΰè + // GL/GR領域 if((dwSrcData >= 0x21U) && (dwSrcData <= 0x7EU)){ - // GLÎΰè + // GL領域 const CODE_SET CurCodeSet = (m_pSingleGL)? *m_pSingleGL : *m_pLockingGL; m_pSingleGL = NULL; if(abCharSizeTable[CurCodeSet]){ - // 2¥Ð¥¤¥È¥³¡¼¥É + // 2バイトコード if((dwSrcLen - dwSrcPos) < 2UL)break; dwDstLen += ProcessCharCode(&lpszDst[dwDstLen], ((WORD)pSrcData[dwSrcPos + 0] << 8) | (WORD)pSrcData[dwSrcPos + 1], CurCodeSet); dwSrcPos++; } else{ - // 1¥Ð¥¤¥È¥³¡¼¥É + // 1バイトコード dwDstLen += ProcessCharCode(&lpszDst[dwDstLen], (WORD)dwSrcData, CurCodeSet); } } else if((dwSrcData >= 0xA1U) && (dwSrcData <= 0xFEU)){ - // GRÎΰè + // GR領域 const CODE_SET CurCodeSet = *m_pLockingGR; if(abCharSizeTable[CurCodeSet]){ - // 2¥Ð¥¤¥È¥³¡¼¥É + // 2バイトコード if((dwSrcLen - dwSrcPos) < 2UL)break; dwDstLen += ProcessCharCode(&lpszDst[dwDstLen], ((WORD)(pSrcData[dwSrcPos + 0] & 0x7FU) << 8) | (WORD)(pSrcData[dwSrcPos + 1] & 0x7FU), CurCodeSet); dwSrcPos++; } else{ - // 1¥Ð¥¤¥È¥³¡¼¥É + // 1バイトコード dwDstLen += ProcessCharCode(&lpszDst[dwDstLen], (WORD)(dwSrcData & 0x7FU), CurCodeSet); } } else{ - // À©¸æ¥³¡¼¥É + // 制御コード switch(dwSrcData){ case 0x0FU : LockingShiftGL(0U); break; // LS0 case 0x0EU : LockingShiftGL(1U); break; // LS1 case 0x19U : SingleShiftGL(2U); break; // SS2 case 0x1DU : SingleShiftGL(3U); break; // SS3 case 0x1BU : m_byEscSeqCount = 1U; break; // ESC + case 0x89U : m_emStrSize = STR_MEDIUM; break; // MSZ + case 0x8AU : m_emStrSize = STR_NORMAL; break; // NSZ case 0x20U : - case 0xA0U : lpszDst[dwDstLen++] = TEXT(' '); break; // SP - default : break; // ÈóÂбþ + case 0xA0U : + //SP 空白 + //空白は文字サイズの影響あり + if( IsSmallCharMode() == false ){ + strcpy(&lpszDst[dwDstLen], " "); + dwDstLen += 3U; + } else { + lpszDst[dwDstLen++] = TEXT(' '); + } + break; + default : break; // 非対応 } } } else{ - // ¥¨¥¹¥±¡¼¥×¥·¡¼¥±¥ó¥¹½èÍý + // エスケープシーケンス処理 ProcessEscapeSeq(dwSrcData); } dwSrcPos++; } - // ½ªÃ¼Ê¸»ú + // 終端文字 lpszDst[dwDstLen] = TEXT('\0'); - return dwDstLen; } @@ -189,32 +251,39 @@ const DWORD ProcessCharCode(TCHAR *lpszDst, const WORD wCode, const CODE_SET Cod case CODE_KANJI : case CODE_JIS_KANJI_PLANE_1 : case CODE_JIS_KANJI_PLANE_2 : - // ´Á»ú¥³¡¼¥É½ÐÎÏ + // 漢字コード出力 return PutKanjiChar(lpszDst, wCode); case CODE_ALPHANUMERIC : case CODE_PROP_ALPHANUMERIC : - // ±Ñ¿ô»ú¥³¡¼¥É½ÐÎÏ + // 英数字コード出力 + if( IsSmallCharMode() == false ){ + //全角テーブルコード取得 return PutAlphanumericChar(lpszDst, wCode); + } else { + //半角はそのまま出力 + lpszDst[0] = wCode; + return 1UL; + } case CODE_HIRAGANA : case CODE_PROP_HIRAGANA : - // ¤Ò¤é¤¬¤Ê¥³¡¼¥É½ÐÎÏ + // ひらがなコード出力 return PutHiraganaChar(lpszDst, wCode); case CODE_PROP_KATAKANA : case CODE_KATAKANA : - // ¥«¥¿¥«¥Ê¥³¡¼¥É½ÐÎÏ + // カタカナコード出力 return PutKatakanaChar(lpszDst, wCode); case CODE_JIS_X0201_KATAKANA : - // JIS¥«¥¿¥«¥Ê¥³¡¼¥É½ÐÎÏ + // JISカタカナコード出力 return PutJisKatakanaChar(lpszDst, wCode); -#if 1 + case CODE_ADDITIONAL_SYMBOLS : - // Äɲå·¥ó¥Ü¥ë¥³¡¼¥É½ÐÎÏ + // 追加シンボルコード出力 return PutSymbolsChar(lpszDst, wCode); -#endif + default : return 0UL; } @@ -222,185 +291,232 @@ const DWORD ProcessCharCode(TCHAR *lpszDst, const WORD wCode, const CODE_SET Cod const DWORD PutKanjiChar(TCHAR *lpszDst, const WORD wCode) { - // JIS¢ªShift-JIS´Á»ú¥³¡¼¥ÉÊÑ´¹ - const WORD wShiftJIS = convertjis(wCode); + char code[9]; + char xcode[5]; + iconv_t cd; -#ifdef _UNICODE - // Shift-JIS ¢ª UNICODE - const char szShiftJIS[3] = {(char)(wShiftJIS >> 8), (char)(wShiftJIS & 0x00FFU), '\0'}; - ::MultiByteToWideChar(CP_OEMCP, MB_PRECOMPOSED, szShiftJIS, 2, lpszDst, 2); + size_t inbyte = 8; + size_t outbyte = sizeof(xcode); - return 1UL; -#else - // Shift-JIS ¢ª Shift-JIS - lpszDst[0] = (wShiftJIS >> 8) & 0xFF; - lpszDst[1] = (char)(wShiftJIS & 0x00FFU); + memset(xcode, '\0', sizeof(xcode)); - return 2UL; -#endif + const char *fptr; + char *tptr; + + code[0] = 0x1BU; + code[1] = 0x24U; + code[2] = 0x40U; + code[3] = wCode >> 8; + code[4] = wCode & 0xFF; + code[5] = 0x1BU; + code[6] = 0x28U; + code[7] = 0x4AU; + code[8] = '\0'; + + cd = iconv_open("UTF-8","ISO-2022-JP"); + + fptr = code; + tptr = xcode; + iconv(cd, &fptr, &inbyte, &tptr, &outbyte); + + iconv_close(cd); + + strncpy(lpszDst, xcode, strlen(xcode)); + + return strlen(lpszDst); } const DWORD PutAlphanumericChar(TCHAR *lpszDst, const WORD wCode) { - // ±Ñ¿ô»úʸ»ú¥³¡¼¥ÉÊÑ´¹ + // 英数字全角文字コード変換 static const TCHAR *acAlphanumericTable = - TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡") - TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡") - TEXT("¡¡¡ª¡É¡ô¡ð¡ó¡õ¡Ç¡Ê¡Ë¡ö¡Ü¡¤¡Ý¡¥¡¿") - TEXT("£°£±£²£³£´£µ£¶£·£¸£¹¡§¡¨¡ã¡á¡ä¡©") - TEXT("¡÷£Á£Â£Ã£Ä£Å£Æ£Ç£È£É£Ê£Ë£Ì£Í£Î£Ï") - TEXT("£Ð£Ñ£Ò£Ó£Ô£Õ£Ö£×£Ø£Ù£Ú¡Î¡ï¡Ï¡°¡²") - TEXT("¡¡£á£â£ã£ä£å£æ£ç£è£é£ì£ë£ì£í£î£ï") - TEXT("£ð£ñ£ò£ó£ô£õ£ö£÷£ø£ù£ú¡Ð¡Ã¡Ñ¡±¡¡"); + TEXT("                ") + TEXT("                ") + TEXT(" !”#$%&’()*+,-./") + TEXT("0123456789:;<=>?") + TEXT("@ABCDEFGHIJKLMNO") + TEXT("PQRSTUVWXYZ[¥]^_") + TEXT(" abcdefghijklmno") + TEXT("pqrstuvwxyz{|} ̄ "); #ifdef _UNICODE - lpszDst[0] = acAlphanumericTable[wCode]; + lpszDst[0] = acAlphanumericTableZenkaku[wCode]; return 1UL; #else - lpszDst[0] = acAlphanumericTable[wCode * 2U + 0U]; - lpszDst[1] = acAlphanumericTable[wCode * 2U + 1U]; + lpszDst[0] = acAlphanumericTable[wCode * 3U + 0U]; + lpszDst[1] = acAlphanumericTable[wCode * 3U + 1U]; + lpszDst[2] = acAlphanumericTable[wCode * 3U + 2U]; - return 2UL; + return 3UL; #endif } const DWORD PutHiraganaChar(TCHAR *lpszDst, const WORD wCode) { - // ¤Ò¤é¤¬¤Êʸ»ú¥³¡¼¥ÉÊÑ´¹ + // ひらがな文字コード変換 static const TCHAR *acHiraganaTable = - TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡") - TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡") - TEXT("¡¡¤¡¤¢¤£¤¤¤¥¤¦¤§¤¨¤©¤ª¤«¤¬¤­¤®¤¯") - TEXT("¤°¤±¤²¤³¤´¤µ¤¶¤·¤¸¤¹¤º¤»¤¼¤½¤¾¤¿") - TEXT("¤À¤Á¤Â¤Ã¤Ä¤Å¤Æ¤Ç¤È¤É¤Ê¤Ë¤Ì¤Í¤Î¤Ï") - TEXT("¤Ð¤Ñ¤Ò¤Ó¤Ô¤Õ¤Ö¤×¤Ø¤Ù¤Ú¤Û¤Ü¤Ý¤Þ¤ß") - TEXT("¤à¤á¤â¤ã¤ä¤å¤æ¤ç¤è¤é¤ê¤ë¤ì¤í¤î¤ï") - TEXT("¤ð¤ñ¤ò¤ó¡¡¡¡¡¡¡µ¡¶¡¼¡£¡Ö¡×¡¢¡¦¡¡"); + TEXT("                ") + TEXT("                ") + TEXT(" ぁあぃいぅうぇえぉおかがきぎく") + TEXT("ぐけげこごさざしじすずせぜそぞた") + TEXT("だちぢっつづてでとどなにぬねのは") + TEXT("ばぱひびぴふぶぷへべぺほぼぽまみ") + TEXT("むめもゃやゅゆょよらりるれろゎわ") + TEXT("ゐゑをん   ゝゞー。「」、・ "); #ifdef _UNICODE lpszDst[0] = acHiraganaTable[wCode]; return 1UL; #else - lpszDst[0] = acHiraganaTable[wCode * 2U + 0U]; - lpszDst[1] = acHiraganaTable[wCode * 2U + 1U]; + lpszDst[0] = acHiraganaTable[wCode * 3U + 0U]; + lpszDst[1] = acHiraganaTable[wCode * 3U + 1U]; + lpszDst[2] = acHiraganaTable[wCode * 3U + 2U]; - return 2UL; + return 3UL; #endif } const DWORD PutKatakanaChar(TCHAR *lpszDst, const WORD wCode) { - // ¥«¥¿¥«¥Ê±Ñ¿ô»úʸ»ú¥³¡¼¥ÉÊÑ´¹ + // カタカナ英数字文字コード変換 static const TCHAR *acKatakanaTable = - TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡") - TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡") - TEXT("¡¡¥¡¥¢¥£¥¤¥¥¥¦¥§¥¨¥©¥ª¥«¥¬¥­¥®¥¯") - TEXT("¥°¥±¥²¥³¥´¥µ¥¶¥·¥¸¥¹¥º¥»¥¼¥½¥¾¥¿") - TEXT("¥À¥Á¥Â¥Ã¥Ä¥Å¥Æ¥Ç¥È¥É¥Ê¥Ë¥Ì¥Í¥Î¥Ï") - TEXT("¥Ð¥Ñ¥Ò¥Ó¥Ô¥Õ¥Ö¥×¥Ø¥Ù¥Ú¥Û¥Ü¥Ý¥Þ¥ß") - TEXT("¥à¥á¥â¥ã¥ä¥å¥æ¥ç¥è¥é¥ê¥ë¥ì¥í¥î¥ï") - TEXT("¥ð¥ñ¥ò¥ó¥ô¥õ¥ö¡³¡´¡¼¡£¡Ö¡×¡¢¡¦¡¡"); + TEXT("                ") + TEXT("                ") + TEXT(" ァアィイゥウェエォオカガキギク") + TEXT("グケゲコゴサザシジスズセゼソゾタ") + TEXT("ダチヂッツヅテデトドナニヌネノハ") + TEXT("バパヒビピフブプヘベペホボポマミ") + TEXT("ムメモャヤュユョヨラリルレロヮワ") + TEXT("ヰヱヲンヴヵヶヽヾー。「」、・ "); #ifdef _UNICODE lpszDst[0] = acKatakanaTable[wCode]; return 1UL; #else - lpszDst[0] = acKatakanaTable[wCode * 2U + 0U]; - lpszDst[1] = acKatakanaTable[wCode * 2U + 1U]; + lpszDst[0] = acKatakanaTable[wCode * 3U + 0U]; + lpszDst[1] = acKatakanaTable[wCode * 3U + 1U]; + lpszDst[2] = acKatakanaTable[wCode * 3U + 2U]; - return 2UL; + return 3UL; #endif } const DWORD PutJisKatakanaChar(TCHAR *lpszDst, const WORD wCode) { - // JIS¥«¥¿¥«¥Êʸ»ú¥³¡¼¥ÉÊÑ´¹ + // JISカタカナ文字コード変換 static const TCHAR *acJisKatakanaTable = - TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡") - TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡") - TEXT("¡¡¡£¡Ö¡×¡¢¡¦¥ò¥¡¥£¥¥¥§¥©¥ã¥å¥ç¥Ã") - TEXT("¡¼¥¢¥¤¥¦¥¨¥ª¥«¥­¥¯¥±¥³¥µ¥·¥¹¥»¥½") - TEXT("¥¿¥Á¥Ä¥Æ¥È¥Ê¥Ë¥Ì¥Í¥Î¥Ï¥Ò¥Õ¥Ø¥Û¥Þ") - TEXT("¥ß¥à¥á¥â¥ä¥æ¥è¥é¥ê¥ë¥ì¥í¥ï¥ó¡«¡¬") - TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡") - TEXT("¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡"); + TEXT("                ") + TEXT("                ") + TEXT(" 。「」、・ヲァィゥェォャュョッ") + TEXT("ーアイウエオカキクケコサシスセソ") + TEXT("タチツテトナニヌネノハヒフヘホマ") + TEXT("ミムメモヤユヨラリルレロワン゛゜") + TEXT("                ") + TEXT("                "); #ifdef _UNICODE lpszDst[0] = acJisKatakanaTable[wCode]; return 1UL; #else - lpszDst[0] = acJisKatakanaTable[wCode * 2U + 0U]; - lpszDst[1] = acJisKatakanaTable[wCode * 2U + 1U]; + lpszDst[0] = acJisKatakanaTable[wCode * 3U + 0U]; + lpszDst[1] = acJisKatakanaTable[wCode * 3U + 1U]; + lpszDst[2] = acJisKatakanaTable[wCode * 3U + 2U]; - return 2UL; + return 3UL; #endif } const DWORD PutSymbolsChar(TCHAR *lpszDst, const WORD wCode) { - // Äɲå·¥ó¥Ü¥ëʸ»ú¥³¡¼¥ÉÊÑ´¹(¤È¤ê¤¢¤¨¤ºÉ¬Íפ½¤¦¤Ê¤â¤Î¤À¤±) + // 追加シンボル文字コード変換(とりあえず必要そうなものだけ) static const TCHAR *aszSymbolsTable1[] = { - _T("[HV]"), _T("[SD]"), _T("[£Ð]"), _T("[£×]"), _T("[MV]"), _T("[¼ê]"), _T("[»ú]"), _T("[ÁÐ]"), // 0x7A50 - 0x7A57 90/48 - 90/55 - _T("[¥Ç]"), _T("[£Ó]"), _T("[Æó]"), _T("[¿]"), _T("[²ò]"), _T("[SS]"), _T("[£Â]"), _T("[£Î]"), // 0x7A58 - 0x7A5F 90/56 - 90/63 - _T("¢£"), _T("¡ü"), _T("[Å·]"), _T("[¸ò]"), _T("[±Ç]"), _T("[̵]"), _T("[ÎÁ]"), _T("[ǯÎðÀ©¸Â]"), // 0x7A60 - 0x7A67 90/64 - 90/71 - _T("[Á°]"), _T("[¸å]"), _T("[ºÆ]"), _T("[¿·]"), _T("[½é]"), _T("[½ª]"), _T("[À¸]"), _T("[ÈÎ]"), // 0x7A68 - 0x7A6F 90/72 - 90/79 - _T("[À¼]"), _T("[¿á]"), _T("[PPV]"), _T("(Èë)"), _T("¤Û¤«") // 0x7A70 - 0x7A74 90/80 - 90/84 + _T("[HV]"), _T("[SD]"), _T("[ï¼°]"), _T("[ï¼·]"), _T("[MV]"), _T("[手]"), _T("[字]"), _T("[双]"), // 0x7A50 - 0x7A57 90/48 - 90/55 + _T("[デ]"), _T("[ï¼³]"), _T("[二]"), _T("[多]"), _T("[解]"), _T("[SS]"), _T("[ï¼¢]"), _T("[ï¼®]"), // 0x7A58 - 0x7A5F 90/56 - 90/63 + _T("■"), _T("●"), _T("[天]"), _T("[交]"), _T("[映]"), _T("[無]"), _T("[料]"), _T("[年齢制限]"), // 0x7A60 - 0x7A67 90/64 - 90/71 + _T("[前]"), _T("[後]"), _T("[再]"), _T("[新]"), _T("[初]"), _T("[終]"), _T("[生]"), _T("[販]"), // 0x7A68 - 0x7A6F 90/72 - 90/79 + _T("[声]"), _T("[吹]"), _T("[PPV]"), _T("(秘)"), _T("ほか") // 0x7A70 - 0x7A74 90/80 - 90/84 }; static const TCHAR *aszSymbolsTable2[] = { - _T("¢ª"), _T("¢«"), _T("¢¬"), _T("¢­"), _T("¡ü"), _T("¡û"), _T("ǯ"), _T("·î"), // 0x7C21 - 0x7C28 92/01 - 92/08 - _T("Æü"), _T("±ß"), _T("­Ö"), _T("ΩÊý£í"), _T("­Ñ"), _T("Ê¿Êý­Ñ"), _T("ΩÊý­Ñ"), _T("£°."), // 0x7C29 - 0x7C30 92/09 - 92/16 - _T("£±."), _T("£²."), _T("£³."), _T("£´."), _T("£µ."), _T("£¶."), _T("£·."), _T("£¸."), // 0x7C31 - 0x7C38 92/17 - 92/24 - _T("£¹."), _T("»á"), _T("Éû"), _T("¸µ"), _T("¸Î"), _T("Á°"), _T("¿·"), _T("£°,"), // 0x7C39 - 0x7C40 92/25 - 92/32 - _T("£±,"), _T("£²,"), _T("£³,"), _T("£´,"), _T("£µ,"), _T("£¶,"), _T("£·,"), _T("£¸,"), // 0x7C41 - 0x7C48 92/33 - 92/40 - _T("£¹,"), _T("(¼Ò)"), _T("(ºâ)"), _T("(Í­)"), _T("(³ô)"), _T("(Âå)"), _T("(Ìä)"), _T("¡ä"), // 0x7C49 - 0x7C50 92/41 - 92/48 - _T("¡ã"), _T("¡Ú"), _T("¡Û"), _T("¡þ"), _T("^2"), _T("^3"), _T("(CD)"), _T("(vn)"), // 0x7C51 - 0x7C58 92/49 - 92/56 + _T("→"), _T("←"), _T("↑"), _T("↓"), _T("●"), _T("○"), _T("å¹´"), _T("月"), // 0x7C21 - 0x7C28 92/01 - 92/08 + _T("日"), _T("円"), _T("㎡"), _T("㎥"), _T("㎝"), _T("㎠"), _T("㎤"), _T("0."), // 0x7C29 - 0x7C30 92/09 - 92/16 + _T("1."), _T("2."), _T("3."), _T("4."), _T("5."), _T("6."), _T("7."), _T("8."), // 0x7C31 - 0x7C38 92/17 - 92/24 + _T("9."), _T("氏"), _T("副"), _T("元"), _T("故"), _T("前"), _T("新"), _T("0,"), // 0x7C39 - 0x7C40 92/25 - 92/32 + _T("1,"), _T("2,"), _T("3,"), _T("4,"), _T("5,"), _T("6,"), _T("7,"), _T("8,"), // 0x7C41 - 0x7C48 92/33 - 92/40 + _T("9,"), _T("(社)"), _T("(財)"), _T("(有)"), _T("(æ ª)"), _T("(代)"), _T("(問)"), _T("▶"), // 0x7C49 - 0x7C50 92/41 - 92/48 + _T("◀"), _T("〖"), _T("〗"), _T("⟐"), _T("^2"), _T("^3"), _T("(CD)"), _T("(vn)"), // 0x7C51 - 0x7C58 92/49 - 92/56 _T("(ob)"), _T("(cb)"), _T("(ce"), _T("mb)"), _T("(hp)"), _T("(br)"), _T("(p)"), _T("(s)"), // 0x7C59 - 0x7C60 92/57 - 92/64 _T("(ms)"), _T("(t)"), _T("(bs)"), _T("(b)"), _T("(tb)"), _T("(tp)"), _T("(ds)"), _T("(ag)"), // 0x7C61 - 0x7C68 92/65 - 92/72 _T("(eg)"), _T("(vo)"), _T("(fl)"), _T("(ke"), _T("y)"), _T("(sa"), _T("x)"), _T("(sy"), // 0x7C69 - 0x7C70 92/73 - 92/80 - _T("n)"), _T("(or"), _T("g)"), _T("(pe"), _T("r)"), _T("(R)"), _T("(C)"), _T("(ä·)"), // 0x7C71 - 0x7C78 92/81 - 92/88 - _T("DJ"), _T("[±é]"), _T("Fax") // 0x7C79 - 0x7C7B 92/89 - 92/91 + _T("n)"), _T("(or"), _T("g)"), _T("(pe"), _T("r)"), _T("(R)"), _T("(C)"), _T("(箏)"), // 0x7C71 - 0x7C78 92/81 - 92/88 + _T("DJ"), _T("[演]"), _T("Fax") // 0x7C79 - 0x7C7B 92/89 - 92/91 }; static const TCHAR *aszSymbolsTable3[] = { - _T("(·î)"), _T("(²Ð)"), _T("(¿å)"), _T("(ÌÚ)"), _T("(¶â)"), _T("(ÅÚ)"), _T("(Æü)"), _T("(½Ë)"), // 0x7D21 - 0x7D28 93/01 - 93/08 - _T("­í"), _T("­î"), _T("­ï"), _T("­ß"), _T("­â"), _T("­ä"), _T("(¢©)"), _T("¡û"), // 0x7D29 - 0x7D30 93/09 - 93/16 - _T("¡ÌËÜ¡Í"), _T("¡Ì»°¡Í"), _T("¡ÌÆó¡Í"), _T("¡Ì°Â¡Í"), _T("¡ÌÅÀ¡Í"), _T("¡ÌÂÇ¡Í"), _T("¡ÌÅð¡Í"), _T("¡Ì¾¡¡Í"), // 0x7D31 - 0x7D38 93/17 - 93/24 - _T("¡ÌÇÔ¡Í"), _T("¡Ì£Ó¡Í"), _T("¡ÎÅê¡Ï"), _T("¡ÎÊá¡Ï"), _T("¡Î°ì¡Ï"), _T("¡ÎÆó¡Ï"), _T("¡Î»°¡Ï"), _T("¡ÎÍ·¡Ï"), // 0x7D39 - 0x7D40 93/25 - 93/32 - _T("¡Îº¸¡Ï"), _T("¡ÎÃæ¡Ï"), _T("¡Î±¦¡Ï"), _T("¡Î»Ø¡Ï"), _T("¡ÎÁö¡Ï"), _T("¡ÎÂÇ¡Ï"), _T("­È"), _T("­Ô"), // 0x7D41 - 0x7D48 93/33 - 93/40 - _T("Hz"), _T("ha"), _T("km"), _T("Ê¿Êýkm"), _T("hPa"), _T("¡¦"), _T("¡¦"), _T("1/2"), // 0x7D49 - 0x7D50 93/41 - 93/48 + _T("㈪"), _T("㈫"), _T("㈬"), _T("㈭"), _T("㈮"), _T("㈯"), _T("㈰"), _T("㈷"), // 0x7D21 - 0x7D28 93/01 - 93/08 + _T("㍾"), _T("㍽"), _T("㍼"), _T("㍻"), _T("№"), _T("℡"), _T("〶"), _T("○"), // 0x7D29 - 0x7D30 93/09 - 93/16 + _T("〔本〕"), _T("〔三〕"), _T("〔二〕"), _T("〔安〕"), _T("〔点〕"), _T("〔打〕"), _T("〔盗〕"), _T("〔勝〕"), // 0x7D31 - 0x7D38 93/17 - 93/24 + _T("〔敗〕"), _T("〔S〕"), _T("[投]"), _T("[捕]"), _T("[一]"), _T("[二]"), _T("[三]"), _T("[遊]"), // 0x7D39 - 0x7D40 93/25 - 93/32 + _T("[左]"), _T("[中]"), _T("[右]"), _T("[指]"), _T("[走]"), _T("[打]"), _T("㍑"), _T("㎏"), // 0x7D41 - 0x7D48 93/33 - 93/40 + _T("㎐"), _T("ha"), _T("㎞"), _T("㎢"), _T("㍱"), _T("・"), _T("・"), _T("1/2"), // 0x7D49 - 0x7D50 93/41 - 93/48 _T("0/3"), _T("1/3"), _T("2/3"), _T("1/4"), _T("3/4"), _T("1/5"), _T("2/5"), _T("3/5"), // 0x7D51 - 0x7D58 93/49 - 93/56 - _T("4/5"), _T("1/6"), _T("5/6"), _T("1/7"), _T("1/8"), _T("1/9"), _T("1/10"), _T("À²¤ì"), // 0x7D59 - 0x7D60 93/57 - 93/64 - _T("ÆÞ¤ê"), _T("±«"), _T("Àã"), _T("¢¤"), _T("¢¥"), _T("¢¦"), _T("¢§"), _T("¢¡"), // 0x7D61 - 0x7D68 93/65 - 93/72 - _T("¡¦"), _T("¡¦"), _T("¡¦"), _T("¡þ"), _T("¡ý"), _T("!!"), _T("!?"), _T("ÆÞ/À²"), // 0x7D69 - 0x7D70 93/73 - 93/80 - _T("±«"), _T("±«"), _T("Àã"), _T("ÂçÀã"), _T("Íë"), _T("Í뱫"), _T("¡¡"), _T("¡¦"), // 0x7D71 - 0x7D78 93/81 - 93/88 - _T("¡¦"), _T("¢ö"), _T("­ä") // 0x7D79 - 0x7D7B 93/89 - 93/91 + _T("4/5"), _T("1/6"), _T("5/6"), _T("1/7"), _T("1/8"), _T("1/9"), _T("1/10"), _T("☀"), // 0x7D59 - 0x7D60 93/57 - 93/64 + _T("☁"), _T("☂"), _T("☃"), _T("☖"), _T("☗"), _T("▽"), _T("▼"), _T("♦"), // 0x7D61 - 0x7D68 93/65 - 93/72 + _T("♥"), _T("♣"), _T("♠"), _T("⌺"), _T("⦿"), _T("‼"), _T("⁉"), _T("(曇/晴)"), // 0x7D69 - 0x7D70 93/73 - 93/80 + _T("☔"), _T("(雨)"), _T("(雪)"), _T("(大雪)"), _T("⚡"), _T("(雷雨)"), _T(" "), _T("・"), // 0x7D71 - 0x7D78 93/81 - 93/88 + _T("・"), _T("♬"), _T("☎") // 0x7D79 - 0x7D7B 93/89 - 93/91 }; static const TCHAR *aszSymbolsTable4[] = { - _T("­µ"), _T("­¶"), _T("­·"), _T("­¸"), _T("­¹"), _T("­º"), _T("­»"), _T("­¼"), // 0x7E21 - 0x7E28 94/01 - 94/08 - _T("­½"), _T("­¾"), _T("XI"), _T("X­¶"), _T("­±"), _T("­²"), _T("­³"), _T("­´"), // 0x7E29 - 0x7E30 94/09 - 94/16 - _T("(1)"), _T("(2)"), _T("(3)"), _T("(4)"), _T("(5)"), _T("(6)"), _T("(7)"), _T("(8)"), // 0x7E31 - 0x7E38 94/17 - 94/24 - _T("(9)"), _T("(10)"), _T("(11)"), _T("(12)"), _T("(21)"), _T("(22)"), _T("(23)"), _T("(24)"), // 0x7E39 - 0x7E40 94/25 - 94/32 + _T("Ⅰ"), _T("Ⅱ"), _T("Ⅲ"), _T("Ⅳ"), _T("Ⅴ"), _T("Ⅵ"), _T("Ⅶ"), _T("Ⅷ"), // 0x7E21 - 0x7E28 94/01 - 94/08 + _T("Ⅸ"), _T("Ⅹ"), _T("Ⅺ"), _T("Ⅻ"), _T("⑰"), _T("⑱"), _T("⑲"), _T("⑳"), // 0x7E29 - 0x7E30 94/09 - 94/16 + _T("⑴"), _T("⑵"), _T("⑶"), _T("⑷"), _T("⑸"), _T("⑹"), _T("⑺"), _T("⑻"), // 0x7E31 - 0x7E38 94/17 - 94/24 + _T("⑼"), _T("⑽"), _T("⑾"), _T("⑿"), _T("㉑"), _T("㉒"), _T("㉓"), _T("㉔"), // 0x7E39 - 0x7E40 94/25 - 94/32 _T("(A)"), _T("(B)"), _T("(C)"), _T("(D)"), _T("(E)"), _T("(F)"), _T("(G)"), _T("(H)"), // 0x7E41 - 0x7E48 94/33 - 94/40 _T("(I)"), _T("(J)"), _T("(K)"), _T("(L)"), _T("(M)"), _T("(N)"), _T("(O)"), _T("(P)"), // 0x7E49 - 0x7E50 94/41 - 94/48 _T("(Q)"), _T("(R)"), _T("(S)"), _T("(T)"), _T("(U)"), _T("(V)"), _T("(W)"), _T("(X)"), // 0x7E51 - 0x7E58 94/49 - 94/56 - _T("(Y)"), _T("(Z)"), _T("(25)"), _T("(26)"), _T("(27)"), _T("(28)"), _T("(29)"), _T("(30)"), // 0x7E59 - 0x7E60 94/57 - 94/64 - _T("­¡"), _T("­¢"), _T("­£"), _T("­¤"), _T("­¥"), _T("­¦"), _T("­§"), _T("­¨"), // 0x7E61 - 0x7E68 94/65 - 94/72 - _T("­©"), _T("­ª"), _T("­«"), _T("­¬"), _T("­­"), _T("­®"), _T("­¯"), _T("­°"), // 0x7E69 - 0x7E70 94/73 - 94/80 - _T("­¡"), _T("­¢"), _T("­£"), _T("­¤"), _T("­¥"), _T("­¦"), _T("­§"), _T("­¨"), // 0x7E71 - 0x7E78 94/81 - 94/88 - _T("­©"), _T("­ª"), _T("­«"), _T("­¬"), _T("(31)") // 0x7E79 - 0x7E7D 94/89 - 94/93 + _T("(Y)"), _T("(Z)"), _T("㉕"), _T("㉖"), _T("㉗"), _T("㉘"), _T("㉙"), _T("㉚"), // 0x7E59 - 0x7E60 94/57 - 94/64 + _T("①"), _T("②"), _T("③"), _T("④"), _T("⑤"), _T("⑥"), _T("⑦"), _T("⑧"), // 0x7E61 - 0x7E68 94/65 - 94/72 + _T("⑨"), _T("⑩"), _T("⑪"), _T("⑫"), _T("⑬"), _T("⑭"), _T("⑮"), _T("⑯"), // 0x7E69 - 0x7E70 94/73 - 94/80 + _T("❶"), _T("❷"), _T("❸"), _T("❹"), _T("❺"), _T("❻"), _T("❼"), _T("❽"), // 0x7E71 - 0x7E78 94/81 - 94/88 + _T("❾"), _T("❿"), _T("⓫"), _T("⓬"), _T("㉛") // 0x7E79 - 0x7E7D 94/89 - 94/93 }; - // ¥·¥ó¥Ü¥ë¤òÊÑ´¹¤¹¤ë + static const TCHAR *aszSymbolsTable5[] = + { + _T("㐂"), _T("亭"), _T("份"), _T("仿"), _T("侚"), _T("俉"), _T("傜"), _T("儞"), // 0x7521 - 0x7528 85/01 - 85/08 + _T("冼"), _T("㔟"), _T("匇"), _T("卡"), _T("卬"), _T("詹"), _T("吉"), _T("呍"), // 0x7529 - 0x7530 85/09 - 85/16 + _T("咖"), _T("咜"), _T("咩"), _T("唎"), _T("啊"), _T("噲"), _T("囤"), _T("圳"), // 0x7531 - 0x7538 85/17 - 85/24 + _T("圴"), _T("塚"), _T("墀"), _T("姤"), _T("娣"), _T("婕"), _T("寬"), _T("﨑"), // 0x7539 - 0x7540 85/25 - 85/32 + _T("㟢"), _T("庬"), _T("å¼´"), _T("彅"), _T("å¾·"), _T("怗"), _T("恵"), _T("愰"), // 0x7541 - 0x7548 85/33 - 85/40 + _T("昤"), _T("曈"), _T("曙"), _T("曺"), _T("曻"), _T("桒"), _T("・"), _T("椑"), // 0x7549 - 0x7550 85/41 - 85/48 + _T("椻"), _T("橅"), _T("檑"), _T("櫛"), _T("・"), _T("・"), _T("・"), _T("毱"), // 0x7551 - 0x7558 85/49 - 85/56 + _T("æ³ "), _T("æ´®"), _T("海"), _T("涿"), _T("淊"), _T("æ·¸"), _T("渚"), _T("潞"), // 0x7559 - 0x7560 85/57 - 85/64 + _T("濹"), _T("灤"), _T("・"), _T("・"), _T("煇"), _T("燁"), _T("爀"), _T("玟"), // 0x7561 - 0x7568 85/65 - 85/72 + _T("・"), _T("珉"), _T("珖"), _T("琛"), _T("琡"), _T("琢"), _T("琦"), _T("琪"), // 0x7569 - 0x7570 85/73 - 85/80 + _T("琬"), _T("琹"), _T("瑋"), _T("㻚"), _T("畵"), _T("疁"), _T("睲"), _T("䂓"), // 0x7571 - 0x7578 85/81 - 85/88 + _T("磈"), _T("磠"), _T("祇"), _T("禮"), _T("・"), _T("・") // 0x7579 - 0x757E 85/89 - 85/94 + }; + + static const TCHAR *aszSymbolsTable6[] = + { + _T("・"), _T("秚"), _T("稞"), _T("ç­¿"), _T("ç°±"), _T("䉤"), _T("綋"), _T("羡"), // 0x7621 - 0x7628 86/01 - 86/08 + _T("脘"), _T("脺"), _T("・"), _T("芮"), _T("葛"), _T("蓜"), _T("蓬"), _T("蕙"), // 0x7629 - 0x7630 86/09 - 86/16 + _T("藎"), _T("蝕"), _T("蟬"), _T("蠋"), _T("裵"), _T("角"), _T("諶"), _T("跎"), // 0x7631 - 0x7638 86/17 - 86/24 + _T("è¾»"), _T("迶"), _T("郝"), _T("鄧"), _T("鄭"), _T("醲"), _T("鈳"), _T("銈"), // 0x7639 - 0x7640 86/25 - 86/32 + _T("錡"), _T("鍈"), _T("閒"), _T("雞"), _T("餃"), _T("饀"), _T("髙"), _T("鯖"), // 0x7641 - 0x7648 86/33 - 86/40 + _T("鷗"), _T("麴"), _T("麵") // 0x7649 - 0x764B 86/41 - 86/43 + }; + + // シンボルを変換する if((wCode >= 0x7A50U) && (wCode <= 0x7A74U)){ strcpy(lpszDst, aszSymbolsTable1[wCode - 0x7A50U]); } @@ -413,8 +529,14 @@ const DWORD PutSymbolsChar(TCHAR *lpszDst, const WORD wCode) else if((wCode >= 0x7E21U) && (wCode <= 0x7E7DU)){ strcpy(lpszDst, aszSymbolsTable4[wCode - 0x7E21U]); } + else if((wCode >= 0x7521U) && (wCode <= 0x757EU)){ + strcpy(lpszDst, aszSymbolsTable5[wCode - 0x7521U]); + } + else if((wCode >= 0x7621U) && (wCode <= 0x764BU)){ + strcpy(lpszDst, aszSymbolsTable6[wCode - 0x7621U]); + } else{ - strcpy(lpszDst, TEXT("¡¦")); + strcpy(lpszDst, TEXT("・")); } return strlen(lpszDst); @@ -422,9 +544,9 @@ const DWORD PutSymbolsChar(TCHAR *lpszDst, const WORD wCode) void ProcessEscapeSeq(const BYTE byCode) { - // ¥¨¥¹¥±¡¼¥×¥·¡¼¥±¥ó¥¹½èÍý + // エスケープシーケンス処理 switch(m_byEscSeqCount){ - // 1¥Ð¥¤¥ÈÌÜ + // 1バイト目 case 1U : switch(byCode){ // Invocation of code elements @@ -440,11 +562,11 @@ void ProcessEscapeSeq(const BYTE byCode) case 0x29U : m_byEscSeqIndex = 1U; break; case 0x2AU : m_byEscSeqIndex = 2U; break; case 0x2BU : m_byEscSeqIndex = 3U; break; - default : m_byEscSeqCount = 0U; return; // ¥¨¥é¡¼ + default : m_byEscSeqCount = 0U; return; // エラー } break; - // 2¥Ð¥¤¥ÈÌÜ + // 2バイト目 case 2U : if(DesignationGSET(m_byEscSeqIndex, byCode)){ m_byEscSeqCount = 0U; @@ -457,11 +579,11 @@ void ProcessEscapeSeq(const BYTE byCode) case 0x29 : m_bIsEscSeqDrcs = false; m_byEscSeqIndex = 1U; break; case 0x2A : m_bIsEscSeqDrcs = false; m_byEscSeqIndex = 2U; break; case 0x2B : m_bIsEscSeqDrcs = false; m_byEscSeqIndex = 3U; break; - default : m_byEscSeqCount = 0U; return; // ¥¨¥é¡¼ + default : m_byEscSeqCount = 0U; return; // エラー } break; - // 3¥Ð¥¤¥ÈÌÜ + // 3バイト目 case 3U : if(!m_bIsEscSeqDrcs){ if(DesignationGSET(m_byEscSeqIndex, byCode)){ @@ -480,13 +602,13 @@ void ProcessEscapeSeq(const BYTE byCode) m_bIsEscSeqDrcs = true; } else{ - // ¥¨¥é¡¼ + // エラー m_byEscSeqCount = 0U; return; } break; - // 4¥Ð¥¤¥ÈÌÜ + // 4バイト目 case 4U : DesignationDRCS(m_byEscSeqIndex, byCode); m_byEscSeqCount = 0U; @@ -516,7 +638,7 @@ void SingleShiftGL(const BYTE byIndexG) const bool DesignationGSET(const BYTE byIndexG, const BYTE byCode) { - // G¤Î¥°¥é¥Õ¥£¥Ã¥¯¥»¥Ã¥È¤ò³ä¤êÅö¤Æ¤ë + // Gのグラフィックセットを割り当てる switch(byCode){ case 0x42U : m_CodeG[byIndexG] = CODE_KANJI; return true; // Kanji case 0x4AU : m_CodeG[byIndexG] = CODE_ALPHANUMERIC; return true; // Alphanumeric @@ -533,13 +655,13 @@ const bool DesignationGSET(const BYTE byIndexG, const BYTE byCode) case 0x39U : m_CodeG[byIndexG] = CODE_JIS_KANJI_PLANE_1; return true; // JIS compatible Kanji Plane 1 case 0x3AU : m_CodeG[byIndexG] = CODE_JIS_KANJI_PLANE_2; return true; // JIS compatible Kanji Plane 2 case 0x3BU : m_CodeG[byIndexG] = CODE_ADDITIONAL_SYMBOLS; return true; // Additional symbols - default : return false; // ÉÔÌÀ¤Ê¥°¥é¥Õ¥£¥Ã¥¯¥»¥Ã¥È + default : return false; // 不明なグラフィックセット } } const bool DesignationDRCS(const BYTE byIndexG, const BYTE byCode) { - // DRCS¤Î¥°¥é¥Õ¥£¥Ã¥¯¥»¥Ã¥È¤ò³ä¤êÅö¤Æ¤ë + // DRCSのグラフィックセットを割り当てる switch(byCode){ case 0x40U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-0 case 0x41U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-1 @@ -558,42 +680,6 @@ const bool DesignationDRCS(const BYTE byIndexG, const BYTE byCode) case 0x4EU : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-14 case 0x4FU : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-15 case 0x70U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // Macro - default : return false; // ÉÔÌÀ¤Ê¥°¥é¥Õ¥£¥Ã¥¯¥»¥Ã¥È - } + default : return false; // 不明なグラフィックセット } - -WORD convertjis(DWORD jiscode) { - char code[3]; - char xcode[4]; - iconv_t cd; - - size_t inbyte = 2; - size_t outbyte = 4; - - const char *fptr; - char *tptr; - - WORD rtn; - - code[0] = jiscode >> 8; - code[1] = jiscode & 0xFF; - code[3] = '\0'; - - /* - cd = iconv_open("ISO-2022-JP","UTF-8"); - - fptr = code; - tptr = xcode; - iconv(cd, &fptr, &inbyte, &tptr, &outbyte); - - iconv_close(cd); - */ - - xcode[0] = code[0] | 0x80; - xcode[1] = code[1] | 0x80; - - rtn = ((xcode[0] << 8) & 0xFF00) | (xcode[1] & 0xFF); - - return rtn; - } diff --git a/epgdump/cdt.c b/epgdump/cdt.c new file mode 100644 index 0000000..a55acbd --- /dev/null +++ b/epgdump/cdt.c @@ -0,0 +1,131 @@ +// -*- tab-width:4 -*- + +#include +#include +#include + +#include "cdt.h" +#include "ts_ctl.h" +#include "clt2png.h" + +int parseCDThead(unsigned char *data, CDThead *h) { + int boff = 0; + + memset(h, 0, sizeof(CDThead)); + + h->table_id = getBit(data, &boff, 8); + h->section_syntax_indicator = getBit(data, &boff, 1); + h->reserved_future_use1 = getBit(data, &boff, 1); + h->reserved1 = getBit(data, &boff, 2); + h->section_length = getBit(data, &boff, 12); + h->download_data_id = getBit(data, &boff, 16); + h->reserved2 = getBit(data, &boff, 2); + h->version_number = getBit(data, &boff, 5); + h->current_next_indicator = getBit(data, &boff, 1); + h->section_number = getBit(data, &boff, 8); + h->last_section_number = getBit(data, &boff, 8); + h->original_network_id = getBit(data, &boff, 16); + h->data_type = getBit(data, &boff, 8); + h->reserved_future_use2 = getBit(data, &boff, 4); + h->descriptors_loop_length = getBit(data, &boff, 12); + + return 13; +} + +int parseCDTdesc(unsigned char *data, CDTdesc *desc) { +// ほとんど呼ばれることはない + int boff = 0; + + memset(desc, 0, sizeof(CDTdesc)); + + desc->descriptor_tag = getBit(data, &boff, 8); + desc->descriptor_length = getBit(data, &boff, 8); + + return desc->descriptor_length + 2; +} + +int parseCDTdata(unsigned char *data, CDTdata *cdtd) { + int boff = 0; + + memset(cdtd, 0, sizeof(CDTdata)); + + cdtd->logo_type = getBit(data, &boff, 8); + cdtd->reserved_future_use1 = getBit(data, &boff, 7); + cdtd->logo_id = getBit(data, &boff, 9); + cdtd->reserved_future_use2 = getBit(data, &boff, 4); + cdtd->logo_version = getBit(data, &boff, 12); + cdtd->data_size = getBit(data, &boff, 16); + cdtd->data = calloc(1, cdtd->data_size); + memcpy(cdtd->data, data + boff / 8, cdtd->data_size); + //boff += cdtd->data_size * 8; + + return cdtd->data_size + 7; +} + +void dumpCDT(unsigned char *ptr, STATION *station, int station_count) +{ + CDThead cdth; + CDTdesc desc; + CDTdata cdtd; + LOGO * pLogo; + + int len = 0; + int loop_len = 0; + int desc_len = 0; + int i = 0; + + /* CDT */ + len = parseCDThead(ptr, &cdth); + ptr += len; + loop_len = cdth.section_length - (len - 3 + 4); // 3は共通ヘッダ長 4はCRC + + desc_len = cdth.descriptors_loop_length; + while(desc_len > 0) { + len = parseCDTdesc(ptr, &desc); + ptr += len; + desc_len -= len; + } + + while(loop_len > 0) { + /* + logo_type + 0x00 24x48 864 SD4:3 スモール + 0x01 24x36 648 SD16:9 スモール + 0x02 27x48 972 HD スモール + 0x03 36x72 1296 SD4:3 ラージ + 0x04 36x54 972 SD16:9 ラージ + 0x05 36x64 1152 HD ラージ + */ + len = parseCDTdata(ptr, &cdtd); + ptr += len; + loop_len -= len; +/* + char fname[16]; + sprintf(fname,"%d_%d.png",cdth.download_data_id,cdtd.logo_type); + FILE* png = fopen(fname,"wb"); + void* mem_png = NULL; + int size_png; + clt2png(cdtd.data,&mem_png, &size_png); + fwrite(mem_png, 1, size_png, png); + fclose(png); +*/ +#if 0 + printf("CDT=(%d:%d:%d:%d:%d:%dbyte:desc%dbyte)%d,%d,%d,%d\n", + cdth.table_id, cdth.download_data_id, cdth.version_number, + cdth.original_network_id, cdth.data_type, + cdth.section_length, cdth.descriptors_loop_length, + + cdtd.logo_type, cdtd.logo_id, cdtd.logo_version, + cdtd.data_size); +#endif + for ( i = 0; i < station_count; i++ ) { + pLogo = &station[i].logo_array[cdtd.logo_type]; + if ( station[i].logo_download_data_id == cdth.download_data_id ) { + pLogo->logo = NULL; + clt2png(cdtd.data, &pLogo->logo, &pLogo->logo_size); + } + } + } + return; +} + diff --git a/epgdump/cdt.h b/epgdump/cdt.h new file mode 100644 index 0000000..9d39bf6 --- /dev/null +++ b/epgdump/cdt.h @@ -0,0 +1,56 @@ +#ifndef CDT_H +#define CDT_H 1 + +#include +#include + +#include "sdt.h" +#include "util.h" +#include "ts_ctl.h" + +typedef struct _CDThead { + unsigned char table_id; + int section_syntax_indicator; + int reserved_future_use1; + int reserved1; + int section_length; + int download_data_id; + int reserved2; + int version_number; + int current_next_indicator; + int section_number; + int last_section_number; + int original_network_id; + int reserved_future_use2; + int data_type; + int descriptors_loop_length; +} CDThead; + +typedef struct _CDTdesc { + unsigned char descriptor_tag; + int descriptor_length; +} CDTdesc; + +typedef struct _CDTdata { + int logo_type; + int reserved_future_use1; + int logo_id; + int reserved_future_use2; + int logo_version; + int data_size; + void *data; +} CDTdata; + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ + + int parseCDThead(unsigned char *data, CDThead *h); + int parseCDTdesc(unsigned char *data, CDTdesc *desc); + void dumpCDT(unsigned char *ptr, STATION *station, int station_count); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/epgdump/clt2png.c b/epgdump/clt2png.c new file mode 100644 index 0000000..fecc5c7 --- /dev/null +++ b/epgdump/clt2png.c @@ -0,0 +1,465 @@ +// ƒf[ƒ^•ú‘——pƒvƒƒOƒ‰ƒ€‹l‚ߍ‡‚킹 ‚»‚Ì2‚æ‚è—¬—p +// ƒJƒ‰[ƒ}ƒbƒvƒf[ƒ^‚ðPNG‚É“K—p‚·‚é + +#include +#include +#include + +#define bool char +#define true 1 +#define false 0 +#define inline + +typedef unsigned char byte; +typedef unsigned short uint16; +typedef unsigned long uint32; + +typedef struct _rgb_color { + byte r; + byte g; + byte b; + byte a; +} rgb_color; + +typedef struct _color_map_data { + byte clut_type; + byte depth; + byte region_flag; + byte start_end_flag; + byte reserved_future_use; + uint16 top_left_x; + uint16 top_left_y; + uint16 bottom_right_x; + uint16 bottom_right_y; + uint16 start_index; + uint16 end_index; + rgb_color color_map[0x10000]; +} color_map_data; + +static const rgb_color default_colormap[128] = { + { 0, 0, 0, 255}, + {255, 0, 0, 255}, + { 0, 255, 0, 255}, + {255, 255, 0, 255}, + { 0, 0, 0, 255}, + {255, 0, 255, 255}, + { 0, 255, 255, 255}, + {255, 255, 255, 255}, + { 0, 0, 0, 0}, + {170, 0, 0, 255}, + { 0, 170, 0, 255}, + {170, 170, 0, 255}, + { 0, 0, 170, 255}, + {170, 0, 170, 255}, + { 0, 170, 170, 255}, + {170, 170, 170, 255}, + { 0, 0, 85, 255}, + { 0, 85, 0, 255}, + { 0, 85, 85, 255}, + { 0, 85, 170, 255}, + { 0, 85, 255, 255}, + { 0, 170, 85, 255}, + { 0, 170, 255, 255}, + { 0, 255, 85, 255}, + { 0, 255, 170, 255}, + { 85, 0, 0, 255}, + { 85, 0, 85, 255}, + { 85, 0, 170, 255}, + { 85, 0, 255, 255}, + { 85, 85, 0, 255}, + { 85, 85, 85, 255}, + { 85, 85, 170, 255}, + { 85, 85, 255, 255}, + { 85, 170, 0, 255}, + { 85, 170, 85, 255}, + { 85, 170, 170, 255}, + { 85, 170, 255, 255}, + { 85, 255, 0, 255}, + { 85, 255, 85, 255}, + { 85, 255, 170, 255}, + { 85, 255, 255, 255}, + {170, 0, 85, 255}, + {170, 0, 255, 255}, + {170, 85, 0, 255}, + {170, 85, 85, 255}, + {170, 85, 170, 255}, + {170, 85, 255, 255}, + {170, 170, 85, 255}, + {170, 170, 255, 255}, + {170, 255, 0, 255}, + {170, 255, 85, 255}, + {170, 255, 170, 255}, + {170, 255, 255, 255}, + {255, 0, 85, 255}, + {255, 0, 170, 255}, + {255, 85, 0, 255}, + {255, 85, 85, 255}, + {255, 85, 170, 255}, + {255, 85, 255, 255}, + {255, 170, 0, 255}, + {255, 170, 85, 255}, + {255, 170, 170, 255}, + {255, 170, 255, 255}, + {255, 225, 85, 255}, + {225, 225, 170, 255}, + { 0, 0, 0, 128}, + {255, 0, 0, 128}, + { 0, 255, 0, 128}, + {255, 255, 0, 128}, + { 0, 0, 255, 128}, + {255, 0, 255, 128}, + { 0, 255, 255, 128}, + {255, 255, 255, 128}, + {170, 0, 0, 128}, + { 0, 170, 0, 128}, + {170, 170, 0, 128}, + { 0, 0, 170, 128}, + {170, 0, 170, 128}, + { 0, 170, 170, 128}, + {170, 170, 170, 128}, + { 0, 0, 85, 128}, + { 0, 85, 0, 128}, + { 0, 85, 85, 128}, + { 0, 85, 170, 128}, + { 0, 85, 255, 128}, + { 0, 170, 85, 128}, + { 0, 170, 255, 128}, + { 0, 255, 85, 128}, + { 0, 255, 170, 128}, + { 85, 0, 0, 128}, + { 85, 0, 85, 128}, + { 85, 0, 170, 128}, + { 85, 0, 255, 128}, + { 85, 85, 0, 128}, + { 85, 85, 85, 128}, + { 85, 85, 170, 128}, + { 85, 85, 255, 128}, + { 85, 170, 0, 128}, + { 85, 170, 85, 128}, + { 85, 170, 170, 128}, + { 85, 170, 255, 128}, + { 85, 255, 0, 128}, + { 85, 255, 85, 128}, + { 85, 255, 170, 128}, + { 85, 255, 255, 128}, + {170, 0, 85, 128}, + {170, 0, 255, 128}, + {170, 85, 0, 128}, + {170, 85, 85, 128}, + {170, 85, 170, 128}, + {170, 85, 255, 128}, + {170, 170, 85, 128}, + {170, 170, 255, 128}, + {170, 255, 0, 128}, + {170, 255, 85, 128}, + {170, 255, 170, 128}, + {170, 255, 255, 128}, + {255, 0, 85, 128}, + {255, 0, 170, 128}, + {255, 85, 0, 128}, + {255, 85, 85, 128}, + {255, 85, 170, 128}, + {255, 85, 255, 128}, + {255, 170, 0, 128}, + {255, 170, 85, 128}, + {255, 170, 170, 128}, + {255, 170, 255, 128}, + {255, 255, 85, 128}, +}; + + +/* + Y = 0.2126 * R + 0.7152 * G + 0.0722 * B + Cb = -(0.2126/1.8556)*(224/219) * R -(0.7152/1.8556)*(224/219) * G 0.5*(224/219) * B + Cr = 0.5*(224/219) * R -(0.7152/1.5748)*(224/219) * G -(0.0722/1.5748)*(224/219) * B +*/ + +inline byte ycbcr_to_r(int y,int cb,int cr) +{ + int r=(76309*(y-16)+104597*(cr-128)+32768)/65536; + return (byte)(r<0?0:r>255?255:r); +} + +inline byte ycbcr_to_g(int y,int cb,int cr) +{ + int g=(76309*(y-16)-25675*(cb-128)-53279*(cr-128)+32768)/65536; + return (byte)(g<0?0:g>255?255:g); +} + +inline byte ycbcr_to_b(int y,int cb,int cr) +{ + int b=(76309*(y-16)+132201*(cb-128)+32768)/65536; + return (byte)(b<0?0:b>255?255:b); +} + + +byte read_byte(void *fp, int *index_fp) +{ + int data = *((unsigned char*)fp + *index_fp++); + return (byte)data; +} + + +uint16 read_word(void *fp, int *index_fp) +{ + byte data=read_byte(fp, index_fp); + + return ((uint16)data<<8)|(uint16)read_byte(fp, index_fp); +} + + +uint32 read_dword(void *fp, int *index_fp) +{ + byte data1=read_byte(fp, index_fp); + byte data2=read_byte(fp, index_fp); + byte data3=read_byte(fp, index_fp); + byte data4=read_byte(fp, index_fp); + + return ((uint32)data1<<24)|((uint32)data2<<16)|((uint32)data3<<8)|(uint32)data4; +} + + +void read_data(void *fp,int *index_fp,void *data,size_t size) +{ + memcpy(data,fp + *index_fp, size); + *index_fp += size; +} + + +void write_dword(void **fp, int *index_fp,uint32 value) +{ + byte data[4]; + + data[0]=(byte)(value>>24); + data[1]=(byte)((value>>16)&0xFF); + data[2]=(byte)((value>>8)&0xFF); + data[3]=(byte)(value&0xFF); + *fp = realloc(*fp, *index_fp + 4); + memcpy(*fp + *index_fp, data, 4); + *index_fp += 4; +} + + +void write_data(void **fp,int *index_fp,void *data,size_t size) +{ + *fp = realloc(*fp, *index_fp + size); + memcpy(*fp + *index_fp, data, size); + *index_fp += size; +} + + +uint32 calc_crc(const byte *data,size_t size) +{ + static const uint32 crc_table[256] = { + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, + 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, + 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, + 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, + 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, + 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, + 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, + 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, + 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, + 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, + 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, + 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, + 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, + 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, + 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, + 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, + 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, + 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, + 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, + 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, + 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, + 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, + 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, + 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, + 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, + 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, + 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, + 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, + 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, + 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, + 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, + 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, + 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, + 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, + 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, + 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D, + }; + uint32 crc; + + crc=0xFFFFFFFFUL; + for (size_t i=0;i>8)^crc_table[(crc^data[i])&0x000000FFUL]; + return ~crc; +} + + +int clt2png(void* input, void** output, int* output_size) +{ + int input_index = 0, output_index = 0; + + color_map_data colormap; + memset(colormap.color_map,0,sizeof(colormap.color_map)); + memcpy(colormap.color_map,default_colormap,sizeof(default_colormap)); + + if (input!=NULL) { + // Parse color_map_data + byte b=read_byte(input, &input_index); + colormap.clut_type=(b&0x80)>>7; + colormap.depth=(b&0x60)>>5; + if (colormap.depth==3) { + printf("Error : Unknown depth (%d)\n",colormap.depth); + return 1; + } + colormap.region_flag=(b&0x10)>>4; + colormap.start_end_flag=(b&0x08)>>3; + colormap.reserved_future_use=b&0x07; + if (colormap.region_flag) { + colormap.top_left_x=read_word(input, &input_index); + colormap.top_left_y=read_word(input, &input_index); + colormap.bottom_right_x=read_word(input, &input_index); + colormap.bottom_right_y=read_word(input, &input_index); + } + if (colormap.start_end_flag) { + if (colormap.depth==0) { + b=read_byte(input, &input_index); + colormap.start_index=b>>4; + colormap.end_index=b&0x0F; + } else if (colormap.depth==1) { + colormap.start_index=read_byte(input, &input_index); + colormap.end_index=read_byte(input, &input_index); + } else if (colormap.depth==2) { + colormap.start_index=read_word(input, &input_index); + colormap.end_index=read_word(input, &input_index); + } + } else { + colormap.start_index=0; + switch (colormap.depth) { + case 0: colormap.end_index=15; break; + case 1: colormap.end_index=255; break; + case 2: colormap.end_index=65535; break; + } + } + for (uint16 i=colormap.start_index;i<=colormap.end_index;i++) { + if (colormap.clut_type==0) { + int y,cb,cr; + y=read_byte(input, &input_index); + cb=read_byte(input, &input_index); + cr=read_byte(input, &input_index); + colormap.color_map[i].r=ycbcr_to_r(y,cb,cr); + colormap.color_map[i].g=ycbcr_to_g(y,cb,cr); + colormap.color_map[i].b=ycbcr_to_b(y,cb,cr); + } else { + colormap.color_map[i].r=read_byte(input, &input_index); + colormap.color_map[i].g=read_byte(input, &input_index); + colormap.color_map[i].b=read_byte(input, &input_index); + } + colormap.color_map[i].a=read_byte(input, &input_index); + } + input_index = 0; + } + + // Open PNG file + + byte buffer[8]; + read_data(input,&input_index,buffer,8); + if (memcmp(buffer,"\x89PNG\r\n\x1A\n",8)!=0) { + printf("Error : Not a PNG format\n"); + return 1; + } + write_data(output,&output_index,buffer,8); + int bit_depth=0,color_type=-1; + bool has_palette=false; + while (true) { + read_data(input,&input_index,buffer,8); + uint32 data_size=((uint32)buffer[0]<<24)|((uint32)buffer[1]<<16)|((uint32)buffer[2]<<8)|(uint32)buffer[3]; + if (memcmp(buffer+4,"IHDR",4)==0) { + byte header[13]; + read_data(input,&input_index,header,13); + bit_depth=header[8]; + color_type=header[9]; + input_index -= 13; + } else if (memcmp(buffer+4,"PLTE",4)==0) { + has_palette=true; + } else if (memcmp(buffer+4,"IDAT",4)==0) { + if (!has_palette && bit_depth<=8 && color_type==3) { + int num_colors=1< +#include +#include + +#include "dsmcc.h" +#include "ts_ctl.h" +#include "clt2png.h" + +// STD-B21 p130 (144) +int parseDSMCChead(unsigned char *data, DSMCChead *dsmh) { + int boff = 0; + + memset(dsmh, 0, sizeof(DSMCChead)); + + dsmh->table_id = getBit(data, &boff, 8); + dsmh->section_syntax_indicator = getBit(data, &boff, 1); + dsmh->complement_indicator = getBit(data, &boff,1); + dsmh->reserved1 = getBit(data, &boff, 2); + dsmh->section_length = getBit(data, &boff, 12); + dsmh->table_id_extension = getBit(data, &boff, 16); + dsmh->reserved2 = getBit(data, &boff, 2); + dsmh->version_number = getBit(data, &boff, 5); + dsmh->current_next_indicator = getBit(data, &boff, 1); + dsmh->section_number = getBit(data, &boff, 8); + dsmh->last_section_number = getBit(data, &boff, 8); + + return 8; +} + +int parseDSMCCbodyDII(unsigned char *data, DSMCCbodyDII *dsmbdii) { + int boff = 0, i; + DSMCCbodyDIIModule *module; + + memset(dsmbdii, 0, sizeof(DSMCCbodyDII)); + + // header + dsmbdii->protocolDiscriminator = getBit(data, &boff, 8); + dsmbdii->dsmccType = getBit(data, &boff, 8); + dsmbdii->messageId = getBit(data, &boff, 16); + dsmbdii->transaction_id = getBit(data, &boff, 32); + dsmbdii->reserved = getBit(data, &boff, 8); + dsmbdii->adaptationLength = getBit(data, &boff, 8); + dsmbdii->messageLength = getBit(data, &boff, 16); + if ( dsmbdii->adaptationLength > 0 ) { + dsmbdii->dsmccAdaptationHeader = allocCopy(data, &boff, dsmbdii->adaptationLength); + } + + // body + dsmbdii->downloadId = getBit(data, &boff, 32); + dsmbdii->blockSize = getBit(data, &boff, 16); + dsmbdii->windowSize = getBit(data, &boff, 8); + dsmbdii->ackPeriod = getBit(data, &boff, 8); + dsmbdii->tCDownloadWindow = getBit(data, &boff, 32); + dsmbdii->tCDownloadScenario = getBit(data, &boff, 32); + dsmbdii->compatibilityDescriptor = getBit(data, &boff, 16); +/* + see http://www.atsc.org/cms/standards/a_90-with-att.pdf + + compatibilityDescriptorLength 16 + descriptorCount 16 + for(i=0;icompatibilityDescriptor * 8; + dsmbdii->numberOfModules = getBit(data, &boff, 16); + + if ( dsmbdii->numberOfModules > 0 ) { + dsmbdii->modules = calloc(1, sizeof(DSMCCbodyDIIModule) * dsmbdii->numberOfModules); + + for (i=0; inumberOfModules; i++) { + module = dsmbdii->modules + sizeof(DSMCCbodyDIIModule) * i; + module->moduleId = getBit(data, &boff, 16); + module->moduleSize = getBit(data, &boff, 32); + module->moduleVersion = getBit(data, &boff, 8); + module->moduleInfoLength = getBit(data, &boff, 8); + module->moduleInfo = allocCopy(data, &boff, module->moduleInfoLength); + } + } + + dsmbdii->privateDataLength = getBit(data, &boff, 8); + dsmbdii->privateData = allocCopy(data, &boff, dsmbdii->privateDataLength); + + return boff / 8; +} + +int parseDSMCCbodyDDB(unsigned char *data, DSMCCbodyDDB *dsmbddb) { + int boff = 0; + + memset(dsmbddb, 0, sizeof(DSMCCbodyDDB)); + + // header + dsmbddb->protocolDiscriminator = getBit(data, &boff, 8); + dsmbddb->dsmccType = getBit(data, &boff, 8); + dsmbddb->messageId = getBit(data, &boff, 16); + dsmbddb->downloadId = getBit(data, &boff, 32); + dsmbddb->reserved1 = getBit(data, &boff, 8); + dsmbddb->adaptationLength = getBit(data, &boff, 8); + dsmbddb->messageLength = getBit(data, &boff, 16); + if ( dsmbddb->adaptationLength > 0 ) { + dsmbddb->dsmccAdaptationHeader = allocCopy(data, &boff, dsmbddb->adaptationLength); + } + + // body + dsmbddb->moduleId = getBit(data, &boff, 16); + dsmbddb->moduleVersion = getBit(data, &boff, 8); + dsmbddb->reserved2 = getBit(data, &boff, 8); + dsmbddb->blockNumber = getBit(data, &boff, 16); + dsmbddb->blockData = allocCopy(data, &boff, dsmbddb->adaptationLength); + + return boff / 8; +} + +void dumpDSMCC(unsigned char *ptr, STATION *station, int station_count) +{ + DSMCChead dsmh; + DSMCCbodyDII dsmbdii; + DSMCCbodyDDB dsmbddb; + DSMCCbodyDIIModule *module; + + int len = 0; + int loop_len = 0; + int i = 0; + + /* DSMCC */ + len = parseDSMCChead(ptr, &dsmh); + ptr += len; + //loop_len = dsmh.section_length - (len - 3 + 4); // 3は共通ヘッダ長 4はCRC +/* + printf("DSMCChead=(%d:%d:%d:%d)\n", + dsmh.table_id, dsmh.section_length, + dsmh.table_id_extension, dsmh.section_number); +*/ + if ( dsmh.table_id == 0x3B ) { + len = parseDSMCCbodyDII(ptr, &dsmbdii); +#if 1 + printf("DSMCCbDDI=(%d:%d:%d:%d:%d:%d) (%d:%d:%d:%d)\n", + dsmbdii.protocolDiscriminator, dsmbdii.dsmccType, + dsmbdii.messageId, dsmbdii.transaction_id, + dsmbdii.adaptationLength, dsmbdii.messageLength, + + dsmbdii.downloadId , dsmbdii.blockSize , dsmbdii.compatibilityDescriptor , + dsmbdii.numberOfModules); +#endif + for (i=0; imoduleInfo == 0x01 ) { + printf("1 %d %s\n",module, module->moduleInfo + 2); + } + else if ( *module->moduleInfo == 0x02 ) { + printf("2 %s\n",module->moduleInfo + 2); + } + else if ( *module->moduleInfo == 0x03 ) { + printf("3 %s\n",module->moduleInfo); + } + */ + } + } + else if ( dsmh.table_id == 0x3C ) { + len = parseDSMCCbodyDDB(ptr, &dsmbddb); +// if ( station[0].logo_download_data_id == dsmbddb.downloadId ) { +// if ( 151585024 == dsmbddb.downloadId ) { +#if 1 + printf("DSMCCbDDB=(%d:%d:%d:%d:%d:%d) (%d:%d:%d)\n", + dsmbddb.protocolDiscriminator, dsmbddb.dsmccType, + dsmbddb.messageId, dsmbddb.downloadId, + dsmbddb.adaptationLength, dsmbddb.messageLength, + + dsmbddb.moduleId , dsmbddb.moduleVersion , dsmbddb.blockNumber); +#endif +// } + } + + return; +} + diff --git a/epgdump/dsmcc.h b/epgdump/dsmcc.h new file mode 100644 index 0000000..4ff5a06 --- /dev/null +++ b/epgdump/dsmcc.h @@ -0,0 +1,97 @@ +#ifndef DSMCC_H +#define DSMCC_H 1 + +#include +#include + +#include "sdt.h" +#include "util.h" +#include "ts_ctl.h" + +typedef struct _DSMCChead { + int table_id; + int section_syntax_indicator; + int complement_indicator; + int reserved1; + int section_length; + int table_id_extension; + int reserved2; + int version_number; + int current_next_indicator; + int section_number; + int last_section_number; +} DSMCChead; +/* +typedef struct _DSMCCmsghead { + int protocolDiscriminator; + int dsmccType; + int messageId; + int transaction_id; + int reserved; + int adaptationLength; + int messageLength; + void *dsmccAdaptationHeader; +} DSMCCmsghead; +*/ +typedef struct _DSMCCbodyDIIModule { + int moduleId; + int moduleSize; + int moduleVersion; + int moduleInfoLength; + unsigned char *moduleInfo; +} DSMCCbodyDIIModule; + +typedef struct _DSMCCbodyDII { + int protocolDiscriminator; + int dsmccType; + int messageId; + int transaction_id; + int reserved; + int adaptationLength; + int messageLength; + void *dsmccAdaptationHeader; + + int downloadId; + int blockSize; + int windowSize; + int ackPeriod; + int tCDownloadWindow; + int tCDownloadScenario; + int compatibilityDescriptor; + int numberOfModules; + void *modules; + int privateDataLength; + void *privateData; +} DSMCCbodyDII; + +typedef struct _DSMCCbodyDDB { + int protocolDiscriminator; + int dsmccType; + int messageId; + unsigned int downloadId; + int reserved1; + int adaptationLength; + int messageLength; + void *dsmccAdaptationHeader; + + int moduleId; + int moduleVersion; + int reserved2; + int blockNumber; + void *blockData; +} DSMCCbodyDDB; + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ + + int parseDSMCChead(unsigned char *data, DSMCChead *h); + int parseDSMCCbodyDDB(unsigned char *data, DSMCCbodyDDB *dsmbddb); + void dumpDSMCC(unsigned char *ptr, STATION *station, int station_count); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + diff --git a/epgdump/eit.c b/epgdump/eit.c index 23857df..f977e0c 100755 --- a/epgdump/eit.c +++ b/epgdump/eit.c @@ -1,3 +1,6 @@ +// -*- tab-width:4 -*- +// see TR-B14 4-296 (p.318) + #include #include #include @@ -5,18 +8,11 @@ #include "eit.h" char *subtitle_cnv_str[] = { -// "¡¡Âè", -// "¡¼Âè", -// "-Âè", -// " Âè", -// "¡¡¡Ö", -// "¡¡¡ô", -// "¡Ê", -// "¡Ö", NULL }; static void timecmp(int *,int *,int *, int, int, int); +void append_desc(EIT_CONTROL* eittop, int service_id, int event_id, EEVTDitem* eevtitem); int parseEIThead(unsigned char *data, EIThead *h) { int boff = 0; @@ -62,7 +58,7 @@ int parseEITbody(unsigned char *data, EITbody *b) b->free_CA_mode = getBit(data, &boff, 1); b->descriptors_loop_length = getBit(data, &boff, 12); - /* ÆüÉÕÊÑ´¹ */ + /* 日付変換 */ tnum = (b->start_time[0] & 0xFF) << 8 | (b->start_time[1] & 0xFF); b->yy = (tnum - 15078.2) / 365.25; @@ -96,14 +92,14 @@ int parseEITbody(unsigned char *data, EITbody *b) b->dhh = b->dhm = b->dss = 0; }else{ memset(buf, '\0', sizeof(buf)); - sprintf(buf, "%x", b->duration[0]); - b->dhh = atoi(buf); + sprintf(buf, "%x", b->duration[0]); + b->dhh = atoi(buf); memset(buf, '\0', sizeof(buf)); - sprintf(buf, "%x", b->duration[1]); - b->dhm = atoi(buf); + sprintf(buf, "%x", b->duration[1]); + b->dhm = atoi(buf); memset(buf, '\0', sizeof(buf)); - sprintf(buf, "%x", b->duration[2]); - b->dss = atoi(buf); + sprintf(buf, "%x", b->duration[2]); + b->dss = atoi(buf); } return 12; } @@ -140,7 +136,7 @@ int parseContentDesc(unsigned char *data, ContentDesc *desc) { } desc->descriptor_length = getBit(data, &boff, 8); memcpy(desc->content, data+(boff/8), desc->descriptor_length); - //getStr(desc->content, data, &boff, desc->descriptor_length); + /* getStr(desc->content, data, &boff, desc->descriptor_length); */ return desc->descriptor_length + 2; } @@ -197,11 +193,13 @@ int parseEEVTDitem(unsigned char *data, EEVTDitem *desc) { memset(desc, 0, sizeof(EEVTDitem)); desc->item_description_length = getBit(data, &boff, 8); + memset(desc->item_description, 0, MAXSECLEN); getStr(desc->item_description, data, &boff, desc->item_description_length); desc->item_length = getBit(data, &boff, 8); -// memcpy(desc->item, data + (boff / 8), desc->item_length); - getStr(desc->item, data, &boff, desc->item_length); + memset(desc->item, 0, MAXSECLEN); + memcpy(desc->item, data + (boff / 8), desc->item_length); + /* getStr(desc->item, data, &boff, desc->item_length); */ return desc->item_description_length + desc->item_length + 2; } @@ -212,6 +210,7 @@ int parseEEVTDtail(unsigned char *data, EEVTDtail *desc) { memset(desc, 0, sizeof(EEVTDtail)); desc->text_length = getBit(data, &boff, 8); + memset(desc->text, 0, MAXSECLEN); getStr(desc->text, data, &boff, desc->text_length); return desc->text_length + 1; @@ -221,76 +220,44 @@ int checkEEVTDitem(EEVTDitem *save, EEVTDitem *new, int descriptor_number) { EEVTDitem swap; int boff = 0; + if(new == NULL) { if(save->item_length != 0) { swap = *save; + memset(save->item, 0, MAXSECLEN); getStr(save->item, (unsigned char*)swap.item, &boff, swap.item_length); - - - //save->descriptor_number = descriptor_number; - //*new = swap; - //*save = swap; - if (swap.descriptor_number==1){ -// printf("descriptor_num %d typeB\n",swap.descriptor_number); - } - return 1; } else { - - - //printf("descriptor_num %d typeC\n",swap.descriptor_number); - - - return 0; } } if(new->item_description_length == 0) { - /* ³¤­ Êݸ */ + /* 続き 保存 */ memcpy(save->item + save->item_length, new->item, new->item_length); save->item_length += new->item_length; - - - if (swap.descriptor_number==1){ - printf("descriptor_num %d typeD\n",swap.descriptor_number); - } - - return 0; } else { - /* ¥Ö¥ì¡¼¥¯¡£save¤ò°õºþÂоݤˤ¹¤ë¡£save¤ò¥¯¥ê¥¢? */ + /* ブレーク。saveを印刷対象にする。saveをクリア? */ if(save->item_length != 0) { - /* ÂàÈòºÑ¤ß¤¬¤¢¤ê */ + /* 退避済みがあり */ swap = *save; + memset(save->item, 0, MAXSECLEN); getStr(save->item, (unsigned char*)swap.item, &boff, swap.item_length); + + // swap save new -> swap save new + // b c -> ( c) c b swap = *new; *new = *save; *save = swap; save->descriptor_number = descriptor_number; - - - - - if (swap.descriptor_number==1){ - printf("descriptor_num %d typeE\n",swap.descriptor_number); - } - - + return 1; } else { *save = *new; save->descriptor_number = descriptor_number; - - if (swap.descriptor_number==1){ - printf("descriptor_num %d typeF\n",swap.descriptor_number); - } - - return 0; } } - - return 1; } EIT_CONTROL *searcheit(EIT_CONTROL *top, int servid, int eventid) { @@ -306,11 +273,34 @@ EIT_CONTROL *searcheit(EIT_CONTROL *top, int servid, int eventid) } return NULL ; } +char *strstr_eucjp(const char *str, const char *search) +{ + char *pos ; + pos = (char *)str ; + + while (*pos != '\0') { + if (*pos == *search) { + if (strncmp(pos, search, strlen(search)) == 0) { + return pos ; + } + } + if ((unsigned char)*pos == 0x8Fu) { + pos += 3 ; + } else if ((unsigned char)*pos >= 0x80u) { + pos += 2 ; + } else { + pos += 1 ; + } + } + + return NULL ; +} void conv_title_subtitle(EIT_CONTROL *eitptr) { int lp = 0 ; - size_t addsize ; +// size_t addsize ; char *ptr ; + char *ptr2 ; char *newsubtitle ; for(lp = 0 ; subtitle_cnv_str[lp] != NULL ; lp++){ @@ -318,14 +308,25 @@ void conv_title_subtitle(EIT_CONTROL *eitptr) if(ptr == NULL){ continue ; } - // ¥¿¥¤¥È¥ë¤¬¤Ê¤¯¤Ê¤é¤Ê¤¤¤è¤¦¤Ë + // タイトルがなくならないように if(ptr == eitptr->title){ continue ; } + /* + ptr2 = ptr ; + for( ; (unsigned char)*ptr2 == 0x20u ; ptr2++ ); + for( ; (unsigned char)*ptr2 == 0xA1u && (unsigned char)*(ptr2+1) == 0xA1u ; ptr2 += 2); + for( ; (unsigned char)*ptr2 == 0x20u ; ptr2++ ); + newsubtitle = calloc(1, ((strlen(ptr2) + 2) + (strlen(eitptr->subtitle) + 1))); + memcpy(newsubtitle, ptr2, strlen(ptr2)); +// *(newsubtitle+strlen(ptr)) = ' '; + strcat(newsubtitle, "▽"); + */ newsubtitle = calloc(1, ((strlen(ptr) + 1) + (strlen(eitptr->subtitle) + 1))); memcpy(newsubtitle, ptr, strlen(ptr)); newsubtitle[strlen(ptr)] = ' '; - *ptr = NULL ; + + *ptr = '\0'; strcat(newsubtitle, eitptr->subtitle); free(eitptr->subtitle); eitptr->subtitle = newsubtitle ; @@ -407,7 +408,6 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans int loop_len = 0; int loop_blen = 0; int loop_elen = 0; - int str_alen = 0; int ehh, emm, ess; @@ -415,23 +415,29 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans len = parseEIThead(ptr, &eith); ptr += len; - loop_len = eith.section_length - (len - 3 + 4); // 3¤Ï¶¦Ḁ̈إåÀĹ 4¤ÏCRC + loop_len = eith.section_length - (len - 3 + 4); // 3は共通ヘッダ長 4はCRC while(loop_len > 0) { - /* Ϣ³¤¹¤ë³ÈÄ¥¥¤¥Ù¥ó¥È¤Ï¡¢´Á»ú¥³¡¼¥É¤¬µã¤­Ê̤줷¤Æ - ʬ³ä¤µ¤ì¤ë¤è¤¦¤À¡£Ï¢Â³¤«¤É¤¦¤«¤Ï¡¢item_description_length¤¬ - ÀßÄꤵ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤ÇȽÃǤǤ­¤ë¤è¤¦¤À¡£ */ + /* 連続する拡張イベントは、漢字コードが泣き別れして + 分割されるようだ。連続かどうかは、item_description_lengthが + 設定されているかどうかで判断できるようだ。 */ memset(&save_eevtitem, 0, sizeof(EEVTDitem)); len = parseEITbody(ptr, &eitb); ptr += len; loop_len -= len; - + /* printf("evtid:%d\n", eitb.event_id); */ - + loop_blen = eitb.descriptors_loop_length; loop_len -= loop_blen; + while(loop_blen > 0) { + /*yukikaze-test*/ + //printf("desc_tag"); + //int itt=getBit(*ptr,0,8); + //printf("%x",itt); + len = parseSEVTdesc(ptr, &sevtd); if(len > 0) { @@ -483,10 +489,10 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans len = parseEEVTDhead(ptr, &eevthead); /* - if(eith.service_id == 19304 && - eitb.event_id == 46564) { - printf("aa"); - } + if(eith.service_id == 19304 && + eitb.event_id == 46564) { + printf("aa"); + } */ if(len > 0) { @@ -501,60 +507,27 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans ptr += len; loop_elen -= len; loop_blen -= len; - - if (1||checkEEVTDitem(&save_eevtitem, &eevtitem, - eevthead.descriptor_number)) { -#if 0 - { - if (eevtitem.descriptor_number>0){ - //printf("descriptor_num %d\n",eevtitem.descriptor_number); - } - - /* long format */ - //printf("descriptor_num %d\n",eevtitem.descriptor_number); -#if 1 - printf("EEVT,%d,%d,%d,%s,%s\n", - eith.service_id, - eitb.event_id, - eevtitem.descriptor_number, // ÂàÈò¹àÌÜ - eevtitem.item_description, - eevtitem.item); -#endif - } -#endif - cur = searcheit(eittop, eith.service_id, eitb.event_id); - if(cur == NULL){ - curtmp = NULL; - cur = calloc(1, sizeof(EIT_CONTROL)); - } - else { - curtmp = cur; - } + if(checkEEVTDitem(&save_eevtitem, &eevtitem, + eevthead.descriptor_number)) { -#if 1 - if ( cur->desc ) { - str_alen = strlen( cur->desc ); - } - else { - str_alen = 0; - } - eevtitem.item_description_length = strlen(eevtitem.item_description); - eevtitem.item_length = strlen(eevtitem.item); - cur->desc = realloc(cur->desc, str_alen + eevtitem.item_description_length + eevtitem.item_length + 1000); - if ( !str_alen ) *cur->desc = '\0'; - - if ( eevtitem.item_description_length && !strstr(cur->desc, eevtitem.item_description) ) { - strcat(cur->desc, eevtitem.item_description); - strcat(cur->desc, "\t"); + { + if (eevtitem.descriptor_number>0){ + //printf("descriptor_num %d\n",eevtitem.descriptor_number); + } + /* long format */ + //printf("descriptor_num %d\n",eevtitem.descriptor_number); +#if 0 + printf("EEVT,%d,%d,%d,%s,%s\n", + eith.service_id, + eitb.event_id, + eevtitem.descriptor_number, // 退避項目 + eevtitem.item_description, + eevtitem.item); +#endif } + append_desc(eittop, eith.service_id, eitb.event_id, &eevtitem); - if ( eevtitem.item_length && !strstr(cur->desc, eevtitem.item) ) { - strcat(cur->desc, eevtitem.item); - strcat(cur->desc, "\\n"); - } -#endif - if ( !curtmp ) enqueue(eittop, cur); } } @@ -572,7 +545,7 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans ContentDesc contentDesc; len = parseContentDesc(ptr, &contentDesc); if (len > 0) { - int header_printed = 0; + //int header_printed = 0; for (int i = 0; i < contentDesc.descriptor_length - 1; i+=2) { /* if (0xff == (unsigned char)contentDesc.content[i]) @@ -580,16 +553,15 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans */ #if 0 if (!header_printed) { - fprintf(out, "Content,%d,%d", + fprintf(out, "Content,%d,%d\n", eith.service_id, eitb.event_id); header_printed = 1; } #endif -#if 0 - fprintf(out, ",%02x%02x", (unsigned char)contentDesc.content[i], (unsigned char)contentDesc.content[i+1]); -#endif + //fprintf(out, ",%02x%02x", (unsigned char)contentDesc.content[i], (unsigned char)contentDesc.content[i+1]); + } if((eith.original_network_id == original_network_id) && (eith.transport_stream_id == transport_stream_id)){ cur = searcheit(eittop, eith.service_id, eitb.event_id); @@ -600,8 +572,8 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans fprintf(stdout, ",%02x%02x", (unsigned char)contentDesc.content[0], (unsigned char)contentDesc.content[1]); fprintf(stdout, ",%02x%02x\n", (unsigned char)contentDesc.content[2], (unsigned char)contentDesc.content[3]); #endif - } + #if 0 if (header_printed) { fprintf(out, "\n"); @@ -634,12 +606,12 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans ptr += len; loop_blen -= len; } - /* ºÇ¸å¤Î¥Ö¥ì¡¼¥¯¥Á¥§¥Ã¥¯ */ - + /* 最後のブレークチェック */ + if(checkEEVTDitem(&save_eevtitem, NULL, 0)) { #if 0 - if(mode == 1) { /* long format */ - fprintf(out, "EEVT,%d,%d,%d,%s,%s\n", + { /* long format */ + fprintf(stdout, "EEVT,%d,%d,%d,%s,%s\n", eith.service_id, eitb.event_id, save_eevtitem.descriptor_number, @@ -647,12 +619,45 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans save_eevtitem.item); } #endif + append_desc(eittop, eith.service_id, eitb.event_id, &save_eevtitem); } } return; } +void append_desc(EIT_CONTROL* eittop, int service_id, int event_id, EEVTDitem* eevtitem) { + EIT_CONTROL *cur; + int str_alen = 0; + + cur = searcheit(eittop, service_id, event_id); + if (cur == NULL) { + return; + } + + if ( cur->desc ) { + str_alen = strlen( cur->desc ); + } + else { + str_alen = 0; + } + //eevtitem->item_description_length = strlen(eevtitem->item_description); + //eevtitem->item_length = strlen(eevtitem->item); + cur->desc = realloc(cur->desc, str_alen + eevtitem->item_description_length + eevtitem->item_length + 1000); + if ( !str_alen ) *cur->desc = '\0'; + + if ( eevtitem->item_description_length && !strstr(cur->desc, eevtitem->item_description) ) { + strcat(cur->desc + str_alen, eevtitem->item_description); + strcat(cur->desc, "\t"); + } + + if ( eevtitem->item_length && !strstr(cur->desc, eevtitem->item) ) { + strcat(cur->desc + str_alen, eevtitem->item); + //printf("%s\n",eevtitem->item); + strcat(cur->desc, "\\n"); + } +} + void timecmp(int *thh, int *tmm, int *tss, int dhh, int dmm, int dss) { diff --git a/epgdump/eit.h b/epgdump/eit.h index 15f910b..2301fe9 100755 --- a/epgdump/eit.h +++ b/epgdump/eit.h @@ -32,7 +32,7 @@ typedef struct _EITbody { int running_status; int free_CA_mode; int descriptors_loop_length; - /* °Ê²¼¤Ï²òÀÏ·ë²ÌÊݸÍÑ */ + /* 以下は解析結果保存用 */ int yy; int mm; int dd; @@ -87,7 +87,7 @@ typedef struct _EEVTDitem { char item_description[MAXSECLEN]; int item_length; char item[MAXSECLEN]; - /* ÂàÈòÍÑ */ + /* 退避用 */ int descriptor_number; } EEVTDitem; diff --git a/epgdump/epgdump.c b/epgdump/epgdump.c index 38dc1e1..305b838 100755 --- a/epgdump/epgdump.c +++ b/epgdump/epgdump.c @@ -7,8 +7,11 @@ #include #include "ts.h" +#include "psi.h" #include "sdt.h" +#include "sdtt.h" #include "eit.h" +#include "dsmcc.h" #include "ts_ctl.h" typedef struct _ContentTYPE{ @@ -18,134 +21,83 @@ typedef struct _ContentTYPE{ #define CAT_COUNT 16 static CONTENT_TYPE ContentCatList[CAT_COUNT] = { - { "¥Ë¥å¡¼¥¹¡¦ÊóÆ»", "news" }, - { "¥¹¥Ý¡¼¥Ä", "sports" }, - { "¾ðÊó", "information" }, - { "¥É¥é¥Þ", "drama" }, - { "²»³Ú", "music" }, - { "¥Ð¥é¥¨¥Æ¥£", "variety" }, - { "±Ç²è", "cinema" }, - { "¥¢¥Ë¥á¡¦Æû£", "anime" }, - { "¥É¥­¥å¥á¥ó¥¿¥ê¡¼¡¦¶µÍÜ", "documentary" }, - { "±é·à", "stage" }, - { "¼ñÌ£¡¦¼ÂÍÑ", "hobby" }, - { "Ê¡»ã", "etc" }, //Ê¡»ã - { "ͽÈ÷", "etc" }, //ͽÈ÷ - { "ͽÈ÷", "etc" }, //ͽÈ÷ - { "ͽÈ÷", "etc" }, //ͽÈ÷ - { "¤½¤Î¾", "etc" } //¤½¤Î¾ -}; -typedef struct _TAG_STATION -{ - char *name; - char *ontv; - int tsId; // OriginalNetworkID - int onId; // TransportStreamID - int svId; // ServiceID -} STATION; - -static STATION bsSta[] = { - { "NHK BS1", "3001.ontvjapan.com", 16625, 4, 101}, - { "NHK BS2", "3002.ontvjapan.com", 16625, 4, 102}, - { "NHK BSh", "3003.ontvjapan.com", 16626, 4, 103}, - { "BSÆü¥Æ¥ì", "3004.ontvjapan.com", 16592, 4, 141}, - { "BSÄ«Æü", "3005.ontvjapan.com", 16400, 4, 151}, - { "BS-i", "3006.ontvjapan.com", 16401, 4, 161}, - { "BS¥¸¥ã¥Ñ¥ó", "3007.ontvjapan.com", 16433, 4, 171}, - { "BS¥Õ¥¸", "3008.ontvjapan.com", 16593, 4, 181}, - { "WOWOW", "3009.ontvjapan.com", 16432, 4, 191}, - { "WOWOW2", "3010.ontvjapan.com", 16432, 4, 192}, - { "WOWOW3", "3011.ontvjapan.com", 16432, 4, 193}, - { "BS11", "3013.ontvjapan.com", 16528, 4, 211}, - { "TwellV", "3014.ontvjapan.com", 16530, 4, 222}, + { "ニュース・報道", "news" }, + { "スポーツ", "sports" }, + { "情報", "information" }, + { "ドラマ", "drama" }, + { "音楽", "music" }, + { "バラエティ", "variety" }, + { "映画", "cinema" }, + { "アニメ・特撮", "anime" }, + { "ドキュメンタリー・教養", "documentary" }, + { "演劇", "stage" }, + { "趣味・実用", "hobby" }, + { "福祉", "etc" }, //福祉 + { "予備", "etc" }, //予備 + { "予備", "etc" }, //予備 + { "予備", "etc" }, //予備 + { "その他", "etc" } //その他 }; -static int bsStaCount = sizeof(bsSta) / sizeof (STATION); - - - -static STATION csSta[] = { - { "¥¹¥¿¡¼£ã£è¥×¥é¥¹", "1002.ontvjapan.com", 24608, 6, 237}, - { "ÆüËܱDzèÀìÌç£ã£è£È£Ä", "1086.ontvjapan.com", 24608, 6, 239}, - { "¥Õ¥¸¥Æ¥ì¥Ó£Ã£Ó£È£Ä", "306ch.epgdata.ontvjapan", 24608, 6, 306}, - { "¥·¥ç¥Ã¥×¥Á¥ã¥ó¥Í¥ë", "1059.ontvjapan.com", 24704, 6, 55}, - { "¥­¥Ã¥º¥¹¥Æ¡¼¥·¥ç¥ó£È£Ä", "335ch.ontvjapan.com", 24704, 6, 335}, - { "¥¶¡¦¥·¥Í¥Þ", "1217.ontvjapan.com", 24736, 6, 228}, - { "¥¹¥«¥Á¥ã¥ó£È£Ä£¸£°£°", "800ch.epgdata.ontvjapan", 24736, 6, 800}, - { "¥¹¥«¥Á¥ã¥ó£¸£°£±", "801ch.epgdata.ontvjapan", 24736, 6, 801}, - { "¥¹¥«¥Á¥ã¥ó£¸£°£²", "802ch.epgdata.ontvjapan", 24736, 6, 802}, - { "£å£²¥×¥í¥â", "100ch.epgdata.ontvjapan", 28736, 7, 100}, - { "¥¤¥ó¥¿¡¼¥í¡¼¥«¥ë£Ô£Ö", "194ch.epgdata.ontvjapan", 28736, 7, 194}, - { "£Ê¥¹¥Ý¡¼¥Ä¡¡£Å£Ó£Ð£Î", "1025.ontvjapan.com", 28736, 7, 256}, - { "£Æ£Ï£Ø", "1016.ontvjapan.com", 28736, 7, 312}, - { "¥¹¥Ú¡¼¥¹¥·¥ã¥ï¡¼£Ô£Ö", "1018.ontvjapan.com", 28736, 7, 322}, - { "¥«¡¼¥È¥¥¡¼¥ó¡¡¥Í¥Ã¥È", "1046.ontvjapan.com", 28736, 7, 331}, - { "¥È¥¥¡¼¥ó¡¦¥Ç¥£¥º¥Ë¡¼", "1213.ontvjapan.com", 28736, 7, 334}, - { "Åì±Ç¥Á¥ã¥ó¥Í¥ë", "1010.ontvjapan.com", 28768, 7, 221}, - { "±ÒÀ±·à¾ì", "1005.ontvjapan.com", 28768, 7, 222}, - { "¥Á¥ã¥ó¥Í¥ë£Î£Å£Ã£Ï", "1008.ontvjapan.com", 28768, 7, 223}, - { "Íβè¡ú¥·¥Í¥Õ¥£¥ë", "1009.ontvjapan.com", 28768, 7, 224}, - { "¥¹¥¿¡¼¡¦¥¯¥é¥·¥Ã¥¯", "1003.ontvjapan.com", 28768, 7, 238}, - { "»þÂå·àÀìÌç¥Á¥ã¥ó¥Í¥ë", "1133.ontvjapan.com", 28768, 7, 292}, - { "¥¹¡¼¥Ñ¡¼¥É¥é¥Þ", "1006.ontvjapan.com", 28768, 7, 310}, - { "£Á£Ø£Î", "1014.ontvjapan.com", 28768, 7, 311}, - { "¥Ê¥·¥ç¥¸¥ª¥Á¥ã¥ó¥Í¥ë", "1204.ontvjapan.com", 28768, 7, 343}, - { "¥ï¥ó¥Æ¥ó¥Ý¡¼¥¿¥ë", "110ch.epgdata.ontvjapan", 28864, 7, 110}, - { "¥´¥ë¥Õ¥Á¥ã¥ó¥Í¥ë", "1028.ontvjapan.com", 28864, 7, 260}, - { "¥Æ¥ìÄ«¥Á¥ã¥ó¥Í¥ë", "1092.ontvjapan.com", 28864, 7, 303}, - { "£Í£Ô£Ö", "1019.ontvjapan.com", 28864, 7, 323}, - { "¥ß¥å¡¼¥¸¥Ã¥¯¡¦¥¨¥¢", "1024.ontvjapan.com", 28864, 7, 324}, - { "Ä«Æü¥Ë¥å¡¼¥¹¥¿¡¼", "1067.ontvjapan.com", 28864, 7, 352}, - { "£Â£Â£Ã¥ï¡¼¥ë¥É", "1070.ontvjapan.com", 28864, 7, 353}, - { "£Ã£Î£Î£ê", "1069.ontvjapan.com", 28864, 7, 354}, - { "¥¸¥ã¥¹¥È¡¦¥¢¥¤", "361ch.epgdata.ontvjapan", 28864, 7, 361}, - { "£Ê¥¹¥Ý¡¼¥Ä¡¡£±", "1041.ontvjapan.com", 28896, 7, 251}, - { "£Ê¥¹¥Ý¡¼¥Ä¡¡£²", "1042.ontvjapan.com", 28896, 7, 252}, - { "£Ê¥¹¥Ý¡¼¥Ä£Ð£ì£õ£ó£È", "1043.ontvjapan.com", 28896, 7, 253}, - { "£Ç£Á£Ï£Ò£Á", "1026.ontvjapan.com", 28896, 7, 254}, - { "£ó£ë£ù¡¦£Á¥¹¥Ý¡¼¥Ä¡Ü", "1040.ontvjapan.com", 28896, 7, 255}, - { "ÊõÄÍ¥×¥í¥â¥Á¥ã¥ó¥Í¥ë", "101ch.epgdata.ontvjapan", 28928, 7, 101}, - { "£Ó£Ë£Ù¡¦£Ó£Ô£Á£Ç£Å", "1207.ontvjapan.com", 28928, 7, 290}, - { "¥Á¥ã¥ó¥Í¥ë¶ä²Ï", "305ch.epgdata.ontvjapan", 28928, 7, 305}, - { "£Á£Ô-£Ø", "1201.ontvjapan.com", 28928, 7, 333}, - { "¥Ò¥¹¥È¥ê¡¼¥Á¥ã¥ó¥Í¥ë", "1050.ontvjapan.com", 28928, 7, 342}, - { "¥¹¥«¥Á¥ã¥ó£¸£°£³", "803ch.epgdata.ontvjapan", 28928, 7, 803}, - { "¥¹¥«¥Á¥ã¥ó£¸£°£´", "804ch.epgdata.ontvjapan", 28928, 7, 804}, - { "¥à¡¼¥Ó¡¼¥×¥é¥¹£È£Ä", "1007.ontvjapan.com", 28960, 7, 240}, - { "¥´¥ë¥Õ¥Í¥Ã¥È¥ï¡¼¥¯", "1027.ontvjapan.com", 28960, 7, 262}, - { "£Ì£á£Ì£á¡¡£È£Ä", "1074.ontvjapan.com", 28960, 7, 314}, - { "¥Õ¥¸¥Æ¥ì¥Ó£Ï£Î£Å", "1073.ontvjapan.com", 28992, 7, 307}, - { "¥Õ¥¸¥Æ¥ì¥Ó£Ô£×£Ï", "1072.ontvjapan.com", 28992, 7, 308}, - { "¥¢¥Ë¥Þ¥Ã¥¯¥¹", "1047.ontvjapan.com", 28992, 7, 332}, - { "¥Ç¥£¥¹¥«¥Ð¥ê¡¼", "1062.ontvjapan.com", 28992, 7, 340}, - { "¥¢¥Ë¥Þ¥ë¥×¥é¥Í¥Ã¥È", "1193.ontvjapan.com", 28992, 7, 341}, - { "£Ã-£Ô£Â£Ó¥¦¥¨¥ë¥«¥à", "160ch.epgdata.ontvjapan", 29024, 7, 160}, - { "£Ñ£Ö£Ã", "1120.ontvjapan.com", 29024, 7, 161}, - { "¥×¥é¥¤¥à£³£¶£µ¡¥£Ô£Ö", "185ch.epgdata.ontvjapan", 29024, 7, 185}, - { "¥Õ¥¡¥ß¥ê¡¼·à¾ì", "1015.ontvjapan.com", 29024, 7, 293}, - { "£Ô£Â£Ó¥Á¥ã¥ó¥Í¥ë", "3201.ontvjapan.com", 29024, 7, 301}, - { "¥Ç¥£¥º¥Ë¡¼¥Á¥ã¥ó¥Í¥ë", "1090.ontvjapan.com", 29024, 7, 304}, - { "MUSIC ON! TV", "1022.ontvjapan.com", 29024, 7, 325}, - { "¥­¥Ã¥º¥¹¥Æ¡¼¥·¥ç¥ó", "1045.ontvjapan.com", 29024, 7, 330}, - { "£Ô£Â£Ó¥Ë¥å¡¼¥¹¥Ð¡¼¥É", "1076.ontvjapan.com", 29024, 7, 351}, - { "£Ã£ÓÆüËÜÈÖÁÈ¥¬¥¤¥É", "147ch.epgdata.ontvjapan", 29056, 7, 147}, - { "Æü¥Æ¥ì£Ç¡Ü", "1068.ontvjapan.com", 29056, 7, 257}, - { "fashion TV", "5004.ontvjapan.com", 29056, 7, 291}, - { "Æü¥Æ¥ì¥×¥é¥¹", "300ch.epgdata.ontvjapan", 29056, 7, 300}, - { "¥¨¥³¥ß¥å¡¼¥¸¥Ã¥¯£Ô£Ö", "1023.ontvjapan.com", 29056, 7, 320}, - { "Music Japan TV", "1208.ontvjapan.com", 29056, 7, 321}, - { "Æü¥Æ¥ì£Î£Å£×£Ó£²£´", "2002.ontvjapan.com", 29056, 7, 350}, -}; -static int csStaCount = sizeof(csSta) / sizeof (STATION); SVT_CONTROL *svttop = NULL; -#define SECCOUNT 4 +#define SECCOUNT 64 char title[1024]; char subtitle[1024]; char desc[102400] = {0}; char Category[1024]; char ServiceName[1024]; -iconv_t cd ; +char Logo[8192]; +static unsigned char *base64 = (unsigned char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +static void base64_char(unsigned long bb, int srclen, unsigned char *dest, int j) +{ + int x, i, base; + + /* 最終位置の計算 */ + for ( i = srclen; i < 2; i++ ) + bb <<= 8; + + /* BASE64変換 */ + for ( base = 18, x = 0; x < srclen + 2; x++, base -= 6) { + dest[j++] = base64[ (unsigned long)((bb>>base) & 0x3F) ]; + } + + /* 端数の判断 */ + for ( i = x; i < 4; i++ ) { + dest[j++] = (unsigned char)'='; /* 端数 */ + } + +} + +static void base64_encode(unsigned char *dest, const unsigned char *src, int len) +{ + unsigned char *p = src; + unsigned long bb = (unsigned long)0; + int i = 0, j = 0; + + while (len--) + { + bb <<= 8; + bb |= (unsigned long)*p; + + /* 24bit単位に編集 */ + if (i == 2) { + base64_char(bb, i, dest, j); + + j = j + 4; + i = 0; + bb = 0; + } else + i++; + + p++; + } + + /* 24bitに満たない場合 */ + if (i) base64_char(bb, i - 1, dest, j); + +} void xmlspecialchars(char *str) { @@ -158,27 +110,67 @@ void xmlspecialchars(char *str) -void GetSDT(FILE *infile, SVT_CONTROL *svttop, SECcache *secs, int count) +void GetSDT(FILE *infile, SVT_CONTROL *svttop, SECcache *secs, + int count, STATION **station, int * station_count, char *header, int is_bs_cs) { SECcache *bsecs; + int pmtpids[SECCOUNT]; + memset(pmtpids, 0, sizeof(pmtpids)); + int dsmccpids[SECCOUNT]; + memset(dsmccpids, 0, sizeof(dsmccpids)); + int i = 0; while((bsecs = readTS(infile, secs, count)) != NULL) { + /* PAT */ + if(is_bs_cs && (bsecs->pid & 0xFF) == 0x00) { + dumpPAT(bsecs->buf, secs, count, pmtpids); + } /* SDT */ - if((bsecs->pid & 0xFF) == 0x11) { - dumpSDT(bsecs->buf, svttop); + else if((bsecs->pid & 0xFF) == 0x11) { + dumpSDT(bsecs->buf, svttop, station, station_count, header); + } + /* TOT */ + else if((bsecs->pid & 0xFF) == 0x14) { + dumpTOT(bsecs->buf); + } + /* SDTT */ + else if((bsecs->pid & 0xFF) == 0x23) { + dumpSDTT(bsecs->buf, *station, *station_count); + } + /* CDT */ + else if((bsecs->pid & 0xFF) == 0x29) { + dumpCDT(bsecs->buf, *station, *station_count); + } + else if ( is_bs_cs ) { + for ( i = 1; i < SECCOUNT; i++ ) { + if ( pmtpids[i] == 0 ) { + break; + } + /* PMT specified by PAT */ + if ( bsecs->pid == pmtpids[i] ) { + dumpPMT(bsecs->buf, secs, count, dsmccpids); + } + } + + for ( i = 0; i < SECCOUNT; i++ ) { + if ( dsmccpids[i] == 0 ) { + break; + } + /* DSM-CC specified by PMT */ + if ( bsecs->pid == dsmccpids[i] ) { + dumpDSMCC(bsecs->buf, *station, *station_count); + } + } } } } -void GetEIT(FILE *infile, FILE *outfile, STATION *psta, SECcache *secs, int count) + +void GetEIT(FILE *infile, FILE *outfile, STATION *psta, SECcache *secs) { SECcache *bsecs; EIT_CONTROL *eitcur ; EIT_CONTROL *eitnext ; EIT_CONTROL *eittop = NULL; - char *outptr ; - char *inptr ; - size_t ilen; - size_t olen; time_t l_time ; time_t end_time ; struct tm tl ; @@ -186,6 +178,11 @@ void GetEIT(FILE *infile, FILE *outfile, STATION *psta, SECcache *secs, int coun char cendtime[32]; char cstarttime[32]; + memset(secs, 0, sizeof(SECcache) * SECCOUNT); + secs[0].pid = 0x12; /* EIT */ + secs[1].pid = 0x26; /* EIT */ + secs[2].pid = 0x27; /* EIT */ + eittop = calloc(1, sizeof(EIT_CONTROL)); eitcur = eittop ; fseek(infile, 0, SEEK_SET); @@ -208,38 +205,22 @@ void GetEIT(FILE *infile, FILE *outfile, STATION *psta, SECcache *secs, int coun if(eitcur->content_type > CAT_COUNT){ eitcur->content_type = CAT_COUNT -1 ; } - outptr = title ; memset(title, '\0', sizeof(title)); - ilen = strlen(eitcur->title); - olen = sizeof(title); - inptr = eitcur->title; - iconv(cd, &inptr, &ilen, &outptr, &olen); + strcpy(title, eitcur->title); xmlspecialchars(title); memset(subtitle, '\0', sizeof(subtitle)); - ilen = strlen(eitcur->subtitle); - olen = sizeof(subtitle); - outptr = subtitle ; - inptr = eitcur->subtitle; - iconv(cd, &inptr, &ilen, &outptr, &olen); + strcpy(subtitle, eitcur->subtitle); xmlspecialchars(subtitle); memset(desc, '\0', sizeof(desc)); if ( eitcur->desc ) { - ilen = strlen(eitcur->desc); - olen = sizeof(desc); - outptr = desc ; - inptr = eitcur->desc; - iconv(cd, &inptr, &ilen, &outptr, &olen); + strcpy(desc, eitcur->desc); xmlspecialchars(desc); } memset(Category, '\0', sizeof(Category)); - ilen = strlen(ContentCatList[eitcur->content_type].japanese); - olen = sizeof(Category); - outptr = Category ; - inptr = ContentCatList[eitcur->content_type].japanese; - iconv(cd, &inptr, &ilen, &outptr, &olen); + strcpy(Category, ContentCatList[eitcur->content_type].japanese); xmlspecialchars(Category); tl.tm_sec = eitcur->ss ; @@ -254,7 +235,7 @@ void GetEIT(FILE *infile, FILE *outfile, STATION *psta, SECcache *secs, int coun l_time = mktime(&tl); if((eitcur->ehh == 0) && (eitcur->emm == 0) && (eitcur->ess == 0)){ (void)time(&l_time); - end_time = l_time + (60 * 5); // £µÊ¬¸å¤ËÀßÄê + end_time = l_time + (60 * 5); // 5分後に設定 endtl = localtime(&end_time); }else{ end_time = l_time + eitcur->ehh * 3600 + eitcur->emm * 60 + eitcur->ess; @@ -264,24 +245,22 @@ void GetEIT(FILE *infile, FILE *outfile, STATION *psta, SECcache *secs, int coun memset(cstarttime, '\0', sizeof(cstarttime)); strftime(cendtime, (sizeof(cendtime) - 1), "%Y%m%d%H%M%S", endtl); strftime(cstarttime, (sizeof(cstarttime) - 1), "%Y%m%d%H%M%S", &tl); -#if 1 - fprintf(outfile, " \n", - cstarttime, cendtime, psta->ontv); + fprintf(outfile, " \n", + cstarttime, cendtime, psta->ontv, eitcur->event_id); fprintf(outfile, " %s\n", title); fprintf(outfile, " %s\n", subtitle); fprintf(outfile, " %s\n", desc); fprintf(outfile, " %s\n", Category); -// fprintf(outfile, " %s\n", ContentCatList[eitcur->content_type].english); + //fprintf(outfile, " %s\n", ContentCatList[eitcur->content_type].english); fprintf(outfile, " \n"); -#else +#if 0 fprintf(outfile, "(%x:%x:%x)%s,%s,%s,%s,%s,%s\n", eitcur->servid, eitcur->table_id, eitcur->event_id, cstarttime, cendtime, title, subtitle, Category, ContentCatList[eitcur->content_type].english); -#endif -#if 0 + fprintf(outfile, "(%x:%x)%04d/%02d/%02d,%02d:%02d:%02d,%02d:%02d:%02d,%s,%s,%s,%s\n", eitcur->table_id, eitcur->event_id, eitcur->yy, eitcur->mm, eitcur->dd, @@ -300,75 +279,195 @@ void GetEIT(FILE *infile, FILE *outfile, STATION *psta, SECcache *secs, int coun free(eittop); eittop = NULL; } +void checkSta_BS(STATION **station,int *stalength){ + STATION *statmp; + int chl[30]; + int chlt=0; + int stal=0; + STATION * statin= *station; + statmp=malloc(sizeof(STATION)*2); + for (int i=0;i<*stalength;i++){ + int noidinchl=1; + for (int j=0;j= 290){ + noidinchl=0; + } + } + if (noidinchl==1){ + statmp=realloc(statmp,(stal+1)*sizeof(STATION)); + statmp[stal]=statin[i]; + //memcpy(statmp[stal-1],station[i],sizeof(STATION)); + chl[chlt]=statin[i].svId; + chlt++; + stal++; + } + } + //*station=realloc(station,(stal+1)*sizeof(STATION)); + //memcpy(*station,statmp,(stal+1)*sizeof(STATION)); + *station=statmp; + *stalength=stal; + //memcpy(statin,statmp,chlt*sizeof(STATION)); + //free(statmp); +} + +void checkSta(STATION **station,int *stalength){ + STATION *statmp; + int chl[90]; + int chlt=0; + int stal=0; + STATION * statin= *station; + statmp=malloc(sizeof(STATION)*2); + for (int i=0;i<*stalength;i++){ + int noidinchl=1; + for (int j=0;j \n", argv[0]); - fprintf(stdout, "Usage : %s \n", argv[0]); - fprintf(stdout, "ontvcode ¥Á¥ã¥ó¥Í¥ë¼±Ê̻ҡ£****.ontvjapan.com ¤Ê¤É\n"); - fprintf(stdout, "/BS BS¥â¡¼¥É¡£°ì¤Ä¤ÎTS¤«¤éBSÁ´¶É¤Î¥Ç¡¼¥¿¤òÆɤ߹þ¤ß¤Þ¤¹¡£\n"); - fprintf(stdout, "/CS CS¥â¡¼¥É¡£°ì¤Ä¤ÎTS¤«¤éÊ£¿ô¶É¤Î¥Ç¡¼¥¿¤òÆɤ߹þ¤ß¤Þ¤¹¡£\n"); + fprintf(stdout, "Usage : %s {/BS|/CS} \n", argv[0]); + fprintf(stdout, "Usage : %s \n", argv[0]); + fprintf(stdout, "\n"); + fprintf(stdout, "id チャンネル識別子。地上波の物理チャンネルを与えます。\n"); + fprintf(stdout, "/BS BSモード。一つのTSからBS全局のデータを読み込みます。\n"); + fprintf(stdout, "/CS CSモード。一つのTSから複数局のデータを読み込みます。\n"); + fprintf(stdout, "/TIME 時刻合わせモード。TSからTOT(Time Offset Table)を読み込みます。\n"); + fprintf(stdout, " recpt1 <任意> 10(秒以上) - | epgdump /TIME - <任意>の形で使用してください。\n"); + fprintf(stdout, " TOTは5秒に1回しか来ないため、recpt1に与える時間をある程度長くしてください。\n"); +/* + fprintf(stdout, " ontvcode Channel identifier (ex. ****.ontvjapan.com)\n"); + fprintf(stdout, " /BS BS mode\n"); + fprintf(stdout, " This mode reads the data of all BS TV stations\n"); + fprintf(stdout, " from one TS data.\n"); + fprintf(stdout, " /CS CS mode\n"); + fprintf(stdout, " This mode reads the data of two or more CS TV stations\n"); + fprintf(stdout, " from one TS data.\n"); +*/ return 0; } if(strcmp(arg_onTV, "/BS") == 0){ - pStas = bsSta; - staCount = bsStaCount; + STATION *sta = NULL; + int sta_count = 0; + svttop = calloc(1, sizeof(SVT_CONTROL)); + char *head="BS"; + GetSDT(infile, svttop, secs, SECCOUNT,&sta, &sta_count, head, 1); + checkSta_BS(&sta,&sta_count); + pStas = sta; + staCount = sta_count; + //staCount = sizeof(pStas) / sizeof (STATION); act = 0 ; }else if(strcmp(arg_onTV, "/CS") == 0){ - pStas = csSta; - staCount = csStaCount; + STATION *sta=NULL; + int sta_count = 0; + svttop = calloc(1, sizeof(SVT_CONTROL)); + char *head="CS"; + GetSDT(infile, svttop, secs, SECCOUNT,&sta, &sta_count, head, 1); + checkSta(&sta,&sta_count); + pStas = sta; + staCount = sta_count; + //staCount=sizeof(pStas) / sizeof (STATION); + act = 0 ; + }else if(strcmp(arg_onTV, "/TEST") == 0){ + STATION *sta=NULL; + int sta_count = 0; + svttop = calloc(1, sizeof(SVT_CONTROL)); + char *head="TEST"; + GetSDT(infile, svttop, secs, SECCOUNT,&sta, &sta_count, head, 0); + checkSta(&sta,&sta_count); + //if (sta_count) + printf("Station count: %d\n1st ontv=%s,name=%s\n",sta_count, sta[0].ontv, sta[0].name); + pStas = sta; + staCount = sta_count;// sizeof(pStas) / sizeof (STATION); act = 0 ; + }else if(strcmp(arg_onTV, "/TIME") == 0){ + printf("TSに載っている時刻データは2秒ほど早めてあるのかもしれません。\n"); + memset(secs, 0, sizeof(SECcache) * SECCOUNT); + secs[0].pid = 0x14; /* TOT */ + + GetSDT(infile, NULL, secs, SECCOUNT,NULL, NULL,NULL, 0); + act = 0 ; + + goto cleanup; }else{ + if(infile == NULL){ + fprintf(stderr, "Can't open file: %s\n", argv[2]); + return 1; + } + /* act = 1 ; svttop = calloc(1, sizeof(SVT_CONTROL)); GetSDT(infile, svttop, secs, SECCOUNT); - svtcur = svttop->next ; //ÀèƬ + svtcur = svttop->next ; //先頭 if(svtcur == NULL){ free(svttop); - return ; + return 1; } pStas = calloc(1, sizeof(STATION)); @@ -378,41 +477,58 @@ int main(int argc, char *argv[]) pStas->ontv = arg_onTV ; pStas->name = svtcur->servicename ; staCount = 1; + */ + + // 地上波のマルチチャンネル対応のため + STATION *sta = NULL; + int sta_count = 0; + svttop = calloc(1, sizeof(SVT_CONTROL)); + //char *head=arg_onTV; + GetSDT(infile, svttop, secs, SECCOUNT, &sta, &sta_count, arg_onTV, 0); + checkSta(&sta, &sta_count); + //if (sta_count) printf("Station count: %d\n1st ontv=%s,name=%s\n",sta_count, sta[0].ontv, sta[0].name); + pStas = sta; + staCount = sta_count;// sizeof(pStas) / sizeof (STATION); + act = 0 ; } fprintf(outfile, "\n"); fprintf(outfile, "\n\n"); fprintf(outfile, "\n"); - cd = iconv_open("UTF-8", "EUC-JP"); for(lp = 0 ; lp < staCount ; lp++){ memset(ServiceName, '\0', sizeof(ServiceName)); - ilen = strlen(pStas[lp].name); - olen = sizeof(ServiceName); - outptr = ServiceName ; - inptr = pStas[lp].name ; - iconv(cd, &inptr, &ilen, &outptr, &olen); + strcpy(ServiceName, pStas[lp].name); xmlspecialchars(ServiceName); fprintf(outfile, " \n", pStas[lp].ontv); fprintf(outfile, " %s\n", ServiceName); + + memset(Logo, '\0', sizeof(Logo)); + for ( i = 0 ; i < 6 ; i++) { + if (pStas[lp].logo_array[i].logo) { + base64_encode(Logo, pStas[lp].logo_array[i].logo, pStas[lp].logo_array[i].logo_size); + xmlspecialchars(Logo); + fprintf(outfile, " %s\n", i, Logo); + } + } + fprintf(outfile, " \n"); } for(lp = 0 ; lp < staCount ; lp++){ - GetEIT(infile, outfile, &pStas[lp], secs, SECCOUNT); + GetEIT(infile, outfile, &pStas[lp], secs); } fprintf(outfile, "\n"); +cleanup: if(inclose) { fclose(infile); } - if(outclose) { fclose(outfile); } - iconv_close(cd); if(act){ free(pStas); - svtcur = svttop ; //ÀèƬ + svtcur = svttop ; //先頭 while(svtcur != NULL){ svtsave = svtcur->next ; free(svtcur); diff --git a/epgdump/psi.c b/epgdump/psi.c new file mode 100644 index 0000000..bfeaeda --- /dev/null +++ b/epgdump/psi.c @@ -0,0 +1,203 @@ +// -*- tab-width:4 -*- + +#include +#include +#include + +#include "psi.h" + +int parsePAThead(unsigned char *data, PAThead *path) { + int boff = 0; + + memset(path, 0, sizeof(PAThead)); + + path->table_id = getBit(data, &boff, 8); + path->section_syntax_indicator = getBit(data, &boff, 1); + path->zero = getBit(data, &boff, 1); + path->reserved1 = getBit(data, &boff, 2); + path->section_length = getBit(data, &boff, 12); + path->transport_stream_id = getBit(data, &boff, 16); + path->reserved2 = getBit(data, &boff, 2); + path->version_number = getBit(data, &boff, 5); + path->current_next_indicator = getBit(data, &boff, 1); + path->section_number = getBit(data, &boff, 8); + path->last_section_number = getBit(data, &boff, 8); + + return 8; +} + +int parsePATbody(unsigned char *data, PATbody *patb) { + int boff = 0; + + memset(patb, 0, sizeof(PATbody)); + + patb->program_number = getBit(data, &boff, 16); + patb->reserved = getBit(data, &boff, 3); + if ( patb->program_number == 0 ) { + patb->network_PID = getBit(data, &boff, 13); + } + else { + patb->program_map_PID = getBit(data, &boff, 13); + } + + return 4; +} + +void dumpPAT(unsigned char *ptr, SECcache *secs, int count, int *pmtpids) +{ + int len = 0; + int loop_len = 0; + int i; + + PAThead path; + PATbody patb; + + /* PAT */ + len = parsePAThead(ptr, &path); + ptr += len; + + // printf("PAT=()\n"); + + loop_len = path.section_length; + while ( loop_len > 0 ) { + len = parsePATbody(ptr, &patb); + ptr += len; + loop_len -= len; + + if ( patb.program_number != 0 ) { + for ( i = 1; i < count; i++ ) { + if ( secs[i].pid == patb.program_map_PID ) { + break; + } + if ( secs[i].pid == 0 ) { + // printf("PAT: Adding PID(0x%04x) to secs[%d]\n", patb.program_map_PID, i); + secs[i].pid = patb.program_map_PID; + break; + } + } + for ( i = 0; i < count; i++ ) { + if ( pmtpids[i] == patb.program_map_PID ) { + break; + } + if ( pmtpids[i] == 0 ) { + // printf("PAT: Adding PID(0x%04x) to pmtpids[%d]\n", patb.program_map_PID, i); + pmtpids[i] = patb.program_map_PID; + break; + } + } + } + } + + return; +} + +int parsePMThead(unsigned char *data, PMThead *pmth) { + int boff = 0; + + memset(pmth, 0, sizeof(PMThead)); + + pmth->table_id = getBit(data, &boff, 8); + pmth->section_syntax_indicator = getBit(data, &boff, 1); + pmth->zero = getBit(data, &boff, 1); + pmth->reserved1 = getBit(data, &boff, 2); + pmth->section_length = getBit(data, &boff, 12); + pmth->program_number = getBit(data, &boff, 16); + pmth->reserved2 = getBit(data, &boff, 2); + pmth->version_number = getBit(data, &boff, 5); + pmth->current_next_indicator = getBit(data, &boff, 1); + pmth->section_number = getBit(data, &boff, 8); + pmth->last_section_number = getBit(data, &boff, 8); + pmth->reserved3 = getBit(data, &boff, 3); + pmth->PCR_PID = getBit(data, &boff, 13); + pmth->reserved4 = getBit(data, &boff, 4); + pmth->program_info_length = getBit(data, &boff, 12); + + return 12; +} + +int parsePMTbody(unsigned char *data, PMTbody *pmtb) { + int boff = 0; + + memset(pmtb, 0, sizeof(PMTbody)); + + pmtb->stream_type = getBit(data, &boff, 8); + pmtb->reserved1 = getBit(data, &boff, 3); + pmtb->elementary_PID = getBit(data, &boff, 13); + pmtb->reserved2 = getBit(data, &boff, 4); + pmtb->ES_info_length = getBit(data, &boff, 12); + + return 5; +} + +void dumpPMT(unsigned char *ptr, SECcache *secs, int count, int *dsmccpids) +{ + int len = 0; + int loop_len = 0; + int desc_len = 0; + int i; + + PMThead pmth; + PMTbody pmtb; + + /* PMT */ + len = parsePMThead(ptr, &pmth); + ptr += len; +/* + printf("PMT=(%d:%d:%d:%d:%d:%d:%d:%d)\n", + pmth.table_id, pmth.section_length , + pmth.program_number , pmth.version_number , + pmth.section_number , pmth.last_section_number , + pmth.PCR_PID , pmth.program_info_length); +*/ + loop_len = pmth.program_info_length; + while ( loop_len > 0 ) { + len = parseOTHERdesc(ptr); + ptr += len; + loop_len -= len; + } + + loop_len = pmth.section_length - pmth.program_info_length - 13;// 9はヘッダ長 4はCRC + while ( loop_len > 0 ) { + len = parsePMTbody(ptr, &pmtb); + ptr += len; + loop_len -= len; +/* + printf("PMTb=(0x%x:%d:%d)\n", + pmtb.stream_type , pmtb.elementary_PID , pmtb.ES_info_length); +*/ + if ( pmtb.stream_type == 0x0B || pmtb.stream_type == 0x0D ) { + for ( i = 1; i < count; i++ ) { + if ( secs[i].pid == pmtb.elementary_PID ) { + break; + } + if ( secs[i].pid == 0 ) { + printf("PMT: Adding PID(0x%04x) to secs[%d]\n", pmtb.elementary_PID, i); + secs[i].pid = pmtb.elementary_PID; + break; + } + } + for ( i = 0; i < count; i++ ) { + if ( dsmccpids[i] == pmtb.elementary_PID ) { + break; + } + if ( dsmccpids[i] == 0 ) { + printf("PMT: Adding PID(0x%04x) to dsmccpids[%d]\n", pmtb.elementary_PID, i); + dsmccpids[i] = pmtb.elementary_PID; + break; + } + } + } + + desc_len = pmtb.ES_info_length; + loop_len -= desc_len; + + while ( desc_len > 0 ) { + len = parseOTHERdesc(ptr); + ptr += len; + desc_len -= len; + } + } + + return; +} + diff --git a/epgdump/psi.h b/epgdump/psi.h new file mode 100644 index 0000000..fa00c1d --- /dev/null +++ b/epgdump/psi.h @@ -0,0 +1,71 @@ +#ifndef PSI_H +#define PSI_H 1 + +#include +#include + +#include "ts.h" +#include "util.h" + +typedef struct _PAThead { + unsigned char table_id; + int section_syntax_indicator; + int zero; + int reserved1; + int section_length; + int transport_stream_id; + int reserved2; + int version_number; + int current_next_indicator; + int section_number; + int last_section_number; +} PAThead; + +typedef struct _PATbody { + int program_number; + int reserved; + int network_PID; + int program_map_PID; +} PATbody; + +typedef struct _PMThead { + int table_id; + int section_syntax_indicator; + int zero; + int reserved1; + int section_length; + int program_number; + int reserved2; + int version_number; + int current_next_indicator; + int section_number; + int last_section_number; + int reserved3; + int PCR_PID; + int reserved4; + int program_info_length; +} PMThead; + +typedef struct _PMTbody { + int stream_type; + int reserved1; + int elementary_PID; + int reserved2; + int ES_info_length; +} PMTbody; + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ + + int parsePAThead(unsigned char *data, PAThead *path); + int parsePATbody(unsigned char *data, PATbody *patb); + void dumpPAT(unsigned char *ptr, SECcache *secs, int count, int *pmtpids); + void dumpPMT(unsigned char *ptr, SECcache *secs, int count, int *dsmccpids); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + diff --git a/epgdump/readme.txt b/epgdump/readme.txt index 7727058..95df4db 100755 --- a/epgdump/readme.txt +++ b/epgdump/readme.txt @@ -17,11 +17,15 @@ Linux Žg—p•û–@‚͈ȉº‚Ì’Ê‚è‚Å‚·B -Usage : ./epgdump /BS -Usage : ./epgdump -ontvcode ƒ`ƒƒƒ“ƒlƒ‹Ž¯•ÊŽqB****.ontvjapan.com ‚È‚Ç +Usage : ./epgdump {/BS|/CS} +Usage : ./epgdump + +id ƒ`ƒƒƒ“ƒlƒ‹Ž¯•ÊŽqB’nã”g‚Ì•¨—ƒ`ƒƒƒ“ƒlƒ‹‚ð—^‚¦‚Ü‚·B /BS BSƒ‚[ƒhBˆê‚‚ÌTS‚©‚çBS‘S‹Ç‚̃f[ƒ^‚ð“ǂݍž‚Ý‚Ü‚·B /CS CSƒ‚[ƒhBˆê‚‚ÌTS‚©‚ç•¡”‹Ç‚̃f[ƒ^‚ð“ǂݍž‚Ý‚Ü‚·B +/TIME Žž‡‚킹ƒ‚[ƒhBTS‚©‚çTOT(Time Offset Table)‚ð“ǂݍž‚Ý‚Ü‚·B + recpt1 <”CˆÓ> 10(•bˆÈã) - | epgdump /TIME - <”CˆÓ>‚ÌŒ`‚ÅŽg—p‚µ‚Ä‚­‚¾‚³‚¢B + TOT‚Í5•b‚É1‰ñ‚µ‚©—ˆ‚È‚¢‚½‚߁Arecpt1‚É—^‚¦‚鎞ŠÔ‚ð‚ ‚é’ö“x’·‚­‚µ‚Ä‚­‚¾‚³‚¢B make‚·‚é‚Æepgdump‚ªƒrƒ‹ƒh‚³‚ê‚Ü‚·B @@ -49,6 +53,7 @@ Special Thanks: EŠg’£ƒc[ƒ‹’†‚̐l EŸN/E9PqspSkŽ EARIB(Ž‘—¿‚Ì–³—¿ƒ_ƒEƒ“ƒ[ƒh‚ɑ΂µ‚Ä) +Eƒf[ƒ^•ú‘——pƒvƒƒOƒ‰ƒ€‹l‚ߍ‡‚킹 ‚»‚Ì2‚Ì•û(clt2png‚̃\[ƒXƒR[ƒh‚ðŽg—p) “®ìŠm”FŠÂ‹«: Debian GNU/Linux sid diff --git a/epgdump/sdt.c b/epgdump/sdt.c index 46a74ff..bfc3c28 100755 --- a/epgdump/sdt.c +++ b/epgdump/sdt.c @@ -1,3 +1,5 @@ +// -*- tab-width:4 -*- + #include #include #include @@ -46,10 +48,10 @@ int parseSDTbody(unsigned char *data, SDTbody *b) { } int parseSVCdesc(unsigned char *data, SVCdesc *desc) { +//0x48のサービス記述子、放送局の名前などが入っているよう int boff = 0; - - memset(desc, 0, sizeof(SVCdesc)); + memset(desc, 0, sizeof(SVCdesc)); desc->descriptor_tag = getBit(data, &boff, 8); desc->descriptor_length = getBit(data, &boff, 8); desc->service_type = getBit(data, &boff, 8); @@ -60,7 +62,36 @@ int parseSVCdesc(unsigned char *data, SVCdesc *desc) { return desc->descriptor_length + 2; } -int serachid(SVT_CONTROL *top, int service_id) + +int parseLOGdesc(unsigned char *data, LOGdesc *desc) { +//0xC1のデジタルコピー制御記述子 +//0xCFのロゴ伝送記述子 + int boff = 0; + + memset(desc, 0, sizeof(LOGdesc)); + desc->descriptor_tag = getBit(data, &boff, 8); + desc->descriptor_length = getBit(data, &boff, 8); + desc->logo_transmission_type = getBit(data, &boff, 8); + if ( desc->logo_transmission_type == 0x01 ) { + desc->reserved_future_use1 = getBit(data, &boff, 7); + desc->logo_id = getBit(data, &boff, 9); + desc->reserved_future_use2 = getBit(data, &boff, 4); + desc->logo_version = getBit(data, &boff, 12); + desc->download_data_id = getBit(data, &boff, 16); + } + else if ( desc->logo_transmission_type == 0x02 ) { + desc->reserved_future_use1 = getBit(data, &boff, 7); + desc->logo_id = getBit(data, &boff, 9); + } + else if ( desc->logo_transmission_type == 0x03 ) { + memcpy(desc->logo_char, data + boff / 8, desc->descriptor_length); + // getStr(desc->logo_char, data, &boff, desc->descriptor_length); + } + + return desc->descriptor_length + 2; +} + +int serachid(SVT_CONTROL *top, int service_id) { SVT_CONTROL *cur = top ; while(cur != NULL){ @@ -72,7 +103,7 @@ int serachid(SVT_CONTROL *top, int service_id) return 0 ; } -void enqueue_sdt(SVT_CONTROL *top, SVT_CONTROL *sdtptr) +void enqueue_sdt(SVT_CONTROL *top, SVT_CONTROL *sdtptr) { SVT_CONTROL *cur ; @@ -103,64 +134,140 @@ void enqueue_sdt(SVT_CONTROL *top, SVT_CONTROL *sdtptr) } -void dumpSDT(unsigned char *ptr, SVT_CONTROL *top) +void dumpSDT(unsigned char *ptr, SVT_CONTROL *top,STATION **station, int * station_count,char *ontvheader) { SDThead sdth; SDTbody sdtb; SVCdesc desc; + LOGdesc logd; SVT_CONTROL *svtptr ; + STATION * pStation = *station; int rc ; int len = 0; int loop_len = 0; + int desc_len = 0; + char sid[80]; + int stationi = *station_count; + int i = 0; /* SDT */ len = parseSDThead(ptr, &sdth); ptr += len; - loop_len = sdth.section_length - (len - 3 + 4); // 3¤Ï¶¦Ḁ̈إåÀĹ 4¤ÏCRC + loop_len = sdth.section_length - (len - 3 + 4); // 3は共通ヘッダ長 4はCRC while(loop_len > 0) { len = parseSDTbody(ptr, &sdtb); + //printf("body %d - %d = %d\n",loop_len,len,loop_len - len); ptr += len; loop_len -= len; - parseSVCdesc(ptr, &desc); - - rc = serachid(top, sdtb.service_id); - if(rc == 0){ - svtptr = calloc(1, sizeof(SVT_CONTROL)); - svtptr->event_id = sdtb.service_id; - svtptr->original_network_id = sdth.original_network_id; - svtptr->transport_stream_id = sdth.transport_stream_id; - svtptr->event_id = sdtb.service_id; - memcpy(svtptr->servicename, desc.service_name, strlen(desc.service_name)); - enqueue_sdt(top, svtptr); + + desc_len = sdtb.descriptors_loop_length; + loop_len -= desc_len; + while(desc_len > 0) { + if ( *ptr == 0xCF ) { + len = parseLOGdesc(ptr, &logd); + ptr += len; + desc_len -= len; + + #if 0 + printf("LOG=%d,%d,%d,%d\n", + logd.logo_transmission_type, logd.logo_id, + logd.logo_version, logd.download_data_id); + #endif + + if ( logd.logo_transmission_type != 0x01 ) continue; + for (i=0; ioriginal_network_id = sdth.original_network_id; + svtptr->transport_stream_id = sdth.transport_stream_id; + svtptr->event_id = sdtb.service_id; + memcpy(svtptr->servicename, desc.service_name, strlen(desc.service_name)); + if (desc.service_type == 1){ + enqueue_sdt(top, svtptr); + + sprintf(sid, "%s_%d", ontvheader, sdtb.service_id ); + for (i=0; i0){ + ptr += sdtb.descriptors_loop_length; + } +*/ } - + *station = pStation; + *station_count = stationi; + //printf("stationi %d -",stationi);//stationi==294で落ちる return; } + diff --git a/epgdump/sdt.h b/epgdump/sdt.h index 81f7335..f6b877a 100755 --- a/epgdump/sdt.h +++ b/epgdump/sdt.h @@ -44,6 +44,35 @@ typedef struct _SVCdesc { char service_name[MAXSECLEN]; } SVCdesc; +typedef struct _LOGdesc { + int descriptor_tag; + int descriptor_length; + int logo_transmission_type; + int reserved_future_use1; + int logo_id; + int reserved_future_use2; + int logo_version; + int download_data_id; + + char logo_char[MAXSECLEN]; +} LOGdesc; + +typedef struct _TAG_LOGO +{ + void *logo; + int logo_size; +} LOGO; + +typedef struct _TAG_STATION +{ + char *name; + char *ontv; + int tsId; // OriginalNetworkID + int onId; // TransportStreamID + int svId; // ServiceID + unsigned int logo_download_data_id; + LOGO logo_array[6]; +} STATION; #ifdef __cplusplus extern "C"{ @@ -52,7 +81,7 @@ extern "C"{ int parseSDThead(unsigned char *data, SDThead *h); int parseSDTbody(unsigned char *data, SDTbody *b); int parseSVCdesc(unsigned char *data, SVCdesc *desc); - void dumpSDT(unsigned char *data, SVT_CONTROL *top); + void dumpSDT(unsigned char *ptr, SVT_CONTROL *top, STATION **station, int * station_count, char *ontvheader); #ifdef __cplusplus } diff --git a/epgdump/sdtt.c b/epgdump/sdtt.c new file mode 100644 index 0000000..cdb2fdd --- /dev/null +++ b/epgdump/sdtt.c @@ -0,0 +1,290 @@ +// -*- tab-width:4 -*- + +#include +#include +#include + +#include "sdtt.h" +#include "ts_ctl.h" +#include "clt2png.h" + +// STD-B21 p130 (144) +int parseSDTThead(unsigned char *data, SDTThead *h) { + int boff = 0; + + memset(h, 0, sizeof(SDTThead)); + + h->table_id = getBit(data, &boff, 8); + h->section_syntax_indicator = getBit(data, &boff, 1); + h->reserved_future_use1 = getBit(data, &boff, 1); + h->reserved1 = getBit(data, &boff, 2); + h->section_length = getBit(data, &boff, 12); + h->maker_id = getBit(data, &boff, 8); + h->model_id = getBit(data, &boff, 8); + // boff -= 16; + // h->table_id_ext = getBit(data, &boff, 16); + h->reserved2 = getBit(data, &boff, 2); + h->version_number = getBit(data, &boff, 5); + h->current_next_indicator = getBit(data, &boff, 1); + h->section_number = getBit(data, &boff, 8); + h->last_section_number = getBit(data, &boff, 8); + h->transport_stream_id = getBit(data, &boff, 16); + h->original_network_id = getBit(data, &boff, 16); + h->service_id = getBit(data, &boff, 16); + h->num_of_contents = getBit(data, &boff, 8); + + return 15; +} + +// STD-B21 p130 (144) +int parseSDTTcont(unsigned char *data, SDTTcont *sdtc) { + int boff = 0; + + memset(sdtc, 0, sizeof(SDTTcont)); + sdtc->group = getBit(data, &boff, 4); + sdtc->target_version = getBit(data, &boff, 12); + sdtc->new_version = getBit(data, &boff, 12); + sdtc->download_level = getBit(data, &boff, 2); + sdtc->version_indicator = getBit(data, &boff, 2); + sdtc->content_description_length = getBit(data, &boff, 12); + sdtc->reserved1 = getBit(data, &boff, 4); + sdtc->schedule_description_length = getBit(data, &boff, 12); + sdtc->schedule_timeshift_information = getBit(data, &boff, 4); + /* + for (i=0; ischedule_description_length / 8; i++) { + sdtc->start_time = getBit(data, &boff, 40); + sdtc->duration = getBit(data, &boff, 24); + } + */ + + return sdtc->schedule_description_length + 8; + //return sdtc->content_description_length + 8; +} + +// STD-B21 p132 (146) +int parseSDTTdesc(unsigned char *data, SDTTdesc *sdts) { +// 0xC9(201) + int boff = 0; + int i = 0; + SDTTdescModule *module; + + memset(sdts, 0, sizeof(SDTTdesc)); + sdts->descriptor_tag = getBit(data, &boff, 8); + sdts->descriptor_length = getBit(data, &boff, 8); + sdts->reboot = getBit(data, &boff, 1); + sdts->add_on = getBit(data, &boff, 1); + sdts->compatibility_flag = getBit(data, &boff, 1); + sdts->module_info_flag = getBit(data, &boff, 1); + sdts->text_info_flag = getBit(data, &boff, 1); + sdts->reserved1 = getBit(data, &boff, 3); + sdts->component_size = getBit(data, &boff, 32); + sdts->download_id = getBit(data, &boff, 32); + sdts->time_out_value_DII = getBit(data, &boff, 32); + sdts->leak_rate = getBit(data, &boff, 22); + sdts->reserved2 = getBit(data, &boff,2); + sdts->component_tag = getBit(data, &boff, 8); + + if ( sdts->compatibility_flag == 1) { + sdts->compatibility_length = getBit(data, &boff, 16); + boff += sdts->compatibility_length * 8; + } + if ( sdts->module_info_flag == 1) { + sdts->num_of_modules = getBit(data, &boff, 16); + + if ( sdts->num_of_modules > 0 ) + sdts->modules = calloc(1, sizeof(SDTTdescModule) * ( sdts->num_of_modules + 1 )); + + for (i=0; inum_of_modules; i++) { + module = sdts->modules + sizeof(SDTTdescModule) * i;// &sdts->modules[i]; + module->module_id = getBit(data, &boff, 16); + module->module_size = getBit(data, &boff, 32); + module->module_info_length = getBit(data, &boff, 8); + if ( *(data + boff / 8) == 0x01 ) { + /* Type 記述子 モジュールの型(MIME 形式等) */ + module->descriptor_tag = getBit(data, &boff, 8); + module->descriptor_length = getBit(data, &boff, 8); + module->Type = allocCopy(data, &boff, module->descriptor_length); + module->Type[module->descriptor_length] = '\0'; + // +1 byte for null-terminated + } + else if ( *(data + boff / 8) == 0x02 ) { + /* Name 記述子 モジュール名(ファイル名) */ + module->descriptor_tag = getBit(data, &boff, 8); + module->descriptor_length = getBit(data, &boff, 8); + module->Name = allocCopy(data, &boff, module->descriptor_length); + module->Name[module->descriptor_length] = '\0'; + } + else if ( *(data + boff / 8) == 0x03 ) { + /* Info 記述子 モジュール情報(文字型) */ + module->descriptor_tag = getBit(data, &boff, 8); + module->descriptor_length = getBit(data, &boff, 8); + boff += 24; // ISO_639_language_code + module->Info = allocCopy(data, &boff, module->descriptor_length - 3); + module->Info[module->descriptor_length] = '\0'; + } + else { + module->module_info_byte = allocCopy(data, &boff, module->module_info_length); + } + } + } + sdts->private_data_length = getBit(data, &boff, 8); + sdts->private_data_byte = allocCopy(data, &boff, sdts->private_data_length); + if ( sdts->text_info_flag == 1) { + sdts->ISO_639_language_code = getBit(data, &boff, 24); + sdts->text_length = getBit(data, &boff, 8); + getStr(sdts->text_char, data, &boff, sdts->text_length); + //sdts->text_char = allocCopy(data, &boff, sdts->text_length); + } + + return boff / 8; +} + +// STD-B21 p193 (209) +int parseSDTTdata(unsigned char *data, SDTTdata *cdtd) { + int boff = 0, i, j; + SDTTdataLoop *loop; + SDTTdataService *service; + + memset(cdtd, 0, sizeof(SDTTdata)); + + cdtd->logo_type = getBit(data, &boff, 8); + cdtd->number_of_loop = getBit(data, &boff, 16); + cdtd->loop = calloc(1, sizeof(SDTTdataLoop) * cdtd->number_of_loop); + + for (i=0; inumber_of_loop; i++) { + loop = cdtd->loop + sizeof(SDTTdataLoop) * i; + + loop->reserved_future_use1 = getBit(data, &boff, 7); + loop->logo_id = getBit(data, &boff, 9); + loop->number_of_services = getBit(data, &boff, 8); + loop->services = calloc(1, sizeof(SDTTdataService) * loop->number_of_services); + + for (j=0; jnumber_of_services; j++) { + service = loop->services + sizeof(SDTTdataService) * j; + service->original_network_id = getBit(data, &boff, 16); + service->transport_stream_id = getBit(data, &boff, 16); + service->service_id = getBit(data, &boff, 16); + } + loop->data_size = getBit(data, &boff, 16); + loop->data = allocCopy(data, &boff, loop->data_size); + } + + return boff / 8; +} + +void dumpSDTT(unsigned char *ptr, STATION *station, int station_count) +{ + SDTThead sdth; + SDTTcont sdtc; + SDTTdesc sdts; + SDTTdata sdtd; + SDTTdescModule *module; + + int len = 0; + int loop_len = 0; + int desc_len = 0; + int i, j; + + /* SDTT */ + len = parseSDTThead(ptr, &sdth); + ptr += len; + loop_len = sdth.section_length - (len - 3 + 4); // 3は共通ヘッダ長 4はCRC + + /* + printf("SDTT=(%d:%d:%d:%d:%d:%d:%d:%d:%d:%d)\n", + sdth.table_id, sdth.section_number, sdth.version_number, + sdth.maker_id, sdth.model_id, + sdth.transport_stream_id, sdth.original_network_id, + sdth.service_id, sdth.num_of_contents, sdth.section_length); + */ + + if ( sdth.maker_id == 0xff && sdth.model_id == 0xfe ) + printf("BS FOUND\n"); + + if ( sdth.maker_id == 0xff && sdth.model_id == 0xfc ) + printf("BS/広帯域 CS FOUND\n"); + + if ( ! ( sdth.maker_id == 0xff && ( sdth.model_id == 0xfc || sdth.model_id == 0xfe ) ) ) + return; + + while(loop_len > 0) { + /* + logo_type + 0x00 24x48 864 SD4:3 スモール + 0x01 24x36 648 SD16:9 スモール + 0x02 27x48 972 HD スモール + 0x03 36x72 1296 SD4:3 ラージ + 0x04 36x54 972 SD16:9 ラージ + 0x05 36x64 1152 HD ラージ + */ + + for (i=0; i 0) { + if ( *ptr != 0xC9 ) { + len = parseOTHERdesc(ptr); + ptr += len; + desc_len -= len; + continue; + } + + len = parseSDTTdesc(ptr, &sdts); + ptr += len; + desc_len -= len; +#if 1 + printf("SDTTdesc %d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%s\n", + sdts.descriptor_tag, sdts.descriptor_length, + sdts.reboot, sdts.add_on, + sdts.compatibility_flag, sdts.module_info_flag, sdts.text_info_flag, + sdts.component_size, sdts.download_id, sdts.time_out_value_DII, + sdts.leak_rate, sdts.component_tag, + sdts.text_info_flag ? sdts.text_char : ""); +#endif + for (i=0; idescriptor_tag == 0x01 ) { + printf("sdts.Type %s id:%d\n", module->Type, sdts.download_id); + } + else if ( module->descriptor_tag == 0x02 ) { + printf("sdts.Name %s id:%d\n", module->Name, sdts.download_id); + + if ( strstr( module->Name, "CS_LOGO" ) ) { + station[0].logo_download_data_id = sdts.download_id; + } + else if ( strstr( module->Name, "LOGO" ) ) { + station[0].logo_download_data_id = sdts.download_id; + } + } + else if ( module->descriptor_tag == 0x03 ) { + printf("sdts.Info %s id:%d\n", module->Info, sdts.download_id); + } + else { + printf("MIB: %s\n", module->module_info_byte); + } + } +/* + len = parseSDTTdata(ptr, &sdtd); + ptr += len; + desc_len -= len; +*/ +#if 0 + printf("SDTT=(%d:%d:%d:%d:%d:%dbyte:desc%dbyte)%d,%d,%d,%d\n", + cdth.table_id, cdth.download_data_id, cdth.version_number, + cdth.original_network_id, cdth.data_type, + cdth.section_length, cdth.descriptors_loop_length, + + cdtdte.logo_type, cdtdte.logo_id, cdtdte.logo_version, + cdtdte.data_size); +#endif + } + } + } + return; +} + diff --git a/epgdump/sdtt.h b/epgdump/sdtt.h new file mode 100644 index 0000000..65eaad9 --- /dev/null +++ b/epgdump/sdtt.h @@ -0,0 +1,115 @@ +#ifndef SDTT_H +#define SDTT_H 1 + +#include +#include + +#include "sdt.h" +#include "util.h" +#include "ts_ctl.h" + +typedef struct _SDTThead { + unsigned char table_id; + int section_syntax_indicator; + int reserved_future_use1; + int reserved1; + int section_length; + int maker_id; + int model_id; +// int table_id_ext; + int reserved2; + int version_number; + int current_next_indicator; + int section_number; + int last_section_number; + int transport_stream_id; + int original_network_id; + int service_id; + int num_of_contents; +} SDTThead; + +typedef struct _SDTTcont { + int group; + int target_version; + int new_version; + int download_level; + int version_indicator; + int content_description_length; + int reserved1; + int schedule_description_length; + int schedule_timeshift_information; +} SDTTcont; + +typedef struct _SDTTdescModule { + int module_id; + int module_size; + int module_info_length; + void *module_info_byte; + int descriptor_tag; + int descriptor_length; + char *Type; + char *Name; + char *Info; +} SDTTdescModule; + +typedef struct _SDTTdesc { + int descriptor_tag; + int descriptor_length; + int reboot; + int add_on; + int compatibility_flag; + int compatibility_length; + int module_info_flag; + int text_info_flag; + int reserved1; + int component_size; + unsigned int download_id; + int time_out_value_DII; + int leak_rate; + int reserved2; + int component_tag; + int num_of_modules; + void *modules; + int private_data_length; + void *private_data_byte; + int ISO_639_language_code; + int text_length; + //void *text_char; + char text_char; +} SDTTdesc; + +typedef struct _SDTTdataService { + int original_network_id; + int transport_stream_id; + int service_id; +} SDTTdataService; + +typedef struct _SDTTdataLoop { + int reserved_future_use1; + int logo_id; + int number_of_services; + SDTTdataService *services; + int data_size; + void *data; +} SDTTdataLoop; + +typedef struct _SDTTdataBC { + int logo_type; + int number_of_loop; + SDTTdataLoop *loop; +} SDTTdata; + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ + + int parseSDTThead(unsigned char *data, SDTThead *h); + int parseSDTTdesc(unsigned char *data, SDTTdesc *sdts); + void dumpSDTT(unsigned char *ptr, STATION *station, int station_count); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif + diff --git a/epgdump/tags b/epgdump/tags new file mode 100644 index 0000000..5f87182 --- /dev/null +++ b/epgdump/tags @@ -0,0 +1,113 @@ +!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ +!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ +!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ +!_TAG_PROGRAM_NAME Exuberant Ctags // +!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ +!_TAG_PROGRAM_VERSION 5.7 // +AribToString aribstr.c /^int AribToString($/;" f +AribToStringInternal aribstr.c /^const DWORD AribToStringInternal(TCHAR *lpszDst, $/;" f +BYTE aribstr.c 28;" d file: +CAT_COUNT epgdump.c 18;" d file: +CODE_ADDITIONAL_SYMBOLS aribstr.c 24;" d file: +CODE_ALPHANUMERIC aribstr.c 11;" d file: +CODE_HIRAGANA aribstr.c 12;" d file: +CODE_JIS_KANJI_PLANE_1 aribstr.c 22;" d file: +CODE_JIS_KANJI_PLANE_2 aribstr.c 23;" d file: +CODE_JIS_X0201_KATAKANA aribstr.c 21;" d file: +CODE_KANJI aribstr.c 10;" d file: +CODE_KATAKANA aribstr.c 13;" d file: +CODE_MOSAIC_A aribstr.c 14;" d file: +CODE_MOSAIC_B aribstr.c 15;" d file: +CODE_MOSAIC_C aribstr.c 16;" d file: +CODE_MOSAIC_D aribstr.c 17;" d file: +CODE_PROP_ALPHANUMERIC aribstr.c 18;" d file: +CODE_PROP_HIRAGANA aribstr.c 19;" d file: +CODE_PROP_KATAKANA aribstr.c 20;" d file: +CODE_SET aribstr.c 36;" d file: +CODE_UNKNOWN aribstr.c 9;" d file: +CONTENT_TYPE epgdump.c /^}CONTENT_TYPE;$/;" t typeref:struct:_ContentTYPE file: +CalcCrc ts.c /^unsigned int CalcCrc(unsigned int crc, unsigned char *buf, int len) {$/;" f +Category epgdump.c /^char Category[1024];$/;" v +ContentCatList epgdump.c /^static CONTENT_TYPE ContentCatList[CAT_COUNT] = {$/;" v file: +DWORD aribstr.c 30;" d file: +DesignationDRCS aribstr.c /^const bool DesignationDRCS(const BYTE byIndexG, const BYTE byCode)$/;" f +DesignationGSET aribstr.c /^const bool DesignationGSET(const BYTE byIndexG, const BYTE byCode)$/;" f +GetEIT epgdump.c /^void GetEIT(FILE *infile, FILE *outfile, SVT_CONTROL *svtcur, SECcache *secs, int count)$/;" f +GetSDT epgdump.c /^void GetSDT(FILE *infile, SVT_CONTROL *svttop, SECcache *secs, int count)$/;" f +LockingShiftGL aribstr.c /^void LockingShiftGL(const BYTE byIndexG)$/;" f +LockingShiftGR aribstr.c /^void LockingShiftGR(const BYTE byIndexG)$/;" f +ProcessCharCode aribstr.c /^const DWORD ProcessCharCode(TCHAR *lpszDst, const WORD wCode, const CODE_SET CodeSet)$/;" f +ProcessEscapeSeq aribstr.c /^void ProcessEscapeSeq(const BYTE byCode)$/;" f +PutAlphanumericChar aribstr.c /^const DWORD PutAlphanumericChar(TCHAR *lpszDst, const WORD wCode)$/;" f +PutHiraganaChar aribstr.c /^const DWORD PutHiraganaChar(TCHAR *lpszDst, const WORD wCode)$/;" f +PutJisKatakanaChar aribstr.c /^const DWORD PutJisKatakanaChar(TCHAR *lpszDst, const WORD wCode)$/;" f +PutKanjiChar aribstr.c /^const DWORD PutKanjiChar(TCHAR *lpszDst, const WORD wCode)$/;" f +PutKatakanaChar aribstr.c /^const DWORD PutKatakanaChar(TCHAR *lpszDst, const WORD wCode)$/;" f +PutSymbolsChar aribstr.c /^const DWORD PutSymbolsChar(TCHAR *lpszDst, const WORD wCode)$/;" f +SECCOUNT epgdump.c 140;" d file: +STATION epgdump.c /^} STATION;$/;" t typeref:struct:_TAG_STATION file: +ServiceName epgdump.c /^char ServiceName[1024];$/;" v +SingleShiftGL aribstr.c /^void SingleShiftGL(const BYTE byIndexG)$/;" f +TCHAR aribstr.c 27;" d file: +TEXT aribstr.c 34;" d file: +WORD aribstr.c 29;" d file: +_ContentTYPE epgdump.c /^typedef struct _ContentTYPE{$/;" s file: +_T aribstr.c 35;" d file: +_TAG_STATION epgdump.c /^typedef struct _TAG_STATION$/;" s file: +abCharSizeTable aribstr.c /^static const bool abCharSizeTable[] =$/;" v file: +bool aribstr.c 31;" d file: +bsSta epgdump.c /^static STATION bsSta[] = {$/;" v file: +bsSta xmldata.c /^static STATION bsSta[] = {$/;" v file: +bsStaCount epgdump.c /^static int bsStaCount = sizeof(bsSta) \/ sizeof (STATION);$/;" v file: +bsStaCount xmldata.c /^static int bsStaCount = sizeof(bsSta) \/ sizeof (STATION);$/;" v file: +cd epgdump.c /^iconv_t cd ;$/;" v +checkEEVTDitem eit.c /^int checkEEVTDitem(EEVTDitem *save, EEVTDitem *new, int descriptor_number) {$/;" f +checkcrc ts.c /^int checkcrc(SECcache *secs) {$/;" f +convertjis aribstr.c /^WORD convertjis(DWORD jiscode) {$/;" f +csSta epgdump.c /^static STATION csSta[] = {$/;" v file: +csSta xmldata.c /^static STATION csSta[] = {$/;" v file: +csStaCount epgdump.c /^static int csStaCount = sizeof(csSta) \/ sizeof (STATION);$/;" v file: +csStaCount xmldata.c /^static int csStaCount = sizeof(csSta) \/ sizeof (STATION);$/;" v file: +dumpEIT eit.c /^void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int transport_stream_id, EIT_CONTROL *eittop)$/;" f +dumpSDT sdt.c /^void dumpSDT(unsigned char *ptr, SVT_CONTROL *top)$/;" f +english epgdump.c /^ char *english ;$/;" m struct:_ContentTYPE file: +enqueue eit.c /^void enqueue(EIT_CONTROL *top, EIT_CONTROL *eitptr)$/;" f +enqueue_sdt sdt.c /^void enqueue_sdt(SVT_CONTROL *top, SVT_CONTROL *sdtptr)$/;" f +false aribstr.c 33;" d file: +getBit util.c /^int getBit(unsigned char *byte, int *pbit, int gbit) {$/;" f +getStr util.c /^void getStr(char *tostr, unsigned char *byte, int *pbit, int len) {$/;" f +japanese epgdump.c /^ char *japanese ;$/;" m struct:_ContentTYPE file: +m_CodeG aribstr.c /^static int m_CodeG[4];$/;" v file: +m_bIsEscSeqDrcs aribstr.c /^static bool m_bIsEscSeqDrcs;$/;" v file: +m_byEscSeqCount aribstr.c /^static BYTE m_byEscSeqCount;$/;" v file: +m_byEscSeqIndex aribstr.c /^static BYTE m_byEscSeqIndex;$/;" v file: +m_pLockingGL aribstr.c /^static int *m_pLockingGL;$/;" v file: +m_pLockingGR aribstr.c /^static int *m_pLockingGR;$/;" v file: +m_pSingleGL aribstr.c /^static int *m_pSingleGL;$/;" v file: +main epgdump.c /^int main(int argc, char *argv[])$/;" f +name epgdump.c /^ char *name;$/;" m struct:_TAG_STATION file: +onId epgdump.c /^ int onId; \/\/ TransportStreamID$/;" m struct:_TAG_STATION file: +ontv epgdump.c /^ char *ontv;$/;" m struct:_TAG_STATION file: +parseContentDesc eit.c /^int parseContentDesc(unsigned char *data, ContentDesc *desc) {$/;" f +parseEEVTDhead eit.c /^int parseEEVTDhead(unsigned char *data, EEVTDhead *desc) {$/;" f +parseEEVTDitem eit.c /^int parseEEVTDitem(unsigned char *data, EEVTDitem *desc) {$/;" f +parseEEVTDtail eit.c /^int parseEEVTDtail(unsigned char *data, EEVTDtail *desc) {$/;" f +parseEITbody eit.c /^int parseEITbody(unsigned char *data, EITbody *b) {$/;" f +parseEIThead eit.c /^int parseEIThead(unsigned char *data, EIThead *h) {$/;" f +parseOTHERdesc util.c /^int parseOTHERdesc(unsigned char *data) {$/;" f +parseSDTbody sdt.c /^int parseSDTbody(unsigned char *data, SDTbody *b) {$/;" f +parseSDThead sdt.c /^int parseSDThead(unsigned char *data, SDThead *h) {$/;" f +parseSEVTdesc eit.c /^int parseSEVTdesc(unsigned char *data, SEVTdesc *desc) {$/;" f +parseSVCdesc sdt.c /^int parseSVCdesc(unsigned char *data, SVCdesc *desc) {$/;" f +parseSeriesDesc eit.c /^int parseSeriesDesc(unsigned char *data, SeriesDesc *desc) {$/;" f +readTS ts.c /^SECcache *readTS(FILE *in, SECcache secs[], int size) {$/;" f +searcheit eit.c /^EIT_CONTROL *searcheit(EIT_CONTROL *top, int servid, int eventid)$/;" f +serachid sdt.c /^int serachid(SVT_CONTROL *top, int service_id)$/;" f +subtitle epgdump.c /^char subtitle[1024];$/;" v +svId epgdump.c /^ int svId; \/\/ ServiceID$/;" m struct:_TAG_STATION file: +svttop epgdump.c /^SVT_CONTROL *svttop = NULL;$/;" v +timecmp eit.c /^void timecmp(int *thh, int *tmm, int *tss,$/;" f +title epgdump.c /^char title[1024];$/;" v +true aribstr.c 32;" d file: +tsId epgdump.c /^ int tsId; \/\/ OriginalNetworkID$/;" m struct:_TAG_STATION file: +xmlspecialchars epgdump.c /^void xmlspecialchars(char *str)$/;" f diff --git a/epgdump/tot.c b/epgdump/tot.c new file mode 100644 index 0000000..15c7641 --- /dev/null +++ b/epgdump/tot.c @@ -0,0 +1,70 @@ +// -*- tab-width:4 -*- + +#include +#include +#include + +#include "tot.h" +#include "ts_ctl.h" + +int parseTOThead(unsigned char *data, TOThead *toth) { + int boff = 0; + + memset(toth, 0, sizeof(TOThead)); + + toth->table_id = getBit(data, &boff, 8); + toth->section_syntax_indicator = getBit(data, &boff, 1); + toth->reserved_future_use1 = getBit(data, &boff, 1); + toth->reserved1 = getBit(data, &boff, 2); + toth->section_length = getBit(data, &boff, 12); + memcpy(toth->JST_time, data + boff / 8, 5); + boff += 40; + // toth->JST_time = getBit(data, &boff, 40); + toth->reserved2 = getBit(data, &boff, 4); + toth->descriptors_loop_length = getBit(data, &boff, 12); + + return 10; +} + +int parseTOTdesc(unsigned char *data, TOTdesc *totd) { + int boff = 0; + + memset(totd, 0, sizeof(TOTdesc)); + + totd->descriptor_tag = getBit(data, &boff, 8); + totd->descriptor_length = getBit(data, &boff, 8); + + return totd->descriptor_length + 2; +} + +void dumpTOT(unsigned char *ptr) +{ + TOThead toth; + TOTdesc totd; + + int len = 0; + int loop_len = 0; + int desc_len = 0; + int i = 0; + time_t tot; + + /* TOT */ + len = parseTOThead(ptr, &toth); + ptr += len; + loop_len = toth.section_length - (len - 3 + 4); // 3は共通ヘッダ長 4はCRC + + tot = parseMJD( toth.JST_time ); + printf("TOT diff:%d[秒] %s", + (int)difftime( time(NULL), tot ), ctime(&tot)); + //ptm = localtime(time(NULL)); +/* + desc_len = toth.descriptors_loop_length; + while(desc_len > 0) { + len = parseTOTdesc(ptr, &totd); + ptr += len; + desc_len -= len; + } +*/ + return; +} + diff --git a/epgdump/tot.h b/epgdump/tot.h new file mode 100644 index 0000000..4699370 --- /dev/null +++ b/epgdump/tot.h @@ -0,0 +1,38 @@ +#ifndef TOT_H +#define TOT_H 1 + +#include +#include + +#include "util.h" +#include "ts_ctl.h" + +typedef struct _TOThead { + unsigned char table_id; + int section_syntax_indicator; + int reserved_future_use1; + int reserved1; + int section_length; + unsigned char JST_time[5]; + int reserved2; + int descriptors_loop_length; +} TOThead; + +typedef struct _TOTdesc { + unsigned char descriptor_tag; + int descriptor_length; +} TOTdesc; + +#ifdef __cplusplus +extern "C"{ +#endif /* __cplusplus */ + + int parseTOThead(unsigned char *data, TOThead *toth); + int parseTOTdesc(unsigned char *data, TOTdesc *totd); + void dumpTOT(unsigned char *ptr); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/epgdump/ts.c b/epgdump/ts.c index c6cac1c..7036bc3 100755 --- a/epgdump/ts.c +++ b/epgdump/ts.c @@ -22,7 +22,7 @@ SECcache *readTS(FILE *in, SECcache secs[], int size) { int inchar; int i; - /* sync¥Ð¥¤¥È¤Þ¤ÇÆɤßÈô¤Ð¤· */ + /* syncバイトまで読み飛ばし */ if(rcount == 0) { while((inchar = fgetc(in)) != EOF) { if((inchar & 0xFF) == 0x47) { @@ -38,9 +38,9 @@ SECcache *readTS(FILE *in, SECcache secs[], int size) { retry: - /* Ì᤹¤Ù¤­»Ä¤ê¤¬¤¢¤ë¤«? */ + /* 戻すべき残りがあるか? */ if(ridx >= 0 && secs[ridx].cont) { - /* ¥Ð¥Ã¥Õ¥¡¥Á¥§¥Ã¥¯ */ + /* バッファチェック */ if((secs[ridx].cur.payload[secs[ridx].curlen] & 0xFF) == 0xFF) { secs[ridx].cont = 0; secs[ridx].seclen = 0; @@ -48,14 +48,14 @@ retry: secs[ridx].curlen = 0; } else { len = secs[ridx].cur.payloadlen - secs[ridx].curlen; - /* Á´ÉôÀßÄêºÑ¤ß¥Á¥§¥Ã¥¯ */ + /* 全部設定済みチェック */ if(len == 0) { secs[ridx].cont = 0; secs[ridx].seclen = 0; secs[ridx].setlen = 0; secs[ridx].curlen = 0; } else { - /* ¤³¤³¤Çseclen¤¬¸Ù¤ë¤è¤¦¤ËTSʬ³ä¤µ¤ì¤Æ¤¤¤ë¤Èº¤¤ë¤Ê @@ + /* ここでseclenが跨るようにTS分割されていると困るな @@ if(secs[ridx].pid == 0x12) { int check = secs[ridx].cur.payload[secs[ridx].curlen] & 0xFF; if(!(check == 0x4E || @@ -67,7 +67,14 @@ retry: */ boff = 12; - secs[ridx].seclen = getBit(&secs[ridx].cur.payload[secs[ridx].curlen], &boff, 12) + 3; // ¥Ø¥Ã¥À + secs[ridx].seclen = getBit(&secs[ridx].cur.payload[secs[ridx].curlen], &boff, 12) + 3; // ヘッダ + /* + if(secs[ridx].seclen > MAXSECLEN){ + // セクションが MAXSECLEN より大きい時はこのセクションをスキップ + secs[ridx].cont = 0; + goto retry; + } + */ /* if(secs[ridx].seclen == 2334) { @@ -75,13 +82,13 @@ retry: } */ - /* TS¥Ç¡¼¥¿Ä¹-ÀßÄêºÑ¤ß¥Ç¡¼¥¿Ä¹ */ + /* TSデータ長-設定済みデータ長 */ if(secs[ridx].seclen > len) { memcpy(secs[ridx].buf, &secs[ridx].cur.payload[secs[ridx].curlen], len); secs[ridx].setlen = len; secs[ridx].curlen = 0; secs[ridx].cont = 1; - /* ¼¡¤Î¥ì¥³¡¼¥ÉÆɤ߹þ¤ß */ + /* 次のレコード読み込み */ } else { memcpy(secs[ridx].buf, &secs[ridx].cur.payload[secs[ridx].curlen], secs[ridx].seclen); @@ -89,11 +96,11 @@ retry: secs[ridx].curlen += secs[ridx].seclen; secs[ridx].cont = 1; - /* CRC¤Î¥Á¥§¥Ã¥¯ */ + /* CRCのチェック */ if(checkcrc(&(secs[ridx]))) { - return &(secs[ridx]); /* Ìá¤ë */ + return &(secs[ridx]); /* 戻る */ } - goto retry; /* ¤â¤¦°ì²ó */ + goto retry; /* もう一回 */ } } } @@ -102,14 +109,14 @@ retry: int roffset = 0; while(1) { if(fread(buf+roffset, 188-roffset, 1, in) != 1) { - /* »Ä¤ê¤Î½èÍý? */ + /* 残りの処理? */ return NULL; } roffset = 0; rcount++; if((buf[0] & 0xFF) != 0x47) { - /* ºÇ½é¤ÏbufÃæ¤Ë0x47¤¬¤¢¤ë¤«¥Á¥§¥Ã¥¯ */ + /* 最初はbuf中に0x47があるかチェック */ for(i = 1; i < 188; i++) { if((buf[i] & 0xFF) == 0x47) { break; @@ -117,7 +124,7 @@ retry: } if(i < 188) { - /* ¤½¤³¤«¤éºÆÆɤ߹þ¤ß¤·¤ÆÍߤ·¤¤¤Î¤Çseek */ + /* そこから再読み込みして欲しいのでseek */ //fseek(in, (188 - i) * -1, SEEK_CUR); roffset = i; memmove(buf, buf + i, 188 - i); @@ -197,16 +204,17 @@ retry: shall be '1', indicating that the first byte of the payload of this Transport Stream packet carries the pointer_field. */ if(pk.payload_unit_start_indicator == 1) { - /* pointer_field¤Ï¤¤¤é¤Ê¤¤ */ + /* pointer_fieldはいらない */ payptr += 1; pk.payloadlen -= 1; } + memset(pk.payload, 0xFF, sizeof(pk.payload)); -#if 1 /* 07/07/2009 add: */ + /* 07/07/2009 add: */ + //if((pk.payloadlen <= 0) || (pk.payloadlen > sizeof(pk.payload))){ if( pk.payloadlen > sizeof(pk.payload) ){ continue; } -#endif memcpy(pk.payload, payptr, pk.payloadlen); /* @@ -219,15 +227,22 @@ retry: } */ - /* ¶½Ì£¤Î¤¢¤ëpid¤«³Îǧ */ + /* 興味のあるpidか確認 */ for(int i = 0;i < size; i++) { if(secs[i].pid == pk.pid) { secs[i].cur = pk; - /* ÅÓÃæ½èÍýÃ椫ºÇ½é¤«? */ + /* 途中処理中か最初か? */ if(!secs[i].cont) { - /* ºÇ½é ¥»¥¯¥·¥ç¥óŤòÄ´¤Ù¤ë */ + /* 最初 セクション長を調べる */ boff = 12; - secs[i].seclen = getBit(secs[i].cur.payload, &boff, 12) + 3; // ¥Ø¥Ã¥À; + secs[i].seclen = getBit(secs[i].cur.payload, &boff, 12) + 3; // ヘッダ; + /* + if(secs[i].seclen > MAXSECLEN){ + // セクション長が MAXSECLEN より長いときはこのセクションをスキップ + secs[i].cont = 0; + goto retry; + } + */ /* if(secs[i].seclen == 2334) { printf("aa"); @@ -245,32 +260,32 @@ retry: secs[i].curlen = secs[i].seclen; secs[i].cont = 1; ridx = i; - /* CRC¤Î¥Á¥§¥Ã¥¯ */ + /* CRCのチェック */ if(checkcrc(&(secs[ridx]))) { - return &(secs[i]); /* ¼è¤ê¹ç¤¨¤ºÌá¤ë */ + return &(secs[i]); /* 取り合えず戻る */ } - goto retry; /* »Ä¤ê½èÍý¤Ø */ + goto retry; /* 残り処理へ */ } - /* ¥»¥¯¥·¥ç¥óĹ-ÀßÄêºÑ¤ßĹ */ + /* セクション長-設定済み長 */ len = secs[i].seclen - secs[i].setlen; if(len > secs[i].cur.payloadlen) { - /* Á´ÂΞÁ÷ */ + /* 全体転送 */ memcpy(&secs[i].buf[secs[i].setlen], secs[i].cur.payload, secs[i].cur.payloadlen); secs[i].setlen += secs[i].cur.payloadlen; continue; } - /* ¥»¥¯¥·¥ç¥óŤλĤê¤òÀßÄê */ + /* セクション長の残りを設定 */ memcpy(&secs[i].buf[secs[i].setlen], secs[i].cur.payload, len); secs[i].setlen = secs[i].seclen; secs[i].curlen += len; secs[i].cont = 1; ridx = i; - /* CRC¤Î¥Á¥§¥Ã¥¯ */ + /* CRCのチェック */ if(checkcrc(&(secs[ridx]))) { return &(secs[i]); } - goto retry; /* »Ä¤ê½èÍý¤Ø */ + goto retry; /* 残り処理へ */ } } } @@ -278,7 +293,7 @@ retry: //return NULL; } -/* BonTest/TsStream.cpp¤«¤é¤Î¥Ñ¥¯¥ê */ +/* BonTest/TsStream.cppからのパクリ */ unsigned int CalcCrc(unsigned int crc, unsigned char *buf, int len) { unsigned int c = crc; int n; @@ -312,17 +327,16 @@ unsigned int CalcCrc(unsigned int crc, unsigned char *buf, int len) { int checkcrc(SECcache *secs) { -#if 1 /* 07/07/2009 add: °Û¾ï¾õÂÖ²óÈò¤Î¤¿¤á */ - /* ¥»¥¯¥·¥ç¥óºÇÂçŤòĶ¤¨¤ë¤³¤È¤Ê¤É¤¢¤êÆÀ¤Ê¤¤¤Ï¤º¤À¤¬... */ + /* 07/07/2009 add: 異常状態回避のため */ + /* セクション最大長を超えることなどあり得ないはずだが... */ if( secs->seclen > MAXSECLEN ){ - /* ¤è¤¯Ê¬¤«¤é¤ó¤Î¤ÇÇË´þ¤·¤Æ¤ä¤ë */ + /* よく分からんので破棄してやる */ return 0; } -#endif - /* ¥»¥¯¥·¥ç¥ó¤Î½ª¤ê¤ËÃÖ¤«¤ì¤ë4¥Ð¥¤¥È¤ÎCRC32¤Ï¡¢ - CRC·×»»¤Î·ë²Ì0¤Ë¤Ê¤ë¤è¤¦¤ËÀßÄꤵ¤ì¤ë¡£ - Ãͤ¬È¯À¸¤·¤¿¾ì¹ç¤Ï¡¢¥¨¥é¡¼¤Ê¤Î¤ÇÂоݳ°¤Ë¤¹¤ë */ + /* セクションの終りに置かれる4バイトのCRC32は、 + CRC計算の結果0になるように設定される。 + 値が発生した場合は、エラーなので対象外にする */ if(CalcCrc(0xffffffffU, secs->buf, secs->seclen)) { // fprintf(stderr, "tblid:0x%x CRC error\n", secs->buf[0]); return 0; diff --git a/epgdump/ts_ctl.h b/epgdump/ts_ctl.h index 1d74dd0..098ac73 100755 --- a/epgdump/ts_ctl.h +++ b/epgdump/ts_ctl.h @@ -7,10 +7,10 @@ typedef struct _SVT_CONTROL SVT_CONTROL; struct _SVT_CONTROL{ SVT_CONTROL *next ; SVT_CONTROL *prev ; - int event_id ; // ¥¤¥Ù¥ó¥ÈID + int event_id ; // イベントID int original_network_id ; // OriginalNetworkID - int transport_stream_id ; // TransporrtStreamID - char servicename[MAXSECLEN] ; // ¥µ¡¼¥Ó¥¹Ì¾ + int transport_stream_id ; // TransportStreamID + char servicename[MAXSECLEN] ; // サービス名 }; typedef struct _EIT_CONTROL EIT_CONTROL; @@ -19,13 +19,13 @@ struct _EIT_CONTROL{ EIT_CONTROL *prev ; int table_id ; int servid ; - int event_id ; // ¥¤¥Ù¥ó¥ÈID - int content_type ; // ¥³¥ó¥Æ¥ó¥È¥¿¥¤¥× - int yy; - int mm; - int dd; - int hh; - int hm; + int event_id ; // イベントID + int content_type ; // コンテントタイプ + int yy; + int mm; + int dd; + int hh; + int hm; int ss; int dhh; int dhm; @@ -33,8 +33,10 @@ struct _EIT_CONTROL{ int ehh; int emm; int ess; - char *title ; // ¥¿¥¤¥È¥ë - char *subtitle ; // ¥µ¥Ö¥¿¥¤¥È¥ë - char *desc ; // Description + char *title ; // タイトル + char *subtitle ; // サブタイトル + char *desc ; // Description + int desc_length ; // Description Length }; #endif + diff --git a/epgdump/util.c b/epgdump/util.c index 1dc39bb..f85021f 100755 --- a/epgdump/util.c +++ b/epgdump/util.c @@ -7,16 +7,28 @@ int strrep(char *buf, char *mae, char *ato) { - char *mituke; + char *mitsuke, *findpos; size_t maelen, atolen; + int shift; + findpos = buf; maelen = strlen(mae); atolen = strlen(ato); - if (maelen == 0 || (mituke = strstr(buf, mae)) == NULL) return 0; - memmove(mituke + atolen, mituke + maelen, strlen(buf) - (mituke + maelen - buf ) + 1); - memcpy(mituke, ato, atolen); + shift = (int)(strlen(ato)-strlen(mae)); + + if (maelen == 0 || strstr(findpos, mae) == NULL) return 0; + while ((mitsuke = strstr(findpos, mae)) != NULL) { + if (shift > 0) { + memmove(mitsuke + shift, mitsuke, strlen(mitsuke) + 1); + } else if (shift < 0) { + memmove(mitsuke, mitsuke - shift, strlen(mitsuke) + shift + 1); + } + memmove(mitsuke, ato, atolen); + findpos = mitsuke + atolen; + } return 1; } + int getBit(unsigned char *byte, int *pbit, int gbit) { int pbyte = *pbit / 8; unsigned char *fbyte = byte + pbyte; @@ -24,19 +36,19 @@ int getBit(unsigned char *byte, int *pbit, int gbit) { int cutbit = *pbit - (pbyte * 8); int lcutbit = 32 - (cutbit + gbit); - unsigned char tbuf[4]; /* int¤ÎºÇÂç32bit */ + unsigned char tbuf[4]; /* intの最大32bit */ unsigned int tnum; memcpy(tbuf, fbyte, sizeof(unsigned char) * 4); - /* ÀèƬ¥Ð¥¤¥È¤«¤éÉÔÍ×bit¤ò¥«¥Ã¥È */ + /* 先頭バイトから不要bitをカット */ tbuf[0] = tbuf[0] << cutbit; tbuf[0] = tbuf[0] >> cutbit; - /* int¤Ë¤·¤Æ¤·¤Þ¤¦ */ + /* intにしてしまう */ tnum = tbuf[0] << 24 | tbuf[1] << 16 | tbuf[2] << 8 | tbuf[3]; - /* ¸å¤í¤ÎÉÔÍץХ¤¥È¤ò¥«¥Ã¥È */ + /* 後ろの不要バイトをカット */ tnum = tnum >> lcutbit; *pbit += gbit; @@ -74,3 +86,43 @@ int parseOTHERdesc(unsigned char *data) { return descriptor_length + 2; } +void* allocCopy(void* src, int *boff, size_t size) { + void* mem = NULL; + if ( size == 0 ) return NULL; + + mem = malloc(size); + memcpy(mem, src + *boff / 8, size); + *boff += size * 8; + return mem; +} + +//#define BCD(n) ((n/100)<<8)|(((n%100)/10)<<4)|(n%10) +#define BCD(n) ((n>>4)*10+(n&0xf)) + +time_t parseMJD( unsigned char *data ) { + int tnum, year, mon, mday; + struct tm MJD; + + tnum = (data[0] & 0xFF) << 8 | (data[1] & 0xFF); + year = (tnum - 15078.2) / 365.25; + mon = ((tnum - 14956.1) - (int)(year * 365.25)) / 30.6001; + mday = (tnum - 14956) - (int)(year * 365.25) - (int)(mon * 30.6001); + + if(mon == 14 || mon == 15) { + year += 1; + mon -= 13; + } else { + mon -= 1; + } + + memset( &MJD, 0, sizeof(MJD) ); + MJD.tm_year = year; + MJD.tm_mon = mon - 1; + MJD.tm_mday = mday; + + MJD.tm_hour = BCD(data[2]); + MJD.tm_min = BCD(data[3]); + MJD.tm_sec = BCD(data[4]); + return mktime( &MJD ); +} + diff --git a/epgdump/util.h b/epgdump/util.h index 483f624..2cc701c 100755 --- a/epgdump/util.h +++ b/epgdump/util.h @@ -1,15 +1,19 @@ #ifndef UTIL_H -#define UTILH 1 +#define UTIL_H 1 #define MAXSECLEN 4096 +#include + #ifdef __cplusplus extern "C"{ #endif /* __cplusplus */ - int getBit(unsigned char *byte, int *pbit, int gbit); - void getStr(char *tostr, unsigned char *byte, int *pbit, int len); - int parseOTHERdesc(unsigned char *data); + int getBit(unsigned char *byte, int *pbit, int gbit); + void getStr(char *tostr, unsigned char *byte, int *pbit, int len); + int parseOTHERdesc(unsigned char *data); + void* allocCopy(void* src, int *boff, size_t size); + time_t parseMJD( unsigned char *data ); #ifdef __cplusplus } diff --git a/epgdump/xmldata.c b/epgdump/xmldata.c index 56e087b..06a617e 100755 --- a/epgdump/xmldata.c +++ b/epgdump/xmldata.c @@ -2,14 +2,15 @@ static STATION bsSta[] = { { "NHK BS1", "3001.ontvjapan.com", 16625, 4, 101}, { "NHK BS2", "3002.ontvjapan.com", 16625, 4, 102}, { "NHK BSh", "3003.ontvjapan.com", 16626, 4, 103}, - { "BSÆü¥Æ¥ì", "3004.ontvjapan.com", 16592, 4, 141}, - { "BSÄ«Æü", "3005.ontvjapan.com", 16400, 4, 151}, - { "BS-i", "3006.ontvjapan.com", 16401, 4, 161}, - { "BS¥¸¥ã¥Ñ¥ó", "3007.ontvjapan.com", 16433, 4, 171}, - { "BS¥Õ¥¸", "3008.ontvjapan.com", 16593, 4, 181}, + { "BS日テレ", "3004.ontvjapan.com", 16592, 4, 141}, + { "BS朝日", "3005.ontvjapan.com", 16400, 4, 151}, + { "BS-TBS", "3006.ontvjapan.com", 16401, 4, 161}, + { "BSジャパン", "3007.ontvjapan.com", 16433, 4, 171}, + { "BSフジ", "3008.ontvjapan.com", 16593, 4, 181}, { "WOWOW", "3009.ontvjapan.com", 16432, 4, 191}, { "WOWOW2", "3010.ontvjapan.com", 16432, 4, 192}, { "WOWOW3", "3011.ontvjapan.com", 16432, 4, 193}, + { "スター・チャンネル", "3012.ontvjapan.com", 16529, 4, 200}, { "BS11", "3013.ontvjapan.com", 16528, 4, 211}, { "TwellV", "3014.ontvjapan.com", 16530, 4, 222}, }; @@ -19,75 +20,75 @@ static int bsStaCount = sizeof(bsSta) / sizeof (STATION); static STATION csSta[] = { - { "¥¹¥¿¡¼£ã£è¥×¥é¥¹", "1002.ontvjapan.com", 24608, 6, 237}, - { "ÆüËܱDzèÀìÌç£ã£è£È£Ä", "1086.ontvjapan.com", 24608, 6, 239}, - { "¥Õ¥¸¥Æ¥ì¥Ó£Ã£Ó£È£Ä", "306ch.epgdata.ontvjapan", 24608, 6, 306}, - { "¥·¥ç¥Ã¥×¥Á¥ã¥ó¥Í¥ë", "1059.ontvjapan.com", 24704, 6, 55}, - { "¥¶¡¦¥·¥Í¥Þ", "1217.ontvjapan.com", 24736, 6, 228}, - { "¥¹¥«¥Á¥ã¥ó£È£Ä£¸£°£°", "800ch.epgdata.ontvjapan", 24736, 6, 800}, - { "¥¹¥«¥Á¥ã¥ó£¸£°£±", "801ch.epgdata.ontvjapan", 24736, 6, 801}, - { "¥¹¥«¥Á¥ã¥ó£¸£°£²", "802ch.epgdata.ontvjapan", 24736, 6, 802}, - { "£å£²¥×¥í¥â", "100ch.epgdata.ontvjapan", 28736, 7, 100}, - { "¥¤¥ó¥¿¡¼¥í¡¼¥«¥ë£Ô£Ö", "194ch.epgdata.ontvjapan", 28736, 7, 194}, - { "£Ê¥¹¥Ý¡¼¥Ä¡¡£Å£Ó£Ð£Î", "1025.ontvjapan.com", 28736, 7, 256}, - { "£Æ£Ï£Ø", "1016.ontvjapan.com", 28736, 7, 312}, - { "¥¹¥Ú¡¼¥¹¥·¥ã¥ï¡¼£Ô£Ö", "1018.ontvjapan.com", 28736, 7, 322}, - { "¥«¡¼¥È¥¥¡¼¥ó¡¡¥Í¥Ã¥È", "1046.ontvjapan.com", 28736, 7, 331}, - { "¥È¥¥¡¼¥ó¡¦¥Ç¥£¥º¥Ë¡¼", "1213.ontvjapan.com", 28736, 7, 334}, - { "Åì±Ç¥Á¥ã¥ó¥Í¥ë", "1010.ontvjapan.com", 28768, 7, 221}, - { "±ÒÀ±·à¾ì", "1005.ontvjapan.com", 28768, 7, 222}, - { "¥Á¥ã¥ó¥Í¥ë£Î£Å£Ã£Ï", "1008.ontvjapan.com", 28768, 7, 223}, - { "Íβè¡ú¥·¥Í¥Õ¥£¥ë", "1009.ontvjapan.com", 28768, 7, 224}, - { "¥¹¥¿¡¼¡¦¥¯¥é¥·¥Ã¥¯", "1003.ontvjapan.com", 28768, 7, 238}, - { "»þÂå·àÀìÌç¥Á¥ã¥ó¥Í¥ë", "1133.ontvjapan.com", 28768, 7, 292}, - { "¥¹¡¼¥Ñ¡¼¥É¥é¥Þ", "1006.ontvjapan.com", 28768, 7, 310}, - { "£Á£Ø£Î", "1014.ontvjapan.com", 28768, 7, 311}, - { "¥Ê¥·¥ç¥¸¥ª¥Á¥ã¥ó¥Í¥ë", "1204.ontvjapan.com", 28768, 7, 343}, - { "¥ï¥ó¥Æ¥ó¥Ý¡¼¥¿¥ë", "110ch.epgdata.ontvjapan", 28864, 7, 110}, - { "¥´¥ë¥Õ¥Á¥ã¥ó¥Í¥ë", "1028.ontvjapan.com", 28864, 7, 260}, - { "¥Æ¥ìÄ«¥Á¥ã¥ó¥Í¥ë", "1092.ontvjapan.com", 28864, 7, 303}, - { "£Í£Ô£Ö", "1019.ontvjapan.com", 28864, 7, 323}, - { "¥ß¥å¡¼¥¸¥Ã¥¯¡¦¥¨¥¢", "1024.ontvjapan.com", 28864, 7, 324}, - { "Ä«Æü¥Ë¥å¡¼¥¹¥¿¡¼", "1067.ontvjapan.com", 28864, 7, 352}, - { "£Â£Â£Ã¥ï¡¼¥ë¥É", "1070.ontvjapan.com", 28864, 7, 353}, - { "£Ã£Î£Î£ê", "1069.ontvjapan.com", 28864, 7, 354}, - { "¥¸¥ã¥¹¥È¡¦¥¢¥¤", "361ch.epgdata.ontvjapan", 28864, 7, 361}, - { "£Ê¥¹¥Ý¡¼¥Ä¡¡£±", "1041.ontvjapan.com", 28896, 7, 251}, - { "£Ê¥¹¥Ý¡¼¥Ä¡¡£²", "1042.ontvjapan.com", 28896, 7, 252}, - { "£Ê¥¹¥Ý¡¼¥Ä£Ð£ì£õ£ó£È", "1043.ontvjapan.com", 28896, 7, 253}, - { "£Ç£Á£Ï£Ò£Á", "1026.ontvjapan.com", 28896, 7, 254}, - { "£ó£ë£ù¡¦£Á¥¹¥Ý¡¼¥Ä¡Ü", "1040.ontvjapan.com", 28896, 7, 255}, - { "ÊõÄÍ¥×¥í¥â¥Á¥ã¥ó¥Í¥ë", "101ch.epgdata.ontvjapan", 28928, 7, 101}, - { "£Ó£Ë£Ù¡¦£Ó£Ô£Á£Ç£Å", "1207.ontvjapan.com", 28928, 7, 290}, - { "¥Á¥ã¥ó¥Í¥ë¶ä²Ï", "305ch.epgdata.ontvjapan", 28928, 7, 305}, - { "£Á£Ô-£Ø", "1201.ontvjapan.com", 28928, 7, 333}, - { "¥Ò¥¹¥È¥ê¡¼¥Á¥ã¥ó¥Í¥ë", "1050.ontvjapan.com", 28928, 7, 342}, - { "¥¹¥«¥Á¥ã¥ó£¸£°£³", "803ch.epgdata.ontvjapan", 28928, 7, 803}, - { "¥¹¥«¥Á¥ã¥ó£¸£°£´", "804ch.epgdata.ontvjapan", 28928, 7, 804}, - { "¥à¡¼¥Ó¡¼¥×¥é¥¹£È£Ä", "1007.ontvjapan.com", 28960, 7, 240}, - { "¥´¥ë¥Õ¥Í¥Ã¥È¥ï¡¼¥¯", "1027.ontvjapan.com", 28960, 7, 262}, - { "£Ì£á£Ì£á¡¡£È£Ä", "1074.ontvjapan.com", 28960, 7, 314}, - { "¥Õ¥¸¥Æ¥ì¥Ó£·£³£¹", "1073.ontvjapan.com", 28992, 7, 258}, - { "¥Õ¥¸¥Æ¥ì¥Ó£·£²£±", "1072.ontvjapan.com", 28992, 7, 302}, - { "¥¢¥Ë¥Þ¥Ã¥¯¥¹", "1047.ontvjapan.com", 28992, 7, 332}, - { "¥Ç¥£¥¹¥«¥Ð¥ê¡¼", "1062.ontvjapan.com", 28992, 7, 340}, - { "¥¢¥Ë¥Þ¥ë¥×¥é¥Í¥Ã¥È", "1193.ontvjapan.com", 28992, 7, 341}, - { "£Ã-£Ô£Â£Ó¥¦¥¨¥ë¥«¥à", "160ch.epgdata.ontvjapan", 29024, 7, 160}, - { "£Ñ£Ö£Ã", "1120.ontvjapan.com", 29024, 7, 161}, - { "¥×¥é¥¤¥à£³£¶£µ¡¥£Ô£Ö", "185ch.epgdata.ontvjapan", 29024, 7, 185}, - { "¥Õ¥¡¥ß¥ê¡¼·à¾ì", "1015.ontvjapan.com", 29024, 7, 293}, - { "£Ô£Â£Ó¥Á¥ã¥ó¥Í¥ë", "3201.ontvjapan.com", 29024, 7, 301}, - { "¥Ç¥£¥º¥Ë¡¼¥Á¥ã¥ó¥Í¥ë", "1090.ontvjapan.com", 29024, 7, 304}, + { "スターchプラス", "1002.ontvjapan.com", 24608, 6, 237}, + { "日本映画専門chHD", "1086.ontvjapan.com", 24608, 6, 239}, + { "フジテレビCSHD", "306ch.epgdata.ontvjapan", 24608, 6, 306}, + { "ショップチャンネル", "1059.ontvjapan.com", 24704, 6, 55}, + { "ザ・シネマ", "1217.ontvjapan.com", 24736, 6, 228}, + { "スカチャンHD800", "800ch.epgdata.ontvjapan", 24736, 6, 800}, + { "スカチャン801", "801ch.epgdata.ontvjapan", 24736, 6, 801}, + { "スカチャン802", "802ch.epgdata.ontvjapan", 24736, 6, 802}, + { "e2プロモ", "100ch.epgdata.ontvjapan", 28736, 7, 100}, + { "インターローカルTV", "194ch.epgdata.ontvjapan", 28736, 7, 194}, + { "Jスポーツ ESPN", "1025.ontvjapan.com", 28736, 7, 256}, + { "FOX", "1016.ontvjapan.com", 28736, 7, 312}, + { "スペースシャワーTV", "1018.ontvjapan.com", 28736, 7, 322}, + { "カートゥーン ネット", "1046.ontvjapan.com", 28736, 7, 331}, + { "トゥーン・ディズニー", "1213.ontvjapan.com", 28736, 7, 334}, + { "東映チャンネル", "1010.ontvjapan.com", 28768, 7, 221}, + { "衛星劇場", "1005.ontvjapan.com", 28768, 7, 222}, + { "チャンネルNECO", "1008.ontvjapan.com", 28768, 7, 223}, + { "洋画★シネフィル", "1009.ontvjapan.com", 28768, 7, 224}, + { "スター・クラシック", "1003.ontvjapan.com", 28768, 7, 238}, + { "時代劇専門チャンネル", "1133.ontvjapan.com", 28768, 7, 292}, + { "スーパードラマ", "1006.ontvjapan.com", 28768, 7, 310}, + { "AXN", "1014.ontvjapan.com", 28768, 7, 311}, + { "ナショジオチャンネル", "1204.ontvjapan.com", 28768, 7, 343}, + { "ワンテンポータル", "110ch.epgdata.ontvjapan", 28864, 7, 110}, + { "ゴルフチャンネル", "1028.ontvjapan.com", 28864, 7, 260}, + { "テレ朝チャンネル", "1092.ontvjapan.com", 28864, 7, 303}, + { "MTV", "1019.ontvjapan.com", 28864, 7, 323}, + { "ミュージック・エア", "1024.ontvjapan.com", 28864, 7, 324}, + { "朝日ニュースター", "1067.ontvjapan.com", 28864, 7, 352}, + { "BBCワールド", "1070.ontvjapan.com", 28864, 7, 353}, + { "CNNj", "1069.ontvjapan.com", 28864, 7, 354}, + { "ジャスト・アイ", "361ch.epgdata.ontvjapan", 28864, 7, 361}, + { "Jスポーツ 1", "1041.ontvjapan.com", 28896, 7, 251}, + { "Jスポーツ 2", "1042.ontvjapan.com", 28896, 7, 252}, + { "JスポーツPlusH", "1043.ontvjapan.com", 28896, 7, 253}, + { "GAORA", "1026.ontvjapan.com", 28896, 7, 254}, + { "sky・Aスポーツ+", "1040.ontvjapan.com", 28896, 7, 255}, + { "宝塚プロモチャンネル", "101ch.epgdata.ontvjapan", 28928, 7, 101}, + { "SKY・STAGE", "1207.ontvjapan.com", 28928, 7, 290}, + { "チャンネル銀河", "305ch.epgdata.ontvjapan", 28928, 7, 305}, + { "AT-X", "1201.ontvjapan.com", 28928, 7, 333}, + { "ヒストリーチャンネル", "1050.ontvjapan.com", 28928, 7, 342}, + { "スカチャン803", "803ch.epgdata.ontvjapan", 28928, 7, 803}, + { "スカチャン804", "804ch.epgdata.ontvjapan", 28928, 7, 804}, + { "ムービープラスHD", "1007.ontvjapan.com", 28960, 7, 240}, + { "ゴルフネットワーク", "1027.ontvjapan.com", 28960, 7, 262}, + { "LaLa HD", "1074.ontvjapan.com", 28960, 7, 314}, + { "フジテレビ739", "1073.ontvjapan.com", 28992, 7, 258}, + { "フジテレビ721", "1072.ontvjapan.com", 28992, 7, 302}, + { "アニマックス", "1047.ontvjapan.com", 28992, 7, 332}, + { "ディスカバリー", "1062.ontvjapan.com", 28992, 7, 340}, + { "アニマルプラネット", "1193.ontvjapan.com", 28992, 7, 341}, + { "ï¼£-TBSウエルカム", "160ch.epgdata.ontvjapan", 29024, 7, 160}, + { "QVC", "1120.ontvjapan.com", 29024, 7, 161}, + { "プライム365.TV", "185ch.epgdata.ontvjapan", 29024, 7, 185}, + { "ファミリー劇場", "1015.ontvjapan.com", 29024, 7, 293}, + { "TBSチャンネル", "3201.ontvjapan.com", 29024, 7, 301}, + { "ディズニーチャンネル", "1090.ontvjapan.com", 29024, 7, 304}, { "MUSIC ON! TV", "1022.ontvjapan.com", 29024, 7, 325}, - { "¥­¥Ã¥º¥¹¥Æ¡¼¥·¥ç¥ó", "1045.ontvjapan.com", 29024, 7, 330}, - { "£Ô£Â£Ó¥Ë¥å¡¼¥¹¥Ð¡¼¥É", "1076.ontvjapan.com", 29024, 7, 351}, - { "£Ã£ÓÆüËÜÈÖÁÈ¥¬¥¤¥É", "147ch.epgdata.ontvjapan", 29056, 7, 147}, - { "Æü¥Æ¥ì£Ç¡Ü", "1068.ontvjapan.com", 29056, 7, 257}, + { "キッズステーション", "1045.ontvjapan.com", 29024, 7, 330}, + { "TBSニュースバード", "1076.ontvjapan.com", 29024, 7, 351}, + { "CS日本番組ガイド", "147ch.epgdata.ontvjapan", 29056, 7, 147}, + { "日テレG+", "1068.ontvjapan.com", 29056, 7, 257}, { "fashion TV", "5004.ontvjapan.com", 29056, 7, 291}, - { "Æü¥Æ¥ì¥×¥é¥¹", "300ch.epgdata.ontvjapan", 29056, 7, 300}, - { "¥¨¥³¥ß¥å¡¼¥¸¥Ã¥¯£Ô£Ö", "1023.ontvjapan.com", 29056, 7, 320}, + { "日テレプラス", "300ch.epgdata.ontvjapan", 29056, 7, 300}, + { "エコミュージックTV", "1023.ontvjapan.com", 29056, 7, 320}, { "Music Japan TV", "1208.ontvjapan.com", 29056, 7, 321}, - { "Æü¥Æ¥ì£Î£Å£×£Ó£²£´", "2002.ontvjapan.com", 29056, 7, 350}, + { "日テレNEWS24", "2002.ontvjapan.com", 29056, 7, 350}, }; static int csStaCount = sizeof(csSta) / sizeof (STATION);