Split the enable-lfe-remixing setting into two

remixing-produce-lfe controls upmixing, and remixing-consume-lfe
controls downmixing. The motivation is that a user might want to
synthesize LFE while playing stereo audio on his/her 5.1 speakers,
but at the same time follow the industry recommendation to omit
the LFE channel when producting a stereo downmix (e.g. for headphones)
from 5.1 content. Or the other way round.

Fixes: #753.
This commit is contained in:
Alexander Patrakov 2019-12-10 06:50:59 +00:00 committed by Georg Chini
parent b94dba9daf
commit 464828faf2
12 changed files with 101 additions and 26 deletions

View file

@ -144,7 +144,8 @@ pa_core* pa_core_new(pa_mainloop_api *m, bool shared, bool enable_memfd, size_t
c->realtime_priority = 5;
c->disable_remixing = false;
c->remixing_use_all_sink_channels = true;
c->disable_lfe_remixing = true;
c->remixing_produce_lfe = false;
c->remixing_consume_lfe = false;
c->lfe_crossover_freq = 0;
c->deferred_volume = true;
c->resample_method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 1;

View file

@ -220,7 +220,8 @@ struct pa_core {
bool avoid_resampling:1;
bool disable_remixing:1;
bool remixing_use_all_sink_channels:1;
bool disable_lfe_remixing:1;
bool remixing_produce_lfe:1;
bool remixing_consume_lfe:1;
bool deferred_volume:1;
pa_resample_method_t resample_method;

View file

@ -1099,7 +1099,7 @@ static void setup_remap(const pa_resampler *r, pa_remap_t *m, bool *lfe_remixed)
* right input channel. Something is really wrong in this
* case anyway. */
} else if (on_lfe(b) && !(r->flags & PA_RESAMPLER_NO_LFE)) {
} else if (on_lfe(b) && (r->flags & PA_RESAMPLER_PRODUCE_LFE)) {
/* We are not connected and an LFE. Let's average all
* channels for LFE. */
@ -1150,7 +1150,7 @@ static void setup_remap(const pa_resampler *r, pa_remap_t *m, bool *lfe_remixed)
m->map_table_f[oc][ic] = (1.f/9.f) / (float) ic_unconnected_center;
ic_unconnected_center_mixed_in = true;
} else if (on_lfe(a) && !(r->flags & PA_RESAMPLER_NO_LFE))
} else if (on_lfe(a) && (r->flags & PA_RESAMPLER_CONSUME_LFE))
m->map_table_f[oc][ic] = .375f / (float) ic_unconnected_lfe;
}
}

View file

@ -68,8 +68,9 @@ typedef enum pa_resample_flags {
PA_RESAMPLER_VARIABLE_RATE = 0x0001U,
PA_RESAMPLER_NO_REMAP = 0x0002U, /* implies NO_REMIX */
PA_RESAMPLER_NO_REMIX = 0x0004U,
PA_RESAMPLER_NO_LFE = 0x0008U,
PA_RESAMPLER_NO_FILL_SINK = 0x0010U,
PA_RESAMPLER_PRODUCE_LFE = 0x0020U,
PA_RESAMPLER_CONSUME_LFE = 0x0040U,
} pa_resample_flags_t;
struct pa_resampler {

View file

@ -476,7 +476,8 @@ int pa_sink_input_new(
((data->flags & PA_SINK_INPUT_NO_REMAP) ? PA_RESAMPLER_NO_REMAP : 0) |
(core->disable_remixing || (data->flags & PA_SINK_INPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0) |
(core->remixing_use_all_sink_channels ? 0 : PA_RESAMPLER_NO_FILL_SINK) |
(core->disable_lfe_remixing ? PA_RESAMPLER_NO_LFE : 0)))) {
(core->remixing_produce_lfe ? PA_RESAMPLER_PRODUCE_LFE : 0) |
(core->remixing_consume_lfe ? PA_RESAMPLER_CONSUME_LFE : 0)))) {
pa_log_warn("Unsupported resampling operation.");
return -PA_ERR_NOTSUPPORTED;
}
@ -2313,7 +2314,8 @@ int pa_sink_input_update_resampler(pa_sink_input *i) {
((i->flags & PA_SINK_INPUT_NO_REMAP) ? PA_RESAMPLER_NO_REMAP : 0) |
(i->core->disable_remixing || (i->flags & PA_SINK_INPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0) |
(i->core->remixing_use_all_sink_channels ? 0 : PA_RESAMPLER_NO_FILL_SINK) |
(i->core->disable_lfe_remixing ? PA_RESAMPLER_NO_LFE : 0));
(i->core->remixing_produce_lfe ? PA_RESAMPLER_PRODUCE_LFE : 0) |
(i->core->remixing_consume_lfe ? PA_RESAMPLER_CONSUME_LFE : 0));
if (!new_resampler) {
pa_log_warn("Unsupported resampling operation.");

View file

@ -414,7 +414,8 @@ int pa_source_output_new(
((data->flags & PA_SOURCE_OUTPUT_NO_REMAP) ? PA_RESAMPLER_NO_REMAP : 0) |
(core->disable_remixing || (data->flags & PA_SOURCE_OUTPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0) |
(core->remixing_use_all_sink_channels ? 0 : PA_RESAMPLER_NO_FILL_SINK) |
(core->disable_lfe_remixing ? PA_RESAMPLER_NO_LFE : 0)))) {
(core->remixing_produce_lfe ? PA_RESAMPLER_PRODUCE_LFE : 0) |
(core->remixing_consume_lfe ? PA_RESAMPLER_CONSUME_LFE : 0)))) {
pa_log_warn("Unsupported resampling operation.");
return -PA_ERR_NOTSUPPORTED;
}
@ -1755,7 +1756,8 @@ int pa_source_output_update_resampler(pa_source_output *o) {
((o->flags & PA_SOURCE_OUTPUT_NO_REMAP) ? PA_RESAMPLER_NO_REMAP : 0) |
(o->core->disable_remixing || (o->flags & PA_SOURCE_OUTPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0) |
(o->core->remixing_use_all_sink_channels ? 0 : PA_RESAMPLER_NO_FILL_SINK) |
(o->core->disable_lfe_remixing ? PA_RESAMPLER_NO_LFE : 0));
(o->core->remixing_produce_lfe ? PA_RESAMPLER_PRODUCE_LFE : 0) |
(o->core->remixing_consume_lfe ? PA_RESAMPLER_CONSUME_LFE : 0));
if (!new_resampler) {
pa_log_warn("Unsupported resampling operation.");