summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-06-03 14:46:04 +0000
committerjstebbins <[email protected]>2009-06-03 14:46:04 +0000
commitfa937f5aab19995d36ffbb59eb017d9428a5037f (patch)
tree5d69ec5db7af5d1c1a9023b1e26e699198ff916f /libhb
parent30bf591dfa913e1524b9789cd5fae829ad494d00 (diff)
softsubs: allow 1 source to many output subs by duplicating the
subtitle buffer where necessary git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2475 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/decmpeg2.c33
-rw-r--r--libhb/reader.c17
2 files changed, 33 insertions, 17 deletions
diff --git a/libhb/decmpeg2.c b/libhb/decmpeg2.c
index cd3c5a324..06522dfae 100644
--- a/libhb/decmpeg2.c
+++ b/libhb/decmpeg2.c
@@ -46,7 +46,7 @@ typedef struct hb_libmpeg2_s
int64_t last_pts;
int cadence[12];
int flag;
- hb_subtitle_t * subtitle;
+ hb_list_t * list_subtitle;
} hb_libmpeg2_t;
/**********************************************************************
@@ -70,6 +70,8 @@ static void hb_mpeg2_cc( hb_libmpeg2_t * m, uint8_t *cc_block )
uint8_t cc_valid = (*cc_block & 4) >>2;
uint8_t cc_type = *cc_block & 3;
hb_buffer_t *cc_buf;
+ int i;
+ hb_subtitle_t * subtitle;
if( !m->job )
{
@@ -85,12 +87,16 @@ static void hb_mpeg2_cc( hb_libmpeg2_t * m, uint8_t *cc_block )
{
case 0:
// CC1 stream
- cc_buf = hb_buffer_init( 2 );
- if( cc_buf )
+ for (i = 0; i < hb_list_count( m->list_subtitle ); i++)
{
- cc_buf->start = m->last_pts;
- memcpy( cc_buf->data, cc_block+1, 2 );
- hb_fifo_push( m->subtitle->fifo_in, cc_buf );
+ subtitle = hb_list_item( m->list_subtitle, i );
+ cc_buf = hb_buffer_init( 2 );
+ if( cc_buf )
+ {
+ cc_buf->start = m->last_pts;
+ memcpy( cc_buf->data, cc_block+1, 2 );
+ hb_fifo_push( subtitle->fifo_in, cc_buf );
+ }
}
break;
case 1:
@@ -408,7 +414,7 @@ static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
*
* Send them on to the closed caption decoder if requested and found.
*/
- if( ( !m->job || m->subtitle) &&
+ if( ( !m->job || hb_list_count( m->list_subtitle) ) &&
( m->info->user_data_len != 0 &&
m->info->user_data[0] == 0x43 &&
m->info->user_data[1] == 0x43 ) )
@@ -582,6 +588,7 @@ static int decmpeg2Init( hb_work_object_t * w, hb_job_t * job )
* If not scanning, then are we supposed to extract Closed Captions
* and send them to the decoder?
*/
+ pv->libmpeg2->list_subtitle = hb_list_init();
if( job )
{
hb_subtitle_t * subtitle;
@@ -592,8 +599,7 @@ static int decmpeg2Init( hb_work_object_t * w, hb_job_t * job )
subtitle = hb_list_item( job->list_subtitle, i);
if( subtitle && subtitle->source == CC608SUB )
{
- pv->libmpeg2->subtitle = subtitle;
- break;
+ hb_list_add(pv->libmpeg2->list_subtitle, subtitle);
}
}
@@ -635,19 +641,23 @@ static int decmpeg2Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
/* if we got an empty buffer signaling end-of-stream send it downstream */
if ( (*buf_in)->size == 0 )
{
+ int i;
+
hb_list_add( pv->list, *buf_in );
*buf_in = NULL;
status = HB_WORK_DONE;
/*
* Let the Closed Captions know that it is the end of the data.
*/
- if( pv->libmpeg2->subtitle )
+ for (i = 0; i < hb_list_count( pv->libmpeg2->list_subtitle ); i++)
{
+ hb_subtitle_t * subtitle;
hb_buffer_t *buf_eof = hb_buffer_init( 0 );
+ subtitle = hb_list_item( pv->libmpeg2->list_subtitle, i );
if( buf_eof )
{
- hb_fifo_push( pv->libmpeg2->subtitle->fifo_in, buf_eof );
+ hb_fifo_push( subtitle->fifo_in, buf_eof );
}
}
}
@@ -686,6 +696,7 @@ static void decmpeg2Close( hb_work_object_t * w )
hb_log( "mpeg2 done: %d frames", pv->libmpeg2->nframes );
}
hb_list_close( &pv->list );
+ hb_list_close( &pv->libmpeg2->list_subtitle );
hb_libmpeg2_close( &pv->libmpeg2 );
free( pv );
}
diff --git a/libhb/reader.c b/libhb/reader.c
index 9ac515c4e..ad0fe64dd 100644
--- a/libhb/reader.c
+++ b/libhb/reader.c
@@ -501,8 +501,8 @@ static hb_fifo_t ** GetFifoForId( hb_job_t * job, int id )
hb_title_t * title = job->title;
hb_audio_t * audio;
hb_subtitle_t * subtitle;
- int i, n;
- static hb_fifo_t * fifos[8];
+ int i, n, count;
+ static hb_fifo_t * fifos[100];
memset(fifos, 0, sizeof(fifos));
@@ -523,7 +523,10 @@ static hb_fifo_t ** GetFifoForId( hb_job_t * job, int id )
}
}
- for( i=0; i < hb_list_count( title->list_subtitle ); i++ ) {
+ n = 0;
+ count = hb_list_count( title->list_subtitle );
+ count = count > 99 ? 99 : count;
+ for( i=0; i < count; i++ ) {
subtitle = hb_list_item( title->list_subtitle, i );
if (id == subtitle->id) {
subtitle->hits++;
@@ -534,12 +537,14 @@ static hb_fifo_t ** GetFifoForId( hb_job_t * job, int id )
* we are scanning and looking for forced subs, then pass them up
* to decode whether the sub is a forced one.
*/
- fifos[0] = subtitle->fifo_in;
- return fifos;
+ fifos[n++] = subtitle->fifo_in;
}
- break;
}
}
+ if ( n != 0 )
+ {
+ return fifos;
+ }
if( !job->indepth_scan )
{