--- ./src/flac/main.c Tue Jan 14 16:32:55 2003 +++ ../flac-1.1.0/./src/flac/main.c Fri Feb 21 12:47:22 2003 @@ -1404,9 +1404,9 @@ fmt= RAW; } else { - if(!strncmp(lookahead, "RIFF", 4) && !strncmp(lookahead+8, "WAVE", 4)) + if(!strncmp((const char *) lookahead, "RIFF", 4) && !strncmp((const char *) (lookahead+8), "WAVE", 4)) fmt= WAV; - else if(!strncmp(lookahead, "FORM", 4) && !strncmp(lookahead+8, "AIFF", 4)) + else if(!strncmp((const char *) lookahead, "FORM", 4) && !strncmp((const char *) (lookahead+8), "AIFF", 4)) fmt= AIF; else { if(fmt != RAW) --- ./src/flac/Makefile.in Sat Jan 25 13:42:28 2003 +++ ../flac-1.1.0/./src/flac/Makefile.in Fri Feb 21 13:07:33 2003 @@ -164,7 +164,7 @@ $(top_builddir)/src/share/utf8/libutf8.a \ $(top_builddir)/src/libFLAC/libFLAC.la \ @OGG_LIBS@ \ - @LIBICONV@ \ + $(LIBICONV) \ -lm subdir = src/flac --- ./src/flac/vorbiscomment.c Thu Jan 2 02:18:53 2003 +++ ../flac-1.1.0/./src/flac/vorbiscomment.c Fri Feb 21 12:47:22 2003 @@ -109,10 +109,10 @@ FLAC__ASSERT(0 != needs_write); if(raw) { - entry.entry = field->field; + entry.entry = (FLAC__byte *) field->field; } else if(utf8_encode(field->field, &converted) >= 0) { - entry.entry = converted; + entry.entry = (FLAC__byte *) converted; needs_free = true; } else { @@ -120,7 +120,7 @@ return false; } - entry.length = strlen(entry.entry); + entry.length = strlen((const char *) entry.entry); if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, block->data.vorbis_comment.num_comments, entry, /*copy=*/true)) { if(needs_free) --- ./src/libOggFLAC/stream_decoder.c Thu Jan 2 02:18:56 2003 +++ ../flac-1.1.0/./src/libOggFLAC/stream_decoder.c Fri Feb 21 12:47:22 2003 @@ -466,7 +466,7 @@ ogg_bytes_to_read = min(*bytes, OGG_BYTES_CHUNK); oggbuf = ogg_sync_buffer(&decoder->private_->ogg.sync_state, ogg_bytes_to_read); - if(decoder->private_->read_callback(decoder, oggbuf, &ogg_bytes_to_read, decoder->private_->client_data) != FLAC__STREAM_DECODER_READ_STATUS_CONTINUE) { + if(decoder->private_->read_callback(decoder, (FLAC__byte *) oggbuf, &ogg_bytes_to_read, decoder->private_->client_data) != FLAC__STREAM_DECODER_READ_STATUS_CONTINUE) { decoder->protected_->state = OggFLAC__STREAM_DECODER_READ_ERROR; return FLAC__STREAM_DECODER_READ_STATUS_ABORT; } --- ./src/plugin_common/charset.c Thu Jan 2 02:18:56 2003 +++ ../flac-1.1.0/./src/plugin_common/charset.c Fri Feb 21 12:47:22 2003 @@ -88,7 +88,7 @@ outptr = out; retry: - if (iconv(cd, &input, &length, &outptr, &outleft) == -1) + if (iconv(cd, (char **) &input, &length, &outptr, &outleft) == -1) { int used; switch (errno) --- ./src/plugin_common/dither.c Thu Jan 2 02:18:56 2003 +++ ../flac-1.1.0/./src/plugin_common/dither.c Fri Feb 21 12:47:22 2003 @@ -99,6 +99,76 @@ return output >> scalebits; } +unsigned FLAC__plugin_common__pack_pcm_signed(FLAC__byte *data, FLAC__int32 *input, unsigned wide_samples, unsigned channels, unsigned source_bps, unsigned target_bps) +{ + static dither_state dither[FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS]; + FLAC__byte * const start = data; + FLAC__int32 sample; + unsigned samples = wide_samples * channels; + const unsigned bytes_per_sample = target_bps / 8; + + FLAC__ASSERT(FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS == 2); + FLAC__ASSERT(channels > 0 && channels <= FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS); + FLAC__ASSERT(source_bps < 32); + FLAC__ASSERT(target_bps <= 24); + FLAC__ASSERT(target_bps <= source_bps); + FLAC__ASSERT((source_bps & 7) == 0); + FLAC__ASSERT((target_bps & 7) == 0); + + if(source_bps != target_bps) { + const FLAC__int32 MIN = -(1L << source_bps); + const FLAC__int32 MAX = ~MIN; /*(1L << (source_bps-1)) - 1 */ + const unsigned dither_twiggle = channels - 1; + unsigned dither_source = 0; + + while(samples--) { + sample = linear_dither(source_bps, target_bps, *input++, &dither[dither_source], MIN, MAX); + dither_source ^= dither_twiggle; + + switch(target_bps) { + case 8: + data[0] = sample ^ 0x80; + break; + case 16: + data[0] = (FLAC__byte)(sample >> 8); + data[1] = (FLAC__byte)sample; + break; + case 24: + data[0] = (FLAC__byte)(sample >> 16); + data[1] = (FLAC__byte)(sample >> 8); + data[2] = (FLAC__byte)sample; + break; + } + + data += bytes_per_sample; + } + } + else { + while(samples--) { + sample = *input++; + + switch(target_bps) { + case 8: + data[0] = sample ^ 0x80; + break; + case 16: + data[0] = (FLAC__byte)(sample >> 8); + data[1] = (FLAC__byte)sample; + break; + case 24: + data[0] = (FLAC__byte)(sample >> 16); + data[1] = (FLAC__byte)(sample >> 8); + data[2] = (FLAC__byte)sample; + break; + } + + data += bytes_per_sample; + } + } + + return data - start; +} + unsigned FLAC__plugin_common__pack_pcm_signed_little_endian(FLAC__byte *data, FLAC__int32 *input, unsigned wide_samples, unsigned channels, unsigned source_bps, unsigned target_bps) { static dither_state dither[FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS]; --- ./src/plugin_common/dither.h Thu Jan 2 02:18:56 2003 +++ ../flac-1.1.0/./src/plugin_common/dither.h Fri Feb 21 12:47:22 2003 @@ -22,6 +22,7 @@ #include "defs.h" /* buy FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS for the caller */ #include "FLAC/ordinals.h" +unsigned FLAC__plugin_common__pack_pcm_signed(FLAC__byte *data, FLAC__int32 *input, unsigned wide_samples, unsigned channels, unsigned source_bps, unsigned target_bps); unsigned FLAC__plugin_common__pack_pcm_signed_little_endian(FLAC__byte *data, FLAC__int32 *input, unsigned wide_samples, unsigned channels, unsigned source_bps, unsigned target_bps); #endif --- ./src/plugin_common/vorbiscomment.c Thu Jan 2 02:18:56 2003 +++ ../flac-1.1.0/./src/plugin_common/vorbiscomment.c Fri Feb 21 12:47:22 2003 @@ -32,7 +32,7 @@ #endif const FLAC__byte *eq = memchr(entry->entry, '=', entry->length); const unsigned field_name_length = strlen(field_name); - return (0 != eq && (unsigned)(eq-entry->entry) == field_name_length && 0 == FLAC__STRNCASECMP(field_name, entry->entry, field_name_length)); + return (0 != eq && (unsigned)(eq-entry->entry) == field_name_length && 0 == FLAC__STRNCASECMP(field_name, (const char *) entry->entry, field_name_length)); } static void local__vcentry_parse_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry, char **dest) @@ -74,7 +74,7 @@ sprintf(s, "%s=%s", name, value); entry.length = strlen(s); - entry.entry = s; + entry.entry = (FLAC__byte *) s; if(l == -1) FLAC__metadata_object_vorbiscomment_insert_comment(block, block->data.vorbis_comment.num_comments, entry, /*copy=*/true); --- ./src/metaflac/operations_shorthand_vorbiscomment.c Thu Jan 2 02:18:56 2003 +++ ../flac-1.1.0/./src/metaflac/operations_shorthand_vorbiscomment.c Fri Feb 21 12:47:22 2003 @@ -179,10 +179,10 @@ FLAC__ASSERT(0 != needs_write); if(raw) { - entry.entry = field->field; + entry.entry = (FLAC__byte *) field->field; } else if(utf8_encode(field->field, &converted) >= 0) { - entry.entry = converted; + entry.entry = (FLAC__byte *) converted; needs_free = true; } else { @@ -190,7 +190,7 @@ return false; } - entry.length = strlen(entry.entry); + entry.length = strlen((const char *) entry.entry); if(!FLAC__metadata_object_vorbiscomment_insert_comment(block, block->data.vorbis_comment.num_comments, entry, /*copy=*/true)) { if(needs_free) --- ./src/libFLAC/stream_decoder.c Tue Jan 14 01:57:37 2003 +++ ../flac-1.1.0/./src/libFLAC/stream_decoder.c Fri Feb 21 12:47:22 2003 @@ -1147,7 +1147,7 @@ memset(obj, 0, sizeof(FLAC__StreamMetadata_CueSheet)); FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN % 8 == 0); - if(!FLAC__bitbuffer_read_byte_block_aligned_no_crc(decoder->private_->input, obj->media_catalog_number, FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN/8, read_callback_, decoder)) + if(!FLAC__bitbuffer_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte *) obj->media_catalog_number, FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN/8, read_callback_, decoder)) return false; /* the read_callback_ sets the state for us */ if(!FLAC__bitbuffer_read_raw_uint64(decoder->private_->input, &obj->lead_in, FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN, read_callback_, decoder)) @@ -1179,7 +1179,7 @@ track->number = (FLAC__byte)x; FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN % 8 == 0); - if(!FLAC__bitbuffer_read_byte_block_aligned_no_crc(decoder->private_->input, track->isrc, FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN/8, read_callback_, decoder)) + if(!FLAC__bitbuffer_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte *) track->isrc, FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN/8, read_callback_, decoder)) return false; /* the read_callback_ sets the state for us */ if(!FLAC__bitbuffer_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN, read_callback_, decoder)) --- ./src/share/grabbag/replaygain.c Tue Jan 7 18:53:21 2003 +++ ../flac-1.1.0/./src/share/grabbag/replaygain.c Fri Feb 21 12:47:22 2003 @@ -99,7 +99,7 @@ #endif setlocale(LC_ALL, saved_locale); - entry.entry = buffer; + entry.entry = (FLAC__byte *) buffer; entry.length = strlen(buffer); return FLAC__metadata_object_vorbiscomment_insert_comment(block, block->data.vorbis_comment.num_comments, entry, /*copy=*/true); @@ -384,8 +384,8 @@ FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); if( - FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, tag_album_gain_) < 0 || - FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, tag_album_peak_) < 0 + FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, (const char *) tag_album_gain_) < 0 || + FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, (const char *) tag_album_peak_) < 0 ) return "memory allocation error"; @@ -404,8 +404,8 @@ FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); if( - FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, tag_title_gain_) < 0 || - FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, tag_title_peak_) < 0 + FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, (const char *) tag_title_gain_) < 0 || + FLAC__metadata_object_vorbiscomment_remove_entries_matching(block, (const char *) tag_title_peak_) < 0 ) return "memory allocation error"; @@ -587,9 +587,9 @@ FLAC__ASSERT(0 != block); FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); - if(0 > (gain_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, album_mode? tag_album_gain_ : tag_title_gain_))) + if(0 > (gain_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, (const char *) (album_mode? tag_album_gain_ : tag_title_gain_)))) return false; - if(0 > (peak_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, album_mode? tag_album_peak_ : tag_title_peak_))) + if(0 > (peak_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, /*offset=*/0, (const char *) (album_mode? tag_album_peak_ : tag_title_peak_)))) return false; if(!parse_double_(block->data.vorbis_comment.comments + gain_offset, gain)) --- ./src/test_libOggFLAC/encoders.c Fri Jan 10 02:49:08 2003 +++ ../flac-1.1.0/./src/test_libOggFLAC/encoders.c Fri Feb 21 12:47:22 2003 @@ -76,9 +76,10 @@ FLAC__StreamEncoderState state_; FLAC__StreamDecoderState dstate; FLAC__int32 samples[1024]; - FLAC__int32 *samples_array[1] = { samples }; + FLAC__int32 *samples_array[1]; unsigned i; + samples_array[0] = samples; printf("\n+++ libOggFLAC unit test: OggFLAC__StreamEncoder\n\n"); printf("testing OggFLAC__stream_encoder_new()... "); --- ./src/test_libFLAC++/metadata_manip.cpp Thu Jan 2 02:19:02 2003 +++ ../flac-1.1.0/./src/test_libFLAC++/metadata_manip.cpp Fri Feb 21 12:47:22 2003 @@ -42,7 +42,7 @@ public: inline OurFileDecoder(bool ignore_metadata): ignore_metadata_(ignore_metadata), error_occurred_(false) { } - bool ignore_metadata_;; + bool ignore_metadata_; bool error_occurred_; protected: ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]); --- ./src/plugin_xmms/plugin.c Fri Jan 3 19:41:30 2003 +++ ../flac-1.1.0/./src/plugin_xmms/plugin.c Fri Feb 21 12:47:22 2003 @@ -122,6 +122,7 @@ static file_info_struct file_info_; static pthread_t decode_thread_; static FLAC__bool audio_error_ = false; +static FLAC__bool is_big_endian_host_; #define BITRATE_HIST_SEGMENT_MSEC 500 /* 500ms * 50 = 25s should be enough */ @@ -138,7 +139,10 @@ void FLAC_XMMS__init() { ConfigFile *cfg; + FLAC__uint32 test = 1; + is_big_endian_host_ = (*((FLAC__byte*)(&test)))? false : true; + flac_cfg.title.tag_override = FALSE; g_free(flac_cfg.title.tag_format); flac_cfg.title.convert_char_set = FALSE; @@ -360,6 +364,18 @@ &file_info_.dither_context ); } + else if(is_big_endian_host_) { + bytes = (int)FLAC__plugin_common__pack_pcm_signed( + sample_buffer_, + reservoir_, + n, + channels, + bits_per_sample, + flac_cfg.output.resolution.normal.dither_24_to_16? + min(bits_per_sample, 16) : + bits_per_sample + ); + } else { bytes = (int)FLAC__plugin_common__pack_pcm_signed_little_endian( sample_buffer_, @@ -515,7 +531,7 @@ file_info->sample_format = FMT_S8; } else if(file_info->bits_per_sample == 16 || file_info->bits_per_sample == 24) { - file_info->sample_format = FMT_S16_LE; + file_info->sample_format = (is_big_endian_host_) ? FMT_S16_BE : FMT_S16_LE; } else { /*@@@ need some error here like wa2: MessageBox(mod_.hMainWindow, "ERROR: plugin can only handle 8/16/24-bit samples\n", "ERROR: plugin can only handle 8/16/24-bit samples", 0); */ @@ -527,7 +543,7 @@ file_info->sample_format = FMT_S8; } else if(file_info->bits_per_sample == 16) { - file_info->sample_format = FMT_S16_LE; + file_info->sample_format = (is_big_endian_host_) ? FMT_S16_BE : FMT_S16_LE; } else { /*@@@ need some error here like wa2: MessageBox(mod_.hMainWindow, "ERROR: plugin can only handle 8/16-bit samples\n", "ERROR: plugin can only handle 8/16-bit samples", 0); */ --- ./src/test_libFLAC/encoders.c Fri Jan 10 02:48:55 2003 +++ ../flac-1.1.0/./src/test_libFLAC/encoders.c Fri Feb 21 12:47:22 2003 @@ -126,9 +126,10 @@ FLAC__StreamEncoderState state; FLAC__StreamDecoderState dstate; FLAC__int32 samples[1024]; - FLAC__int32 *samples_array[1] = { samples }; + FLAC__int32 *samples_array[1]; unsigned i; + samples_array[0] = samples; printf("\n+++ libFLAC unit test: FLAC__StreamEncoder\n\n"); printf("testing FLAC__stream_encoder_new()... "); @@ -433,9 +434,10 @@ FLAC__StreamEncoderState state_; FLAC__StreamDecoderState dstate; FLAC__int32 samples[1024]; - FLAC__int32 *samples_array[1] = { samples }; + FLAC__int32 *samples_array[1]; unsigned i; + samples_array[0] = samples; printf("\n+++ libFLAC unit test: FLAC__SeekableStreamEncoder\n\n"); printf("testing FLAC__seekable_stream_encoder_new()... "); @@ -738,9 +740,10 @@ FLAC__StreamEncoderState state__; FLAC__StreamDecoderState dstate; FLAC__int32 samples[1024]; - FLAC__int32 *samples_array[1] = { samples }; + FLAC__int32 *samples_array[1]; unsigned i; + samples_array[0] = samples; printf("\n+++ libFLAC unit test: FLAC__FileEncoder\n\n"); printf("testing FLAC__file_encoder_new()... "); --- ./configure.in Wed Jan 15 15:56:07 2003 +++ ../flac-1.1.0/./configure.in Fri Feb 21 12:47:22 2003 @@ -150,7 +150,7 @@ dnl AC_CHECK_FUNCS(getopt_long , , [LIBOBJS="$LIBOBJS getopt.o getopt1.o"] ) AC_CHECK_FUNCS(getopt_long, [], []) -AC_CANONICAL_HOST +dnl AC_CANONICAL_HOST case "$host_cpu" in i*86) cpu_ia32=true ; AC_DEFINE(FLAC__CPU_IA32) ;; powerpc) cpu_ppc=true ; AC_DEFINE(FLAC__CPU_PPC) ;; @@ -358,7 +358,7 @@ if test x$debug = xtrue; then OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -g -O0 -DDEBUG" else - OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -O3 -DNDEBUG" + OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -DNDEBUG" if test x$GCC = xyes; then OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -fomit-frame-pointer -funroll-loops -finline-functions -Wall -W -Winline -DFLaC__INLINE=__inline__" fi --- ./ltmain.sh Mon Sep 9 14:12:10 2002 +++ ../flac-1.1.0/./ltmain.sh Fri Feb 21 12:48:26 2003 @@ -61,7 +61,7 @@ default_mode= help="Try \`$progname --help' for more information." magic="%%%MAGIC variable%%%" -mkdir="mkdir" +mkdir="mkdir -p" mv="mv -f" rm="rm -f" --- ./configure Sat Jan 25 13:41:21 2003 +++ ../flac-1.1.0/./configure Fri Feb 21 12:47:50 2003 @@ -11251,7 +11251,7 @@ if test x$debug = xtrue; then OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -g -O0 -DDEBUG" else - OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -O3 -DNDEBUG" + OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -DNDEBUG" if test x$GCC = xyes; then OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -fomit-frame-pointer -funroll-loops -finline-functions -Wall -W -Winline -DFLaC__INLINE=__inline__" fi