Commit b5e60e5b authored by Josh Coalson's avatar Josh Coalson
Browse files

change force_mid_side to loose_mid_side

parent fce38134
......@@ -57,7 +57,7 @@ typedef struct {
FLAC__EncoderState state; /* must be FLAC__ENCODER_UNINITIALIZED when passed to FLAC__encoder_init() */
bool streamable_subset;
bool do_mid_side_stereo; /* 0 or 1; 1 only if channels==2 */
bool force_mid_side_stereo; /* 0 or 1; 1 only if channels==2 and do_mid_side_stereo==true */
bool loose_mid_side_stereo; /* 0 or 1; 1 only if channels==2 and do_mid_side_stereo==true */
unsigned channels; /* must be <= FLAC__MAX_CHANNELS */
unsigned bits_per_sample; /* do not give the encoder wider data than what you specify here or bad things will happen! */
unsigned sample_rate;
......
......@@ -81,7 +81,7 @@ static int32 *input[FLAC__MAX_CHANNELS];
/* local routines */
static bool init(encoder_wrapper_struct *encoder_wrapper);
static bool init_encoder(bool lax, bool do_mid_side, bool force_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned rice_optimization_level, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned channels, unsigned bps, unsigned sample_rate, encoder_wrapper_struct *encoder_wrapper);
static bool init_encoder(bool lax, bool do_mid_side, bool loose_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned rice_optimization_level, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned channels, unsigned bps, unsigned sample_rate, encoder_wrapper_struct *encoder_wrapper);
static void format_input(unsigned wide_samples, bool is_big_endian, bool is_unsigned_samples, unsigned channels, unsigned bps, encoder_wrapper_struct *encoder_wrapper);
static FLAC__EncoderWriteStatus write_callback(const FLAC__Encoder *encoder, const byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
static void metadata_callback(const FLAC__Encoder *encoder, const FLAC__StreamMetaData *metadata, void *client_data);
......@@ -93,7 +93,7 @@ static void print_stats(const encoder_wrapper_struct *encoder_wrapper);
static bool read_little_endian_uint16(FILE *f, uint16 *val, bool eof_ok);
static bool read_little_endian_uint32(FILE *f, uint32 *val, bool eof_ok);
int encode_wav(const char *infile, const char *outfile, bool verbose, uint64 skip, bool verify, bool lax, bool do_mid_side, bool force_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned rice_optimization_level, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision)
int encode_wav(const char *infile, const char *outfile, bool verbose, uint64 skip, bool verify, bool lax, bool do_mid_side, bool loose_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned rice_optimization_level, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision)
{
encoder_wrapper_struct encoder_wrapper;
FILE *fin;
......@@ -245,7 +245,7 @@ int encode_wav(const char *infile, const char *outfile, bool verbose, uint64 ski
encoder_wrapper.total_samples_to_encode = data_bytes / bytes_per_wide_sample - skip;
encoder_wrapper.unencoded_size = encoder_wrapper.total_samples_to_encode * bytes_per_wide_sample + 44; /* 44 for the size of the WAV headers */
if(!init_encoder(lax, do_mid_side, force_mid_side, do_exhaustive_model_search, do_qlp_coeff_prec_search, rice_optimization_level, max_lpc_order, blocksize, qlp_coeff_precision, channels, bps, sample_rate, &encoder_wrapper))
if(!init_encoder(lax, do_mid_side, loose_mid_side, do_exhaustive_model_search, do_qlp_coeff_prec_search, rice_optimization_level, max_lpc_order, blocksize, qlp_coeff_precision, channels, bps, sample_rate, &encoder_wrapper))
goto wav_abort_;
encoder_wrapper.verify_fifo.into_frames = true;
......@@ -322,7 +322,7 @@ wav_abort_:
return 1;
}
int encode_raw(const char *infile, const char *outfile, bool verbose, uint64 skip, bool verify, bool lax, bool do_mid_side, bool force_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned rice_optimization_level, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, bool is_big_endian, bool is_unsigned_samples, unsigned channels, unsigned bps, unsigned sample_rate)
int encode_raw(const char *infile, const char *outfile, bool verbose, uint64 skip, bool verify, bool lax, bool do_mid_side, bool loose_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned rice_optimization_level, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, bool is_big_endian, bool is_unsigned_samples, unsigned channels, unsigned bps, unsigned sample_rate)
{
encoder_wrapper_struct encoder_wrapper;
FILE *fin;
......@@ -395,7 +395,7 @@ int encode_raw(const char *infile, const char *outfile, bool verbose, uint64 ski
}
}
if(!init_encoder(lax, do_mid_side, force_mid_side, do_exhaustive_model_search, do_qlp_coeff_prec_search, rice_optimization_level, max_lpc_order, blocksize, qlp_coeff_precision, channels, bps, sample_rate, &encoder_wrapper))
if(!init_encoder(lax, do_mid_side, loose_mid_side, do_exhaustive_model_search, do_qlp_coeff_prec_search, rice_optimization_level, max_lpc_order, blocksize, qlp_coeff_precision, channels, bps, sample_rate, &encoder_wrapper))
goto raw_abort_;
encoder_wrapper.verify_fifo.into_frames = true;
......@@ -483,10 +483,10 @@ bool init(encoder_wrapper_struct *encoder_wrapper)
return true;
}
bool init_encoder(bool lax, bool do_mid_side, bool force_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned rice_optimization_level, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned channels, unsigned bps, unsigned sample_rate, encoder_wrapper_struct *encoder_wrapper)
bool init_encoder(bool lax, bool do_mid_side, bool loose_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned rice_optimization_level, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned channels, unsigned bps, unsigned sample_rate, encoder_wrapper_struct *encoder_wrapper)
{
if(channels != 2 || bps > 16)
do_mid_side = force_mid_side = false;
do_mid_side = loose_mid_side = false;
if(encoder_wrapper->verify) {
unsigned i;
......@@ -523,7 +523,7 @@ bool init_encoder(bool lax, bool do_mid_side, bool force_mid_side, bool do_exhau
encoder_wrapper->encoder->qlp_coeff_precision = qlp_coeff_precision;
encoder_wrapper->encoder->max_lpc_order = max_lpc_order;
encoder_wrapper->encoder->do_mid_side_stereo = do_mid_side;
encoder_wrapper->encoder->force_mid_side_stereo = force_mid_side;
encoder_wrapper->encoder->loose_mid_side_stereo = loose_mid_side;
encoder_wrapper->encoder->do_exhaustive_model_search = do_exhaustive_model_search;
encoder_wrapper->encoder->do_qlp_coeff_prec_search = do_qlp_coeff_prec_search;
encoder_wrapper->encoder->rice_optimization_level = rice_optimization_level;
......
......@@ -21,7 +21,7 @@
#include "FLAC/ordinals.h"
int encode_wav(const char *infile, const char *outfile, bool verbose, uint64 skip, bool verify, bool lax, bool do_mid_side, bool force_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned rice_optimization_level, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision);
int encode_raw(const char *infile, const char *outfile, bool verbose, uint64 skip, bool verify, bool lax, bool do_mid_side, bool force_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned rice_optimization_level, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, bool is_big_endian, bool is_unsigned_samples, unsigned channels, unsigned bps, unsigned sample_rate);
int encode_wav(const char *infile, const char *outfile, bool verbose, uint64 skip, bool verify, bool lax, bool do_mid_side, bool loose_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned rice_optimization_level, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision);
int encode_raw(const char *infile, const char *outfile, bool verbose, uint64 skip, bool verify, bool lax, bool do_mid_side, bool loose_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned rice_optimization_level, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, bool is_big_endian, bool is_unsigned_samples, unsigned channels, unsigned bps, unsigned sample_rate);
#endif
......@@ -32,7 +32,7 @@ int main(int argc, char *argv[])
{
int i;
bool verify = false, verbose = true, lax = false, mode_decode = false, test_only = false, analyze = false;
bool do_mid_side = true, force_mid_side = false, do_exhaustive_model_search = false, do_qlp_coeff_prec_search = false;
bool do_mid_side = true, loose_mid_side = false, do_exhaustive_model_search = false, do_qlp_coeff_prec_search = false;
unsigned max_lpc_order = 8;
unsigned qlp_coeff_precision = 0;
uint64 skip = 0;
......@@ -80,9 +80,9 @@ int main(int argc, char *argv[])
else if(0 == strcmp(argv[i], "-m-"))
do_mid_side = false;
else if(0 == strcmp(argv[i], "-M"))
force_mid_side = do_mid_side = true;
loose_mid_side = do_mid_side = true;
else if(0 == strcmp(argv[i], "-M-"))
force_mid_side = do_mid_side = false;
loose_mid_side = do_mid_side = false;
else if(0 == strcmp(argv[i], "-p"))
do_qlp_coeff_prec_search = true;
else if(0 == strcmp(argv[i], "-p-"))
......@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
else if(0 == strcmp(argv[i], "-0")) {
do_exhaustive_model_search = false;
do_mid_side = false;
force_mid_side = false;
loose_mid_side = false;
qlp_coeff_precision = 0;
rice_optimization_level = 0;
max_lpc_order = 0;
......@@ -122,7 +122,7 @@ int main(int argc, char *argv[])
else if(0 == strcmp(argv[i], "-1")) {
do_exhaustive_model_search = false;
do_mid_side = true;
force_mid_side = true;
loose_mid_side = true;
qlp_coeff_precision = 0;
rice_optimization_level = 0;
max_lpc_order = 0;
......@@ -130,14 +130,14 @@ int main(int argc, char *argv[])
else if(0 == strcmp(argv[i], "-2")) {
do_exhaustive_model_search = false;
do_mid_side = true;
force_mid_side = false;
loose_mid_side = false;
qlp_coeff_precision = 0;
max_lpc_order = 0;
}
else if(0 == strcmp(argv[i], "-4")) {
do_exhaustive_model_search = false;
do_mid_side = false;
force_mid_side = false;
loose_mid_side = false;
qlp_coeff_precision = 0;
rice_optimization_level = 0;
max_lpc_order = 8;
......@@ -145,7 +145,7 @@ int main(int argc, char *argv[])
else if(0 == strcmp(argv[i], "-5")) {
do_exhaustive_model_search = false;
do_mid_side = true;
force_mid_side = true;
loose_mid_side = true;
qlp_coeff_precision = 0;
rice_optimization_level = 0;
max_lpc_order = 8;
......@@ -153,21 +153,21 @@ int main(int argc, char *argv[])
else if(0 == strcmp(argv[i], "-6")) {
do_exhaustive_model_search = false;
do_mid_side = true;
force_mid_side = false;
loose_mid_side = false;
qlp_coeff_precision = 0;
max_lpc_order = 8;
}
else if(0 == strcmp(argv[i], "-8")) {
do_exhaustive_model_search = false;
do_mid_side = true;
force_mid_side = false;
loose_mid_side = false;
qlp_coeff_precision = 0;
max_lpc_order = 32;
}
else if(0 == strcmp(argv[i], "-9")) {
do_exhaustive_model_search = true;
do_mid_side = true;
force_mid_side = false;
loose_mid_side = false;
do_qlp_coeff_prec_search = true;
rice_optimization_level = 99;
max_lpc_order = 32;
......@@ -263,7 +263,7 @@ int main(int argc, char *argv[])
if(!mode_decode) {
printf("options:%s -b %u%s -l %u%s%s -q %u -r %u%s\n",
lax?" --lax":"", (unsigned)blocksize, force_mid_side?" -M":do_mid_side?" -m":"", max_lpc_order,
lax?" --lax":"", (unsigned)blocksize, loose_mid_side?" -M":do_mid_side?" -m":"", max_lpc_order,
do_exhaustive_model_search?" -e":"", do_qlp_coeff_prec_search?" -p":"",
qlp_coeff_precision, (unsigned)rice_optimization_level,
verify? " -V":""
......@@ -278,9 +278,9 @@ int main(int argc, char *argv[])
return decode_raw(argv[i], test_only? 0 : argv[i+1], analyze, verbose, skip, format_is_big_endian, format_is_unsigned_samples);
else
if(format_is_wave)
return encode_wav(argv[i], argv[i+1], verbose, skip, verify, lax, do_mid_side, force_mid_side, do_exhaustive_model_search, do_qlp_coeff_prec_search, rice_optimization_level, max_lpc_order, (unsigned)blocksize, qlp_coeff_precision);
return encode_wav(argv[i], argv[i+1], verbose, skip, verify, lax, do_mid_side, loose_mid_side, do_exhaustive_model_search, do_qlp_coeff_prec_search, rice_optimization_level, max_lpc_order, (unsigned)blocksize, qlp_coeff_precision);
else
return encode_raw(argv[i], argv[i+1], verbose, skip, verify, lax, do_mid_side, force_mid_side, do_exhaustive_model_search, do_qlp_coeff_prec_search, rice_optimization_level, max_lpc_order, (unsigned)blocksize, qlp_coeff_precision, format_is_big_endian, format_is_unsigned_samples, format_channels, format_bps, format_sample_rate);
return encode_raw(argv[i], argv[i+1], verbose, skip, verify, lax, do_mid_side, loose_mid_side, do_exhaustive_model_search, do_qlp_coeff_prec_search, rice_optimization_level, max_lpc_order, (unsigned)blocksize, qlp_coeff_precision, format_is_big_endian, format_is_unsigned_samples, format_channels, format_bps, format_sample_rate);
return 0;
}
......@@ -340,7 +340,7 @@ int usage(const char *message, ...)
printf(" --lax : allow encoder to generate non-Subset files\n");
printf(" -b blocksize : default is 1152 for -l 0, else 4608; should be 192/576/1152/2304/4608 (unless --lax is used)\n");
printf(" -m : try mid-side coding for each frame (stereo input only)\n");
printf(" -M : force mid-side coding for all frames (stereo input only)\n");
printf(" -M : loose mid-side coding for all frames (stereo input only)\n");
printf(" -0 .. -9 : fastest compression .. highest compression, default is -6\n");
printf(" these are synonyms for other options:\n");
printf(" -0 : synonymous with -l 0\n");
......
This diff is collapsed.
......@@ -52,11 +52,11 @@ static bool stream_decoder_skip_id3v2_tag_(FLAC__StreamDecoder *decoder);
static bool stream_decoder_frame_sync_(FLAC__StreamDecoder *decoder);
static bool stream_decoder_read_frame_(FLAC__StreamDecoder *decoder, bool *got_a_frame);
static bool stream_decoder_read_frame_header_(FLAC__StreamDecoder *decoder);
static bool stream_decoder_read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel);
static bool stream_decoder_read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel);
static bool stream_decoder_read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, const unsigned order);
static bool stream_decoder_read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, const unsigned order);
static bool stream_decoder_read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel);
static bool stream_decoder_read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps);
static bool stream_decoder_read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps);
static bool stream_decoder_read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order);
static bool stream_decoder_read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order);
static bool stream_decoder_read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps);
static bool stream_decoder_read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigned predictor_order, unsigned partition_order, int32 *residual);
static bool stream_decoder_read_zero_padding_(FLAC__StreamDecoder *decoder);
static bool read_callback_(byte buffer[], unsigned *bytes, void *client_data);
......@@ -602,7 +602,33 @@ bool stream_decoder_read_frame_(FLAC__StreamDecoder *decoder, bool *got_a_frame)
if(!stream_decoder_allocate_output_(decoder, decoder->guts->frame.header.blocksize))
return false;
for(channel = 0; channel < decoder->guts->frame.header.channels; channel++) {
if(!stream_decoder_read_subframe_(decoder, channel))
/*
* first figure the correct bits-per-sample of the subframe
*/
unsigned bps = decoder->guts->frame.header.bits_per_sample;
switch(decoder->guts->frame.header.channel_assignment) {
case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
/* no adjustment needed */
break;
case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE:
if(channel == 1)
bps++;
break;
case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE:
if(channel == 0)
bps++;
break;
case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE:
if(channel == 1)
bps++;
break;
default:
assert(0);
}
/*
* now read it
*/
if(!stream_decoder_read_subframe_(decoder, channel, bps))
return false;
if(decoder->state != FLAC__STREAM_DECODER_READ_FRAME) {
decoder->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
......@@ -953,7 +979,7 @@ bool stream_decoder_read_frame_header_(FLAC__StreamDecoder *decoder)
return true;
}
bool stream_decoder_read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel)
bool stream_decoder_read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps)
{
uint32 x;
......@@ -965,28 +991,28 @@ bool stream_decoder_read_subframe_(FLAC__StreamDecoder *decoder, unsigned channe
return true;
}
else if(x == 0) {
return stream_decoder_read_subframe_constant_(decoder, channel);
return stream_decoder_read_subframe_constant_(decoder, channel, bps);
}
else if(x == 2) {
return stream_decoder_read_subframe_verbatim_(decoder, channel);
return stream_decoder_read_subframe_verbatim_(decoder, channel, bps);
}
else if(x < 16) {
decoder->state = FLAC__STREAM_DECODER_UNPARSEABLE_STREAM;
return false;
}
else if(x <= 24) {
return stream_decoder_read_subframe_fixed_(decoder, channel, (x>>1)&7);
return stream_decoder_read_subframe_fixed_(decoder, channel, bps, (x>>1)&7);
}
else if(x < 64) {
decoder->state = FLAC__STREAM_DECODER_UNPARSEABLE_STREAM;
return false;
}
else {
return stream_decoder_read_subframe_lpc_(decoder, channel, ((x>>1)&31)+1);
return stream_decoder_read_subframe_lpc_(decoder, channel, bps, ((x>>1)&31)+1);
}
}
bool stream_decoder_read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel)
bool stream_decoder_read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps)
{
FLAC__Subframe_Constant *subframe = &decoder->guts->frame.subframes[channel].data.constant;
int32 x;
......@@ -995,7 +1021,7 @@ bool stream_decoder_read_subframe_constant_(FLAC__StreamDecoder *decoder, unsign
decoder->guts->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT;
if(!FLAC__bitbuffer_read_raw_int32(&decoder->guts->input, &x, decoder->guts->frame.header.bits_per_sample, read_callback_, decoder))
if(!FLAC__bitbuffer_read_raw_int32(&decoder->guts->input, &x, bps, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->value = x;
......@@ -1007,7 +1033,7 @@ bool stream_decoder_read_subframe_constant_(FLAC__StreamDecoder *decoder, unsign
return true;
}
bool stream_decoder_read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, const unsigned order)
bool stream_decoder_read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order)
{
FLAC__Subframe_Fixed *subframe = &decoder->guts->frame.subframes[channel].data.fixed;
int32 i32;
......@@ -1021,7 +1047,7 @@ bool stream_decoder_read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned
/* read warm-up samples */
for(u = 0; u < order; u++) {
if(!FLAC__bitbuffer_read_raw_int32(&decoder->guts->input, &i32, decoder->guts->frame.header.bits_per_sample, read_callback_, decoder))
if(!FLAC__bitbuffer_read_raw_int32(&decoder->guts->input, &i32, bps, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->warmup[u] = i32;
}
......@@ -1044,7 +1070,7 @@ bool stream_decoder_read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned
/* read residual */
switch(subframe->entropy_coding_method.type) {
case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
if(!stream_decoder_read_residual_partitioned_rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, subframe->residual))
if(!stream_decoder_read_residual_partitioned_rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, decoder->guts->residual[channel]))
return false;
break;
default:
......@@ -1058,7 +1084,7 @@ bool stream_decoder_read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned
return true;
}
bool stream_decoder_read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, const unsigned order)
bool stream_decoder_read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order)
{
FLAC__Subframe_LPC *subframe = &decoder->guts->frame.subframes[channel].data.lpc;
int32 i32;
......@@ -1072,7 +1098,7 @@ bool stream_decoder_read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned ch
/* read warm-up samples */
for(u = 0; u < order; u++) {
if(!FLAC__bitbuffer_read_raw_int32(&decoder->guts->input, &i32, decoder->guts->frame.header.bits_per_sample, read_callback_, decoder))
if(!FLAC__bitbuffer_read_raw_int32(&decoder->guts->input, &i32, bps, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->warmup[u] = i32;
}
......@@ -1117,7 +1143,7 @@ bool stream_decoder_read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned ch
/* read residual */
switch(subframe->entropy_coding_method.type) {
case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
if(!stream_decoder_read_residual_partitioned_rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, subframe->residual))
if(!stream_decoder_read_residual_partitioned_rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, decoder->guts->residual[channel]))
return false;
break;
default:
......@@ -1131,20 +1157,20 @@ bool stream_decoder_read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned ch
return true;
}
bool stream_decoder_read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel)
bool stream_decoder_read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps)
{
FLAC__Subframe_Verbatim *subframe = &decoder->guts->frame.subframes[channel].data.verbatim;
int32 x;
int32 x, *residual = decoder->guts->residual[channel];
unsigned i;
decoder->guts->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM;
subframe->data = decoder->guts->residual[channel];
subframe->data = residual;
for(i = 0; i < decoder->guts->frame.header.blocksize; i++) {
if(!FLAC__bitbuffer_read_raw_int32(&decoder->guts->input, &x, decoder->guts->frame.header.bits_per_sample, read_callback_, decoder))
if(!FLAC__bitbuffer_read_raw_int32(&decoder->guts->input, &x, bps, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->data[i] = x;
residual[i] = x;
}
/* decode the subframe */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment