Fixed WTV
This commit is contained in:
wforums 2014-08-04 21:04:49 +02:00
parent ecc0714f48
commit 405d808d0b
2 changed files with 18 additions and 3 deletions

View File

@ -4,6 +4,7 @@
#define WTV_STREAM2 "\xA2\xC3\xD2\xC2\x7E\x9A\xDA\x11\x8B\xF7\x00\x07\xE9\x5E\xAD\x8D"
#define WTV_DATA "\x95\xC3\xD2\xC2\x7E\x9A\xDA\x11\x8B\xF7\x00\x07\xE9\x5E\xAD\x8D"
#define WTV_STREAM_VIDEO "\x76\x69\x64\x73\x00\x00\x10\x00\x80\x00\x00\xAA\x00\x38\x9B\x71"
#define WTV_STREAM_AUDIO "\x61\x75\x64\x73\x00\x00\x10\x00\x80\x00\x00\xAA\x00\x38\x9B\x71"
#define WTV_STREAM_MSTVCAPTION "\x89\x8A\x8B\xB8\x49\xB0\x80\x4C\xAD\xCF\x58\x98\x98\x5E\x22\xC1"
#define WTV_EOF "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
#define WTV_TIMING "\x5B\x05\xE6\x1B\x97\xA9\x49\x43\x88\x17\x1A\x65\x5A\x29\x8A\x97"
@ -18,6 +19,9 @@
//Maximum size we will try and malloc for chunked_buffer. 100MB
#define WTV_MAX_ALLOC 1024*1024*100
#define WTV_CC_TIMESTAMP_MAGIC 1668330
#define WTV_CC_TIMESTAMP_MAGIC_THRESH 2 //Only switch to alt stream after THRESH magic numbers
struct wtv_chunked_buffer
{
uint64_t skip_chunks[256];

View File

@ -297,6 +297,8 @@ int read_header(struct wtv_chunked_buffer *cb) {
LLONG get_data(struct wtv_chunked_buffer *cb) {
static int video_streams[32];
static int alt_stream; //Stream to use for timestamps if the cc stream has broken timestamps
static int use_alt_stream = 0;
static int num_streams=0;
while(1)
{
@ -368,9 +370,12 @@ LLONG get_data(struct wtv_chunked_buffer *cb) {
video_streams[num_streams]=stream_id; // We keep a list of stream ids
num_streams++; // Even though there should only be 1
}
if (memcmp(stream_type, WTV_STREAM_AUDIO, 16))
alt_stream = stream_id;
len-=28;
}
if( !memcmp(guid, WTV_TIMING, 16 ) && check_stream_id(stream_id, video_streams, num_streams))
if (!memcmp(guid, WTV_TIMING, 16) && ((use_alt_stream < WTV_CC_TIMESTAMP_MAGIC_THRESH && check_stream_id(stream_id, video_streams, num_streams))
|| (use_alt_stream == WTV_CC_TIMESTAMP_MAGIC_THRESH && stream_id == alt_stream)))
{
// The WTV_TIMING GUID contains a timestamp for the given stream_id
dbg_print(CCX_DMT_PARSE, "WTV TIMING\n");
@ -379,12 +384,18 @@ LLONG get_data(struct wtv_chunked_buffer *cb) {
int64_t time;
memcpy(&time, cb->buffer+0x8, 8); // Read the timestamp
dbg_print(CCX_DMT_PARSE, "TIME: %ld\n", time);
if(time!=-1) { // Ignore -1 timestamps
if (time != -1 && time != WTV_CC_TIMESTAMP_MAGIC) { // Ignore -1 timestamps
current_pts = time_to_pes_time(time); // Convert from WTV to PES time
pts_set = 1;
frames_since_ref_time = 0;
set_fts();
}
}
else if (time == WTV_CC_TIMESTAMP_MAGIC && stream_id != alt_stream) {
use_alt_stream++;
mprint("WARNING: %i WTV_CC_TIMESTAMP_MAGIC detected in cc timestamps. \n", use_alt_stream);
if (use_alt_stream == WTV_CC_TIMESTAMP_MAGIC_THRESH)
mprint("WARNING: WTV_CC_TIMESTAMP_MAGIC_THRESH reached. Switching to alt timestamps!\n");
}
len-=16;
}
if( !memcmp(guid, WTV_DATA, 16 )