summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-06-02 15:32:01 +0000
committerjstebbins <[email protected]>2009-06-02 15:32:01 +0000
commitb1fcb3154f5c09a81e0cf712fad9d22f4e8e89bc (patch)
tree263ef770c5316bd112024f2a688c272c69f5b528 /libhb
parent8868e9649a2ff1c60a3334e00418bba92eb67f70 (diff)
softsubtitles:
- when doing an indepth scan, do not scan CC tracks - separate subtitle configureation attributes into separate hb_subtitle_config_t. Add an instance of this to hb_job_t for setting the attributes of the subtitle found through an indepth scan - Add a default_track flag to hb_subtitle_config_t that tells the muxer that the track should be flaged as the default. muxmkv uses this. - When an indepth scan is complete, check to see if the autoselected subtitle matchces (by id) one of the manually selected subtitles. If a match is found, the autoselected subtitle with all the attributes the user assigned to it replaces the manually selected subtitle. - LinGui: Add "Default" column to subtitle tab. This is a radio that lets the user choose which subtitle should be displayed by default. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2468 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/common.h22
-rw-r--r--libhb/decmpeg2.c2
-rw-r--r--libhb/decvobsub.c4
-rw-r--r--libhb/dvd.c2
-rw-r--r--libhb/dvdnav.c2
-rw-r--r--libhb/hb.c66
-rw-r--r--libhb/muxcommon.c2
-rw-r--r--libhb/muxmkv.c6
-rw-r--r--libhb/muxmp4.c2
-rw-r--r--libhb/reader.c2
-rw-r--r--libhb/sync.c8
-rw-r--r--libhb/work.c97
12 files changed, 124 insertions, 91 deletions
diff --git a/libhb/common.h b/libhb/common.h
index 83460653a..b9e26682e 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -55,6 +55,7 @@ typedef struct hb_chapter_s hb_chapter_t;
typedef struct hb_audio_s hb_audio_t;
typedef struct hb_audio_config_s hb_audio_config_t;
typedef struct hb_subtitle_s hb_subtitle_t;
+typedef struct hb_subtitle_config_s hb_subtitle_config_t;
typedef struct hb_metadata_s hb_metadata_t;
typedef struct hb_state_s hb_state_t;
typedef union hb_esconfig_u hb_esconfig_t;
@@ -108,6 +109,13 @@ struct hb_mixdown_s
int amixdown;
};
+struct hb_subtitle_config_s
+{
+ enum subdest { RENDERSUB, PASSTHRUSUB } dest;
+ int force;
+ int default_track;
+};
+
#define HB_VIDEO_RATE_BASE 27000000
extern hb_rate_t hb_video_rates[];
@@ -235,9 +243,10 @@ struct hb_job_s
int mp4_optimize;
int ipod_atom;
- int indepth_scan;
- hb_subtitle_t ** select_subtitle;
- char * native_language;
+ int indepth_scan;
+ hb_subtitle_config_t select_subtitle_config;
+ hb_subtitle_t ** select_subtitle;
+ char * native_language;
int angle; // dvd angle to encode
int frame_to_stop; // declare eof when we hit this frame
@@ -439,12 +448,13 @@ struct hb_chapter_s
struct hb_subtitle_s
{
- int track;
int id;
+ int track;
+
+ hb_subtitle_config_t config;
+
enum subtype { PICTURESUB, TEXTSUB } format;
enum subsource { VOBSUB, SRTSUB, CC608SUB, CC708SUB } source;
- enum subdest { RENDERSUB, PASSTHRUSUB } dest;
- int force;
char lang[1024];
char iso639_2[4];
uint8_t type; /* Closed Caption, Childrens, Directors etc */
diff --git a/libhb/decmpeg2.c b/libhb/decmpeg2.c
index b719370e8..cd3c5a324 100644
--- a/libhb/decmpeg2.c
+++ b/libhb/decmpeg2.c
@@ -472,7 +472,7 @@ static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
}
subtitle->format = TEXTSUB;
subtitle->source = CC608SUB;
- subtitle->dest = PASSTHRUSUB;
+ subtitle->config.dest = PASSTHRUSUB;
subtitle->type = 5;
hb_list_add( m->title->list_subtitle, subtitle );
diff --git a/libhb/decvobsub.c b/libhb/decvobsub.c
index e5633d54d..2a5ccab01 100644
--- a/libhb/decvobsub.c
+++ b/libhb/decvobsub.c
@@ -484,7 +484,7 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
/* Get infos about the subtitle */
ParseControls( w );
- if( job->indepth_scan || ( w->subtitle->force && pv->pts_forced == 0 ) )
+ if( job->indepth_scan || ( w->subtitle->config.force && pv->pts_forced == 0 ) )
{
/*
* Don't encode subtitles when doing a scan.
@@ -495,7 +495,7 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
return NULL;
}
- if (w->subtitle->dest == PASSTHRUSUB)
+ if (w->subtitle->config.dest == PASSTHRUSUB)
{
pv->buf->start = pv->pts_start;
pv->buf->stop = pv->pts_stop;
diff --git a/libhb/dvd.c b/libhb/dvd.c
index fc267778e..d07ccc61f 100644
--- a/libhb/dvd.c
+++ b/libhb/dvd.c
@@ -471,7 +471,7 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t )
lang->iso639_2);
subtitle->format = PICTURESUB;
subtitle->source = VOBSUB;
- subtitle->dest = RENDERSUB; // By default render (burn-in) the VOBSUB.
+ subtitle->config.dest = RENDERSUB; // By default render (burn-in) the VOBSUB.
subtitle->type = lang_extension;
diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c
index 589c9160e..2236f6d10 100644
--- a/libhb/dvdnav.c
+++ b/libhb/dvdnav.c
@@ -638,7 +638,7 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t )
lang->iso639_2);
subtitle->format = PICTURESUB;
subtitle->source = VOBSUB;
- subtitle->dest = RENDERSUB; // By default render (burn-in) the VOBSUB.
+ subtitle->config.dest = RENDERSUB; // By default render (burn-in) the VOBSUB.
subtitle->type = lang_extension;
diff --git a/libhb/hb.c b/libhb/hb.c
index c4045170c..9fdfe90f4 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -1066,7 +1066,8 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
{
subtitle = hb_list_item( title->list_subtitle, i );
- if( strcmp( subtitle->iso639_2, audio_lang ) == 0 )
+ if( strcmp( subtitle->iso639_2, audio_lang ) == 0 &&
+ subtitle->source == VOBSUB )
{
/*
* Matched subtitle language with audio language, so
@@ -1093,56 +1094,45 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
* Not doing a subtitle scan in this pass, but maybe we are in the
* first pass?
*/
- if( job->select_subtitle )
+ if( job->pass != 1 && job->native_language )
{
/*
- * Don't add subtitles here, we'll add them via select_subtitle
- * at the end of the subtitle_scan.
+ * We are not doing a subtitle scan but do want the
+ * native langauge subtitle selected, so select it
+ * for pass 0 or pass 2 of a two pass.
*/
+ for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
+ {
+ subtitle = hb_list_item( title->list_subtitle, i );
+ if( strcmp( subtitle->iso639_2, audio_lang ) == 0 )
+ {
+ /*
+ * Matched subtitle language with audio language, so
+ * add this to our list to scan.
+ */
+ subtitle_copy = malloc( sizeof( hb_subtitle_t ) );
+ memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) );
+ hb_list_add( title_copy->list_subtitle, subtitle_copy );
+ break;
+ }
+ }
} else {
/*
- * Definitely not doing a subtitle scan.
+ * Manually selected subtitles, in which case only
+ * bother adding them for pass 0 or pass 2 of a two
+ * pass.
*/
- if( job->pass != 1 && job->native_language )
+ if( job->pass != 1 )
{
/*
- * We are not doing a subtitle scan but do want the
- * native langauge subtitle selected, so select it
- * for pass 0 or pass 2 of a two pass.
+ * Copy all of them from the input job, to the title_copy/job_copy.
*/
- for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
- {
- subtitle = hb_list_item( title->list_subtitle, i );
- if( strcmp( subtitle->iso639_2, audio_lang ) == 0 )
+ for( i = 0; i < hb_list_count(job->list_subtitle); i++ ) {
+ if( ( subtitle = hb_list_item( job->list_subtitle, i ) ) )
{
- /*
- * Matched subtitle language with audio language, so
- * add this to our list to scan.
- */
subtitle_copy = malloc( sizeof( hb_subtitle_t ) );
memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) );
hb_list_add( title_copy->list_subtitle, subtitle_copy );
- break;
- }
- }
- } else {
- /*
- * Manually selected subtitles, in which case only
- * bother adding them for pass 0 or pass 2 of a two
- * pass.
- */
- if( job->pass != 1 )
- {
- /*
- * Copy all of them from the input job, to the title_copy/job_copy.
- */
- for( i = 0; i < hb_list_count(job->list_subtitle); i++ ) {
- if( ( subtitle = hb_list_item( job->list_subtitle, i ) ) )
- {
- subtitle_copy = malloc( sizeof( hb_subtitle_t ) );
- memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) );
- hb_list_add( title_copy->list_subtitle, subtitle_copy );
- }
}
}
}
diff --git a/libhb/muxcommon.c b/libhb/muxcommon.c
index a404911af..da390c500 100644
--- a/libhb/muxcommon.c
+++ b/libhb/muxcommon.c
@@ -262,7 +262,7 @@ static void MuxerFunc( void * _mux )
{
hb_subtitle_t *subtitle = hb_list_item( title->list_subtitle, i );
- if (subtitle->dest != PASSTHRUSUB)
+ if (subtitle->config.dest != PASSTHRUSUB)
continue;
add_mux_track( mux, subtitle->fifo_out, subtitle->mux_data, 0 );
}
diff --git a/libhb/muxmkv.c b/libhb/muxmkv.c
index ace68f454..2e8814ca9 100644
--- a/libhb/muxmkv.c
+++ b/libhb/muxmkv.c
@@ -287,7 +287,7 @@ static int MKVInit( hb_mux_object_t * m )
int len;
subtitle = hb_list_item( title->list_subtitle, i );
- if (subtitle->dest != PASSTHRUSUB)
+ if (subtitle->config.dest != PASSTHRUSUB)
continue;
memset(track, 0, sizeof(mk_TrackConfig));
@@ -313,6 +313,10 @@ static int MKVInit( hb_mux_object_t * m )
default:
continue;
}
+ if ( subtitle->config.default_track )
+ {
+ track->flagDefault = 1;
+ }
mux_data = calloc(1, sizeof( hb_mux_data_t ) );
subtitle->mux_data = mux_data;
diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c
index 1511713b3..cdb9ce7ae 100644
--- a/libhb/muxmp4.c
+++ b/libhb/muxmp4.c
@@ -408,7 +408,7 @@ static int MP4Init( hb_mux_object_t * m )
hb_subtitle_t *subtitle = hb_list_item( job->list_subtitle, i );
if( subtitle && subtitle->format == TEXTSUB &&
- subtitle->dest == PASSTHRUSUB )
+ subtitle->config.dest == PASSTHRUSUB )
{
uint64_t width, height = 60;
if( job->anamorphic.mode )
diff --git a/libhb/reader.c b/libhb/reader.c
index c865ea85f..9ac515c4e 100644
--- a/libhb/reader.c
+++ b/libhb/reader.c
@@ -527,7 +527,7 @@ static hb_fifo_t ** GetFifoForId( hb_job_t * job, int id )
subtitle = hb_list_item( title->list_subtitle, i );
if (id == subtitle->id) {
subtitle->hits++;
- if( !job->indepth_scan || subtitle->force )
+ if( !job->indepth_scan || subtitle->config.force )
{
/*
* Pass the subtitles to be processed if we are not scanning, or if
diff --git a/libhb/sync.c b/libhb/sync.c
index c4ef6d6df..8ae1b78e8 100644
--- a/libhb/sync.c
+++ b/libhb/sync.c
@@ -303,7 +303,7 @@ static void SyncVideo( hb_work_object_t * w )
for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
{
subtitle = hb_list_item( job->list_subtitle, i );
- if( subtitle->dest == PASSTHRUSUB )
+ if( subtitle->config.dest == PASSTHRUSUB )
{
hb_fifo_push( subtitle->fifo_out, hb_buffer_init( 0 ) );
}
@@ -336,7 +336,7 @@ static void SyncVideo( hb_work_object_t * w )
for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
{
subtitle = hb_list_item( job->list_subtitle, i );
- if( subtitle->dest == PASSTHRUSUB )
+ if( subtitle->config.dest == PASSTHRUSUB )
{
hb_fifo_push( subtitle->fifo_out, hb_buffer_init( 0 ) );
}
@@ -627,7 +627,7 @@ static void SyncVideo( hb_work_object_t * w )
{
if( sub->size > 0 )
{
- if( subtitle->dest == RENDERSUB )
+ if( subtitle->config.dest == RENDERSUB )
{
if ( cur->sub == NULL )
{
@@ -660,7 +660,7 @@ static void SyncVideo( hb_work_object_t * w )
/*
* EOF - consume for rendered, else pass through
*/
- if( subtitle->dest == RENDERSUB )
+ if( subtitle->config.dest == RENDERSUB )
{
sub = hb_fifo_get( subtitle->fifo_raw );
hb_buffer_close( &sub );
diff --git a/libhb/work.c b/libhb/work.c
index 848c798e4..5be4bdf9f 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -280,7 +280,7 @@ void hb_display_job_info( hb_job_t * job )
subtitle->source == VOBSUB ? "VOBSUB" :
((subtitle->source == CC608SUB ||
subtitle->source == CC708SUB) ? "CC" : "SRT"),
- subtitle->dest == RENDERSUB ? "Render/Burn in" : "Pass-Through");
+ subtitle->config.dest == RENDERSUB ? "Render/Burn in" : "Pass-Through");
}
}
@@ -466,18 +466,64 @@ static void do_job( hb_job_t * job, int cpu_count )
hb_list_add( job->list_work, w );
}
- if( job->select_subtitle && !job->indepth_scan )
+ /*
+ * Look for the scanned subtitle in the existing subtitle list
+ */
+ if ( !job->indepth_scan && job->select_subtitle && *(job->select_subtitle) )
{
/*
- * Must be second pass of a two pass with subtitle scan enabled, so
- * add the subtitle that we found on the first pass for use in this
- * pass.
+ * Disable forced subtitles if we didn't find any in the scan
+ * so that we display normal subtitles instead.
+ *
+ * select_subtitle implies that we did a scan.
*/
- if (*(job->select_subtitle))
+ if( (*job->select_subtitle)->config.force &&
+ (*job->select_subtitle)->forced_hits == 0 )
{
- hb_list_add( title->list_subtitle, *( job->select_subtitle ) );
+ (*job->select_subtitle)->config.force = 0;
+ }
+ for( i=0; i < hb_list_count(title->list_subtitle); i++ )
+ {
+ subtitle = hb_list_item( title->list_subtitle, i );
+
+ if( subtitle )
+ {
+ /*
+ * Disable forced subtitles if we didn't find any in the scan
+ * so that we display normal subtitles instead.
+ *
+ * select_subtitle implies that we did a scan.
+ */
+ if( (*job->select_subtitle)->id == subtitle->id )
+ {
+ *subtitle = *(*job->select_subtitle);
+ free( *job->select_subtitle );
+ free( job->select_subtitle );
+ job->select_subtitle = NULL;
+ }
+ }
+ }
+
+ if( job->select_subtitle )
+ {
+ /*
+ * Its not in the existing list
+ *
+ * Must be second pass of a two pass with subtitle scan enabled, so
+ * add the subtitle that we found on the first pass for use in this
+ * pass.
+ */
+ hb_list_add( title->list_subtitle, *job->select_subtitle );
+ free( job->select_subtitle );
+ job->select_subtitle = NULL;
}
}
+ else if ( !job->indepth_scan && job->select_subtitle )
+ {
+ free( job->select_subtitle );
+ job->select_subtitle = NULL;
+ }
+
for( i=0; i < hb_list_count(title->list_subtitle); i++ )
{
@@ -490,22 +536,7 @@ static void do_job( hb_job_t * job, int cpu_count )
subtitle->fifo_sync = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
subtitle->fifo_out = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
- /*
- * Disable forced subtitles if we didn't find any in the scan
- * so that we display normal subtitles instead.
- *
- * select_subtitle implies that we did a scan.
- */
- if( !job->indepth_scan && subtitle->force &&
- job->select_subtitle )
- {
- if( subtitle->forced_hits == 0 )
- {
- subtitle->force = 0;
- }
- }
-
- if( (!job->indepth_scan || subtitle->force) &&
+ if( (!job->indepth_scan || subtitle->config.force) &&
subtitle->source == VOBSUB ) {
/*
* Don't add threads for subtitles when we are scanning, unless
@@ -528,7 +559,7 @@ static void do_job( hb_job_t * job, int cpu_count )
if( !job->indepth_scan &&
subtitle->format == PICTURESUB
- && subtitle->dest == PASSTHRUSUB )
+ && subtitle->config.dest == PASSTHRUSUB )
{
/*
* Passing through a subtitle picture, this will have to
@@ -910,9 +941,14 @@ cleanup:
for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
{
subtitle = hb_list_item( title->list_subtitle, i );
+
hb_log( "Subtitle stream 0x%x '%s': %d hits (%d forced)",
subtitle->id, subtitle->lang, subtitle->hits,
subtitle->forced_hits );
+
+ if( subtitle->hits == 0 )
+ continue;
+
if( subtitle->hits > subtitle_highest )
{
subtitle_highest = subtitle->hits;
@@ -982,19 +1018,12 @@ cleanup:
subtitle = hb_list_item( title->list_subtitle, i );
if( subtitle->id == subtitle_hit )
{
+ subtitle->config = job->select_subtitle_config;
hb_list_rem( title->list_subtitle, subtitle );
- *( job->select_subtitle ) = subtitle;
+ *job->select_subtitle = subtitle;
+ break;
}
}
- } else {
- /*
- * Must be the end of pass 0 or 2 - we don't need this anymore.
- *
- * Have to put the subtitle list back together in the title though
- * or the GUI will have a hissy fit.
- */
- free( job->select_subtitle );
- job->select_subtitle = NULL;
}
}