diff options
Diffstat (limited to 'src/decoder')
-rw-r--r-- | src/decoder/DsdiffDecoderPlugin.cxx | 11 | ||||
-rw-r--r-- | src/decoder/DsfDecoderPlugin.cxx | 21 | ||||
-rw-r--r-- | src/decoder/VorbisDecoderPlugin.cxx | 11 | ||||
-rw-r--r-- | src/decoder/sidplay_decoder_plugin.cxx | 9 |
4 files changed, 23 insertions, 29 deletions
diff --git a/src/decoder/DsdiffDecoderPlugin.cxx b/src/decoder/DsdiffDecoderPlugin.cxx index 43002768a..c4150dd91 100644 --- a/src/decoder/DsdiffDecoderPlugin.cxx +++ b/src/decoder/DsdiffDecoderPlugin.cxx @@ -33,6 +33,7 @@ #include "CheckAudioFormat.hxx" #include "util/bit_reverse.h" #include "util/Error.hxx" +#include "system/ByteOrder.hxx" #include "tag/TagHandler.hxx" #include "DsdLib.hxx" #include "Log.hxx" @@ -56,8 +57,8 @@ struct DsdiffChunkHeader { */ gcc_const uint64_t GetSize() const { - return (((uint64_t)GUINT32_FROM_BE(size_high)) << 32) | - ((uint64_t)GUINT32_FROM_BE(size_low)); + return (uint64_t(FromBE32(size_high)) << 32) | + uint64_t(FromBE32(size_low)); } }; @@ -141,7 +142,7 @@ dsdiff_read_prop_snd(struct decoder *decoder, struct input_stream *is, sizeof(sample_rate))) return false; - metadata->sample_rate = GUINT32_FROM_BE(sample_rate); + metadata->sample_rate = FromBE32(sample_rate); } else if (dsdlib_id_equals(&header.id, "CHNL")) { uint16_t channels; if (header.GetSize() < sizeof(channels) || @@ -150,7 +151,7 @@ dsdiff_read_prop_snd(struct decoder *decoder, struct input_stream *is, !dsdlib_skip_to(decoder, is, chunk_end_offset)) return false; - metadata->channels = GUINT16_FROM_BE(channels); + metadata->channels = FromBE16(channels); } else if (dsdlib_id_equals(&header.id, "CMPR")) { struct dsdlib_id type; if (header.GetSize() < sizeof(type) || @@ -211,7 +212,7 @@ dsdiff_handle_native_tag(struct input_stream *is, if (!dsdlib_read(nullptr, is, &metatag, sizeof(metatag))) return; - uint32_t length = GUINT32_FROM_BE(metatag.size); + uint32_t length = FromBE32(metatag.size); /* Check and limit size of the tag to prevent a stack overflow */ if (length == 0 || length > 60) diff --git a/src/decoder/DsfDecoderPlugin.cxx b/src/decoder/DsfDecoderPlugin.cxx index 4c4a66aaa..28004e8b7 100644 --- a/src/decoder/DsfDecoderPlugin.cxx +++ b/src/decoder/DsfDecoderPlugin.cxx @@ -34,6 +34,7 @@ #include "CheckAudioFormat.hxx" #include "util/bit_reverse.h" #include "util/Error.hxx" +#include "system/ByteOrder.hxx" #include "DsdLib.hxx" #include "tag/TagHandler.hxx" #include "Log.hxx" @@ -107,16 +108,16 @@ dsf_read_metadata(struct decoder *decoder, struct input_stream *is, !dsdlib_id_equals(&dsf_header.id, "DSD ")) return false; - chunk_size = (((uint64_t)GUINT32_FROM_LE(dsf_header.size_high)) << 32) | - ((uint64_t)GUINT32_FROM_LE(dsf_header.size_low)); + chunk_size = (uint64_t(FromLE32(dsf_header.size_high)) << 32) | + uint64_t(FromLE32(dsf_header.size_low)); if (sizeof(dsf_header) != chunk_size) return false; #ifdef HAVE_ID3TAG uint64_t metadata_offset; - metadata_offset = (((uint64_t)GUINT32_FROM_LE(dsf_header.pmeta_high)) << 32) | - ((uint64_t)GUINT32_FROM_LE(dsf_header.pmeta_low)); + metadata_offset = (uint64_t(FromLE32(dsf_header.pmeta_high)) << 32) | + uint64_t(FromLE32(dsf_header.pmeta_low)); #endif /* read the 'fmt ' chunk of the DSF file */ @@ -126,13 +127,13 @@ dsf_read_metadata(struct decoder *decoder, struct input_stream *is, return false; uint64_t fmt_chunk_size; - fmt_chunk_size = (((uint64_t)GUINT32_FROM_LE(dsf_fmt_chunk.size_high)) << 32) | - ((uint64_t)GUINT32_FROM_LE(dsf_fmt_chunk.size_low)); + fmt_chunk_size = (uint64_t(FromLE32(dsf_fmt_chunk.size_high)) << 32) | + uint64_t(FromLE32(dsf_fmt_chunk.size_low)); if (fmt_chunk_size != sizeof(dsf_fmt_chunk)) return false; - uint32_t samplefreq = (uint32_t)GUINT32_FROM_LE(dsf_fmt_chunk.sample_freq); + uint32_t samplefreq = FromLE32(dsf_fmt_chunk.sample_freq); /* for now, only support version 1 of the standard, DSD raw stereo files with a sample freq of 2822400 Hz */ @@ -143,7 +144,7 @@ dsf_read_metadata(struct decoder *decoder, struct input_stream *is, || samplefreq != 2822400) return false; - uint32_t chblksize = (uint32_t)GUINT32_FROM_LE(dsf_fmt_chunk.block_size); + uint32_t chblksize = FromLE32(dsf_fmt_chunk.block_size); /* according to the spec block size should always be 4096 */ if (chblksize != 4096) return false; @@ -158,8 +159,8 @@ dsf_read_metadata(struct decoder *decoder, struct input_stream *is, we use the actual data size as chunk size */ uint64_t data_size; - data_size = (((uint64_t)GUINT32_FROM_LE(data_chunk.size_high)) << 32) | - ((uint64_t)GUINT32_FROM_LE(data_chunk.size_low)); + data_size = (uint64_t(FromLE32(data_chunk.size_high)) << 32) | + uint64_t(FromLE32(data_chunk.size_low)); data_size -= sizeof(data_chunk); metadata->chunk_size = data_size; diff --git a/src/decoder/VorbisDecoderPlugin.cxx b/src/decoder/VorbisDecoderPlugin.cxx index 9ef5e2eea..52e0609b8 100644 --- a/src/decoder/VorbisDecoderPlugin.cxx +++ b/src/decoder/VorbisDecoderPlugin.cxx @@ -27,6 +27,7 @@ #include "util/Error.hxx" #include "util/UriUtil.hxx" #include "util/Macros.hxx" +#include "system/ByteOrder.hxx" #include "CheckAudioFormat.hxx" #include "tag/TagHandler.hxx" #include "Log.hxx" @@ -47,18 +48,10 @@ #define ov_time_seek_page(VF, S) (ov_time_seek_page(VF, (S)*1000)) #endif /* HAVE_TREMOR */ -#include <glib.h> - #include <assert.h> #include <errno.h> #include <unistd.h> -#if G_BYTE_ORDER == G_BIG_ENDIAN -#define VORBIS_BIG_ENDIAN true -#else -#define VORBIS_BIG_ENDIAN false -#endif - struct vorbis_input_stream { struct decoder *decoder; @@ -248,7 +241,7 @@ vorbis_stream_decode(struct decoder *decoder, #ifdef HAVE_TREMOR long nbytes = ov_read(&vf, buffer, sizeof(buffer), - VORBIS_BIG_ENDIAN, 2, 1, + IsBigEndian(), 2, 1, ¤t_section); #else float **per_channel; diff --git a/src/decoder/sidplay_decoder_plugin.cxx b/src/decoder/sidplay_decoder_plugin.cxx index 486dd816f..5123b493f 100644 --- a/src/decoder/sidplay_decoder_plugin.cxx +++ b/src/decoder/sidplay_decoder_plugin.cxx @@ -21,6 +21,7 @@ #include "../DecoderAPI.hxx" #include "tag/TagHandler.hxx" #include "util/Domain.hxx" +#include "system/ByteOrder.hxx" #include "Log.hxx" #include <errno.h> @@ -265,11 +266,9 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs) config.sidEmulation = &builder; config.sidModel = SID2_MODEL_CORRECT; config.sidSamples = true; -#if G_BYTE_ORDER == G_LITTLE_ENDIAN - config.sampleFormat = SID2_LITTLE_SIGNED; -#else - config.sampleFormat = SID2_BIG_SIGNED; -#endif + config.sampleFormat = IsLittleEndian() + ? SID2_LITTLE_SIGNED + : SID2_BIG_SIGNED; if (tune.isStereo()) { config.playback = sid2_stereo; channels = 2; |