diff -urN recdvb-1.3.2/Makefile.in recdvb-1.3.2-http-rev4/Makefile.in
--- recdvb-1.3.2/Makefile.in	2018-08-05 02:16:16.000000000 +0900
+++ recdvb-1.3.2-http-rev4/Makefile.in	2019-10-09 13:03:07.475394438 +0900
@@ -7,7 +7,8 @@
 TARGET = recdvb
 TARGET2 = recdvbctl
 TARGET3 = recdvbchksig
-TARGETS = $(TARGET) $(TARGET2) $(TARGET3)
+TARGET4 = tssplitter_lite
+TARGETS = $(TARGET) $(TARGET2) $(TARGET3) $(TARGET4)
 RELEASE_VERSION = "1.3.2"
 
 CPPFLAGS = -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
@@ -16,14 +17,20 @@
 LIBS     = @LIBS@
 LIBS2    = -lm
 LIBS3    = -lpthread -lm
+LIBS4    =
 LDFLAGS  =
 
 OBJS  = recpt1.o decoder.o mkpath.o tssplitter_lite.o recpt1core.o
 OBJS2 = recpt1ctl.o recpt1core.o
 OBJS3 = checksignal.o recpt1core.o
-OBJALL = $(OBJS) $(OBJS2) $(OBJS3)
+OBJS4 = tssplitter_lite.o tsmain.o
+OBJALL = $(OBJS) $(OBJS2) $(OBJS3) $(OBJS4)
 DEPEND = .deps
 
+ifdef EXTRA_SID
+CPPFLAGS += -DENABLE_EXTRA_SID
+endif
+
 all: $(TARGETS)
 
 clean:
@@ -44,6 +51,9 @@
 $(TARGET3): $(OBJS3)
 	$(CC) $(LDFLAGS) -o $@ $(OBJS3) $(LIBS3)
 
+$(TARGET4): $(OBJS4)
+	$(CC) $(LDFLAGS) -o $@ $(OBJS4) $(LIBS4)
+
 $(DEPEND): version.h
 	$(CC) -MM $(OBJS:.o=.c) $(OBJS2:.o=.c) $(CPPFLAGS) > $@
 
