summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartijn van Beurden <mvanb1@gmail.com>2022-05-21 20:06:57 +0200
committerGitHub <noreply@github.com>2022-05-21 20:06:57 +0200
commitf44d5967fd6779c079a60366c36dfa57b94d296f (patch)
treef7bd817dac0b5e518c8edf3dbe38f0a7571fe9f1 /src
parentbcb7ed12b9d241f882302d38cbd7f5c821112734 (diff)
downloadflac-f44d5967fd6779c079a60366c36dfa57b94d296f.tar.gz
Fix compression of loose mid-side for certain kinds of music
The loose mid-side option only fully evaluates stereo decorrelation once every few frames. However, in case of finding left-side or right-side to be the best option, subsequent frames were coded mid-side, which could be worse off. To not complicate code too much (to make it possible to evaluate only left or right and side frame for example), evaluation of left-side and right-side is completely disabled when loose mid-side is enabled.
Diffstat (limited to 'src')
-rw-r--r--src/libFLAC/stream_encoder.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libFLAC/stream_encoder.c b/src/libFLAC/stream_encoder.c
index d515f966..1fcb22ba 100644
--- a/src/libFLAC/stream_encoder.c
+++ b/src/libFLAC/stream_encoder.c
@@ -3350,7 +3350,11 @@ FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder)
channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT;
min_bits = bits[channel_assignment];
- for(ca = 1; ca <= 3; ca++) {
+
+ /* When doing loose mid-side stereo, ignore left-side
+ * and right-side options */
+ ca = encoder->protected_->loose_mid_side_stereo ? 3 : 1;
+ for( ; ca <= 3; ca++) {
if(bits[ca] < min_bits) {
min_bits = bits[ca];
channel_assignment = (FLAC__ChannelAssignment)ca;