summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2013-10-28 23:44:52 +0000
committerjstebbins <[email protected]>2013-10-28 23:44:52 +0000
commitd4ec9513dc3cee764d5d3bc03c3b6ea95cdaaaaf (patch)
tree9791624a784645979754bef87f1dc1b255ad42d6 /libhb
parentb703e087e610549eea00bf761fd9f6b438169b44 (diff)
libhb: fix BD audio detection problem
BDs can (and occasionally do) have different audio stream types in different clips that compose a playlist. We try to pick the audios that appear in the most clips, but this breaks down when there are only 2 clips to choose from. So in the case of only 2 clips, choose audio from the longest clip. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5863 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/bd.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/libhb/bd.c b/libhb/bd.c
index df7f3d492..4251d0403 100644
--- a/libhb/bd.c
+++ b/libhb/bd.c
@@ -385,30 +385,39 @@ hb_title_t * hb_bd_title_scan( hb_bd_t * d, int tt, uint64_t min_duration )
hb_log( "bd: aspect = %g", title->container_aspect );
/* Detect audio */
- // All BD clips are not all required to have the same audio.
- // But clips that have seamless transition are required
- // to have the same audio as the previous clip.
- // So find the clip that has the most other clips with the
- // matching audio.
// Max primary BD audios is 32
int matches;
int most_audio = 0;
int audio_clip_index = 0;
- for ( ii = 0; ii < ti->clip_count; ii++ )
+ if (ti->clip_count > 2)
{
- matches = 0;
- for ( jj = 0; jj < ti->clip_count; jj++ )
+ // All BD clips are not all required to have the same audio.
+ // But clips that have seamless transition are required
+ // to have the same audio as the previous clip.
+ // So find the clip that has the most other clips with the
+ // matching audio.
+ for ( ii = 0; ii < ti->clip_count; ii++ )
{
- if ( bd_audio_equal( &ti->clips[ii], &ti->clips[jj] ) )
+ matches = 0;
+ for ( jj = 0; jj < ti->clip_count; jj++ )
{
- matches++;
+ if ( bd_audio_equal( &ti->clips[ii], &ti->clips[jj] ) )
+ {
+ matches++;
+ }
+ }
+ if ( matches > most_audio )
+ {
+ most_audio = matches;
+ audio_clip_index = ii;
}
}
- if ( matches > most_audio )
- {
- most_audio = matches;
- audio_clip_index = ii;
- }
+ }
+ else if (ti->clip_count == 2)
+ {
+ // If there are only 2 clips, pick audios from the longer clip
+ if (ti->clips[0].pkt_count < ti->clips[1].pkt_count)
+ audio_clip_index = 1;
}
// Add all the audios found in the above clip.