diff options
author | eddyg <[email protected]> | 2007-08-20 23:50:45 +0000 |
---|---|---|
committer | eddyg <[email protected]> | 2007-08-20 23:50:45 +0000 |
commit | a035bfd29afeb4560d85a295a405a83b76e68784 (patch) | |
tree | 7de643bd649986118159fefb2f368e0aa25d2069 | |
parent | a779f4bd446925e0d1b272de5f30d771c0401424 (diff) |
Added "--subtitle-force" option to the CLI, and added changes to decsub to
select only forced subtitles curtesy of Utumno (thanks!).
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@843 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/common.h | 1 | ||||
-rw-r--r-- | libhb/decsub.c | 50 | ||||
-rw-r--r-- | test/test.c | 18 |
3 files changed, 57 insertions, 12 deletions
diff --git a/libhb/common.h b/libhb/common.h index de56a5c63..22591c602 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -257,6 +257,7 @@ struct hb_job_s int subtitle_scan; hb_subtitle_t ** select_subtitle; + int subtitle_force; char * native_language; #ifdef __LIBHB__ diff --git a/libhb/decsub.c b/libhb/decsub.c index da94ad180..443c0865a 100644 --- a/libhb/decsub.c +++ b/libhb/decsub.c @@ -17,6 +17,7 @@ struct hb_work_private_s int64_t pts; int64_t pts_start; int64_t pts_stop; + int pts_forced; int x; int y; int width; @@ -135,6 +136,7 @@ static void ParseControls( hb_work_object_t * w ) pv->pts_start = 0; pv->pts_stop = 0; + pv->pts_forced = 0; for( i = pv->size_rle; ; ) { @@ -145,26 +147,41 @@ static void ParseControls( hb_work_object_t * w ) { command = pv->buf[i++]; - if( command == 0xFF ) + /* + * There are eight commands available for + * Sub-Pictures. The first SP_DCSQ should contain, as a + * minimum, SET_COLOR, SET_CONTR, SET_DAREA, and + * SET_DSPXA + */ + + if( command == 0xFF ) // 0xFF - CMD_END - ends one SP_DCSQ { break; } switch( command ) { - case 0x00: + case 0x00: // 0x00 - FSTA_DSP - Forced Start Display, no arguments + pv->pts_start = pv->pts + date * 900; + pv->pts_forced = 1; break; - case 0x01: + case 0x01: // 0x01 - STA_DSP - Start Display, no arguments pv->pts_start = pv->pts + date * 900; + pv->pts_forced = 0; break; - case 0x02: + case 0x02: // 0x02 - STP_DSP - Stop Display, no arguments pv->pts_stop = pv->pts + date * 900; break; - case 0x03: - { + case 0x03: // 0x03 - SET_COLOR - Set Colour indices + { + /* + * SET_COLOR - provides four indices into the CLUT + * for the current PGC to associate with the four + * pixel values + */ int colors[4]; int j; @@ -202,8 +219,13 @@ static void ParseControls( hb_work_object_t * w ) i += 2; break; } - case 0x04: + case 0x04: // 0x04 - SET_CONTR - Set Contrast { + /* + * SET_CONTR - directly provides the four contrast + * (alpha blend) values to associate with the four + * pixel values + */ pv->alpha[3] = (pv->buf[i+0]>>4)&0x0f; pv->alpha[2] = (pv->buf[i+0])&0x0f; pv->alpha[1] = (pv->buf[i+1]>>4)&0x0f; @@ -211,7 +233,7 @@ static void ParseControls( hb_work_object_t * w ) i += 2; break; } - case 0x05: + case 0x05: // 0x05 - SET_DAREA - defines the display area { pv->x = (pv->buf[i+0]<<4) | ((pv->buf[i+1]>>4)&0x0f); pv->width = (((pv->buf[i+1]&0x0f)<<8)| pv->buf[i+2]) - pv->x + 1; @@ -220,7 +242,7 @@ static void ParseControls( hb_work_object_t * w ) i += 6; break; } - case 0x06: + case 0x06: // 0x06 - SET_DSPXA - defines the pixel data addresses { pv->offsets[0] = ( pv->buf[i] << 8 ) | pv->buf[i+1]; i += 2; pv->offsets[1] = ( pv->buf[i] << 8 ) | pv->buf[i+1]; i += 2; @@ -385,10 +407,20 @@ static hb_buffer_t * Decode( hb_work_object_t * w ) int * offset; hb_buffer_t * buf; uint8_t * buf_raw = NULL; + hb_job_t * job = pv->job; /* Get infos about the subtitle */ ParseControls( w ); + if( job->subtitle_force && pv->pts_forced == 0 ) + { + /* + * When forcing subtitles, ignore all those that don't + * have the forced flag set. + */ + return NULL; + } + /* Do the actual decoding now */ buf_raw = malloc( pv->width * pv->height * 4 ); diff --git a/test/test.c b/test/test.c index 4bdc87a9c..1aa808f87 100644 --- a/test/test.c +++ b/test/test.c @@ -22,6 +22,7 @@ static char * format = NULL; static int titleindex = 1; static int longest_title = 0; static int subtitle_scan = 0; +static int subtitle_force = 0; static char * native_language = NULL; static int twoPass = 0; static int deinterlace = 0; @@ -597,7 +598,12 @@ static int HandleEvents( hb_handle_t * h ) job->maxWidth = maxWidth; if (maxHeight) job->maxHeight = maxHeight; - + + if( subtitle_force ) + { + job->subtitle_force = subtitle_force; + } + if( twoPass ) { /* @@ -782,9 +788,11 @@ static void ShowHelp() " -X, --maxWidth <#> Set maximum width\n" " -s, --subtitle <number> Select subtitle (default: none)\n" " -U, --subtitle-scan Scan for subtitles on the first pass, and choose\n" - " the one that's only used 20 percent of the time\n" + " the one that's only used 10 percent of the time\n" " or less. This should locate subtitles for short\n" " foreign language segments. Only works with 2-pass.\n" + " -F, --subtitle-force Only display subtitles from the selected stream if\n" + " the subtitles have the forced flag set.\n" " -N, --native-language Select subtitles with this language if it does not\n" " <string> match the Audio language. Provide the language's\n" " iso639-2 code (fre, eng, spa, dut, et cetera)\n" @@ -881,6 +889,7 @@ static int ParseOptions( int argc, char ** argv ) { "mixdown", required_argument, NULL, '6' }, { "subtitle", required_argument, NULL, 's' }, { "subtitle-scan", no_argument, NULL, 'U' }, + { "subtitle-forced", no_argument, NULL, 'F' }, { "native-language", required_argument, NULL,'N' }, { "encoder", required_argument, NULL, 'e' }, @@ -916,7 +925,7 @@ static int ParseOptions( int argc, char ** argv ) int c; c = getopt_long( argc, argv, - "hvuC:f:4i:o:t:Lc:ma:6:s:UN:e:E:2d789gpw:l:n:b:q:S:B:r:R:Qx:TY:X:", + "hvuC:f:4i:o:t:Lc:ma:6:s:UFN:e:E:2d789gpw:l:n:b:q:S:B:r:R:Qx:TY:X:", long_options, &option_index ); if( c < 0 ) { @@ -1015,6 +1024,9 @@ static int ParseOptions( int argc, char ** argv ) case 'U': subtitle_scan = 1; break; + case 'F': + subtitle_force = 1; + break; case 'N': native_language = strdup( optarg ); break; |