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
00101 #define FLAC__MAX_CHANNELS (8u)
00102
00104 #define FLAC__MIN_BITS_PER_SAMPLE (4u)
00105
00107 #define FLAC__MAX_BITS_PER_SAMPLE (32u)
00108
00117 #define FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE (24u)
00118
00123 #define FLAC__MAX_SAMPLE_RATE (655350u)
00124
00126 #define FLAC__MAX_LPC_ORDER (32u)
00127
00131 #define FLAC__MIN_QLP_COEFF_PRECISION (5u)
00132
00136 #define FLAC__MAX_QLP_COEFF_PRECISION (15u)
00137
00139 #define FLAC__MAX_FIXED_ORDER (4u)
00140
00142 #define FLAC__MAX_RICE_PARTITION_ORDER (15u)
00143
00145 #define FLAC__SUBSET_MAX_RICE_PARTITION_ORDER (8u)
00146
00153 extern FLAC_API const char *FLAC__VERSION_STRING;
00154
00159 extern FLAC_API const char *FLAC__VENDOR_STRING;
00160
00162 extern FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4];
00163
00167 extern FLAC_API const unsigned FLAC__STREAM_SYNC;
00168
00170 extern FLAC_API const unsigned FLAC__STREAM_SYNC_LEN;
00171
00173 #define FLAC__STREAM_SYNC_LENGTH (4u)
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00185 typedef enum {
00186 FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = 0
00189 } FLAC__EntropyCodingMethodType;
00190
00196 extern FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[];
00197
00198
00201 typedef struct {
00202
00203 unsigned *parameters;
00206 unsigned *raw_bits;
00209 unsigned capacity_by_order;
00214 } FLAC__EntropyCodingMethod_PartitionedRiceContents;
00215
00218 typedef struct {
00219
00220 unsigned order;
00223 const FLAC__EntropyCodingMethod_PartitionedRiceContents *contents;
00226 } FLAC__EntropyCodingMethod_PartitionedRice;
00227
00228 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN;
00229 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN;
00230 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN;
00232 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
00237 typedef struct {
00238 FLAC__EntropyCodingMethodType type;
00239 union {
00240 FLAC__EntropyCodingMethod_PartitionedRice partitioned_rice;
00241 } data;
00242 } FLAC__EntropyCodingMethod;
00243
00244 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_TYPE_LEN;
00246
00247
00249 typedef enum {
00250 FLAC__SUBFRAME_TYPE_CONSTANT = 0,
00251 FLAC__SUBFRAME_TYPE_VERBATIM = 1,
00252 FLAC__SUBFRAME_TYPE_FIXED = 2,
00253 FLAC__SUBFRAME_TYPE_LPC = 3
00254 } FLAC__SubframeType;
00255
00261 extern FLAC_API const char * const FLAC__SubframeTypeString[];
00262
00263
00266 typedef struct {
00267 FLAC__int32 value;
00268 } FLAC__Subframe_Constant;
00269
00270
00273 typedef struct {
00274 const FLAC__int32 *data;
00275 } FLAC__Subframe_Verbatim;
00276
00277
00280 typedef struct {
00281 FLAC__EntropyCodingMethod entropy_coding_method;
00284 unsigned order;
00287 FLAC__int32 warmup[FLAC__MAX_FIXED_ORDER];
00290 const FLAC__int32 *residual;
00292 } FLAC__Subframe_Fixed;
00293
00294
00297 typedef struct {
00298 FLAC__EntropyCodingMethod entropy_coding_method;
00301 unsigned order;
00304 unsigned qlp_coeff_precision;
00307 int quantization_level;
00310 FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER];
00313 FLAC__int32 warmup[FLAC__MAX_LPC_ORDER];
00316 const FLAC__int32 *residual;
00318 } FLAC__Subframe_LPC;
00319
00320 extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN;
00321 extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN;
00326 typedef struct {
00327 FLAC__SubframeType type;
00328 union {
00329 FLAC__Subframe_Constant constant;
00330 FLAC__Subframe_Fixed fixed;
00331 FLAC__Subframe_LPC lpc;
00332 FLAC__Subframe_Verbatim verbatim;
00333 } data;
00334 unsigned wasted_bits;
00335 } FLAC__Subframe;
00336
00337 extern FLAC_API const unsigned FLAC__SUBFRAME_ZERO_PAD_LEN;
00338 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LEN;
00339 extern FLAC_API const unsigned FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN;
00341 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK;
00342 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK;
00343 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK;
00344 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK;
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00356 typedef enum {
00357 FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0,
00358 FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1,
00359 FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2,
00360 FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3
00361 } FLAC__ChannelAssignment;
00362
00368 extern FLAC_API const char * const FLAC__ChannelAssignmentString[];
00369
00371 typedef enum {
00372 FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER,
00373 FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER
00374 } FLAC__FrameNumberType;
00375
00381 extern FLAC_API const char * const FLAC__FrameNumberTypeString[];
00382
00383
00386 typedef struct {
00387 unsigned blocksize;
00390 unsigned sample_rate;
00393 unsigned channels;
00396 FLAC__ChannelAssignment channel_assignment;
00399 unsigned bits_per_sample;
00402 FLAC__FrameNumberType number_type;
00405 union {
00406 FLAC__uint32 frame_number;
00407 FLAC__uint64 sample_number;
00408 } number;
00412 FLAC__uint8 crc;
00417 } FLAC__FrameHeader;
00418
00419 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC;
00420 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC_LEN;
00421 extern FLAC_API const unsigned FLAC__FRAME_HEADER_RESERVED_LEN;
00422 extern FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCK_SIZE_LEN;
00423 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SAMPLE_RATE_LEN;
00424 extern FLAC_API const unsigned FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN;
00425 extern FLAC_API const unsigned FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN;
00426 extern FLAC_API const unsigned FLAC__FRAME_HEADER_ZERO_PAD_LEN;
00427 extern FLAC_API const unsigned FLAC__FRAME_HEADER_CRC_LEN;
00432 typedef struct {
00433 FLAC__uint16 crc;
00438 } FLAC__FrameFooter;
00439
00440 extern FLAC_API const unsigned FLAC__FRAME_FOOTER_CRC_LEN;
00445 typedef struct {
00446 FLAC__FrameHeader header;
00447 FLAC__Subframe subframes[FLAC__MAX_CHANNELS];
00448 FLAC__FrameFooter footer;
00449 } FLAC__Frame;
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00461 typedef enum {
00462
00463 FLAC__METADATA_TYPE_STREAMINFO = 0,
00466 FLAC__METADATA_TYPE_PADDING = 1,
00469 FLAC__METADATA_TYPE_APPLICATION = 2,
00472 FLAC__METADATA_TYPE_SEEKTABLE = 3,
00475 FLAC__METADATA_TYPE_VORBIS_COMMENT = 4,
00478 FLAC__METADATA_TYPE_CUESHEET = 5,
00481 FLAC__METADATA_TYPE_UNDEFINED = 6
00484 } FLAC__MetadataType;
00485
00491 extern FLAC_API const char * const FLAC__MetadataTypeString[];
00492
00493
00496 typedef struct {
00497 unsigned min_blocksize, max_blocksize;
00498 unsigned min_framesize, max_framesize;
00499 unsigned sample_rate;
00500 unsigned channels;
00501 unsigned bits_per_sample;
00502 FLAC__uint64 total_samples;
00503 FLAC__byte md5sum[16];
00504 } FLAC__StreamMetadata_StreamInfo;
00505
00506 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN;
00507 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN;
00508 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN;
00509 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN;
00510 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN;
00511 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN;
00512 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN;
00513 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN;
00514 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN;
00517 #define FLAC__STREAM_METADATA_STREAMINFO_LENGTH (34u)
00518
00521 typedef struct {
00522 int dummy;
00527 } FLAC__StreamMetadata_Padding;
00528
00529
00532 typedef struct {
00533 FLAC__byte id[4];
00534 FLAC__byte *data;
00535 } FLAC__StreamMetadata_Application;
00536
00537 extern FLAC_API const unsigned FLAC__STREAM_METADATA_APPLICATION_ID_LEN;
00541 typedef struct {
00542 FLAC__uint64 sample_number;
00545 FLAC__uint64 stream_offset;
00549 unsigned frame_samples;
00551 } FLAC__StreamMetadata_SeekPoint;
00552
00553 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN;
00554 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN;
00555 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN;
00558 #define FLAC__STREAM_METADATA_SEEKPOINT_LENGTH (18u)
00559
00564 extern FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
00565
00566
00579 typedef struct {
00580 unsigned num_points;
00581 FLAC__StreamMetadata_SeekPoint *points;
00582 } FLAC__StreamMetadata_SeekTable;
00583
00584
00587 typedef struct {
00588 FLAC__uint32 length;
00589 FLAC__byte *entry;
00590 } FLAC__StreamMetadata_VorbisComment_Entry;
00591
00592 extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN;
00597 typedef struct {
00598 FLAC__StreamMetadata_VorbisComment_Entry vendor_string;
00599 FLAC__uint32 num_comments;
00600 FLAC__StreamMetadata_VorbisComment_Entry *comments;
00601 } FLAC__StreamMetadata_VorbisComment;
00602
00603 extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN;
00610 typedef struct {
00611 FLAC__uint64 offset;
00616 FLAC__byte number;
00618 } FLAC__StreamMetadata_CueSheet_Index;
00619
00620 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN;
00621 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN;
00622 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN;
00629 typedef struct {
00630 FLAC__uint64 offset;
00633 FLAC__byte number;
00636 char isrc[13];
00639 unsigned type:1;
00642 unsigned pre_emphasis:1;
00645 FLAC__byte num_indices;
00648 FLAC__StreamMetadata_CueSheet_Index *indices;
00651 } FLAC__StreamMetadata_CueSheet_Track;
00652
00653 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN;
00654 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN;
00655 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN;
00656 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN;
00657 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN;
00658 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN;
00659 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN;
00666 typedef struct {
00667 char media_catalog_number[129];
00673 FLAC__uint64 lead_in;
00676 FLAC__bool is_cd;
00679 unsigned num_tracks;
00682 FLAC__StreamMetadata_CueSheet_Track *tracks;
00685 } FLAC__StreamMetadata_CueSheet;
00686
00687 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN;
00688 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN;
00689 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN;
00690 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN;
00691 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN;
00698 typedef struct {
00699 FLAC__byte *data;
00700 } FLAC__StreamMetadata_Unknown;
00701
00702
00705 typedef struct {
00706 FLAC__MetadataType type;
00711 FLAC__bool is_last;
00714 unsigned length;
00717 union {
00718 FLAC__StreamMetadata_StreamInfo stream_info;
00719 FLAC__StreamMetadata_Padding padding;
00720 FLAC__StreamMetadata_Application application;
00721 FLAC__StreamMetadata_SeekTable seek_table;
00722 FLAC__StreamMetadata_VorbisComment vorbis_comment;
00723 FLAC__StreamMetadata_CueSheet cue_sheet;
00724 FLAC__StreamMetadata_Unknown unknown;
00725 } data;
00728 } FLAC__StreamMetadata;
00729
00730 extern FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN;
00731 extern FLAC_API const unsigned FLAC__STREAM_METADATA_TYPE_LEN;
00732 extern FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN;
00735 #define FLAC__STREAM_METADATA_HEADER_LENGTH (4u)
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00755 FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate);
00756
00757
00768 FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table);
00769
00770
00783 FLAC_API unsigned FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table);
00784
00785
00804 FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation);
00805
00806
00807
00808 #ifdef __cplusplus
00809 }
00810 #endif
00811
00812 #endif