diff -urN recdvb-1.3.2/recpt1.c recdvb-1.3.2-http-rev4/recpt1.c
--- recdvb-1.3.2/recpt1.c	2018-08-05 02:04:05.000000000 +0900
+++ recdvb-1.3.2-http-rev4/recpt1.c	2019-10-09 14:59:50.710167131 +0900
@@ -375,7 +375,7 @@
 
             /* allocate split buffer */
             if(splitbuf.buffer_size < buf.size && buf.size > 0) {
-                splitbuf.buffer = realloc(splitbuf.buffer, buf.size);
+                splitbuf.buffer = (u_char *)realloc(splitbuf.buffer, buf.size);
                 if(splitbuf.buffer == NULL) {
                     fprintf(stderr, "split buffer allocation failed\n");
                     use_splitter = FALSE;
@@ -933,12 +933,13 @@
 
 		peer_host = gethostbyaddr((char *)&peer_sin.sin_addr.s_addr,
 				  sizeof(peer_sin.sin_addr), AF_INET);
+		char *h_name;
 		if ( peer_host == NULL ){
-			fprintf(stderr, "gethostbyname failed\n");
-			return 1;
-		}
+			h_name = "NONAME";
+		}else
+			h_name = peer_host->h_name;
 
-		fprintf(stderr,"connect from: %s [%s] port %d\n", peer_host->h_name, inet_ntoa(peer_sin.sin_addr), ntohs(peer_sin.sin_port));
+		fprintf(stderr,"connect from: %s [%s] port %d\n", h_name, inet_ntoa(peer_sin.sin_addr), ntohs(peer_sin.sin_port));
 
 		char buf[256];
 		read_line(connected_socket, buf);
@@ -976,8 +977,14 @@
     }
 
 	if(use_http){	// http-server add-
-		char header[] =  "HTTP/1.1 200 OK\r\nContent-Type: video/mpeg\r\nCache-Control: no-cache\r\n\r\n";
-		write(connected_socket, header, strlen(header));
+		char header[] =  "HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\nCache-Control: no-cache\r\n\r\n";
+		int len = strlen(header);
+		if(write(connected_socket, header, len) < len){
+			close(connected_socket);
+			if(use_splitter)
+				split_shutdown(splitter);
+			continue;
+		}
 
 		//set write target to http
 		tdata.wfd = connected_socket;
@@ -990,7 +997,7 @@
 	}else{	// -http-server add
     /* initialize udp connection */
     if(use_udp) {
-      sockdata = calloc(1, sizeof(sock_data));
+      sockdata = (sock_data *)calloc(1, sizeof(sock_data));
       struct in_addr ia;
       ia.s_addr = inet_addr(host_to);
       if(ia.s_addr == INADDR_NONE) {
diff -urN recdvb-1.3.2/recpt1core.c recdvb-1.3.2-http-rev4/recpt1core.c
--- recdvb-1.3.2/recpt1core.c	2016-02-16 08:10:57.000000000 +0900
+++ recdvb-1.3.2-http-rev4/recpt1core.c	2019-10-09 14:53:54.662458876 +0900
@@ -159,11 +159,23 @@
     fprintf(stderr,"Using DVB card \"%s\"\n",fe_info.name);
     prop[0].cmd = DTV_FREQUENCY;
     if(fe_info.type == FE_OFDM){
-        if( (fe_freq = atoi(channel)) == 0){
-          fprintf(stderr, "channel is not number\n");
-          return 1;
+        if( channel[0]!='C' ){
+          if( (fe_freq = atoi(channel)) == 0){
+            fprintf(stderr, "channel is not number\n");
+            return 1;
+          }
+          prop[0].u.data = (fe_freq * 6000 + 395143) * 1000;
+        } else {
+          if( (fe_freq = atoi(channel+1)) == 0){
+            fprintf(stderr, "channel is not Cnn\n\tnn=numeric\n");
+            return 1;
+          }
+          prop[0].u.data = (fe_freq * 6000 + 33143) * 1000;
+          if( fe_freq==22 )
+            prop[0].u.data = prop[0].u.data + (2000 * 1000);
+          if( fe_freq>=23 )
+            prop[0].u.data = prop[0].u.data + (9 * 6000 * 1000);
         }
-        prop[0].u.data = (fe_freq * 6000 + 395143) * 1000;
         fprintf(stderr,"tuning to %d kHz\n",prop[0].u.data / 1000);
     } else {    /* FE_QPSK */
         if( ((channel[0]=='b')||(channel[0]=='B')) && ((channel[1]=='s')||(channel[1]=='S')) ){
diff -urN recdvb-1.3.2/tsmain.c recdvb-1.3.2-http-rev4/tsmain.c
--- recdvb-1.3.2/tsmain.c	1970-01-01 09:00:00.000000000 +0900
+++ recdvb-1.3.2-http-rev4/tsmain.c	2019-10-09 13:03:19.695315123 +0900
@@ -0,0 +1,229 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <fcntl.h>
+#include <sys/stat.h>
+#include "config.h"
+#include "decoder.h"
+#include "tssplitter_lite.h"
+
+#define MAX_READ_SIZE (188 * 100)
+/* maximum write length at once */
+#define SIZE_CHANK 1316
+#define TRUE                1
+#define FALSE               0
+/**************************************************************************/
+/**
+ * °ú¿ôÍÑ¹½Â¤ÂÎ
+ */
+typedef struct {
+	char* src;				// ÆþÎÏ¥Õ¥¡¥¤¥ë
+	char* dst;				// ½ÐÎÏ¥Õ¥¡¥¤¥ë
+	char* sid;				// ½ÐÎÏÂÐ¾Ý¥Á¥ã¥ó¥Í¥ëÈÖ¹æ
+} PARAM;
+typedef int boolean;
+
+void show_usage();
+int AnalyzeParam(int argc, char** argv, PARAM* param);
+
+int execute(PARAM* param);
+
+
+/**************************************************************************/
+
+/**
+ *
+ */
+int main(
+	int argc,							// [in]		°ú¿ô¤Î¸Ä¿ô
+	char** argv)						// [in]		°ú¿ô
+{
+	PARAM param;
+
+	int result;							// ½èÍý·ë²Ì
+
+	// ¥Ñ¥é¥á¡¼¥¿²òÀÏ
+	result = AnalyzeParam(argc, argv, &param);
+	if (TSS_SUCCESS != result)
+	{
+		return result;
+	}
+
+	// ½èÍý¼Â¹Ô
+	result = execute(&param);
+
+	return result;
+}
+
+/**
+ * »ÈÍÑÊýË¡¥á¥Ã¥»¡¼¥¸½ÐÎÏ
+ */
+void show_usage()
+{
+	fprintf(stderr, "tssplitter_lite - tssplitter_lite program Ver. 0.0.0.1\n");
+	fprintf(stderr, "usage: tssplitter_lite srcfile destfile sidlist\n");
+	fprintf(stderr, "\n");
+    fprintf(stderr, "Remarks:\n");
+    fprintf(stderr, "if srcfile is '-', stdin is used for input.\n");
+    fprintf(stderr, "if destfile is '-', stdout is used for output.\n");
+	fprintf(stderr, "\n");
+}
+
+/**
+ * ¥Ñ¥é¥á¡¼¥¿²òÀÏ
+ */
+int AnalyzeParam(
+	int argc,							// [in]		°ú¿ô¤Î¸Ä¿ô
+	char** argv,						// [in]		°ú¿ô
+	PARAM* param)						// [out]	°ú¿ô¾ðÊó¥Ç¡¼¥¿
+{
+	// °ú¿ô¥Á¥§¥Ã¥¯
+	if ((3 != argc) && (4 != argc) && (5 != argc))
+	{
+		show_usage();
+		return TSS_ERROR;
+	}
+
+	param->src		= argv[1];
+	param->dst		= argv[2];
+	if (argc > 3) {
+	  param->sid = argv[3];
+	}
+	else {
+	  param->sid = NULL;
+	}
+
+	return TSS_SUCCESS;
+}
+
+/**
+ * ¼Â½èÍý
+ */
+int execute(
+	PARAM* param)						// [in]		°ú¿ô¾ðÊó¥Ç¡¼¥¿
+{
+	int sfd;							// ¥Õ¥¡¥¤¥ëµ­½Ò»Ò¡ÊÆÉ¤ß¹þ¤ßÍÑ¡Ë
+	int wfd;							// ¥Õ¥¡¥¤¥ëµ­½Ò»Ò¡Ê½ñ¤­¹þ¤ßÍÑ¡Ë
+	splitter *splitter = NULL;
+	static splitbuf_t splitbuf;
+	ARIB_STD_B25_BUFFER buf;
+	int split_select_finish = TSS_ERROR;
+	int code = 0;
+	int wc = 0;
+	int result = TSS_SUCCESS;							// ½èÍý·ë²Ì
+	static uint8_t buffer[MAX_READ_SIZE];
+	boolean use_stdout = TRUE;
+	boolean use_stdin = TRUE;
+
+	// ½é´ü²½
+	splitter = split_startup(param->sid);
+	if (splitter->sid_list == NULL) {
+		fprintf(stderr, "Cannot start TS splitter\n");
+		return 1;
+	}
+
+	buf.data = buffer;
+	splitbuf.buffer_size = MAX_READ_SIZE;
+	splitbuf.buffer = (u_char *)malloc(MAX_READ_SIZE);
+	if(splitbuf.buffer == NULL) {
+		fprintf(stderr, "split buffer allocation failed\n");
+		return 1;
+	}
+
+	// ÆÉ¤ß¹þ¤ß¥Õ¥¡¥¤¥ë¥ª¡¼¥×¥ó
+	if(!strcmp("-", param->src)){
+		sfd = 0; /* stdin */
+	}else{
+		sfd = open(param->src, O_RDONLY);
+		if (sfd < 0){
+			fprintf(stderr, "Cannot open input file: %s\n", param->src);
+			result = 1;
+			goto fin;
+		}else
+			use_stdin = FALSE;
+	}
+
+	// ½ñ¤­¹þ¤ß¥Õ¥¡¥¤¥ë¥ª¡¼¥×¥ó
+	if(!strcmp("-", param->dst)){
+		wfd = 1; /* stdout */
+	}else{
+		wfd = open(param->dst, (O_RDWR | O_CREAT | O_TRUNC), 0666);
+		if (wfd < 0){
+			fprintf(stderr, "Cannot open output file: %s\n", param->dst);
+			result = 1;
+			goto fin;
+		}else
+			use_stdout = FALSE;
+	}
+
+	// ¥Õ¥¡¥¤¥ëÆþÎÏ
+	while ((buf.size = read(sfd, buf.data, MAX_READ_SIZE)) > 0) {
+		splitbuf.buffer_filled = 0;
+
+		while(buf.size) {
+			/* Ê¬Î¥ÂÐ¾ÝPID¤ÎÃê½Ð */
+			if(split_select_finish != TSS_SUCCESS) {
+				split_select_finish = split_select(splitter, &buf);
+				if(split_select_finish == TSS_NULL) {
+					/* malloc¥¨¥é¡¼È¯À¸ */
+					fprintf(stderr, "split_select malloc failed\n");
+					result = 1;
+					goto fin;
+				}
+				else if (split_select_finish != TSS_SUCCESS) {
+//					buf.data = buffer;
+					break;
+				}
+			}
+
+			/* Ê¬Î¥ÂÐ¾Ý°Ê³°¤ò¤Õ¤ë¤¤Íî¤È¤¹ */
+			code = split_ts(splitter, &buf, &splitbuf);
+			if(code == TSS_NULL) {
+				fprintf(stderr, "PMT reading..\n");
+			}
+			else if(code != TSS_SUCCESS) {
+				//¥×¥í¥°¥é¥à¾å¤³¤³¤Ë¤ÏÆþ¤é¤Ê¤¤ fail safe
+				fprintf(stderr, "split_ts failed\n");
+				result = TSS_ERROR;
+				goto fin;
+			}
+			break;
+		}
+
+		/* write data to output file */
+		int size_remain = splitbuf.buffer_filled;
+		int offset = 0;
+
+		while(size_remain > 0) {
+			int ws = size_remain < SIZE_CHANK ? size_remain : SIZE_CHANK;
+
+			wc = write(wfd, splitbuf.buffer + offset, ws);
+			if(wc < 0) {
+				perror("write");
+				result = 1;
+				goto fin;
+			}
+			size_remain -= wc;
+			offset += wc;
+		}
+
+//		buf.data = buffer;
+	}
+fin:
+	// ³«Êü½èÍý
+	free(splitbuf.buffer);
+	split_shutdown(splitter);
+	/* close output file */
+	if(!use_stdout){
+		fsync(wfd);
+		close(wfd);
+	}
+	if(!use_stdin){
+		close(sfd);
+	}
+
+	return result;
+}
+
diff -urN recdvb-1.3.2/tssplitter_lite.c recdvb-1.3.2-http-rev4/tssplitter_lite.c
--- recdvb-1.3.2/tssplitter_lite.c	2013-11-27 16:41:51.000000000 +0900
+++ recdvb-1.3.2-http-rev4/tssplitter_lite.c	2019-10-09 13:03:28.095260603 +0900
@@ -34,7 +34,7 @@
 static int RecreatePat(splitter *sp, unsigned char *buf, int *pos);
 static char** AnalyzeSid(char *sid);
 static int AnalyzePmt(splitter *sp, unsigned char *buf, unsigned char mark);
-static int GetCrc32(unsigned char *data, int len);
+static unsigned int GetCrc32(unsigned char *data, int len);
 static int GetPid(unsigned char *data);
 
 /**
@@ -64,7 +64,7 @@
 	}
 
 	/* sid_list¤Î¿ô¤Ï¥«¥ó¥Þ¤Î¿ô+2(NULL»ß¤á¤¹¤ë¤«¤é) */
-	sid_list = malloc(sizeof(char*)*(CommaNum+2));
+	sid_list = (char **)malloc(sizeof(char*)*(CommaNum+2));
 	if ( sid_list == NULL )
 	{
 		fprintf(stderr, "AnalyzeSid() malloc error.\n");
@@ -139,7 +139,7 @@
 )
 {
 	splitter* sp;
-	sp = malloc(sizeof(splitter));
+	sp = (splitter *)malloc(sizeof(splitter));
 	if ( sp == NULL )
 	{
 		fprintf(stderr, "split_startup malloc error.\n");
@@ -334,7 +334,7 @@
 			}
 			else {
 				splitter->pat_count += 1;
-				if(0 == splitter->pat_count % 0x10) {
+				if(0 == (splitter->pat_count & 0x0fU)) {
 					splitter->pat_count -= 0x10;
 				}
 			}
@@ -383,6 +383,24 @@
 	return result;
 }
 
+#define	ARIB_PID_MAX	20     //Å¬Åö
+
+char	arib_pids[ARIB_PID_MAX];
+int		arib_pids_cnt = 0;
+#ifdef ENABLE_EXTRA_SID
+int		caption;
+int		es_data;
+int		es_other;
+#endif
+
+// PMT¤ËÍ³Íè¤·¤Ê¤¤ARIBÄêµÁPID¤ÎÊÝÂ¸
+void AribPidSet( unsigned char *pids, char pid )
+{
+	*(pids+pid) = 1;
+	if( arib_pids_cnt < ARIB_PID_MAX )
+		arib_pids[arib_pids_cnt++] = pid;
+}
+
 /**
  * PAT ²òÀÏ½èÍý
  *
@@ -423,6 +441,11 @@
 		sp->pmt_retain = 0;
 		memset(pos, 0, sizeof(pos));
 		size = buf[7];
+#ifdef ENABLE_EXTRA_SID
+		caption = FALSE;		// »úËëPIDÊÝÂ¸¥Õ¥é¥°½é´ü²½
+		es_data = FALSE;		// ¥Ç¡¼¥¿ÊüÁ÷
+		es_other = FALSE;
+#endif
 
 		/* prescan SID/PMT */
 		for(i = 13, j = 0; i < (size + 8) - 4; i = i + 4) {
@@ -528,20 +551,33 @@
 				}
 				else if(!strcasecmp(*p, "epg")) {
 					/* epgÃê½Ð¤ËÉ¬Í×¤ÊPID¤Î¤ß¤òÊÝÂ¸¤¹¤ë */
-					sid_found    = TRUE;
-					*(pids+0x11) = 1;
-					*(pids+0x12) = 1;
-					*(pids+0x23) = 1;         // SDTT
-					*(pids+0x29) = 1;         // CDT
+					sid_found = TRUE;
+					AribPidSet(pids, 0x11);
+					AribPidSet(pids, 0x12);
+					AribPidSet(pids, 0x23);         // SDTT
+					AribPidSet(pids, 0x29);         // CDT
 				}
 				else if(!strcasecmp(*p, "epg1seg")) {
 					/* ¥ï¥ó¥»¥°ÍÑepgÃê½Ð¤ËÉ¬Í×¤ÊPID¤Î¤ß¤òÊÝÂ¸¤¹¤ë */
-					sid_found    = TRUE;
-					*(pids+0x11) = 1;
-//					*(pids+0x26) = 1;         // ¼ÖºÜÍÑepg µ¬³Ê¤Î¤ß¤ÇÌ¤Á÷½Ð¤Î¤â¤è¤¦
-					*(pids+0x27) = 1;
+					sid_found = TRUE;
+					AribPidSet(pids, 0x11);
+//					AribPidSet(pids, 0x26);         // ¼ÖºÜÍÑepg µ¬³Ê¤Î¤ß¤ÇÌ¤Á÷½Ð¤Î¤â¤è¤¦
+					AribPidSet(pids, 0x27);
+				}
+#ifdef ENABLE_EXTRA_SID
+				else if(!strcasecmp(*p, "caption")) {
+					/* »úËëPIDÊÝÂ¸ ES PID¤Ê¤Î¤Ç¥Õ¥é¥°¤Î¤ßÊÑ¹¹ */
+					caption = TRUE;
+				}
+				else if(!strcasecmp(*p, "data")) {
+					/* ¥Ç¡¼¥¿ÊüÁ÷PIDÊÝÂ¸ ES PID¤Ê¤Î¤Ç¥Õ¥é¥°¤Î¤ßÊÑ¹¹ */
+					es_data = TRUE;
+				}
+				else if(!strcasecmp(*p, "other")) {
+					/*  ES PID¤Ê¤Î¤Ç¥Õ¥é¥°¤Î¤ßÊÑ¹¹ */
+					es_other = TRUE;
 				}
-
+#endif
 				p++;
 			} /* while */
 		}
@@ -609,7 +645,7 @@
 #endif
 {
 	unsigned char y[LENGTH_CRC_DATA];
-	int crc;
+	unsigned int crc;
 	int i;
 	int j;
 	int pos_i;
@@ -684,8 +720,8 @@
 	unsigned char* pids					// [out]	½ÐÎÏÂÐ¾Ý PID ¾ðÊó
 #endif
 {
-	unsigned char Nall;
-	unsigned char N;
+	unsigned int Nall;
+	unsigned int N;
 	int pcr;
 	int epid;
 	int pid;
@@ -695,7 +731,7 @@
 
 	pid = GetPid(&buf[1]);
 	if (buf[1] & 0x40) {		// PES³«»Ï¥¤¥ó¥¸¥±¡¼¥¿
-		sp->section_remain[pid] = ((buf[6] & 0x0F) << 8) + buf[7] + 3;	// ¥»¥¯¥·¥ç¥ó¥µ¥¤¥º¼èÆÀ(¥Ø¥Ã¥À¹þ)
+		sp->section_remain[pid] = ((uint16_t)(buf[6] & 0x0FU) << 8) + buf[7] + 3;	// ¥»¥¯¥·¥ç¥ó¥µ¥¤¥º¼èÆÀ(¥Ø¥Ã¥À¹þ)
 		payload_offset = 5;
 
 		for (count = 0; sp->pmt_retain > count; count++) {
@@ -710,8 +746,8 @@
 		sp->pids[pcr] = mark;
 
 		// ECM
-		N = ((buf[payload_offset + 10] & 0x0F) << 8) + buf[payload_offset + 11] + payload_offset + 12;	// ES¾ðÊó³«»ÏÅÀ
-		int p = payload_offset + 12;
+		N = ((unsigned int)(buf[payload_offset + 10] & 0x0F) << 8) + buf[payload_offset + 11] + payload_offset + 12;	// ES¾ðÊó³«»ÏÅÀ
+		unsigned int p = payload_offset + 12;
 
 		while(p < N) {
 			uint32_t ca_pid;
@@ -723,7 +759,8 @@
 			p += 2;
 
 			if(tag == 0x09 && len >= 4 && p+len <= N) {
-				ca_pid = ((buf[p+2] << 8) | buf[p+3]) & 0x1fff;
+//				ca_pid = ((buf[p+2] << 8) | buf[p+3]) & 0x1fff;
+				ca_pid = GetPid( &buf[p+2] );
 				sp->pids[ca_pid] = mark;
 			}
 			p += len;
@@ -738,12 +775,30 @@
 	sp->packet_seq[pid] = buf[3] & 0x0F;				// ½ä²ó¥«¥¦¥ó¥¿
 
 	Nall = sp->section_remain[pid];
-	if(Nall > LENGTH_PACKET - payload_offset)
-		Nall = LENGTH_PACKET - payload_offset;
+	if(Nall > LENGTH_PACKET - (unsigned int)payload_offset)
+		Nall = LENGTH_PACKET - (unsigned int)payload_offset;
 
 	// ES PID
 	while (N <= Nall + payload_offset - 5)
 	{
+#ifdef ENABLE_EXTRA_SID
+		do{
+			if( buf[N] == 0x0d ){	// ¥Ç¡¼¥¿ÊüÁ÷
+				if( es_data == FALSE )
+					break;
+			}else
+			if( buf[N] == 0x06 ){	// »úËë
+				if( caption == FALSE )
+					break;
+			}else
+			if( buf[N]==0x0a || buf[N]==0x0b || buf[N]==0x0c )
+				if( es_other == FALSE )
+					break;
+			epid = GetPid(&buf[N + 1]);
+			sp->pids[epid] = mark;
+fprintf(stderr, "type:0x%02X PID:0x%04x\n", buf[N], epid );
+		}while(0);
+#else
 		// ¥¹¥È¥ê¡¼¥à¼ïÊÌ¤¬ 0x0D¡Êtype D¡Ë¤Ï½ÐÎÏÂÐ¾Ý³°
 		if (0x0D != buf[N])
 		{
@@ -751,9 +806,10 @@
 
 			sp->pids[epid] = mark;
 		}
-		N += 4 + (((buf[N + 3]) & 0x0F) << 8) + buf[N + 4] + 1;
+#endif
+		N += 5 + (((unsigned int)buf[N + 3] & 0x0F) << 8) + buf[N + 4];
 		retry_count++;
-		if(retry_count > Nall) {
+		if((unsigned int)retry_count > Nall) {
 			return TSS_ERROR;
 		}
 	}
@@ -761,26 +817,32 @@
 
 	if (sp->section_remain[pid] > 0)
 		return SECTION_CONTINUE;
-	else
+	else{
+		// PMT¤ËÍ³Íè¤·¤Ê¤¤PID¤ÎÊÝ¸î
+		if( mark != 1 ){
+			for( count=0; count<arib_pids_cnt; count++ )
+				sp->pids[(int)arib_pids[count]] = mark;
+		}
 		return TSS_SUCCESS;
+	}
 }
 
 /**
  * CRC ·×»»
  */
-static int GetCrc32(
+static unsigned int GetCrc32(
 	unsigned char* data,				// [in]		CRC ·×»»ÂÐ¾Ý¥Ç¡¼¥¿
 	int len)							// [in]		CRC ·×»»ÂÐ¾Ý¥Ç¡¼¥¿Ä¹
 {
-	int crc;
+	unsigned int crc;
 	int i, j;
-	int c;
-	int bit;
+	unsigned int c;
+	unsigned int bit;
 
-	crc = 0xFFFFFFFF;
+	crc = 0xFFFFFFFFU;
 	for (i = 0; i < len; i++)
 	{
-		char x;
+		unsigned int x;
 		x = data[i];
 
 		for (j = 0; j < 8; j++)
@@ -789,7 +851,7 @@
 			bit = (x >> (7 - j)) & 0x1;
 
 			c = 0;
-			if (crc & 0x80000000)
+			if (crc & 0x80000000U)
 			{
 				c = 1;
 			}
@@ -798,10 +860,10 @@
 
 			if (c ^ bit)
 			{
-				crc ^= 0x04C11DB7;
+				crc ^= 0x04C11DB7U;
 			}
 
-			crc &= 0xFFFFFFFF;
+			crc &= 0xFFFFFFFFU;
 		}
 	}
 
@@ -814,5 +876,5 @@
 static int GetPid(
 	unsigned char* data)				// [in]		¼èÆÀÂÐ¾Ý¥Ç¡¼¥¿¤Î¥Ý¥¤¥ó¥¿
 {
-	return ((data[0] & 0x1F) << 8) + data[1];
+	return (int)((((unsigned int)data[0] & 0x1F) << 8) | (unsigned int)data[1]);
 }
