diff options
author | John Stebbins <[email protected]> | 2015-11-13 10:01:23 -0800 |
---|---|---|
committer | John Stebbins <[email protected]> | 2015-11-13 10:01:23 -0800 |
commit | 7aad3738d855eb4b3d03b3671fbeca9eeba49da0 (patch) | |
tree | 22bd5a6c4a81a8560990c53989e1386758fc2ce2 | |
parent | 474f3e22996eccb53955526bbb8adbd6b29aad85 (diff) |
reader: remove track count limitation
Don't use hard coded 100 fifo array, allocate what is needed.
We probably just crashed if the number of tracks was > 99 since the
limit of 100 fifos was not universally checked.
-rw-r--r-- | libhb/reader.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/libhb/reader.c b/libhb/reader.c index d58271b56..8d32dc31c 100644 --- a/libhb/reader.c +++ b/libhb/reader.c @@ -68,7 +68,7 @@ struct hb_work_private_s int chapter_end; uint64_t st_first; uint64_t duration; - hb_fifo_t * fifos[100]; + hb_fifo_t ** fifos; buffer_splice_list_t * splice_list; int splice_list_size; @@ -282,6 +282,10 @@ static int reader_init( hb_work_object_t * w, hb_job_t * job ) r->splice_list[jj++].id = audio->id; } + // count also happens to be the upper bound for the number of + // fifos that will be needed (+1 for null terminator) + r->fifos = calloc(count + 1, sizeof(hb_fifo_t*)); + // The stream needs to be open before starting the reader thead // to prevent a race with decoders that may share information // with the reader. Specifically avcodec needs this. @@ -299,6 +303,10 @@ static void reader_close( hb_work_object_t * w ) { hb_work_private_t * r = w->private_data; + if ( r == NULL ) + { + return; + } if (r->bd) { hb_bd_stop( r->bd ); @@ -319,6 +327,7 @@ static void reader_close( hb_work_object_t * w ) free( r->stream_timing ); } + free( r->fifos ); free( r ); } @@ -858,9 +867,7 @@ static hb_fifo_t ** GetFifoForId( hb_work_private_t * r, int id ) hb_title_t * title = job->title; hb_audio_t * audio; hb_subtitle_t * subtitle; - int i, n, count; - - memset(r->fifos, 0, sizeof(r->fifos)); + int i, n; if( id == title->video_id ) { @@ -878,13 +885,12 @@ static hb_fifo_t ** GetFifoForId( hb_work_private_t * r, int id ) else { r->fifos[0] = job->fifo_mpeg2; + r->fifos[1] = NULL; return r->fifos; } } - count = hb_list_count( job->list_subtitle ); - count = count > 99 ? 99 : count; - for( i = n = 0; i < count; i++ ) + for( i = n = 0; i < hb_list_count( job->list_subtitle ); i++ ) { subtitle = hb_list_item( job->list_subtitle, i ); if (id == subtitle->id) @@ -895,6 +901,7 @@ static hb_fifo_t ** GetFifoForId( hb_work_private_t * r, int id ) } if ( n != 0 ) { + r->fifos[n] = NULL; return r->fifos; } @@ -911,6 +918,7 @@ static hb_fifo_t ** GetFifoForId( hb_work_private_t * r, int id ) if( n != 0 ) { + r->fifos[n] = NULL; return r->fifos; } } |