1 /* 2 * This program is free software; you can redistribute it and/or modify 3 * it under the terms of the GNU General Public License as published by 4 * the Free Software Foundation; either version 2 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software 14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 */ 16 17 // Enable for debug output 18 //#define AUDIO_SCAN_DEBUG 19 20 #ifdef AUDIO_SCAN_DEBUG 21 # define DEBUG_TRACE(...) PerlIO_printf(PerlIO_stderr(), __VA_ARGS__) 22 #else 23 # define DEBUG_TRACE(...) 24 #endif 25 26 #define LOG_WARN(...) warn(__VA_ARGS__) 27 28 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) 29 # define _PACKED __attribute((packed)) 30 #else 31 # define _PACKED 32 #endif 33 34 #define DEFAULT_BLOCK_SIZE 4096 35 36 #ifndef _MSC_VER 37 // We use the built-in GUID type on Windows 38 typedef struct _GUID { 39 uint32_t Data1; 40 uint16_t Data2; 41 uint16_t Data3; 42 uint8_t Data4[8]; 43 } _PACKED GUID; 44 #endif 45 46 /* for PRIu64 */ 47 #ifdef _MSC_VER 48 #include "pinttypes.h" 49 #else 50 #include <inttypes.h> 51 #endif 52 53 #define HAS_GUID 54 #include "buffer.h" 55 56 /* strlen the length automatically */ 57 #define my_hv_store(a,b,c) hv_store(a,b,strlen(b),c,0) 58 #define my_hv_store_ent(a,b,c) hv_store_ent(a,b,c,0) 59 #define my_hv_fetch(a,b) hv_fetch(a,b,strlen(b),0) 60 #define my_hv_exists(a,b) hv_exists(a,b,strlen(b)) 61 #define my_hv_exists_ent(a,b) hv_exists_ent(a,b,0) 62 #define my_hv_delete(a,b) hv_delete(a,b,strlen(b),0) 63 64 #define GET_INT32BE(b) \ 65 (i = (b[0] << 24) | (b[1] << 16) | b[2] << 8 | b[3], b += 4, i) 66 67 #define GET_INT16BE(b) \ 68 (i = (b[0] << 8) | b[1], b += 2, i) 69 70 #define CONVERT_INT32LE(b) \ 71 (i = (b[3] << 24) | (b[2] << 16) | b[1] << 8 | b[0], i) 72 73 #define CONVERT_INT16LE(b) \ 74 (i = (b[1] << 8) | b[0], i) 75 76 int _check_buf(PerlIO *infile, Buffer *buf, int size, int min_size); 77 void _split_vorbis_comment(char* comment, HV* tags); 78 int32_t skip_id3v2(PerlIO *infile); 79 uint32_t _bitrate(uint32_t audio_size, uint32_t song_length_ms); 80 off_t _file_size(PerlIO *infile); 81 int _env_true(const char *name); 82 int _decode_base64(char *s); 83 HV * _decode_flac_picture(PerlIO *infile, Buffer *buf, uint32_t *pic_length); 84