summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorRodeo <[email protected]>2012-05-03 17:45:00 +0000
committerRodeo <[email protected]>2012-05-03 17:45:00 +0000
commita1161011aae76d215675fc354c42a0fac27d1476 (patch)
treec09d03aa827c78dae3dc0d45749dbd674094c81e /libhb
parent4aeadc9bc63d200d6c0b709eba7e25c4f3afe24c (diff)
audio->config.lang.description: code cleanup.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4637 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/bd.c77
-rw-r--r--libhb/dvd.c130
-rw-r--r--libhb/dvdnav.c126
-rw-r--r--libhb/stream.c46
4 files changed, 199 insertions, 180 deletions
diff --git a/libhb/bd.c b/libhb/bd.c
index f980dac03..782e2d5ce 100644
--- a/libhb/bd.c
+++ b/libhb/bd.c
@@ -121,6 +121,7 @@ static void add_subtitle(int track, hb_list_t *list_subtitle, BLURAY_STREAM_INFO
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)
{
+ const char * codec_name;
hb_audio_t * audio;
iso639_lang_t * lang;
@@ -132,35 +133,67 @@ static void add_audio(int track, hb_list_t *list_audio, BLURAY_STREAM_INFO *bdau
audio->config.in.substream_type = substream_type;
audio->config.in.codec = codec;
audio->config.in.codec_param = codec_param;
- audio->config.lang.type = 0;
+
+ switch( audio->config.in.codec )
+ {
+ case HB_ACODEC_AC3:
+ codec_name = "AC3";
+ break;
+ case HB_ACODEC_DCA:
+ codec_name = "DTS";
+ break;
+ default:
+ {
+ if( audio->config.in.codec & HB_ACODEC_FF_MASK )
+ {
+ switch( bdaudio->coding_type )
+ {
+ case BLURAY_STREAM_TYPE_AUDIO_AC3PLUS:
+ codec_name = "E-AC3";
+ break;
+ case BLURAY_STREAM_TYPE_AUDIO_DTSHD:
+ codec_name = "DTS-HD HRA";
+ break;
+ case BLURAY_STREAM_TYPE_AUDIO_DTSHD_MASTER:
+ codec_name = "DTS-HD MA";
+ break;
+ case BLURAY_STREAM_TYPE_AUDIO_LPCM:
+ codec_name = "BD LPCM";
+ break;
+ case BLURAY_STREAM_TYPE_AUDIO_MPEG1:
+ codec_name = "MPEG1";
+ break;
+ case BLURAY_STREAM_TYPE_AUDIO_MPEG2:
+ codec_name = "MPEG2";
+ break;
+ case BLURAY_STREAM_TYPE_AUDIO_TRUHD:
+ codec_name = "TrueHD";
+ break;
+ default:
+ codec_name = "Unknown FFmpeg";
+ break;
+ }
+ }
+ else
+ {
+ codec_name = "Unknown";
+ }
+ }
+ break;
+ }
lang = lang_for_code2( (char*)bdaudio->lang );
- int stream_type = bdaudio->coding_type;
- snprintf( audio->config.lang.description,
- sizeof( audio->config.lang.description ), "%s (%s)",
- strlen(lang->native_name) ? lang->native_name : lang->eng_name,
- audio->config.in.codec == HB_ACODEC_AC3 ? "AC3" :
- ( audio->config.in.codec == HB_ACODEC_DCA ? "DTS" :
- ( ( audio->config.in.codec & HB_ACODEC_FF_MASK ) ?
- ( stream_type == BLURAY_STREAM_TYPE_AUDIO_LPCM ? "BD LPCM" :
- ( stream_type == BLURAY_STREAM_TYPE_AUDIO_AC3PLUS ? "E-AC3" :
- ( stream_type == BLURAY_STREAM_TYPE_AUDIO_TRUHD ? "TrueHD" :
- ( stream_type == BLURAY_STREAM_TYPE_AUDIO_DTSHD ? "DTS-HD HRA" :
- ( stream_type == BLURAY_STREAM_TYPE_AUDIO_DTSHD_MASTER ? "DTS-HD MA" :
- ( stream_type == BLURAY_STREAM_TYPE_AUDIO_MPEG1 ? "MPEG1" :
- ( stream_type == BLURAY_STREAM_TYPE_AUDIO_MPEG2 ? "MPEG2" :
- "Unknown FFmpeg"
- ) ) ) ) ) ) ) : "Unknown"
- ) ) );
+ audio->config.lang.type = 0;
snprintf( audio->config.lang.simple,
sizeof( audio->config.lang.simple ), "%s",
- strlen(lang->native_name) ? lang->native_name :
- lang->eng_name );
-
+ strlen( lang->native_name ) ? lang->native_name : lang->eng_name );
snprintf( audio->config.lang.iso639_2,
- sizeof( audio->config.lang.iso639_2 ), "%s", lang->iso639_2);
+ sizeof( audio->config.lang.iso639_2 ), "%s", lang->iso639_2 );
+ snprintf( audio->config.lang.description,
+ sizeof( audio->config.lang.description ), "%s (%s)",
+ audio->config.lang.simple, codec_name );
hb_log( "bd: audio id=0x%x, lang=%s, 3cc=%s", audio->id,
audio->config.lang.description, audio->config.lang.iso639_2 );
diff --git a/libhb/dvd.c b/libhb/dvd.c
index f4260d5fc..43af43a05 100644
--- a/libhb/dvd.c
+++ b/libhb/dvd.c
@@ -173,6 +173,7 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur
uint64_t duration;
float duration_correction;
unsigned char unused[1024];
+ const char * codec_name;
hb_log( "scan: scanning title %d", t );
@@ -324,11 +325,9 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur
/* Detect languages */
for( i = 0; i < vts->vtsi_mat->nr_of_vts_audio_streams; i++ )
{
+ int audio_format, lang_code, lang_extension, audio_control, position, j;
hb_audio_t * audio, * audio_tmp;
- int audio_format, lang_code, audio_control,
- position, j;
iso639_lang_t * lang;
- int lang_extension = 0;
hb_log( "scan: checking audio %d", i + 1 );
@@ -354,27 +353,32 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur
case 0x00:
audio->id = ( ( 0x80 + position ) << 8 ) | 0xbd;
audio->config.in.codec = HB_ACODEC_AC3;
+ codec_name = "AC3";
break;
case 0x02:
case 0x03:
audio->id = 0xc0 + position;
audio->config.in.codec = HB_ACODEC_FFMPEG;
+ codec_name = "MPEG";
break;
case 0x04:
audio->id = ( ( 0xa0 + position ) << 8 ) | 0xbd;
audio->config.in.codec = HB_ACODEC_LPCM;
+ codec_name = "LPCM";
break;
case 0x06:
audio->id = ( ( 0x88 + position ) << 8 ) | 0xbd;
audio->config.in.codec = HB_ACODEC_DCA;
+ codec_name = "DTS";
break;
default:
audio->id = 0;
audio->config.in.codec = 0;
+ codec_name = "Unknown";
hb_log( "scan: unknown audio codec (%x)",
audio_format );
break;
@@ -402,36 +406,32 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur
continue;
}
- audio->config.lang.type = lang_extension;
-
lang = lang_for_code( lang_code );
- snprintf( audio->config.lang.description, sizeof( audio->config.lang.description ), "%s (%s)",
- strlen(lang->native_name) ? lang->native_name : lang->eng_name,
- audio->config.in.codec == HB_ACODEC_AC3 ? "AC3" : ( audio->config.in.codec ==
- HB_ACODEC_DCA ? "DTS" : ( audio->config.in.codec ==
- HB_ACODEC_FFMPEG ? "MPEG" : "LPCM" ) ) );
- snprintf( audio->config.lang.simple, sizeof( audio->config.lang.simple ), "%s",
- strlen(lang->native_name) ? lang->native_name : lang->eng_name );
- snprintf( audio->config.lang.iso639_2, sizeof( audio->config.lang.iso639_2 ), "%s",
- lang->iso639_2);
+ audio->config.lang.type = lang_extension;
+
+ snprintf( audio->config.lang.simple,
+ sizeof( audio->config.lang.simple ), "%s",
+ strlen( lang->native_name ) ? lang->native_name : lang->eng_name );
+ snprintf( audio->config.lang.iso639_2,
+ sizeof( audio->config.lang.iso639_2 ), "%s", lang->iso639_2 );
+ snprintf( audio->config.lang.description,
+ sizeof( audio->config.lang.description ), "%s (%s)",
+ audio->config.lang.simple, codec_name );
switch( lang_extension )
{
- case 0:
- case 1:
- break;
- case 2:
- strcat( audio->config.lang.description, " (Visually Impaired)" );
- break;
- case 3:
- strcat( audio->config.lang.description, " (Director's Commentary 1)" );
- break;
- case 4:
- strcat( audio->config.lang.description, " (Director's Commentary 2)" );
- break;
- default:
- break;
+ case 2:
+ strcat( audio->config.lang.description, " (Visually Impaired)" );
+ break;
+ case 3:
+ strcat( audio->config.lang.description, " (Director's Commentary 1)" );
+ break;
+ case 4:
+ strcat( audio->config.lang.description, " (Director's Commentary 2)" );
+ break;
+ default:
+ break;
}
hb_log( "scan: id=0x%x, lang=%s, 3cc=%s ext=%i", audio->id,
@@ -508,52 +508,38 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur
switch( lang_extension )
{
- case 0:
- break;
- case 1:
- break;
- case 2:
- strcat( subtitle->lang, " (Caption with bigger size character)");
- break;
- case 3:
- strcat( subtitle->lang, " (Caption for Children)");
- break;
- case 4:
- break;
- case 5:
- strcat( subtitle->lang, " (Closed Caption)");
- break;
- case 6:
- strcat( subtitle->lang, " (Closed Caption with bigger size character)");
- break;
- case 7:
- strcat( subtitle->lang, " (Closed Caption for Children)");
- break;
- case 8:
- break;
- case 9:
- strcat( subtitle->lang, " (Forced Caption)");
- break;
- case 10:
- break;
- case 11:
- break;
- case 12:
- break;
- case 13:
- strcat( subtitle->lang, " (Director's Commentary)");
- break;
- case 14:
- strcat( subtitle->lang, " (Director's Commentary with bigger size character)");
- break;
- case 15:
- strcat( subtitle->lang, " (Director's Commentary for Children)");
- default:
- break;
+ case 2:
+ strcat( subtitle->lang, " (Caption with bigger size character)" );
+ break;
+ case 3:
+ strcat( subtitle->lang, " (Caption for Children)" );
+ break;
+ case 5:
+ strcat( subtitle->lang, " (Closed Caption)" );
+ break;
+ case 6:
+ strcat( subtitle->lang, " (Closed Caption with bigger size character)" );
+ break;
+ case 7:
+ strcat( subtitle->lang, " (Closed Caption for Children)" );
+ break;
+ case 9:
+ strcat( subtitle->lang, " (Forced Caption)" );
+ break;
+ case 13:
+ strcat( subtitle->lang, " (Director's Commentary)" );
+ break;
+ case 14:
+ strcat( subtitle->lang, " (Director's Commentary with bigger size character)" );
+ break;
+ case 15:
+ strcat( subtitle->lang, " (Director's Commentary for Children)" );
+ default:
+ break;
}
- hb_log( "scan: id=0x%x, lang=%s, 3cc=%s", subtitle->id,
- subtitle->lang, subtitle->iso639_2 );
+ hb_log( "scan: id=0x%x, lang=%s, 3cc=%s ext=%i", subtitle->id,
+ subtitle->lang, subtitle->iso639_2, lang_extension );
hb_list_add( title->list_subtitle, subtitle );
}
diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c
index e40a02f05..1032ce69d 100644
--- a/libhb/dvdnav.c
+++ b/libhb/dvdnav.c
@@ -305,6 +305,7 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura
int longest_pgcn, longest_pgn, longest_pgcn_end;
float duration_correction;
const char * name;
+ const char * codec_name;
hb_log( "scan: scanning title %d", t );
@@ -473,11 +474,9 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura
/* Detect languages */
for( i = 0; i < ifo->vtsi_mat->nr_of_vts_audio_streams; i++ )
{
+ int audio_format, lang_code, lang_extension, audio_control, position, j;
hb_audio_t * audio, * audio_tmp;
- int audio_format, lang_code, audio_control,
- position, j;
iso639_lang_t * lang;
- int lang_extension = 0;
hb_log( "scan: checking audio %d", i + 1 );
@@ -503,27 +502,32 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura
case 0x00:
audio->id = ( ( 0x80 + position ) << 8 ) | 0xbd;
audio->config.in.codec = HB_ACODEC_AC3;
+ codec_name = "AC3";
break;
case 0x02:
case 0x03:
audio->id = 0xc0 + position;
audio->config.in.codec = HB_ACODEC_FFMPEG;
+ codec_name = "MPEG";
break;
case 0x04:
audio->id = ( ( 0xa0 + position ) << 8 ) | 0xbd;
audio->config.in.codec = HB_ACODEC_LPCM;
+ codec_name = "LPCM";
break;
case 0x06:
audio->id = ( ( 0x88 + position ) << 8 ) | 0xbd;
audio->config.in.codec = HB_ACODEC_DCA;
+ codec_name = "DTS";
break;
default:
audio->id = 0;
audio->config.in.codec = 0;
+ codec_name = "Unknown";
hb_log( "scan: unknown audio codec (%x)",
audio_format );
break;
@@ -551,38 +555,32 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura
continue;
}
- audio->config.lang.type = lang_extension;
-
lang = lang_for_code( lang_code );
- snprintf( audio->config.lang.description,
- sizeof( audio->config.lang.description ), "%s (%s)",
- strlen(lang->native_name) ? lang->native_name : lang->eng_name,
- audio->config.in.codec == HB_ACODEC_AC3 ? "AC3" :
- ( audio->config.in.codec == HB_ACODEC_DCA ? "DTS" :
- ( audio->config.in.codec == HB_ACODEC_FFMPEG ? "MPEG" : "LPCM" ) ) );
+ audio->config.lang.type = lang_extension;
+
snprintf( audio->config.lang.simple,
sizeof( audio->config.lang.simple ), "%s",
- strlen(lang->native_name) ? lang->native_name : lang->eng_name );
+ strlen( lang->native_name ) ? lang->native_name : lang->eng_name );
snprintf( audio->config.lang.iso639_2,
- sizeof( audio->config.lang.iso639_2 ), "%s", lang->iso639_2);
+ sizeof( audio->config.lang.iso639_2 ), "%s", lang->iso639_2 );
+ snprintf( audio->config.lang.description,
+ sizeof( audio->config.lang.description ), "%s (%s)",
+ audio->config.lang.simple, codec_name );
switch( lang_extension )
{
- case 0:
- case 1:
- break;
- case 2:
- strcat( audio->config.lang.description, " (Visually Impaired)" );
- break;
- case 3:
- strcat( audio->config.lang.description, " (Director's Commentary 1)" );
- break;
- case 4:
- strcat( audio->config.lang.description, " (Director's Commentary 2)" );
- break;
- default:
- break;
+ case 2:
+ strcat( audio->config.lang.description, " (Visually Impaired)" );
+ break;
+ case 3:
+ strcat( audio->config.lang.description, " (Director's Commentary 1)" );
+ break;
+ case 4:
+ strcat( audio->config.lang.description, " (Director's Commentary 2)" );
+ break;
+ default:
+ break;
}
hb_log( "scan: id=0x%x, lang=%s, 3cc=%s ext=%i", audio->id,
@@ -659,52 +657,38 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura
switch( lang_extension )
{
- case 0:
- break;
- case 1:
- break;
- case 2:
- strcat( subtitle->lang, " (Caption with bigger size character)");
- break;
- case 3:
- strcat( subtitle->lang, " (Caption for Children)");
- break;
- case 4:
- break;
- case 5:
- strcat( subtitle->lang, " (Closed Caption)");
- break;
- case 6:
- strcat( subtitle->lang, " (Closed Caption with bigger size character)");
- break;
- case 7:
- strcat( subtitle->lang, " (Closed Caption for Children)");
- break;
- case 8:
- break;
- case 9:
- strcat( subtitle->lang, " (Forced Caption)");
- break;
- case 10:
- break;
- case 11:
- break;
- case 12:
- break;
- case 13:
- strcat( subtitle->lang, " (Director's Commentary)");
- break;
- case 14:
- strcat( subtitle->lang, " (Director's Commentary with bigger size character)");
- break;
- case 15:
- strcat( subtitle->lang, " (Director's Commentary for Children)");
- default:
- break;
+ case 2:
+ strcat( subtitle->lang, " (Caption with bigger size character)" );
+ break;
+ case 3:
+ strcat( subtitle->lang, " (Caption for Children)" );
+ break;
+ case 5:
+ strcat( subtitle->lang, " (Closed Caption)" );
+ break;
+ case 6:
+ strcat( subtitle->lang, " (Closed Caption with bigger size character)" );
+ break;
+ case 7:
+ strcat( subtitle->lang, " (Closed Caption for Children)" );
+ break;
+ case 9:
+ strcat( subtitle->lang, " (Forced Caption)" );
+ break;
+ case 13:
+ strcat( subtitle->lang, " (Director's Commentary)" );
+ break;
+ case 14:
+ strcat( subtitle->lang, " (Director's Commentary with bigger size character)" );
+ break;
+ case 15:
+ strcat( subtitle->lang, " (Director's Commentary for Children)" );
+ default:
+ break;
}
- hb_log( "scan: id=0x%x, lang=%s, 3cc=%s", subtitle->id,
- subtitle->lang, subtitle->iso639_2 );
+ hb_log( "scan: id=0x%x, lang=%s, 3cc=%s ext=%i", subtitle->id,
+ subtitle->lang, subtitle->iso639_2, lang_extension );
hb_list_add( title->list_subtitle, subtitle );
}
diff --git a/libhb/stream.c b/libhb/stream.c
index 48b1e9742..eb2a42e6f 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -2004,18 +2004,40 @@ static void set_audio_description(
}
else
{
- codec_name = audio->config.in.codec == HB_ACODEC_AC3 ? "AC3" :
- audio->config.in.codec == HB_ACODEC_DCA ? "DTS" :
- audio->config.in.codec == HB_ACODEC_DCA_HD ? "DTS-HD" :
- audio->config.in.codec == HB_ACODEC_LPCM ? "LPCM" :
- (audio->config.in.codec & HB_ACODEC_FF_MASK) ? "FFmpeg" :
- "Unknown";
+ switch( audio->config.in.codec )
+ {
+ case HB_ACODEC_AC3:
+ codec_name = "AC3";
+ break;
+ case HB_ACODEC_DCA:
+ codec_name = "DTS";
+ break;
+ case HB_ACODEC_LPCM:
+ codec_name = "LPCM";
+ break;
+ case HB_ACODEC_MP3:
+ codec_name = "MP3";
+ break;
+ case HB_ACODEC_FFAAC:
+ codec_name = "AAC";
+ break;
+ case HB_ACODEC_DCA_HD:
+ codec_name = "DTS-HD";
+ break;
+ default:
+ codec_name = ( audio->config.in.codec & HB_ACODEC_FF_MASK ) ? "Unknown FFmpeg" : "Unknown";
+ break;
+ }
}
+ snprintf( audio->config.lang.simple,
+ sizeof( audio->config.lang.simple ), "%s",
+ strlen( lang->native_name ) ? lang->native_name : lang->eng_name );
+ snprintf( audio->config.lang.iso639_2,
+ sizeof( audio->config.lang.iso639_2 ), "%s", lang->iso639_2 );
snprintf( audio->config.lang.description,
sizeof( audio->config.lang.description ), "%s (%s)",
- strlen(lang->native_name) ? lang->native_name : lang->eng_name,
- codec_name );
+ audio->config.lang.simple, codec_name );
if ( audio->config.in.channel_layout )
{
@@ -2027,11 +2049,6 @@ static void set_audio_description(
HB_INPUT_CH_LAYOUT_GET_DISCRETE_REAR_COUNT(layout),
HB_INPUT_CH_LAYOUT_GET_DISCRETE_LFE_COUNT(layout) );
}
-
- snprintf( audio->config.lang.simple, sizeof( audio->config.lang.simple ), "%s",
- strlen(lang->native_name) ? lang->native_name : lang->eng_name );
- snprintf( audio->config.lang.iso639_2, sizeof( audio->config.lang.iso639_2 ),
- "%s", lang->iso639_2);
}
// Sort specifies the index in the audio list where you would
@@ -5157,8 +5174,7 @@ static void add_ffmpeg_audio( hb_title_t *title, hb_stream_t *stream, int id )
}
tag = av_dict_get( st->metadata, "language", NULL, 0 );
- set_audio_description( stream, audio,
- lang_for_code2( tag ? tag->value : "und" ) );
+ set_audio_description( stream, audio, lang_for_code2( tag ? tag->value : "und" ) );
audio->config.in.track = id;
hb_list_add( title->list_audio, audio );