[Flac-dev] mid-side coding and bits per sample

Eri Eri guguieri at hotmail.com
Mon Sep 26 01:17:51 PDT 2011

Dear list,

i'm doing a bit of analisys on flac's source code and i've run into something i can't quite grasp.

flac version 1.2.1

flaclib C


function "process_subframes_"

line 2999

    if(do_mid_side) {
        FLAC__ASSERT(encoder->protected_->channels == 2);
        for(channel = 0; channel < 2; channel++) {
            const unsigned w = get_wasted_bits_(encoder->private_->integer_signal_mid_side[channel], encoder->protected_->blocksize);
            encoder->private_->subframe_workspace_mid_side[channel][0].wasted_bits = encoder->private_->subframe_workspace_mid_side[channel][1].wasted_bits = w;
            encoder->private_->subframe_bps_mid_side[channel] = encoder->protected_->bits_per_sample - w + (channel==0? 0:1);

In that piece of code the encoder determines how many wasted bits there are in each channel (mid-side) and calculates effective BPS for each of them. What i don't understand is why it should add one bit to the BPS of the side channel "(channel==0? 0:1)", eventhough there is no "correction" to wasted bits. Could someone shed light on this?
Thank you very much in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/flac-dev/attachments/20110926/9885761a/attachment.htm 

More information about the Flac-dev mailing list