1 /* flac - Command-line FLAC encoder/decoder 2 * Copyright (C) 2000-2009 Josh Coalson 3 * Copyright (C) 2011-2023 Xiph.Org Foundation 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (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 flac__foreign_metadata_h 21 #define flac__foreign_metadata_h 22 23 #ifdef HAVE_CONFIG_H 24 # include <config.h> 25 #endif 26 27 #include "FLAC/metadata.h" 28 #include "utils.h" 29 #include "share/compat.h" 30 31 #define FLAC__FOREIGN_METADATA_NUMBER_OF_RECOGNIZED_APPLICATION_IDS 3 32 33 extern const char *FLAC__FOREIGN_METADATA_APPLICATION_ID[FLAC__FOREIGN_METADATA_NUMBER_OF_RECOGNIZED_APPLICATION_IDS]; 34 35 /* WATCHOUT: these enums are used to index internal arrays */ 36 typedef enum { 37 FOREIGN_BLOCK_TYPE__AIFF = 0, /* for AIFF and AIFF-C */ 38 FOREIGN_BLOCK_TYPE__RIFF = 1, /* for WAVE and RF64 */ 39 FOREIGN_BLOCK_TYPE__WAVE64 = 2 /* only for Sony's flavor */ 40 } foreign_block_type_t; 41 42 typedef struct { 43 /* for encoding, this will be the offset in the WAVE/AIFF file of the chunk */ 44 /* for decoding, this will be the offset in the FLAC file of the chunk data inside the APPLICATION block */ 45 FLAC__off_t offset; 46 /* size is the actual size in bytes of the chunk to be stored/recreated. */ 47 /* It includes the 8 bytes of chunk type and size, and any padding byte for alignment. */ 48 /* For 'data'/'SSND' chunks, the size does not include the actual sound or padding bytes */ 49 /* because these are not stored, they are recreated from the compressed FLAC stream. */ 50 /* So for RIFF 'data', size is 8, and for AIFF 'SSND', size is 8 + 8 + ssnd_offset_size */ 51 /* 32 bit size is OK because we only care about the non-sound data and FLAC metadata */ 52 /* only supports a few megs anyway. */ 53 FLAC__uint32 size; 54 } foreign_block_t; 55 56 typedef struct { 57 foreign_block_type_t type; /* currently we don't support multiple foreign types in a stream (and maybe never will) */ 58 foreign_block_t *blocks; 59 size_t num_blocks; 60 size_t format_block; /* block number of 'fmt ' or 'COMM' chunk */ 61 size_t audio_block; /* block number of 'data' or 'SSND' chunk */ 62 FLAC__bool is_rf64; /* always false if type!=RIFF */ 63 FLAC__bool is_wavefmtex; /* always false if type!=RIFF */ 64 FLAC__bool is_aifc; /* always false if type!=AIFF */ 65 FLAC__bool is_sowt; /* always false if type!=AIFF */ 66 FLAC__uint32 aifc_comm_length; 67 FLAC__uint32 ssnd_offset_size; /* 0 if type!=AIFF */ 68 } foreign_metadata_t; 69 70 foreign_metadata_t *flac__foreign_metadata_new(foreign_block_type_t type); 71 72 void flac__foreign_metadata_delete(foreign_metadata_t *fm); 73 74 FLAC__bool flac__foreign_metadata_read_from_aiff(foreign_metadata_t *fm, const char *filename, const char **error); 75 FLAC__bool flac__foreign_metadata_read_from_wave(foreign_metadata_t *fm, const char *filename, const char **error); 76 FLAC__bool flac__foreign_metadata_read_from_wave64(foreign_metadata_t *fm, const char *filename, const char **error); 77 FLAC__bool flac__foreign_metadata_write_to_flac(foreign_metadata_t *fm, const char *infilename, const char *outfilename, const char **error); 78 79 FLAC__bool flac__foreign_metadata_read_from_flac(foreign_metadata_t *fm, const char *filename, const char **error); 80 FLAC__bool flac__foreign_metadata_write_to_iff(foreign_metadata_t *fm, const char *infilename, const char *outfilename, FLAC__off_t offset1, FLAC__off_t offset2, FLAC__off_t offset3, const char **error); 81 FLAC__bool flac__foreign_metadata_compare_with_iff(foreign_metadata_t *fm, const char *infilename, const char *outfilename, FLAC__off_t offset3, const char **error); 82 83 #endif 84