diff options
author | Max Kellermann <max@duempel.org> | 2014-08-19 22:39:44 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-19 22:39:44 +0200 |
commit | e2adb82e29940c4fc784cef21e6cd1ae389e7a2e (patch) | |
tree | 38422743bdb2ae60455bddb3e8d0e7d2c88f721b /src/decoder | |
parent | bb472206dee0adcff09b2efccfb5795101b45705 (diff) | |
download | mpd-e2adb82e29940c4fc784cef21e6cd1ae389e7a2e.tar.gz mpd-e2adb82e29940c4fc784cef21e6cd1ae389e7a2e.tar.xz mpd-e2adb82e29940c4fc784cef21e6cd1ae389e7a2e.zip |
decoder/DsdLib: use offset_type instead of uint64_t
Diffstat (limited to 'src/decoder')
-rw-r--r-- | src/decoder/plugins/DsdLib.cxx | 6 | ||||
-rw-r--r-- | src/decoder/plugins/DsdLib.hxx | 5 | ||||
-rw-r--r-- | src/decoder/plugins/DsdiffDecoderPlugin.cxx | 19 | ||||
-rw-r--r-- | src/decoder/plugins/DsfDecoderPlugin.cxx | 23 |
4 files changed, 26 insertions, 27 deletions
diff --git a/src/decoder/plugins/DsdLib.cxx b/src/decoder/plugins/DsdLib.cxx index 2f873bac9..d7eb5f7a3 100644 --- a/src/decoder/plugins/DsdLib.cxx +++ b/src/decoder/plugins/DsdLib.cxx @@ -50,12 +50,12 @@ DsdId::Equals(const char *s) const */ bool dsdlib_skip_to(Decoder *decoder, InputStream &is, - uint64_t offset) + offset_type offset) { if (is.IsSeekable()) return is.Seek(offset, IgnoreError()); - if (uint64_t(is.GetOffset()) > offset) + if (is.GetOffset() > offset) return false; return dsdlib_skip(decoder, is, offset - is.GetOffset()); @@ -66,7 +66,7 @@ dsdlib_skip_to(Decoder *decoder, InputStream &is, */ bool dsdlib_skip(Decoder *decoder, InputStream &is, - uint64_t delta) + offset_type delta) { if (delta == 0) return true; diff --git a/src/decoder/plugins/DsdLib.hxx b/src/decoder/plugins/DsdLib.hxx index 4d5830702..8295bcbf6 100644 --- a/src/decoder/plugins/DsdLib.hxx +++ b/src/decoder/plugins/DsdLib.hxx @@ -21,6 +21,7 @@ #define MPD_DECODER_DSDLIB_HXX #include "system/ByteOrder.hxx" +#include "input/Offset.hxx" #include "Compiler.h" #include <stddef.h> @@ -60,11 +61,11 @@ public: bool dsdlib_skip_to(Decoder *decoder, InputStream &is, - uint64_t offset); + offset_type offset); bool dsdlib_skip(Decoder *decoder, InputStream &is, - uint64_t delta); + offset_type delta); /** * Check if the sample frequency is a valid DSD frequency. diff --git a/src/decoder/plugins/DsdiffDecoderPlugin.cxx b/src/decoder/plugins/DsdiffDecoderPlugin.cxx index 3395f9881..7288d4142 100644 --- a/src/decoder/plugins/DsdiffDecoderPlugin.cxx +++ b/src/decoder/plugins/DsdiffDecoderPlugin.cxx @@ -66,7 +66,7 @@ struct dsdiff_native_tag { struct DsdiffMetaData { unsigned sample_rate, channels; bool bitreverse; - uint64_t chunk_size; + offset_type chunk_size; }; static bool lsbitfirst; @@ -113,7 +113,7 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is, offset_type end_offset) { DsdiffChunkHeader header; - while (offset_type(is.GetOffset() + sizeof(header)) <= end_offset) { + while (is.GetOffset() + sizeof(header) <= end_offset) { if (!dsdiff_read_chunk_header(decoder, is, &header)) return false; @@ -252,7 +252,7 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is, and record their position and size */ do { - uint64_t chunk_size = chunk_header->GetSize(); + offset_type chunk_size = chunk_header->GetSize(); /* DIIN chunk, is directly followed by other chunks */ if (chunk_header->id.Equals("DIIN")) @@ -328,12 +328,12 @@ dsdiff_read_metadata(Decoder *decoder, InputStream &is, chunk_header)) return false; } else if (chunk_header->id.Equals("DSD ")) { - const uint64_t chunk_size = chunk_header->GetSize(); + const offset_type chunk_size = chunk_header->GetSize(); metadata->chunk_size = chunk_size; return true; } else { /* ignore unknown chunk */ - const uint64_t chunk_size = chunk_header->GetSize(); + const offset_type chunk_size = chunk_header->GetSize(); const offset_type chunk_end_offset = is.GetOffset() + chunk_size; @@ -356,7 +356,7 @@ bit_reverse_buffer(uint8_t *p, uint8_t *end) static bool dsdiff_decode_chunk(Decoder &decoder, InputStream &is, unsigned channels, unsigned sample_rate, - uint64_t chunk_size) + offset_type chunk_size) { uint8_t buffer[8192]; @@ -370,9 +370,8 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is, /* see how much aligned data from the remaining chunk fits into the local buffer */ size_t now_size = buffer_size; - if (chunk_size < (uint64_t)now_size) { - unsigned now_frames = - (unsigned)chunk_size / frame_size; + if (chunk_size < (offset_type)now_size) { + unsigned now_frames = chunk_size / frame_size; now_size = now_frames * frame_size; } @@ -425,7 +424,7 @@ dsdiff_stream_decode(Decoder &decoder, InputStream &is) } /* calculate song time from DSD chunk size and sample frequency */ - uint64_t chunk_size = metadata.chunk_size; + offset_type chunk_size = metadata.chunk_size; float songtime = ((chunk_size / metadata.channels) * 8) / (float) metadata.sample_rate; diff --git a/src/decoder/plugins/DsfDecoderPlugin.cxx b/src/decoder/plugins/DsfDecoderPlugin.cxx index 19687d06d..08ea6415f 100644 --- a/src/decoder/plugins/DsfDecoderPlugin.cxx +++ b/src/decoder/plugins/DsfDecoderPlugin.cxx @@ -42,7 +42,7 @@ struct DsfMetaData { unsigned sample_rate, channels; bool bitreverse; - uint64_t chunk_size; + offset_type chunk_size; #ifdef HAVE_ID3TAG offset_type id3_offset; uint64_t id3_size; @@ -104,12 +104,12 @@ dsf_read_metadata(Decoder *decoder, InputStream &is, !dsf_header.id.Equals("DSD ")) return false; - const uint64_t chunk_size = dsf_header.size.Read(); + const offset_type chunk_size = dsf_header.size.Read(); if (sizeof(dsf_header) != chunk_size) return false; #ifdef HAVE_ID3TAG - const uint64_t metadata_offset = dsf_header.pmeta.Read(); + const offset_type metadata_offset = dsf_header.pmeta.Read(); #endif /* read the 'fmt ' chunk of the DSF file */ @@ -148,7 +148,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is, /* data size of DSF files are padded to multiple of 4096, we use the actual data size as chunk size */ - uint64_t data_size = data_chunk.size.Read(); + offset_type data_size = data_chunk.size.Read(); if (data_size < sizeof(data_chunk)) return false; @@ -156,7 +156,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is, /* data_size cannot be bigger or equal to total file size */ if (is.KnownSize()) { - const uint64_t size = (uint64_t)is.GetSize(); + const offset_type size = is.GetSize(); if (data_size >= size) return false; } @@ -165,7 +165,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is, bound, because some DSF files contain junk at the end of the "data" chunk */ const uint64_t samplecnt = dsf_fmt_chunk.scnt.Read(); - const uint64_t playable_size = samplecnt * 2 / 8; + const offset_type playable_size = samplecnt * 2 / 8; if (data_size > playable_size) data_size = playable_size; @@ -173,7 +173,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is, metadata->channels = (unsigned) dsf_fmt_chunk.channelnum; metadata->sample_rate = samplefreq; #ifdef HAVE_ID3TAG - metadata->id3_offset = (offset_type)metadata_offset; + metadata->id3_offset = metadata_offset; #endif /* check bits per sample format, determine if bitreverse is needed */ metadata->bitreverse = dsf_fmt_chunk.bitssample == 1; @@ -218,7 +218,7 @@ dsf_to_pcm_order(uint8_t *dest, uint8_t *scratch, size_t nrbytes) static bool dsf_decode_chunk(Decoder &decoder, InputStream &is, unsigned channels, unsigned sample_rate, - uint64_t chunk_size, + offset_type chunk_size, bool bitreverse) { uint8_t buffer[8192]; @@ -237,9 +237,8 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is, /* see how much aligned data from the remaining chunk fits into the local buffer */ size_t now_size = buffer_size; - if (chunk_size < (uint64_t)now_size) { - unsigned now_frames = - (unsigned)chunk_size / frame_size; + if (chunk_size < now_size) { + unsigned now_frames = chunk_size / frame_size; now_size = now_frames * frame_size; } @@ -291,7 +290,7 @@ dsf_stream_decode(Decoder &decoder, InputStream &is) return; } /* Calculate song time from DSD chunk size and sample frequency */ - uint64_t chunk_size = metadata.chunk_size; + offset_type chunk_size = metadata.chunk_size; float songtime = ((chunk_size / metadata.channels) * 8) / (float) metadata.sample_rate; |