diff --git a/src/ccextractor.h b/src/ccextractor.h index 954c6fd7..d6f87469 100644 --- a/src/ccextractor.h +++ b/src/ccextractor.h @@ -116,6 +116,9 @@ struct ts_payload unsigned pid; // Stream PID int counter; // continuity counter int transport_error; // 0 = packet OK, non-zero damaged + unsigned char *section_buf; + int section_index; + int section_size; }; struct PAT_entry @@ -337,7 +340,7 @@ void init_ts( void ); int ts_readpacket(void); long ts_readstream(void); LLONG ts_getmoredata( void ); -int parse_PMT (int pos); +int parse_PMT (unsigned char *buf,int len, int pos); int parse_PAT (void); // myth.cpp diff --git a/src/dvb_subtitle_decoder.c b/src/dvb_subtitle_decoder.c index f94a935a..e9de11fe 100644 --- a/src/dvb_subtitle_decoder.c +++ b/src/dvb_subtitle_decoder.c @@ -20,12 +20,6 @@ #include #include #include -/* convert values between host and network byte order(big endian) */ -#ifdef _WIN32 -#include -#else -#include -#endif #ifdef _MSC_VER #define snprintf(str,size,format,...) _snprintf(str,size-1,format,__VA_ARGS__) @@ -34,6 +28,7 @@ #include "dvb_subtitle_decoder.h" #include "spupng_encoder.h" #include "ocr.h" +#include "utility.h" #define DEBUG #ifdef DEBUG @@ -48,11 +43,6 @@ #define DVBSUB_DISPLAYDEFINITION_SEGMENT 0x14 #define DVBSUB_DISPLAY_SEGMENT 0x80 -#define RL32(x) (*(unsigned int *)(x)) -#define RB32(x) (ntohl(*(unsigned int *)(x))) -#define RL16(x) (*(unsigned short int*)(x)) -#define RB16(x) (ntohs(*(unsigned short int*)(x))) - #define SCALEBITS 10 #define ONE_HALF (1 << (SCALEBITS - 1)) #define FIX(x) ((int) ((x) * (1<pesstart) + { + memcpy(payload->section_buf, buf, size); + payload->section_index = size; + payload->section_size = -1; + } + else + { + memcpy(payload->section_buf + payload->section_index, buf, size); + payload->section_index += size; + + } + if(payload->section_size == -1 && payload->section_index >= 3) + payload->section_size = (RB16(payload->section_buf + 1) & 0xfff) + 3 ; + + if(payload->section_index >= (unsigned)payload->section_size) + parse_PMT(NULL,0,0); + return 0; + +} + /* Program Allocation Table. It contains a list of all programs and the PIDs of their Program Map Table. Returns: gotpes */