00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef FLAC__FORMAT_H
00033 #define FLAC__FORMAT_H
00034
00035 #include "export.h"
00036 #include "ordinals.h"
00037
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041
00086
00087
00088
00089
00090
00092 #define FLAC__MAX_METADATA_TYPE_CODE (126u)
00093
00095 #define FLAC__MIN_BLOCK_SIZE (16u)
00096
00098 #define FLAC__MAX_BLOCK_SIZE (65535u)
00099
00102 #define FLAC__SUBSET_MAX_BLOCK_SIZE_48000HZ (4608u)
00103
00105 #define FLAC__MAX_CHANNELS (8u)
00106
00108 #define FLAC__MIN_BITS_PER_SAMPLE (4u)
00109
00111 #define FLAC__MAX_BITS_PER_SAMPLE (32u)
00112
00121 #define FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE (24u)
00122
00127 #define FLAC__MAX_SAMPLE_RATE (655350u)
00128
00130 #define FLAC__MAX_LPC_ORDER (32u)
00131
00134 #define FLAC__SUBSET_MAX_LPC_ORDER_48000HZ (12u)
00135
00139 #define FLAC__MIN_QLP_COEFF_PRECISION (5u)
00140
00144 #define FLAC__MAX_QLP_COEFF_PRECISION (15u)
00145
00147 #define FLAC__MAX_FIXED_ORDER (4u)
00148
00150 #define FLAC__MAX_RICE_PARTITION_ORDER (15u)
00151
00153 #define FLAC__SUBSET_MAX_RICE_PARTITION_ORDER (8u)
00154
00161 extern FLAC_API const char *FLAC__VERSION_STRING;
00162
00167 extern FLAC_API const char *FLAC__VENDOR_STRING;
00168
00170 extern FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4];
00171
00175 extern FLAC_API const unsigned FLAC__STREAM_SYNC;
00176
00178 extern FLAC_API const unsigned FLAC__STREAM_SYNC_LEN;
00179
00181 #define FLAC__STREAM_SYNC_LENGTH (4u)
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00193 typedef enum {
00194 FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = 0,
00198 FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = 1
00201 } FLAC__EntropyCodingMethodType;
00202
00208 extern FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[];
00209
00210
00213 typedef struct {
00214
00215 unsigned *parameters;
00218 unsigned *raw_bits;
00223 unsigned capacity_by_order;
00228 } FLAC__EntropyCodingMethod_PartitionedRiceContents;
00229
00232 typedef struct {
00233
00234 unsigned order;
00237 const FLAC__EntropyCodingMethod_PartitionedRiceContents *contents;
00240 } FLAC__EntropyCodingMethod_PartitionedRice;
00241
00242 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN;
00243 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN;
00244 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN;
00245 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN;
00247 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
00249 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER;
00254 typedef struct {
00255 FLAC__EntropyCodingMethodType type;
00256 union {
00257 FLAC__EntropyCodingMethod_PartitionedRice partitioned_rice;
00258 } data;
00259 } FLAC__EntropyCodingMethod;
00260
00261 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_TYPE_LEN;
00263
00264
00266 typedef enum {
00267 FLAC__SUBFRAME_TYPE_CONSTANT = 0,
00268 FLAC__SUBFRAME_TYPE_VERBATIM = 1,
00269 FLAC__SUBFRAME_TYPE_FIXED = 2,
00270 FLAC__SUBFRAME_TYPE_LPC = 3
00271 } FLAC__SubframeType;
00272
00278 extern FLAC_API const char * const FLAC__SubframeTypeString[];
00279
00280
00283 typedef struct {
00284 FLAC__int32 value;
00285 } FLAC__Subframe_Constant;
00286
00287
00290 typedef struct {
00291 const FLAC__int32 *data;
00292 } FLAC__Subframe_Verbatim;
00293
00294
00297 typedef struct {
00298 FLAC__EntropyCodingMethod entropy_coding_method;
00301 unsigned order;
00304 FLAC__int32 warmup[FLAC__MAX_FIXED_ORDER];
00307 const FLAC__int32 *residual;
00309 } FLAC__Subframe_Fixed;
00310
00311
00314 typedef struct {
00315 FLAC__EntropyCodingMethod entropy_coding_method;
00318 unsigned order;
00321 unsigned qlp_coeff_precision;
00324 int quantization_level;
00327 FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER];
00330 FLAC__int32 warmup[FLAC__MAX_LPC_ORDER];
00333 const FLAC__int32 *residual;
00335 } FLAC__Subframe_LPC;
00336
00337 extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN;
00338 extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN;
00343 typedef struct {
00344 FLAC__SubframeType type;
00345 union {
00346 FLAC__Subframe_Constant constant;
00347 FLAC__Subframe_Fixed fixed;
00348 FLAC__Subframe_LPC lpc;
00349 FLAC__Subframe_Verbatim verbatim;
00350 } data;
00351 unsigned wasted_bits;
00352 } FLAC__Subframe;
00353
00361 extern FLAC_API const unsigned FLAC__SUBFRAME_ZERO_PAD_LEN;
00362 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LEN;
00363 extern FLAC_API const unsigned FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN;
00365 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK;
00366 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK;
00367 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK;
00368 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK;
00370
00371
00372
00373
00374
00375
00376
00377
00378
00380 typedef enum {
00381 FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0,
00382 FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1,
00383 FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2,
00384 FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3
00385 } FLAC__ChannelAssignment;
00386
00392 extern FLAC_API const char * const FLAC__ChannelAssignmentString[];
00393
00395 typedef enum {
00396 FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER,
00397 FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER
00398 } FLAC__FrameNumberType;
00399
00405 extern FLAC_API const char * const FLAC__FrameNumberTypeString[];
00406
00407
00410 typedef struct {
00411 unsigned blocksize;
00414 unsigned sample_rate;
00417 unsigned channels;
00420 FLAC__ChannelAssignment channel_assignment;
00423 unsigned bits_per_sample;
00426 FLAC__FrameNumberType number_type;
00431 union {
00432 FLAC__uint32 frame_number;
00433 FLAC__uint64 sample_number;
00434 } number;
00438 FLAC__uint8 crc;
00443 } FLAC__FrameHeader;
00444
00445 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC;
00446 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC_LEN;
00447 extern FLAC_API const unsigned FLAC__FRAME_HEADER_RESERVED_LEN;
00448 extern FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN;
00449 extern FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCK_SIZE_LEN;
00450 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SAMPLE_RATE_LEN;
00451 extern FLAC_API const unsigned FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN;
00452 extern FLAC_API const unsigned FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN;
00453 extern FLAC_API const unsigned FLAC__FRAME_HEADER_ZERO_PAD_LEN;
00454 extern FLAC_API const unsigned FLAC__FRAME_HEADER_CRC_LEN;
00459 typedef struct {
00460 FLAC__uint16 crc;
00465 } FLAC__FrameFooter;
00466
00467 extern FLAC_API const unsigned FLAC__FRAME_FOOTER_CRC_LEN;
00472 typedef struct {
00473 FLAC__FrameHeader header;
00474 FLAC__Subframe subframes[FLAC__MAX_CHANNELS];
00475 FLAC__FrameFooter footer;
00476 } FLAC__Frame;
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00488 typedef enum {
00489
00490 FLAC__METADATA_TYPE_STREAMINFO = 0,
00493 FLAC__METADATA_TYPE_PADDING = 1,
00496 FLAC__METADATA_TYPE_APPLICATION = 2,
00499 FLAC__METADATA_TYPE_SEEKTABLE = 3,
00502 FLAC__METADATA_TYPE_VORBIS_COMMENT = 4,
00505 FLAC__METADATA_TYPE_CUESHEET = 5,
00508 FLAC__METADATA_TYPE_PICTURE = 6,
00511 FLAC__METADATA_TYPE_UNDEFINED = 7
00514 } FLAC__MetadataType;
00515
00521 extern FLAC_API const char * const FLAC__MetadataTypeString[];
00522
00523
00526 typedef struct {
00527 unsigned min_blocksize, max_blocksize;
00528 unsigned min_framesize, max_framesize;
00529 unsigned sample_rate;
00530 unsigned channels;
00531 unsigned bits_per_sample;
00532 FLAC__uint64 total_samples;
00533 FLAC__byte md5sum[16];
00534 } FLAC__StreamMetadata_StreamInfo;
00535
00536 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN;
00537 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN;
00538 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN;
00539 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN;
00540 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN;
00541 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN;
00542 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN;
00543 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN;
00544 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN;
00547 #define FLAC__STREAM_METADATA_STREAMINFO_LENGTH (34u)
00548
00551 typedef struct {
00552 int dummy;
00557 } FLAC__StreamMetadata_Padding;
00558
00559
00562 typedef struct {
00563 FLAC__byte id[4];
00564 FLAC__byte *data;
00565 } FLAC__StreamMetadata_Application;
00566
00567 extern FLAC_API const unsigned FLAC__STREAM_METADATA_APPLICATION_ID_LEN;
00571 typedef struct {
00572 FLAC__uint64 sample_number;
00575 FLAC__uint64 stream_offset;
00579 unsigned frame_samples;
00581 } FLAC__StreamMetadata_SeekPoint;
00582
00583 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN;
00584 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN;
00585 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN;
00588 #define FLAC__STREAM_METADATA_SEEKPOINT_LENGTH (18u)
00589
00594 extern FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
00595
00596
00609 typedef struct {
00610 unsigned num_points;
00611 FLAC__StreamMetadata_SeekPoint *points;
00612 } FLAC__StreamMetadata_SeekTable;
00613
00614
00621 typedef struct {
00622 FLAC__uint32 length;
00623 FLAC__byte *entry;
00624 } FLAC__StreamMetadata_VorbisComment_Entry;
00625
00626 extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN;
00631 typedef struct {
00632 FLAC__StreamMetadata_VorbisComment_Entry vendor_string;
00633 FLAC__uint32 num_comments;
00634 FLAC__StreamMetadata_VorbisComment_Entry *comments;
00635 } FLAC__StreamMetadata_VorbisComment;
00636
00637 extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN;
00644 typedef struct {
00645 FLAC__uint64 offset;
00650 FLAC__byte number;
00652 } FLAC__StreamMetadata_CueSheet_Index;
00653
00654 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN;
00655 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN;
00656 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN;
00663 typedef struct {
00664 FLAC__uint64 offset;
00667 FLAC__byte number;
00670 char isrc[13];
00673 unsigned type:1;
00676 unsigned pre_emphasis:1;
00679 FLAC__byte num_indices;
00682 FLAC__StreamMetadata_CueSheet_Index *indices;
00685 } FLAC__StreamMetadata_CueSheet_Track;
00686
00687 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN;
00688 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN;
00689 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN;
00690 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN;
00691 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN;
00692 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN;
00693 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN;
00700 typedef struct {
00701 char media_catalog_number[129];
00707 FLAC__uint64 lead_in;
00710 FLAC__bool is_cd;
00713 unsigned num_tracks;
00716 FLAC__StreamMetadata_CueSheet_Track *tracks;
00719 } FLAC__StreamMetadata_CueSheet;
00720
00721 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN;
00722 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN;
00723 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN;
00724 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN;
00725 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN;
00729 typedef enum {
00730 FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER = 0,
00731 FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD = 1,
00732 FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON = 2,
00733 FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER = 3,
00734 FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER = 4,
00735 FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE = 5,
00736 FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA = 6,
00737 FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST = 7,
00738 FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST = 8,
00739 FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR = 9,
00740 FLAC__STREAM_METADATA_PICTURE_TYPE_BAND = 10,
00741 FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER = 11,
00742 FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST = 12,
00743 FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION = 13,
00744 FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING = 14,
00745 FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE = 15,
00746 FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE = 16,
00747 FLAC__STREAM_METADATA_PICTURE_TYPE_FISH = 17,
00748 FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION = 18,
00749 FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE = 19,
00750 FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE = 20,
00751 FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED
00752 } FLAC__StreamMetadata_Picture_Type;
00753
00760 extern FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[];
00761
00766 typedef struct {
00767 FLAC__StreamMetadata_Picture_Type type;
00770 char *mime_type;
00781 FLAC__byte *description;
00788 FLAC__uint32 width;
00791 FLAC__uint32 height;
00794 FLAC__uint32 depth;
00797 FLAC__uint32 colors;
00802 FLAC__uint32 data_length;
00805 FLAC__byte *data;
00808 } FLAC__StreamMetadata_Picture;
00809
00810 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_TYPE_LEN;
00811 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN;
00812 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN;
00813 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN;
00814 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN;
00815 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN;
00816 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_COLORS_LEN;
00817 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN;
00824 typedef struct {
00825 FLAC__byte *data;
00826 } FLAC__StreamMetadata_Unknown;
00827
00828
00831 typedef struct {
00832 FLAC__MetadataType type;
00837 FLAC__bool is_last;
00840 unsigned length;
00843 union {
00844 FLAC__StreamMetadata_StreamInfo stream_info;
00845 FLAC__StreamMetadata_Padding padding;
00846 FLAC__StreamMetadata_Application application;
00847 FLAC__StreamMetadata_SeekTable seek_table;
00848 FLAC__StreamMetadata_VorbisComment vorbis_comment;
00849 FLAC__StreamMetadata_CueSheet cue_sheet;
00850 FLAC__StreamMetadata_Picture picture;
00851 FLAC__StreamMetadata_Unknown unknown;
00852 } data;
00855 } FLAC__StreamMetadata;
00856
00857 extern FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN;
00858 extern FLAC_API const unsigned FLAC__STREAM_METADATA_TYPE_LEN;
00859 extern FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN;
00862 #define FLAC__STREAM_METADATA_HEADER_LENGTH (4u)
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00880 FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate);
00881
00891 FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(unsigned sample_rate);
00892
00905 FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name);
00906
00921 FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, unsigned length);
00922
00938 FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, unsigned length);
00939
00950 FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table);
00951
00964 FLAC_API unsigned FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table);
00965
00984 FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation);
00985
01002 FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation);
01003
01004
01005
01006 #ifdef __cplusplus
01007 }
01008 #endif
01009
01010 #endif