*
*****************************************************************************/
-typedef enum {
- FLAC__METADATA_TYPE_ENCODING = 0
-} FLAC__MetaDataType;
/*****************************************************************************
*
- * 16: minimum blocksize (in samples) of all blocks in the stream
- * 16: maximum blocksize (in samples) of all blocks in the stream
- * 24: minimum framesize (in bytes) of all frames in the stream; 0 => unknown
- * 24: maximum framesize (in bytes) of all frames in the stream; 0 => unknown
- * 20: sample rate in Hz, 0 is invalid
- * 3: (number of channels)-1
- * 5: (bits per sample)-1
- * 36: total samples, 0 => unknown
- *128: MD5 digest of the original unencoded audio data
- *---- -----------------
- * 34 bytes total
- */
-typedef struct {
- unsigned min_blocksize, max_blocksize;
- unsigned min_framesize, max_framesize;
- unsigned sample_rate;
- unsigned channels;
- unsigned bits_per_sample;
- uint64 total_samples;
- byte md5sum[16];
-} FLAC__StreamMetaData_Encoding;
-
-extern const unsigned FLAC__STREAM_METADATA_ENCODING_MIN_BLOCK_SIZE_LEN; /* = 16 bits */
-extern const unsigned FLAC__STREAM_METADATA_ENCODING_MAX_BLOCK_SIZE_LEN; /* = 16 bits */
-extern const unsigned FLAC__STREAM_METADATA_ENCODING_MIN_FRAME_SIZE_LEN; /* = 24 bits */
-extern const unsigned FLAC__STREAM_METADATA_ENCODING_MAX_FRAME_SIZE_LEN; /* = 24 bits */
-extern const unsigned FLAC__STREAM_METADATA_ENCODING_SAMPLE_RATE_LEN; /* = 20 bits */
-extern const unsigned FLAC__STREAM_METADATA_ENCODING_CHANNELS_LEN; /* = 3 bits */
-extern const unsigned FLAC__STREAM_METADATA_ENCODING_BITS_PER_SAMPLE_LEN; /* = 5 bits */
-extern const unsigned FLAC__STREAM_METADATA_ENCODING_TOTAL_SAMPLES_LEN; /* = 36 bits */
-extern const unsigned FLAC__STREAM_METADATA_ENCODING_MD5SUM_LEN; /* = 128 bits */
-extern const unsigned FLAC__STREAM_METADATA_ENCODING_LENGTH; /* = 34 bytes */
-
-/*****************************************************************************
+ * Subframe structures
*
- * 1: =1 if this is the last meta-data block, else =0
- * 7: meta-data type (c.f. FLAC__MetaDataType)
- * 24: length (in bytes) of the block-specific data to follow
- *---- -----------------
- * 4 bytes total
- */
-typedef struct {
- FLAC__MetaDataType type;
- bool is_last;
- unsigned length; /* in bytes */
- union {
- FLAC__StreamMetaData_Encoding encoding;
- } data;
-} FLAC__StreamMetaData;
-
-extern const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN; /* = 1 bits */
-extern const unsigned FLAC__STREAM_METADATA_TYPE_LEN; /* = 7 bits */
-extern const unsigned FLAC__STREAM_METADATA_LENGTH_LEN; /* = 24 bits */
+ *****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
typedef enum {
+ FLAC__SUBFRAME_TYPE_CONSTANT = 0,
+ FLAC__SUBFRAME_TYPE_VERBATIM = 1,
+ FLAC__SUBFRAME_TYPE_FIXED = 2,
+ FLAC__SUBFRAME_TYPE_LPC = 3
+} FLAC__SubframeType;
+
+/*****************************************************************************
+ *
+ * n: constant value for signal; n = frame's bits-per-sample
+ */
+typedef struct {
+ int32 value;
+} FLAC__SubframeHeader_Constant;
+
+/*****************************************************************************
+ *
+ * n*i: unencoded signal; n = frame's bits-per-sample, i = frame's blocksize
+ */
+/* There is no (trivial) for structure FLAC__SubframeHeader_Verbatim */
+
+/*****************************************************************************
+ *
+ * n: unencoded warm-up samples (n = fixed-predictor order * bits per sample)
+ * ?: entropy coding method info
+ * ?: encoded residual ((blocksize minus fixed-predictor order) samples)
+ * The order is stored in the main subframe header
+ */
+typedef struct {
+ FLAC__EntropyCodingMethod entropy_coding_method;
+ unsigned order;
+ int32 warmup[FLAC__MAX_FIXED_ORDER];
+} FLAC__SubframeHeader_Fixed;
+
+/*****************************************************************************
+ *
+ * n: unencoded warm-up samples (n = lpc order * bits per sample)
+ * 4: (qlp coeff precision in bits)-1 (1111 = invalid, use to check for erroneous sync)
+ * 5: qlp shift needed in bits (signed)
+ * n: unencoded predictor coefficients (n = lpc order * qlp coeff precision)
+ * ?: entropy coding method info
+ * ?: encoded residual ((blocksize minus lpc order) samples)
+ * The order is stored in the main subframe header
+ */
+typedef struct {
+ FLAC__EntropyCodingMethod entropy_coding_method;
+ unsigned order;
+ unsigned qlp_coeff_precision;
+ int quantization_level;
+ int32 qlp_coeff[FLAC__MAX_LPC_ORDER];
+ int32 warmup[FLAC__MAX_LPC_ORDER];
+} FLAC__SubframeHeader_LPC;
+
+extern const unsigned FLAC__SUBFRAME_HEADER_LPC_QLP_COEFF_PRECISION_LEN; /* = 4 bits */
+extern const unsigned FLAC__SUBFRAME_HEADER_LPC_QLP_SHIFT_LEN; /* = 5 bits */
+
+/*****************************************************************************
+ *
+ * 8: subframe type
+ * xxxxxxx1: invalid, to prevent sync-fooling string of 1s (use to check for erroneous sync)
+ * 00000000: constant value
+ * 00000010: verbatim
+ * 000001x0: reserved
+ * 00001xx0: reserved
+ * 0001xxx0: fixed predictor, xxx=order <= 4, else reserved
+ * 001xxxx0: reserved
+ * 01xxxxx0: lpc, xxxxx=order-1
+ * 1xxxxxxx: invalid, to prevent sync-fooling string of 1s (use to check for erroneous sync)
+ * ?: subframe-specific header (c.f. FLAC__SubframeHeader_*)
+ */
+typedef struct {
+ FLAC__SubframeType type;
+ union {
+ FLAC__SubframeHeader_Constant constant;
+ FLAC__SubframeHeader_Fixed fixed;
+ FLAC__SubframeHeader_LPC lpc;
+ } data; /* data will be undefined for FLAC__SUBFRAME_TYPE_VERBATIM */
+} FLAC__SubframeHeader;
+
+extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_CONSTANT; /* = 0x00 */
+extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_VERBATIM; /* = 0x02 */
+extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_FIXED; /* = 0x10 */
+extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_LPC; /* = 0x40 */
+extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_LEN; /* = 8 bits */
+
+typedef struct {
+ FLAC__SubframeHeader header;
+ const int32 *data;
+} FLAC__Subframe;
+
+/*****************************************************************************/
+
+
+/*****************************************************************************
+ *
+ * Frame structures
+ *
+ *****************************************************************************/
+
+typedef enum {
FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0,
FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1,
FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2,
extern const unsigned FLAC__FRAME_HEADER_ZERO_PAD_LEN; /* = 1 bit */
extern const unsigned FLAC__FRAME_HEADER_CRC8_LEN; /* = 8 bits */
+typedef struct {
+ FLAC__FrameHeader header;
+ FLAC__Subframe subframes[FLAC__MAX_CHANNELS];
+} FLAC__Frame;
+
/*****************************************************************************/
-typedef enum {
- FLAC__SUBFRAME_TYPE_CONSTANT = 0,
- FLAC__SUBFRAME_TYPE_VERBATIM = 1,
- FLAC__SUBFRAME_TYPE_FIXED = 2,
- FLAC__SUBFRAME_TYPE_LPC = 3
-} FLAC__SubframeType;
/*****************************************************************************
*
- * n: constant value for signal; n = frame's bits-per-sample
- */
-typedef struct {
- int32 value;
-} FLAC__SubframeHeader_Constant;
-
-/*****************************************************************************
+ * Meta-data structures
*
- * n*i: unencoded signal; n = frame's bits-per-sample, i = frame's blocksize
- */
-/* There is no (trivial) for structure FLAC__SubframeHeader_Verbatim */
+ *****************************************************************************/
+
+typedef enum {
+ FLAC__METADATA_TYPE_ENCODING = 0
+} FLAC__MetaDataType;
/*****************************************************************************
*
- * n: unencoded warm-up samples (n = fixed-predictor order * bits per sample)
- * ?: entropy coding method info
- * ?: encoded residual ((blocksize minus fixed-predictor order) samples)
- * The order is stored in the main subframe header
+ * 16: minimum blocksize (in samples) of all blocks in the stream
+ * 16: maximum blocksize (in samples) of all blocks in the stream
+ * 24: minimum framesize (in bytes) of all frames in the stream; 0 => unknown
+ * 24: maximum framesize (in bytes) of all frames in the stream; 0 => unknown
+ * 20: sample rate in Hz, 0 is invalid
+ * 3: (number of channels)-1
+ * 5: (bits per sample)-1
+ * 36: total samples, 0 => unknown
+ *128: MD5 digest of the original unencoded audio data
+ *---- -----------------
+ * 34 bytes total
*/
typedef struct {
- FLAC__EntropyCodingMethod entropy_coding_method;
- unsigned order;
- int32 warmup[FLAC__MAX_FIXED_ORDER];
-} FLAC__SubframeHeader_Fixed;
+ unsigned min_blocksize, max_blocksize;
+ unsigned min_framesize, max_framesize;
+ unsigned sample_rate;
+ unsigned channels;
+ unsigned bits_per_sample;
+ uint64 total_samples;
+ byte md5sum[16];
+} FLAC__StreamMetaData_Encoding;
+
+extern const unsigned FLAC__STREAM_METADATA_ENCODING_MIN_BLOCK_SIZE_LEN; /* = 16 bits */
+extern const unsigned FLAC__STREAM_METADATA_ENCODING_MAX_BLOCK_SIZE_LEN; /* = 16 bits */
+extern const unsigned FLAC__STREAM_METADATA_ENCODING_MIN_FRAME_SIZE_LEN; /* = 24 bits */
+extern const unsigned FLAC__STREAM_METADATA_ENCODING_MAX_FRAME_SIZE_LEN; /* = 24 bits */
+extern const unsigned FLAC__STREAM_METADATA_ENCODING_SAMPLE_RATE_LEN; /* = 20 bits */
+extern const unsigned FLAC__STREAM_METADATA_ENCODING_CHANNELS_LEN; /* = 3 bits */
+extern const unsigned FLAC__STREAM_METADATA_ENCODING_BITS_PER_SAMPLE_LEN; /* = 5 bits */
+extern const unsigned FLAC__STREAM_METADATA_ENCODING_TOTAL_SAMPLES_LEN; /* = 36 bits */
+extern const unsigned FLAC__STREAM_METADATA_ENCODING_MD5SUM_LEN; /* = 128 bits */
+extern const unsigned FLAC__STREAM_METADATA_ENCODING_LENGTH; /* = 34 bytes */
/*****************************************************************************
*
- * n: unencoded warm-up samples (n = lpc order * bits per sample)
- * 4: (qlp coeff precision in bits)-1 (1111 = invalid, use to check for erroneous sync)
- * 5: qlp shift needed in bits (signed)
- * n: unencoded predictor coefficients (n = lpc order * qlp coeff precision)
- * ?: entropy coding method info
- * ?: encoded residual ((blocksize minus lpc order) samples)
- * The order is stored in the main subframe header
+ * 1: =1 if this is the last meta-data block, else =0
+ * 7: meta-data type (c.f. FLAC__MetaDataType)
+ * 24: length (in bytes) of the block-specific data to follow
+ *---- -----------------
+ * 4 bytes total
*/
typedef struct {
- FLAC__EntropyCodingMethod entropy_coding_method;
- unsigned order;
- unsigned qlp_coeff_precision;
- int quantization_level;
- int32 qlp_coeff[FLAC__MAX_LPC_ORDER];
- int32 warmup[FLAC__MAX_LPC_ORDER];
-} FLAC__SubframeHeader_LPC;
+ FLAC__MetaDataType type;
+ bool is_last;
+ unsigned length; /* in bytes */
+ union {
+ FLAC__StreamMetaData_Encoding encoding;
+ } data;
+} FLAC__StreamMetaData;
+
+extern const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN; /* = 1 bits */
+extern const unsigned FLAC__STREAM_METADATA_TYPE_LEN; /* = 7 bits */
+extern const unsigned FLAC__STREAM_METADATA_LENGTH_LEN; /* = 24 bits */
+
+/*****************************************************************************/
-extern const unsigned FLAC__SUBFRAME_HEADER_LPC_QLP_COEFF_PRECISION_LEN; /* = 4 bits */
-extern const unsigned FLAC__SUBFRAME_HEADER_LPC_QLP_SHIFT_LEN; /* = 5 bits */
/*****************************************************************************
*
- * 8: subframe type
- * xxxxxxx1: invalid, to prevent sync-fooling string of 1s (use to check for erroneous sync)
- * 00000000: constant value
- * 00000010: verbatim
- * 000001x0: reserved
- * 00001xx0: reserved
- * 0001xxx0: fixed predictor, xxx=order <= 4, else reserved
- * 001xxxx0: reserved
- * 01xxxxx0: lpc, xxxxx=order-1
- * 1xxxxxxx: invalid, to prevent sync-fooling string of 1s (use to check for erroneous sync)
- * ?: subframe-specific header (c.f. FLAC__SubframeHeader_*)
- */
-typedef struct {
- FLAC__SubframeType type;
- union {
- FLAC__SubframeHeader_Constant constant;
- FLAC__SubframeHeader_Fixed fixed;
- FLAC__SubframeHeader_LPC lpc;
- } data; /* data will be undefined for FLAC__SUBFRAME_TYPE_VERBATIM */
-} FLAC__SubframeHeader;
+ * Stream structures
+ *
+ *****************************************************************************/
-extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_CONSTANT; /* = 0x00 */
-extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_VERBATIM; /* = 0x02 */
-extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_FIXED; /* = 0x10 */
-extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_LPC; /* = 0x40 */
-extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_LEN; /* = 8 bits */
+typedef struct {
+ FLAC__StreamMetaData_Encoding metadata;
+ FLAC__Frame *frames;
+} FLAC__Stream;
/*****************************************************************************/