summaryrefslogtreecommitdiffstats
path: root/test/test.c
diff options
context:
space:
mode:
authorRodeo <[email protected]>2011-08-19 22:40:26 +0000
committerRodeo <[email protected]>2011-08-19 22:40:26 +0000
commit89b1f5e9b7fe81172664b6d406aac31dd8a68e59 (patch)
treed929d0d89b95a44fed1fa0dfb5c9266ff24e011f /test/test.c
parent6601e3b53dece956aeedbc3d6e72ed6be0a19b1e (diff)
CLI: standardize passthru fallbacks.
copy:aac -> faac copy:ac3 -> ac3 copy:mp3 -> lame copy -> --audio-fallback, else aac, ac3 or lame (if found in the audio copy mask), else dropped copy:dts and copy:dtshd are always dropped. When --audio-copy-mask contains only one codec, 'copy' behaves exactly like codec-specific passthru and --audio-fallback is ignored. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4190 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'test/test.c')
-rw-r--r--test/test.c114
1 files changed, 81 insertions, 33 deletions
diff --git a/test/test.c b/test/test.c
index 3f7c04ec3..f35d9300a 100644
--- a/test/test.c
+++ b/test/test.c
@@ -1965,54 +1965,102 @@ static int HandleEvents( hb_handle_t * h )
}
/* Audio Track Names */
- /* Fix up passthru that needs to fallback to ac3 encode */
+ /* Sanitize passthru (drop/fallback if necessary) */
for( i = 0; i < hb_list_count( job->list_audio ); )
{
audio = hb_list_audio_config_item( job->list_audio, i );
- if ( ( audio->out.codec & HB_ACODEC_AC3 ) &&
- ( audio->out.codec & HB_ACODEC_PASS_FLAG ) &&
- !( audio->out.codec & audio->in.codec ) )
- {
- // AC3 passthru not possible, use fallback
- if ( acodec_fallback )
- {
- fprintf( stderr, "AC3 passthru requested and input codec is not AC3 for track %d, using fallback\n",
- audio->out.track );
- audio->out.codec = get_acodec_for_string( acodec_fallback);
- }
- else
- {
- fprintf( stderr, "AC3 passthru requested and input codec is not AC3 for track %d, using AC3 encoder\n",
- audio->out.track );
- audio->out.codec = HB_ACODEC_AC3;
- }
- audio->out.mixdown = hb_get_default_mixdown( audio->out.codec, audio->in.channel_layout );
- audio->out.bitrate = hb_get_default_audio_bitrate( audio->out.codec, audio->out.samplerate,
- audio->out.mixdown );
- }
- // fix 'copy' to select a specific codec
- if ( audio->out.codec & HB_ACODEC_PASS_FLAG )
- {
- audio->out.codec &= (audio->in.codec | HB_ACODEC_PASS_FLAG);
- if ( !( audio->out.codec & HB_ACODEC_MASK ) )
- {
- if ( acodec_fallback )
+ // check whether we're doing passthru
+ if( audio->out.codec & HB_ACODEC_PASS_FLAG )
+ {
+ // compute the output passthru codec
+ // required to make 'copy' work
+ // doesn't break codec-specific passthru
+ int out_codec = ( audio->out.codec & ( audio->in.codec | HB_ACODEC_PASS_FLAG ) );
+ // check whether passthru is possible or not
+ if( !( out_codec & audio->in.codec ) )
+ {
+ // first, check whether we're doing a codec-specific passthru
+ // for which we have a corresponding encoder
+ // note: Auto Passthru with a single codec in the passthru
+ // mask is assimilated to codec-specific passthru
+ if( audio->out.codec == HB_ACODEC_AAC_PASS )
+ {
+ fprintf( stderr, "AAC passthru requested and input codec is not AAC for track %d, using AAC encoder\n",
+ audio->out.track );
+#ifdef __APPLE_CC__
+ audio->out.codec = HB_ACODEC_CA_AAC;
+#else
+ audio->out.codec = HB_ACODEC_FAAC;
+#endif
+ }
+ else if( audio->out.codec == HB_ACODEC_AC3_PASS )
+ {
+ fprintf( stderr, "AC3 passthru requested and input codec is not AC3 for track %d, using AC3 encoder\n",
+ audio->out.track );
+ audio->out.codec = HB_ACODEC_AC3;
+ }
+ else if( audio->out.codec == HB_ACODEC_MP3_PASS )
+ {
+ fprintf( stderr, "MP3 passthru requested and input codec is not MP3 for track %d, using MP3 encoder\n",
+ audio->out.track );
+ audio->out.codec = HB_ACODEC_LAME;
+ }
+ // we're doing either DTS, DTS-HD or Auto Passthru
+ else if( ( acodec_fallback ) &&
+ ( audio->out.codec != HB_ACODEC_DCA_PASS ) &&
+ ( audio->out.codec != HB_ACODEC_DCA_HD_PASS ) )
+ {
+ // we're doing Auto Passthru and there's a fallback
+ fprintf( stderr, "Auto passthru requested and input codec is not compatible for track %d, using fallback\n",
+ audio->out.track );
+ audio->out.codec = get_acodec_for_string( acodec_fallback );
+ }
+ // we didn't find a suitable fallback
+ // check whether we have an encoder for
+ // one of the allowed passthru codecs
+ else if( audio->out.codec & HB_ACODEC_AAC_PASS )
{
- fprintf( stderr, "Passthru requested and input codec is not compatible for track %d, using fallback\n",
- audio->out.track );
- audio->out.codec = get_acodec_for_string( acodec_fallback);
+ fprintf( stderr, "Auto passthru requested and input codec is not compatible for track %d, using AAC encoder\n",
+ audio->out.track );
+#ifdef __APPLE_CC__
+ audio->out.codec = HB_ACODEC_CA_AAC;
+#else
+ audio->out.codec = HB_ACODEC_FAAC;
+#endif
+ }
+ else if( audio->out.codec & HB_ACODEC_AC3_PASS )
+ {
+ fprintf( stderr, "Auto passthru requested and input codec is not compatible for track %d, using AC3 encoder\n",
+ audio->out.track );
+ audio->out.codec = HB_ACODEC_AC3;
+ }
+ else if( audio->out.codec & HB_ACODEC_MP3_PASS )
+ {
+ fprintf( stderr, "Auto passthru requested and input codec is not compatible for track %d, using MP3 encoder\n",
+ audio->out.track );
+ audio->out.codec = HB_ACODEC_LAME;
}
else
{
// Passthru not possible, drop audio.
fprintf( stderr, "Passthru requested and input codec is not the same as output codec for track %d, dropping track\n",
- audio->out.track );
+ audio->out.track );
hb_audio_t * item = hb_list_item( job->list_audio, i );
hb_list_rem( job->list_audio, item );
continue;
}
+ // we didn't drop the track, set the mixdown and bitrate from libhb defaults
+ audio->out.mixdown = hb_get_default_mixdown( audio->out.codec, audio->in.channel_layout );
+ audio->out.bitrate = hb_get_default_audio_bitrate( audio->out.codec, audio->out.samplerate,
+ audio->out.mixdown );
+ }
+ else
+ {
+ // passthru is possible
+ audio->out.codec = out_codec;
}
}
+ // we didn't drop the track
i++;
}