summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorRodeo <[email protected]>2014-01-25 23:28:31 +0000
committerRodeo <[email protected]>2014-01-25 23:28:31 +0000
commit08d8e59afb83ce9430194364c547d640a8678256 (patch)
treeb46d21324388e679a116ad316863850033ed98fb /libhb
parentd7ad9c9682d83dc8f59bd6ff86d3ec422c1f6adb (diff)
libhb: set audio description in LookForAudio (scan.c).
All audio tracks go through it since SVN revision 5424. This is where we have the most information about each audio track. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5996 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/bd.c7
-rw-r--r--libhb/dvd.c24
-rw-r--r--libhb/dvdnav.c24
-rw-r--r--libhb/scan.c111
-rw-r--r--libhb/stream.c177
5 files changed, 122 insertions, 221 deletions
diff --git a/libhb/bd.c b/libhb/bd.c
index 356e14bee..3f2a0df1c 100644
--- a/libhb/bd.c
+++ b/libhb/bd.c
@@ -194,12 +194,9 @@ static void add_audio(int track, hb_list_t *list_audio, BLURAY_STREAM_INFO *bdau
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 );
- hb_log( "bd: audio id=0x%x, lang=%s, 3cc=%s", audio->id,
- audio->config.lang.description, audio->config.lang.iso639_2 );
+ hb_log("bd: audio id=0x%x, lang=%s (%s), 3cc=%s", audio->id,
+ audio->config.lang.simple, codec_name, audio->config.lang.iso639_2);
audio->config.in.track = track;
hb_list_add( list_audio, audio );
diff --git a/libhb/dvd.c b/libhb/dvd.c
index 240582a52..68c277cc3 100644
--- a/libhb/dvd.c
+++ b/libhb/dvd.c
@@ -424,28 +424,10 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur
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 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,
- audio->config.lang.description, audio->config.lang.iso639_2,
- lang_extension );
+ hb_log("scan: id=0x%x, lang=%s (%s), 3cc=%s ext=%i", audio->id,
+ audio->config.lang.simple, codec_name,
+ audio->config.lang.iso639_2, lang_extension);
audio->config.in.track = i;
hb_list_add( title->list_audio, audio );
diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c
index fa6ee2f24..fbb497a69 100644
--- a/libhb/dvdnav.c
+++ b/libhb/dvdnav.c
@@ -592,28 +592,10 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura
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 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,
- audio->config.lang.description, audio->config.lang.iso639_2,
- lang_extension );
+ hb_log("scan: id=0x%x, lang=%s, 3cc=%s ext=%i", audio->id,
+ audio->config.lang.simple, codec_name,
+ audio->config.lang.iso639_2, lang_extension);
audio->config.in.track = i;
hb_list_add( title->list_audio, audio );
diff --git a/libhb/scan.c b/libhb/scan.c
index 833589f6c..6dc5f6fc6 100644
--- a/libhb/scan.c
+++ b/libhb/scan.c
@@ -1035,7 +1035,116 @@ static void LookForAudio( hb_title_t * title, hb_buffer_t * b )
audio->config.in.flags = info.flags;
audio->config.in.mode = info.mode;
- // update the audio description string based on the info we found
+ // now that we have all the info, set the audio description
+ const char *codec_name = NULL;
+ if (audio->config.in.codec & HB_ACODEC_FF_MASK)
+ {
+ AVCodec *codec = avcodec_find_decoder(audio->config.in.codec_param);
+ if (codec != NULL)
+ {
+ if (info.profile != FF_PROFILE_UNKNOWN)
+ {
+ codec_name = av_get_profile_name(codec, info.profile);
+ }
+ if (codec_name == NULL)
+ {
+ // use our own capitalization for the most common codecs
+ switch (audio->config.in.codec_param)
+ {
+ case AV_CODEC_ID_AAC:
+ codec_name = "AAC";
+ break;
+ case AV_CODEC_ID_AC3:
+ codec_name = "AC3";
+ break;
+ case AV_CODEC_ID_EAC3:
+ codec_name = "E-AC3";
+ break;
+ case AV_CODEC_ID_TRUEHD:
+ codec_name = "TrueHD";
+ break;
+ case AV_CODEC_ID_DTS:
+ codec_name = audio->config.in.codec == HB_ACODEC_DCA_HD ? "DTS-HD" : "DTS";
+ break;
+ case AV_CODEC_ID_FLAC:
+ codec_name = "FLAC";
+ break;
+ case AV_CODEC_ID_MP2:
+ codec_name = "MPEG";
+ break;
+ case AV_CODEC_ID_MP3:
+ codec_name = "MP3";
+ break;
+ case AV_CODEC_ID_PCM_BLURAY:
+ codec_name = "BD LPCM";
+ break;
+ case AV_CODEC_ID_OPUS:
+ codec_name = "Opus";
+ break;
+ case AV_CODEC_ID_VORBIS:
+ codec_name = "Vorbis";
+ break;
+ default:
+ codec_name = codec->name;
+ break;
+ }
+ }
+ }
+ else
+ {
+ switch (audio->config.in.codec)
+ {
+ case HB_ACODEC_DCA:
+ codec_name = "DTS";
+ break;
+ case HB_ACODEC_DCA_HD:
+ codec_name = "DTS-HD";
+ break;
+ case HB_ACODEC_FFAAC:
+ codec_name = "AAC";
+ break;
+ case HB_ACODEC_MP3:
+ codec_name = "MP3";
+ break;
+ default:
+ codec_name = "Unknown (libav)";
+ break;
+ }
+ }
+ }
+ else
+ {
+ switch (audio->config.in.codec)
+ {
+ case HB_ACODEC_AC3:
+ codec_name = "AC3";
+ break;
+ case HB_ACODEC_LPCM:
+ codec_name = "LPCM";
+ break;
+ default:
+ codec_name = "Unknown";
+ break;
+ }
+ }
+ sprintf(audio->config.lang.description, "%s (%s)",
+ audio->config.lang.simple, codec_name);
+
+ switch (audio->config.lang.type)
+ {
+ 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;
+ }
+
if (audio->config.in.channel_layout == AV_CH_LAYOUT_STEREO_DOWNMIX)
{
strcat(audio->config.lang.description, " (Dolby Surround)");
diff --git a/libhb/stream.c b/libhb/stream.c
index eb5350e43..2c1757005 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -1902,183 +1902,14 @@ static const char *stream_type_name2(hb_stream_t *stream, hb_pes_stream_t *pes)
return "Unknown";
}
-static const char *stream_type_name (uint32_t reg_desc, uint8_t stream_type)
+static void set_audio_description(hb_audio_t *audio, iso639_lang_t *lang)
{
- if ( reg_desc == STR4_TO_UINT32("HDMV") )
- {
- // Names for streams we know about.
- switch ( stream_type )
- {
- case 0x80:
- return "BD LPCM";
-
- case 0x83:
- return "TrueHD";
-
- case 0x84:
- return "E-AC3";
-
- case 0x85:
- return "DTS-HD HRA";
-
- case 0x86:
- return "DTS-HD MA";
-
- default:
- break;
- }
- }
- return st2codec[stream_type].name ? st2codec[stream_type].name : "Unknown";
-}
-
-static void set_audio_description(
- hb_stream_t * stream,
- hb_audio_t *audio,
- iso639_lang_t *lang)
-{
- int idx;
- const char *codec_name;
- char codec_name_caps[80];
- AVCodecContext *cc = NULL;
-
- if ( stream && stream->ffmpeg_ic )
- {
- cc = stream->ffmpeg_ic->streams[audio->id]->codec;
- }
-
- // Names for streams we know about.
- if ( audio->config.in.stream_type == 0x80 &&
- audio->config.in.reg_desc == STR4_TO_UINT32("HDMV") )
- {
- // LPCM audio in bluray have an stype of 0x80
- codec_name = "BD LPCM";
- }
- else if ( audio->config.in.stream_type == 0x83 &&
- audio->config.in.reg_desc == STR4_TO_UINT32("HDMV") )
- {
- // This is an interleaved TrueHD/AC-3 stream and the esid of
- // the AC-3 is 0x76
- if (audio->config.in.substream_type == HB_SUBSTREAM_BD_AC3)
- codec_name = "AC3";
- else
- codec_name = "TrueHD";
- }
- else if ( audio->config.in.stream_type == 0x86 &&
- audio->config.in.reg_desc == STR4_TO_UINT32("HDMV") )
- {
- // This is an interleaved DTS-HD MA/DTS stream and the
- // esid of the DTS is 0x71
- if (audio->config.in.substream_type == HB_SUBSTREAM_BD_DTS)
- codec_name = "DTS";
- else
- codec_name = "DTS-HD MA";
- }
- else if ( audio->config.in.stream_type == 0x85 &&
- audio->config.in.reg_desc == STR4_TO_UINT32("HDMV") )
- {
- // DTS-HD HRA audio in bluray has an stype of 0x85
- // which conflicts with ATSC Program ID
- // To distinguish, Bluray streams have a reg_desc of HDMV
- // This is an interleaved DTS-HD HRA/DTS stream and the
- // esid of the DTS is 0x71
- if (audio->config.in.substream_type == HB_SUBSTREAM_BD_DTS)
- codec_name = "DTS";
- else
- codec_name = "DTS-HD HRA";
- }
- else if ( audio->config.in.stream_type == 0x84 &&
- audio->config.in.reg_desc == STR4_TO_UINT32("HDMV") )
- {
- // EAC3 audio in bluray has an stype of 0x84
- // which conflicts with SDDS
- // To distinguish, Bluray streams have a reg_desc of HDMV
- codec_name = "E-AC3";
- }
- // For streams demuxed and decoded by ffmpeg, we have a cached context.
- // Use it to get the name and profile information. Obtaining
- // the profile requires that ffmpeg has already probed the stream.
- else if ( ( audio->config.in.codec & HB_ACODEC_FF_MASK ) && cc &&
- avcodec_find_decoder( cc->codec_id ) )
- {
- AVCodec *codec = avcodec_find_decoder( cc->codec_id );
- codec_name = codec->name;
-
- const char *profile_name;
- profile_name = av_get_profile_name( codec, cc->profile );
- if ( profile_name )
- {
- codec_name = profile_name;
- }
- }
- else if ( stream->hb_stream_type != ffmpeg &&
- (idx = index_of_id( stream, audio->id ) ) >= 0 )
- {
- codec_name = stream_type_name2( stream, &stream->pes.list[idx] );
- }
- else if ( st2codec[audio->config.in.stream_type].kind == A )
- {
- codec_name = stream_type_name(audio->config.in.reg_desc,
- audio->config.in.stream_type);
- }
- // For streams demuxed by us and decoded by ffmpeg, we can lookup the
- // decoder name.
- else if ( ( audio->config.in.codec & HB_ACODEC_FF_MASK ) &&
- avcodec_find_decoder( audio->config.in.codec_param ) )
- {
- codec_name = avcodec_find_decoder( audio->config.in.codec_param )->name;
- strncpyupper( codec_name_caps, codec_name, 80 );
- codec_name = codec_name_caps;
- }
- else
- {
- 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)",
- audio->config.lang.simple, codec_name );
-
- if (audio->config.in.channel_layout == AV_CH_LAYOUT_STEREO_DOWNMIX)
- {
- strcat(audio->config.lang.description, " (Dolby Surround)");
- }
- else if (audio->config.in.channel_layout)
- {
- int lfes = (!!(audio->config.in.channel_layout & AV_CH_LOW_FREQUENCY) +
- !!(audio->config.in.channel_layout & AV_CH_LOW_FREQUENCY_2));
- int channels = av_get_channel_layout_nb_channels(audio->config.in.channel_layout);
- char *desc = audio->config.lang.description +
- strlen(audio->config.lang.description);
- sprintf(desc, " (%d.%d ch)", channels - lfes, lfes);
- }
+ audio->config.lang.type = 0;
}
// Sort specifies the index in the audio list where you would
@@ -2230,7 +2061,7 @@ static void pes_add_audio_to_title(
audio->config.in.codec = pes->codec;
audio->config.in.codec_param = pes->codec_param;
- set_audio_description( stream, audio, lang_for_code( pes->lang_code ) );
+ set_audio_description(audio, lang_for_code(pes->lang_code));
hb_log("stream id 0x%x (type 0x%x substream 0x%x) audio 0x%x",
pes->stream_id, pes->stream_type, pes->stream_id_ext, audio->id);
@@ -5210,7 +5041,7 @@ static void add_ffmpeg_audio(hb_title_t *title, hb_stream_t *stream, int id)
break;
}
- set_audio_description(stream, audio,
+ set_audio_description(audio,
lang_for_code2(tag != NULL ? tag->value : "und"));
hb_list_add(title->list_audio, audio);
}