} hb_stream_type_t;
#define kMaxNumberVideoPIDS 1
-#define kMaxNumberAudioPIDS 15
+#define kMaxNumberAudioPIDS 31
#define kMaxNumberDecodeStreams (kMaxNumberVideoPIDS+kMaxNumberAudioPIDS)
#define kMaxNumberPMTStreams 32
}
}
+static void ts_warn( hb_stream_t*, char*, ... ) HB_WPRINTF(2,3);
+static void ts_err( hb_stream_t*, int, char*, ... ) HB_WPRINTF(3,4);
+
static void ts_warn( hb_stream_t *stream, char *log, ... )
{
- va_list args;
+ va_list args;
va_start( args, log );
ts_warn_helper( stream, log, args );
va_end( args );
static void ts_err( hb_stream_t *stream, int curstream, char *log, ... )
{
- va_list args;
+ va_list args;
va_start( args, log );
ts_warn_helper( stream, log, args );
va_end( args );
**********************************************************************/
hb_stream_t * hb_stream_open( char *path, hb_title_t *title )
{
- FILE *f = fopen( path, "r" );
+ FILE *f = fopen( path, "rb" );
if ( f == NULL )
{
hb_log( "hb_stream_open: open %s failed", path );
off_t pos2 = align_to_next_packet(stream);
if ( pos2 == 0 )
{
- hb_log( "next_packet: eof while re-establishing sync @ %lld", pos );
+ hb_log( "next_packet: eof while re-establishing sync @ %"PRId64, pos );
return NULL;
}
- ts_warn( stream, "next_packet: sync lost @ %lld, regained after %lld bytes",
+ ts_warn( stream, "next_packet: sync lost @ %"PRId64", regained after %"PRId64" bytes",
pos, pos2 );
}
}
buf = hb_ts_stream_getPEStype( stream, stream->ts_video_pids[0] );
if ( buf == NULL )
{
- hb_log("hb_sample_pts: couldn't find video packet near %llu", fpos);
+ hb_log("hb_sample_pts: couldn't find video packet near %"PRIu64, fpos);
return pp;
}
if ( ( buf[7] >> 7 ) != 1 )
{
- hb_log("hb_sample_pts: no PTS in video packet near %llu", fpos);
+ hb_log("hb_sample_pts: no PTS in video packet near %"PRIu64, fpos);
return pp;
}
pp.pts = ( ( (uint64_t)buf[9] >> 1 ) & 7 << 30 ) |
}
int64_t sum_dur = 0;
- hb_chapter_t *chapter;
+ hb_chapter_t *chapter = NULL;
int i;
for ( i = 0; i < chapter_num; ++i)
{
int64_t pos = ( ( ( sum_dur - chapter->duration ) * AV_TIME_BASE ) / 90000 );
- hb_deep_log( 2, "Seeking to chapter %d: starts %lld, ends %lld, AV pos %lld",
+ hb_deep_log( 2, "Seeking to chapter %d: starts %"PRId64", ends %"PRId64", AV pos %"PRId64,
chapter_num, sum_dur - chapter->duration, sum_dur, pos);
if ( chapter_num > 1 && pos > 0 )
stream->a52_info[esindx].lang_code = lang_to_code(lang_for_code2((const char *)&dp[2]));
break;
+ case 0x6a: // DVB AC-3 descriptor
+ stream->ts_stream_type[esindx+1] = 0x81;
+ break;
+
default:
break;
}
static void hb_ts_stream_find_pids(hb_stream_t *stream)
{
- // align to first packet
+ // To be different from every other broadcaster in the world, New Zealand TV
+ // changes PMTs (and thus video & audio PIDs) when 'programs' change. Since
+ // we may have the tail of the previous program at the beginning of this
+ // file, take our PMT from the middle of the file.
+ fseeko(stream->file_handle, 0, SEEK_END);
+ uint64_t fsize = ftello(stream->file_handle);
+ fseeko(stream->file_handle, fsize >> 1, SEEK_SET);
align_to_next_packet(stream);
// Read the Transport Stream Packets (188 bytes each) looking at first for PID 0 (the PAT PID), then decode that
chapter->minutes = ( ( chapter->duration / 90000 ) % 3600 ) / 60;
chapter->seconds = ( chapter->duration / 90000 ) % 60;
strcpy( chapter->title, m->title );
- hb_deep_log( 2, "Added chapter %i, name='%s', dur=%llu, (%02i:%02i:%02i)",
+ hb_deep_log( 2, "Added chapter %i, name='%s', dur=%"PRIu64", (%02i:%02i:%02i)",
chapter->index, chapter->title,
chapter->duration, chapter->hours,
chapter->minutes, chapter->seconds );
{
stream->chapter_end += chapter->duration;
buf->new_chap = stream->chapter + 1;
- hb_deep_log( 2, "ffmpeg_read starting chapter %i at %lld",
+ hb_deep_log( 2, "ffmpeg_read starting chapter %i at %"PRId64,
buf->new_chap, buf->start);
} else {
// Must have run out of chapters, stop looking.