/* This is called after a frame of audio has been quantized and coded. It will write the encoded audio to the bitstream. Note that from a layer3 encoder's perspective the bit stream is primarily a series of main_data() blocks, with header and side information inserted at the proper locations to maintain framing. (See Figure A.7 in the IS).  */
void shine_format_bitstream(shine_global_config *config)
/* This is called after a frame of audio has been quantized and coded. It will write the encoded audio to the bitstream. Note that from a layer3 encoder's perspective the bit stream is primarily a series of main_data() blocks, with header and side information inserted at the proper locations to maintain framing. (See Figure A.7 in the IS).  */
void shine_format_bitstream(shine_global_config *config)
{
        int *pi = &config->l3_enc[ch][gr][0];
        int *pr = &config->mdct_freq[ch][gr][0];
        for ( i = 0; i < GRANULE_SIZE; i++ )
          {
            if ( (pr[i] < 0) && (pi[i] > 0) )
              pi[i] *= -1;
          }
      }
  encodeSideInfo( config );
  encodeMainData( config );
}