Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2012-12-16 13:06:20 +0400
committerHendrik Leppkes <h.leppkes@gmail.com>2012-12-16 13:06:20 +0400
commitc592b3244647f66484f68d3eb33747c9d5c8ed08 (patch)
tree3e6a817df8c788071e511d2f0692bc0e69a97dd2
parenta360d8863f89ac6d9e1f98cc1f700f43cca6425f (diff)
Move clipping protection into avresample.
-rw-r--r--decoder/LAVAudio/PostProcessor.cpp24
m---------ffmpeg0
2 files changed, 2 insertions, 22 deletions
diff --git a/decoder/LAVAudio/PostProcessor.cpp b/decoder/LAVAudio/PostProcessor.cpp
index d7807a16..eb34fe26 100644
--- a/decoder/LAVAudio/PostProcessor.cpp
+++ b/decoder/LAVAudio/PostProcessor.cpp
@@ -581,9 +581,6 @@ HRESULT CLAVAudio::PerformMixing(BufferDetails *buffer)
m_sfRemixFormat = SampleFormat_32;
BOOL bNormalize = !!(m_settings.MixingFlags & LAV_MIXING_FLAG_NORMALIZE_MATRIX);
- // Force FP32 output from remixing when not performing normalization
- if (!bNormalize)
- m_sfRemixFormat = SampleFormat_FP32;
m_avrContext = avresample_alloc_context();
av_opt_set_int(m_avrContext, "in_channel_layout", buffer->dwChannelMask, 0);
@@ -592,6 +589,8 @@ HRESULT CLAVAudio::PerformMixing(BufferDetails *buffer)
av_opt_set_int(m_avrContext, "out_channel_layout", dwMixingLayout, 0);
av_opt_set_int(m_avrContext, "out_sample_fmt", get_ff_sample_fmt(m_sfRemixFormat), 0);
+ av_opt_set_int(m_avrContext, "clip_protection", !bNormalize && (m_settings.MixingFlags & LAV_MIXING_FLAG_CLIP_PROTECTION), 0);
+
// Open Resample Context
ret = avresample_open(m_avrContext);
if (ret < 0) {
@@ -640,25 +639,6 @@ HRESULT CLAVAudio::PerformMixing(BufferDetails *buffer)
return S_FALSE;
}
- if (!(m_settings.MixingFlags & LAV_MIXING_FLAG_NORMALIZE_MATRIX) && (m_settings.MixingFlags & LAV_MIXING_FLAG_CLIP_PROTECTION)) {
- ASSERT(m_sfRemixFormat == SampleFormat_FP32);
-
- DWORD dwSamples = av_get_channel_layout_nb_channels(m_dwRemixLayout) * buffer->nSamples;
- BOOL bNeedNormalize = (m_fMixingClipThreshold > 1.0f);
- float *pfOut = (float *)pOut;
- for (DWORD i = 0; i < dwSamples; i++) {
- const float fVal = abs(pfOut[i]);
- if (fVal > m_fMixingClipThreshold) {
- m_fMixingClipThreshold = fVal;
- bNeedNormalize = TRUE;
- DbgLog((LOG_TRACE, 10, L"PerformMixing: Clipping Protection engaged with coeff of %f", m_fMixingClipThreshold));
- }
- if (bNeedNormalize) {
- pfOut[i] /= m_fMixingClipThreshold;
- }
- }
- }
-
delete buffer->bBuffer;
buffer->bBuffer = pcmOut;
buffer->dwChannelMask = m_dwRemixLayout;
diff --git a/ffmpeg b/ffmpeg
-Subproject 2492b051dd24127bee1c2a7ff9b6e170166da83
+Subproject 08e37f6ada52bee94ed30cfa8dd4d61ec3a42f9