summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
Diffstat (limited to 'libhb')
-rw-r--r--libhb/common.c28
-rw-r--r--libhb/common.h68
-rw-r--r--libhb/deca52.c34
-rw-r--r--libhb/decavcodec.c2
-rw-r--r--libhb/decdca.c12
-rw-r--r--libhb/encavcodecaudio.c2
-rw-r--r--libhb/encfaac.c2
-rw-r--r--libhb/enclame.c2
-rw-r--r--libhb/encvorbis.c2
-rw-r--r--libhb/muxmkv.c17
-rw-r--r--libhb/muxmp4.c6
-rw-r--r--libhb/platform/macosx/encca_aac.c2
-rw-r--r--libhb/sync.c24
13 files changed, 107 insertions, 94 deletions
diff --git a/libhb/common.c b/libhb/common.c
index 0bc48a842..0c3616890 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -96,6 +96,21 @@ int hb_get_video_encoders_count() { return hb_video_encoders_count; }
hb_encoder_t* hb_get_audio_encoders() { return hb_audio_encoders; }
int hb_get_audio_encoders_count() { return hb_audio_encoders_count; }
+int hb_mixdown_get_discrete_channel_count( int amixdown )
+{
+ switch( amixdown )
+ {
+ case HB_AMIXDOWN_6CH:
+ return 6;
+
+ case HB_AMIXDOWN_MONO:
+ return 1;
+
+ default:
+ return 2;
+ }
+}
+
int hb_mixdown_get_mixdown_from_short_name( const char * short_name )
{
int i;
@@ -330,14 +345,13 @@ void hb_get_audio_bitrate_limits(uint32_t codec, int samplerate, int mixdown, in
{
int channels;
- channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(mixdown);
+ channels = hb_mixdown_get_discrete_channel_count( mixdown );
if( codec & HB_ACODEC_PASS_FLAG )
{
- // Bitrates don't apply to "lossless" audio (Passthru, FLAC)
- // ... but may be applied if we fallback to an encoder
- // when the source can not be passed.
- *high = 768;
- *low = 32;
+ // Bitrates don't apply to "lossless" audio (Passthru, FLAC), but may apply
+ // if we fallback to an encoder when the source can't be passed through.
+ *low = hb_audio_bitrates[0].rate;
+ *high = hb_audio_bitrates[hb_audio_bitrates_count-1].rate;
return;
}
switch( codec )
@@ -518,7 +532,7 @@ int hb_get_default_audio_bitrate( uint32_t codec, int samplerate, int mixdown )
if( codec & HB_ACODEC_PASS_FLAG )
return -1;
- channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(mixdown);
+ channels = hb_mixdown_get_discrete_channel_count( mixdown );
// Min bitrate is established such that we get good quality
// audio as a minimum.
diff --git a/libhb/common.h b/libhb/common.h
index ac486b4a5..deb60da86 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -193,8 +193,10 @@ int hb_get_video_encoders_count();
hb_encoder_t* hb_get_audio_encoders();
int hb_get_audio_encoders_count();
+int hb_mixdown_get_discrete_channel_count( int amixdown );
int hb_mixdown_get_mixdown_from_short_name( const char * short_name );
const char * hb_mixdown_get_short_name_from_mixdown( int amixdown );
+
void hb_autopassthru_apply_settings( hb_job_t * job, hb_title_t * title );
void hb_autopassthru_print_settings( hb_job_t * job );
int hb_autopassthru_get_encoder( int in_codec, int copy_mask, int fallback, int muxer );
@@ -418,40 +420,8 @@ struct hb_job_s
#define HB_SUBSTREAM_BD_DTSHD 0x72
#define HB_SUBSTREAM_BD_DTS 0x71
-/* Audio Mixdown */
-/* define some masks, used to extract the various information from the HB_AMIXDOWN_XXXX values */
-#define HB_AMIXDOWN_DCA_FORMAT_MASK 0x00FFF000
-#define HB_AMIXDOWN_A52_FORMAT_MASK 0x00000FF0
-#define HB_AMIXDOWN_DISCRETE_CHANNEL_COUNT_MASK 0x0000000F
-/* define the HB_AMIXDOWN_XXXX values */
-#define HB_AMIXDOWN_NONE 0x00000000
-#define HB_AMIXDOWN_MONO 0x01000011
-// DCA_FORMAT of DCA_MONO = 0 = 0x000
-// A52_FORMAT of A52_MONO = 1 = 0x01
-// discrete channel count of 1
-#define HB_AMIXDOWN_STEREO 0x02002022
-// DCA_FORMAT of DCA_STEREO = 2 = 0x002
-// A52_FORMAT of A52_STEREO = 2 = 0x02
-// discrete channel count of 2
-#define HB_AMIXDOWN_DOLBY 0x040000A2
-// DCA_FORMAT handled directly in decdca.c
-// A52_FORMAT of A52_DOLBY = 10 = 0x0A
-// discrete channel count of 2
-#define HB_AMIXDOWN_DOLBYPLII 0x080004A2
-// DCA_FORMAT handled directly in decdca.c
-// A52_FORMAT of A52_DOLBY | A52_USE_DPLII = 74 = 0x4A
-// discrete channel count of 2
-#define HB_AMIXDOWN_6CH 0x10089176
-// DCA_FORMAT of DCA_3F2R | DCA_LFE = 137 = 0x089
-// A52_FORMAT of A52_3F2R | A52_LFE = 23 = 0x17
-// discrete channel count of 6
-/* define some macros to extract the various information from the HB_AMIXDOWN_XXXX values */
-#define HB_AMIXDOWN_GET_DCA_FORMAT( a ) ( ( a & HB_AMIXDOWN_DCA_FORMAT_MASK ) >> 12 )
-#define HB_AMIXDOWN_GET_A52_FORMAT( a ) ( ( a & HB_AMIXDOWN_A52_FORMAT_MASK ) >> 4 )
-#define HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT( a ) ( ( a & HB_AMIXDOWN_DISCRETE_CHANNEL_COUNT_MASK ) )
-
/* Input Channel Layout */
-/* define some masks, used to extract the various information from the HB_AMIXDOWN_XXXX values */
+/* define some masks, used to extract the various information from the HB_INPUT_CH_LAYOUT_* values */
#define HB_INPUT_CH_LAYOUT_DISCRETE_FRONT_MASK 0x00F0000
#define HB_INPUT_CH_LAYOUT_DISCRETE_REAR_MASK 0x000F000
#define HB_INPUT_CH_LAYOUT_DISCRETE_LFE_MASK 0x0000F00
@@ -470,7 +440,7 @@ struct hb_job_s
#define HB_INPUT_CH_LAYOUT_4F2R 0x0942042
#define HB_INPUT_CH_LAYOUT_3F4R 0x0a34034
#define HB_INPUT_CH_LAYOUT_HAS_LFE 0x0000100
-/* define some macros to extract the various information from the HB_AMIXDOWN_XXXX values */
+/* define some macros to extract the various information from the HB_INPUT_CH_LAYOUT_* values */
#define HB_INPUT_CH_LAYOUT_GET_DISCRETE_FRONT_COUNT( a ) ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_FRONT_MASK ) >> 16 )
#define HB_INPUT_CH_LAYOUT_GET_DISCRETE_REAR_COUNT( a ) ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_REAR_MASK ) >> 12 )
#define HB_INPUT_CH_LAYOUT_GET_DISCRETE_LFE_COUNT( a ) ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_LFE_MASK ) >> 8 )
@@ -486,17 +456,25 @@ struct hb_audio_config_s
/* Output */
struct
{
- int track; /* Output track number */
- uint32_t codec; /* Output audio codec */
- int samplerate; /* Output sample rate (Hz) */
- int samples_per_frame; /* Number of samples per frame */
- int bitrate; /* Output bitrate (Kbps) */
- float quality; /* Output quality (encoder-specific) */
- float compression_level; /* Output compression level (encoder-specific) */
- int mixdown; /* The mixdown used for this audio track (see HB_AMIXDOWN_*) */
- double dynamic_range_compression; /* Amount of DRC applied to this track */
- double gain; /* Gain (in dB), negative is quieter */
- char * name; /* Output track name */
+ enum
+ {
+ HB_AMIXDOWN_NONE = 0,
+ HB_AMIXDOWN_MONO,
+ HB_AMIXDOWN_STEREO,
+ HB_AMIXDOWN_DOLBY,
+ HB_AMIXDOWN_DOLBYPLII,
+ HB_AMIXDOWN_6CH,
+ } mixdown; /* Audio mixdown */
+ int track; /* Output track number */
+ uint32_t codec; /* Output audio codec */
+ int samplerate; /* Output sample rate (Hz) */
+ int samples_per_frame; /* Number of samples per frame */
+ int bitrate; /* Output bitrate (Kbps) */
+ float quality; /* Output quality (encoder-specific) */
+ float compression_level; /* Output compression level (encoder-specific) */
+ double dynamic_range_compression; /* Amount of DRC applied to this track */
+ double gain; /* Gain (in dB), negative is quieter */
+ char * name; /* Output track name */
} out;
/* Input */
diff --git a/libhb/deca52.c b/libhb/deca52.c
index f0befdd01..049281fb5 100644
--- a/libhb/deca52.c
+++ b/libhb/deca52.c
@@ -97,18 +97,36 @@ static int deca52Init( hb_work_object_t * w, hb_job_t * job )
pv->crc_table = av_crc_get_table( AV_CRC_16_ANSI );
pv->list = hb_list_init();
pv->state = a52_init( 0 );
+ pv->level = 1.0;
+ pv->dynamic_range_compression = audio->config.out.dynamic_range_compression;
- /* Decide what format we want out of a52dec
- work.c has already done some of this deduction for us in do_job() */
+ /* Decide what format we want out of a52dec;
+ * work.c has already done some of this deduction for us in do_job(). */
+ switch( audio->config.out.mixdown )
+ {
+ case HB_AMIXDOWN_6CH:
+ pv->flags_out = ( A52_3F2R | A52_LFE );
+ break;
- pv->flags_out = HB_AMIXDOWN_GET_A52_FORMAT(audio->config.out.mixdown);
+ case HB_AMIXDOWN_DOLBYPLII:
+ pv->flags_out = ( A52_DOLBY | A52_USE_DPLII );
+ break;
- /* pass the number of channels used into the private work data */
- /* will only be actually used if we're not doing AC3 passthru */
- pv->out_discrete_channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->config.out.mixdown);
+ case HB_AMIXDOWN_DOLBY:
+ pv->flags_out = A52_DOLBY;
+ break;
- pv->level = 1.0;
- pv->dynamic_range_compression = audio->config.out.dynamic_range_compression;
+ case HB_AMIXDOWN_MONO:
+ pv->flags_out = A52_MONO;
+ break;
+
+ default:
+ pv->flags_out = A52_STEREO;
+ break;
+ }
+
+ /* pass the number of channels used into the private work data */
+ pv->out_discrete_channels = hb_mixdown_get_discrete_channel_count( audio->config.out.mixdown );
return 0;
}
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index fca6c2f45..3efdd276d 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -1459,7 +1459,7 @@ static hb_buffer_t * downmixAudio(
if ( pv->downmix )
{
int n_ch_samples = nsamples / channels;
- int out_channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->config.out.mixdown);
+ int out_channels = hb_mixdown_get_discrete_channel_count( audio->config.out.mixdown );
buf = hb_buffer_init( n_ch_samples * out_channels * sizeof(float) );
hb_sample_t *samples = (hb_sample_t *)buf->data;
diff --git a/libhb/decdca.c b/libhb/decdca.c
index a459dcd23..70ac1aa35 100644
--- a/libhb/decdca.c
+++ b/libhb/decdca.c
@@ -84,6 +84,10 @@ static int decdcaInit( hb_work_object_t * w, hb_job_t * job )
int layout = ( audio->config.in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK );
switch( audio->config.out.mixdown )
{
+ case HB_AMIXDOWN_6CH:
+ pv->flags_out = ( DCA_3F2R | DCA_LFE );
+ break;
+
case HB_AMIXDOWN_DOLBYPLII:
{
if( layout == HB_INPUT_CH_LAYOUT_3F2R )
@@ -129,13 +133,17 @@ static int decdcaInit( hb_work_object_t * w, hb_job_t * job )
}
} break;
+ case HB_AMIXDOWN_MONO:
+ pv->flags_out = DCA_MONO;
+ break;
+
default:
- pv->flags_out = HB_AMIXDOWN_GET_DCA_FORMAT( audio->config.out.mixdown );
+ pv->flags_out = DCA_STEREO;
break;
}
/* pass the number of channels used into the private work data */
- pv->out_discrete_channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT( audio->config.out.mixdown );
+ pv->out_discrete_channels = hb_mixdown_get_discrete_channel_count( audio->config.out.mixdown );
return 0;
}
diff --git a/libhb/encavcodecaudio.c b/libhb/encavcodecaudio.c
index fc692e4be..d7c7b96e8 100644
--- a/libhb/encavcodecaudio.c
+++ b/libhb/encavcodecaudio.c
@@ -47,7 +47,7 @@ static int encavcodecaInit( hb_work_object_t * w, hb_job_t * job )
pv->job = job;
- pv->out_discrete_channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->config.out.mixdown);
+ pv->out_discrete_channels = hb_mixdown_get_discrete_channel_count( audio->config.out.mixdown );
codec = avcodec_find_encoder( w->codec_param );
if( !codec )
diff --git a/libhb/encfaac.c b/libhb/encfaac.c
index 38b44f08d..a4f724a84 100644
--- a/libhb/encfaac.c
+++ b/libhb/encfaac.c
@@ -69,7 +69,7 @@ int encfaacInit( hb_work_object_t * w, hb_job_t * job )
pv->job = job;
/* pass the number of channels used into the private work data */
- pv->out_discrete_channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->config.out.mixdown);
+ pv->out_discrete_channels = hb_mixdown_get_discrete_channel_count( audio->config.out.mixdown );
/* if the sample rate is 'auto' and that has given us an invalid output */
/* rate, map it to the next highest output rate or 48K if above the highest. */
diff --git a/libhb/enclame.c b/libhb/enclame.c
index 04e6ae6d8..9cf7231a1 100644
--- a/libhb/enclame.c
+++ b/libhb/enclame.c
@@ -69,7 +69,7 @@ int enclameInit( hb_work_object_t * w, hb_job_t * job )
lame_set_in_samplerate( pv->lame, audio->config.out.samplerate );
lame_set_out_samplerate( pv->lame, audio->config.out.samplerate );
- pv->out_discrete_channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->config.out.mixdown);
+ pv->out_discrete_channels = hb_mixdown_get_discrete_channel_count( audio->config.out.mixdown );
// Lame's default encoding mode is JOINT_STEREO. This subtracts signal
// that is "common" to left and right (within some threshold) and encodes
// it separately. This improves quality at low bitrates, but hurts
diff --git a/libhb/encvorbis.c b/libhb/encvorbis.c
index d48373e09..66351ee71 100644
--- a/libhb/encvorbis.c
+++ b/libhb/encvorbis.c
@@ -50,7 +50,7 @@ int encvorbisInit( hb_work_object_t * w, hb_job_t * job )
hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) );
w->private_data = pv;
- pv->out_discrete_channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->config.out.mixdown);
+ pv->out_discrete_channels = hb_mixdown_get_discrete_channel_count( audio->config.out.mixdown );
pv->job = job;
diff --git a/libhb/muxmkv.c b/libhb/muxmkv.c
index 7e6884d8a..3551269cd 100644
--- a/libhb/muxmkv.c
+++ b/libhb/muxmkv.c
@@ -204,7 +204,7 @@ static int MKVInit( hb_mux_object_t * m )
mux_data->codec = audio->config.out.codec;
- switch (audio->config.out.codec & HB_ACODEC_MASK)
+ switch( audio->config.out.codec & HB_ACODEC_MASK )
{
case HB_ACODEC_DCA:
case HB_ACODEC_DCA_HD:
@@ -269,7 +269,7 @@ static int MKVInit( hb_mux_object_t * m )
return 0;
}
- if (default_track_flag)
+ if( default_track_flag )
{
track->flagDefault = 1;
default_track_flag = 0;
@@ -284,19 +284,18 @@ static int MKVInit( hb_mux_object_t * m )
lang = lang_for_code2( audio->config.lang.iso639_2 );
track->language = lang->iso639_2b ? lang->iso639_2b : lang->iso639_2;
track->extra.audio.samplingFreq = (float)audio->config.out.samplerate;
- if (audio->config.out.codec & HB_ACODEC_PASS_FLAG)
+ if( audio->config.out.codec & HB_ACODEC_PASS_FLAG )
{
- track->extra.audio.channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT(audio->config.in.channel_layout);
+ track->extra.audio.channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT( audio->config.in.channel_layout );
}
else
{
- track->extra.audio.channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->config.out.mixdown);
+ track->extra.audio.channels = hb_mixdown_get_discrete_channel_count( audio->config.out.mixdown );
}
-// track->defaultDuration = job->arate * 1000;
mux_data->track = mk_createTrack(m->file, track);
- if ( audio->config.out.codec == HB_ACODEC_VORBIS ||
- audio->config.out.codec == HB_ACODEC_FFFLAC )
- free(track->codecPrivate);
+ if( audio->config.out.codec == HB_ACODEC_VORBIS ||
+ audio->config.out.codec == HB_ACODEC_FFFLAC )
+ free( track->codecPrivate );
}
char * subidx_fmt =
diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c
index df55db7fd..4c956ad21 100644
--- a/libhb/muxmp4.c
+++ b/libhb/muxmp4.c
@@ -414,15 +414,13 @@ static int MP4Init( hb_mux_object_t * m )
{
samplerate = audio->config.in.samplerate;
samples_per_frame = audio->config.in.samples_per_frame;
- channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT(
- audio->config.in.channel_layout );
+ channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT( audio->config.in.channel_layout );
}
else
{
samplerate = audio->config.out.samplerate;
samples_per_frame = audio->config.out.samples_per_frame;
- channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(
- audio->config.out.mixdown );
+ channels = hb_mixdown_get_discrete_channel_count( audio->config.out.mixdown );
}
mux_data->track = MP4AddAudioTrack( m->file, samplerate,
samples_per_frame, audio_type );
diff --git a/libhb/platform/macosx/encca_aac.c b/libhb/platform/macosx/encca_aac.c
index d6d0af0c9..621c40c71 100644
--- a/libhb/platform/macosx/encca_aac.c
+++ b/libhb/platform/macosx/encca_aac.c
@@ -140,7 +140,7 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job, enum AAC_MODE mode )
pv->job = job;
// pass the number of channels used into the private work data
- pv->nchannels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT( audio->config.out.mixdown );
+ pv->nchannels = hb_mixdown_get_discrete_channel_count( audio->config.out.mixdown );
bzero( &input, sizeof( AudioStreamBasicDescription ) );
input.mSampleRate = ( Float64 ) audio->config.out.samplerate;
diff --git a/libhb/sync.c b/libhb/sync.c
index 1a10e5e5e..a53936e6c 100644
--- a/libhb/sync.c
+++ b/libhb/sync.c
@@ -1032,11 +1032,11 @@ static void InitAudio( hb_job_t * job, hb_sync_common_t * common, int i )
}
else
{
- /* Not passthru, Initialize libsamplerate */
+ /* Not passthru, initialize libsamplerate */
int error;
- sync->state = src_new( SRC_SINC_MEDIUM_QUALITY,
- HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(
- w->audio->config.out.mixdown), &error );
+ sync->state = src_new( SRC_SINC_MEDIUM_QUALITY,
+ hb_mixdown_get_discrete_channel_count( w->audio->config.out.mixdown ),
+ &error );
sync->data.end_of_input = 0;
}
}
@@ -1069,10 +1069,10 @@ static hb_buffer_t * OutputAudioFrame( hb_audio_t *audio, hb_buffer_t *buf,
/* do sample rate conversion */
int count_in, count_out;
hb_buffer_t * buf_raw = buf;
- int channel_count = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->config.out.mixdown) *
- sizeof( float );
+ int sample_size = hb_mixdown_get_discrete_channel_count( audio->config.out.mixdown ) *
+ sizeof( float );
- count_in = buf_raw->size / channel_count;
+ count_in = buf_raw->size / sample_size;
/*
* When using stupid rates like 44.1 there will always be some
* truncation error. E.g., a 1536 sample AC3 frame will turn into a
@@ -1089,7 +1089,7 @@ static hb_buffer_t * OutputAudioFrame( hb_audio_t *audio, hb_buffer_t *buf,
sync->data.src_ratio = (double)audio->config.out.samplerate /
(double)audio->config.in.samplerate;
- buf = hb_buffer_init( count_out * channel_count );
+ buf = hb_buffer_init( count_out * sample_size );
sync->data.data_in = (float *) buf_raw->data;
sync->data.data_out = (float *) buf->data;
if( src_process( sync->state, &sync->data ) )
@@ -1099,7 +1099,7 @@ static hb_buffer_t * OutputAudioFrame( hb_audio_t *audio, hb_buffer_t *buf,
}
hb_buffer_close( &buf_raw );
- buf->size = sync->data.output_frames_gen * channel_count;
+ buf->size = sync->data.output_frames_gen * sample_size;
duration = (double)( sync->data.output_frames_gen * 90000 ) /
audio->config.out.samplerate;
}
@@ -1182,10 +1182,8 @@ static void InsertSilence( hb_work_object_t * w, int64_t duration )
}
else
{
- buf = hb_buffer_init( w->audio->config.out.samples_per_frame *
- sizeof( float ) *
- HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(
- w->audio->config.out.mixdown) );
+ buf = hb_buffer_init( sizeof( float ) * w->audio->config.out.samples_per_frame *
+ hb_mixdown_get_discrete_channel_count( w->audio->config.out.mixdown ) );
buf->s.start = sync->next_start;
buf->s.stop = buf->s.start + frame_dur;
memset( buf->data, 0, buf->size );