DSF2FLAC
|
00001 /* 00002 * dsf2flac - http://code.google.com/p/dsf2flac/ 00003 * 00004 * A file conversion tool for translating dsf dsd audio files into 00005 * flac pcm audio files. 00006 * 00007 * Copyright (c) 2013 by respective authors. 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 * 00023 * 00024 * Acknowledgements 00025 * 00026 * Many thanks to the following authors and projects whose work has greatly 00027 * helped the development of this tool. 00028 * 00029 * 00030 * Sebastian Gesemann - dsd2pcm (http://code.google.com/p/dsd2pcm/) 00031 * SACD Ripper (http://code.google.com/p/sacd-ripper/) 00032 * Maxim V.Anisiutkin - foo_input_sacd (http://sourceforge.net/projects/sacddecoder/files/) 00033 * Vladislav Goncharov - foo_input_sacd_hq (http://vladgsound.wordpress.com) 00034 * Jesus R - www.sonore.us 00035 * 00036 */ 00037 00048 #ifndef FILEPLUS_H 00049 #define FILEPLUS_H 00050 00051 #include <fstream> 00052 #include "dsf2flac_types.h" 00053 00054 typedef dsf2flac_uint64 stream_size; 00055 00056 class fstreamPlus : public std::fstream 00057 { 00058 public: 00059 fstreamPlus(); 00060 virtual ~fstreamPlus(); 00061 00063 bool seekg(streampos pos); 00064 bool seekg(streamoff pos, ios_base::seekdir way); 00065 00067 // All return true on error. All read "n" numbers (not n chars/bytes!) 00068 bool read_int8 (dsf2flac_int8* b, stream_size n); 00069 bool read_uint8 (dsf2flac_uint8* b, stream_size n); 00070 bool read_uint16 (dsf2flac_uint16* b, stream_size n); 00071 bool read_uint32 (dsf2flac_uint32* b, stream_size n); 00072 bool read_uint64 (dsf2flac_uint64* b, stream_size n); 00073 00074 00076 // All return true on error. All read "n" numbers (not n chars/bytes!) 00077 bool read_int8_rev (dsf2flac_int8* b,stream_size n) { return read_int8 (b,n); }; 00078 bool read_int32_rev (dsf2flac_int32* b,stream_size n); 00079 bool read_uint8_rev (dsf2flac_uint8* b,stream_size n) { return read_uint8(b,n); }; 00080 bool read_uint16_rev(dsf2flac_uint16* b,stream_size n); 00081 bool read_uint32_rev(dsf2flac_uint32* b,stream_size n); 00082 bool read_uint64_rev(dsf2flac_uint64* b,stream_size n); 00083 00084 00086 template<typename rType> static void reverseByteOrder(rType* b,stream_size n); 00087 template<typename rType> static rType reverseByteOrder(rType b); 00088 00089 char* getFilePath(); 00090 00091 private: 00092 00094 template<typename rType> bool read_helper(rType* b, stream_size n); 00095 template<typename rType> bool read_helper_rev(rType* b, stream_size n); 00096 00097 00098 }; 00099 00100 #endif // FILEPLUS_H