From c82bf8a5566d3cde5a65c21cabe8e5e25171a031 Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Thu, 18 Dec 2003 05:21:26 +0000 Subject: [PATCH] fix plugin to match latest api for replaygain synthesis --- src/plugin_winamp2/in_flac.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/plugin_winamp2/in_flac.c b/src/plugin_winamp2/in_flac.c index a1e3b3e..4063a5f 100644 --- a/src/plugin_winamp2/in_flac.c +++ b/src/plugin_winamp2/in_flac.c @@ -65,7 +65,8 @@ static char lastfn_[MAX_PATH]; /* currently playing file (used for getting info static int decode_pos_ms_; /* current decoding position, in milliseconds */ #define SAMPLES_PER_WRITE 576 -static FLAC__int32 reservoir_[FLAC__MAX_BLOCK_SIZE * 2/*for overflow*/ * FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS]; +static FLAC__int32 reservoir_[FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS][FLAC__MAX_BLOCK_SIZE * 2/*for overflow*/]; +static FLAC__int32 *reservoir__[FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS] = { reservoir_[0], reservoir_[1] }; /*@@@ kind of a hard-coded hack */ static char sample_buffer_[SAMPLES_PER_WRITE * FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS * (24/8) * 2]; /* (24/8) for max bytes per sample, and 2 for who knows what */ static unsigned wide_samples_in_reservoir_; static file_info_struct file_info_; @@ -350,7 +351,6 @@ static DWORD WINAPI DecodeThread(void *unused) } else { const unsigned n = min(wide_samples_in_reservoir_, SAMPLES_PER_WRITE); - const unsigned delta = n * channels; int bytes; unsigned i; @@ -359,12 +359,12 @@ static DWORD WINAPI DecodeThread(void *unused) sample_buffer_, true, /* little_endian_data_out */ target_bps == 8, /* unsigned_data_out */ - reservoir_, + reservoir__, n, channels, bits_per_sample, target_bps, - (float)file_info_.replay_scale, + file_info_.replay_scale, cfg.replaygain.hard_limit, cfg.resolution.replaygain.dither, &file_info_.dither_context @@ -373,7 +373,7 @@ static DWORD WINAPI DecodeThread(void *unused) else { bytes = (int)FLAC__plugin_common__pack_pcm_signed_little_endian( sample_buffer_, - reservoir_, + reservoir__, n, channels, bits_per_sample, @@ -381,8 +381,8 @@ static DWORD WINAPI DecodeThread(void *unused) ); } - for(i = delta; i < wide_samples_in_reservoir_ * channels; i++) - reservoir_[i-delta] = reservoir_[i]; + for (i = 0; i < channels; i++) + memmove(&reservoir_[i][0], &reservoir_[i][n], sizeof(reservoir_[0][0]) * (wide_samples_in_reservoir_ - n)); wide_samples_in_reservoir_ -= n; do_vis(sample_buffer_, channels, target_bps, decode_pos_ms_, n); @@ -505,16 +505,15 @@ FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, { file_info_struct *file_info = (file_info_struct *)client_data; const unsigned channels = file_info->channels, wide_samples = frame->header.blocksize; - unsigned wide_sample, offset_sample, channel; + unsigned channel; (void)decoder; if(file_info->abort_flag) return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - for(offset_sample = wide_samples_in_reservoir_ * channels, wide_sample = 0; wide_sample < wide_samples; wide_sample++) - for(channel = 0; channel < channels; channel++, offset_sample++) - reservoir_[offset_sample] = buffer[channel][wide_sample]; + for(channel = 0; channel < channels; channel++) + memcpy(&reservoir_[channel][wide_samples_in_reservoir_], buffer[channel], sizeof(buffer[0][0]) * wide_samples); wide_samples_in_reservoir_ += wide_samples; -- 2.7.4