1 /* 2 * Copyright 2003-2021 The Music Player Daemon Project 3 * http://www.musicpd.org 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 #ifndef MPD_DECODER_DSDLIB_HXX 21 #define MPD_DECODER_DSDLIB_HXX 22 23 #include "util/ByteOrder.hxx" 24 #include "input/Offset.hxx" 25 26 #include <cstdint> 27 28 class TagHandler; 29 class DecoderClient; 30 class InputStream; 31 32 struct DsdId { 33 char value[4]; 34 35 [[gnu::pure]] 36 bool Equals(const char *s) const noexcept; 37 }; 38 39 class DsdUint64 { 40 uint32_t lo; 41 uint32_t hi; 42 43 public: Read() const44 constexpr uint64_t Read() const { 45 return (uint64_t(FromLE32(hi)) << 32) | 46 uint64_t(FromLE32(lo)); 47 } 48 }; 49 50 class DffDsdUint64 { 51 uint32_t hi; 52 uint32_t lo; 53 54 public: Read() const55 constexpr uint64_t Read() const { 56 return (uint64_t(FromBE32(hi)) << 32) | 57 uint64_t(FromBE32(lo)); 58 } 59 }; 60 61 bool 62 dsdlib_skip_to(DecoderClient *client, InputStream &is, 63 offset_type offset); 64 65 bool 66 dsdlib_skip(DecoderClient *client, InputStream &is, 67 offset_type delta); 68 69 /** 70 * Check if the sample frequency is a valid DSD frequency. 71 **/ 72 [[gnu::const]] 73 bool 74 dsdlib_valid_freq(uint32_t samplefreq) noexcept; 75 76 /** 77 * Add tags from ID3 tag. All tags commonly found in the ID3 tags of 78 * DSF and DSDIFF files are imported 79 */ 80 void 81 dsdlib_tag_id3(InputStream &is, TagHandler &handler, 82 offset_type tagoffset); 83 84 #endif 85