From 143f723b12881a8ab3732386785a00840bb2c934 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Thu, 26 Apr 2012 19:11:03 +0000 Subject: PGS (bluray) subtitle support \o/ Thanks to patches supplied by David Mitchell and Rob McMullen we finally have PGS support. I added a fix for libav pgs timestamp processing and detection of forced subtitles to their work, then made foreign audio search work with PGS subs. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4605 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/bd.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'libhb/bd.c') diff --git a/libhb/bd.c b/libhb/bd.c index 9ec4c078a..bb051115a 100644 --- a/libhb/bd.c +++ b/libhb/bd.c @@ -81,6 +81,44 @@ int hb_bd_title_count( hb_bd_t * d ) return d->title_count; } +static void add_subtitle(int track, hb_list_t *list_subtitle, BLURAY_STREAM_INFO *bdsub, uint32_t codec) +{ + hb_subtitle_t * subtitle; + iso639_lang_t * lang; + + subtitle = calloc( sizeof( hb_subtitle_t ), 1 ); + + subtitle->track = track; + subtitle->id = bdsub->pid; + lang = lang_for_code2( (char*)bdsub->lang ); + snprintf( subtitle->lang, sizeof( subtitle->lang ), "%s", + strlen(lang->native_name) ? lang->native_name : lang->eng_name); + snprintf( subtitle->iso639_2, sizeof( subtitle->iso639_2 ), "%s", + lang->iso639_2); + + switch ( bdsub->coding_type ) + { + case BLURAY_STREAM_TYPE_SUB_PG: + subtitle->source = PGSSUB; + subtitle->format = PICTURESUB; + subtitle->config.dest = RENDERSUB; + break; + default: + // Unrecognized, don't add to list + free( subtitle ); + return; + } + subtitle->reg_desc = STR4_TO_UINT32("HDMV"); + subtitle->stream_type = bdsub->coding_type; + subtitle->codec = codec; + + hb_log( "bd: subtitle id=0x%x, lang=%s, 3cc=%s", subtitle->id, + subtitle->lang, subtitle->iso639_2 ); + + hb_list_add( list_subtitle, subtitle ); + return; +} + static void add_audio(int track, hb_list_t *list_audio, BLURAY_STREAM_INFO *bdaudio, int substream_type, uint32_t codec, uint32_t codec_param) { hb_audio_t * audio; @@ -89,6 +127,7 @@ static void add_audio(int track, hb_list_t *list_audio, BLURAY_STREAM_INFO *bdau audio = calloc( sizeof( hb_audio_t ), 1 ); audio->id = (substream_type << 16) | bdaudio->pid; + audio->config.in.reg_desc = STR4_TO_UINT32("HDMV"); audio->config.in.stream_type = bdaudio->coding_type; audio->config.in.substream_type = substream_type; audio->config.in.codec = codec; @@ -393,6 +432,25 @@ hb_title_t * hb_bd_title_scan( hb_bd_t * d, int tt, uint64_t min_duration ) } } + // Add all the subtitles found in the above clip. + for ( ii = 0; ii < ti->clips[audio_clip_index].pg_stream_count; ii++ ) + { + BLURAY_STREAM_INFO * bdpgs; + + bdpgs = &ti->clips[audio_clip_index].pg_streams[ii]; + + switch( bdpgs->coding_type ) + { + case BLURAY_STREAM_TYPE_SUB_PG: + add_subtitle(ii, title->list_subtitle, bdpgs, WORK_DECPGSSUB); + break; + default: + hb_log( "scan: unknown subtitle pid 0x%x codec 0x%x", + bdpgs->pid, bdpgs->coding_type ); + break; + } + } + /* Chapters */ for ( ii = 0; ii < ti->chapter_count; ii++ ) { -- cgit v1.2.3