📄 format.h
字号:
/* libFLAC - Free Lossless Audio Codec library
* Copyright (C) 2000,2001,2002,2003,2004,2005 Josh Coalson
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of the Xiph.org Foundation nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef FLAC__FORMAT_H
#define FLAC__FORMAT_H
#include "export.h"
#include "ordinals.h"
#ifdef __cplusplus
extern "C" {
#endif
/** \file include/FLAC/format.h
*
* \brief
* This module contains structure definitions for the representation
* of FLAC format components in memory. These are the basic
* structures used by the rest of the interfaces.
*
* See the detailed documentation in the
* \link flac_format format \endlink module.
*/
/** \defgroup flac_format FLAC/format.h: format components
* \ingroup flac
*
* \brief
* This module contains structure definitions for the representation
* of FLAC format components in memory. These are the basic
* structures used by the rest of the interfaces.
*
* First, you should be familiar with the
* <A HREF="../format.html">FLAC format</A>. Many of the values here
* follow directly from the specification. As a user of libFLAC, the
* interesting parts really are the structures that describe the frame
* header and metadata blocks.
*
* The format structures here are very primitive, designed to store
* information in an efficient way. Reading information from the
* structures is easy but creating or modifying them directly is
* more complex. For the most part, as a user of a library, editing
* is not necessary; however, for metadata blocks it is, so there are
* convenience functions provided in the \link flac_metadata metadata
* module \endlink to simplify the manipulation of metadata blocks.
*
* \note
* It's not the best convention, but symbols ending in _LEN are in bits
* and _LENGTH are in bytes. _LENGTH symbols are \#defines instead of
* global variables because they are usually used when declaring byte
* arrays and some compilers require compile-time knowledge of array
* sizes when declared on the stack.
*
* \{
*/
/*
Most of the values described in this file are defined by the FLAC
format specification. There is nothing to tune here.
*/
/** The largest legal metadata type code. */
#define FLAC__MAX_METADATA_TYPE_CODE (126u)
/** The minimum block size, in samples, permitted by the format. */
#define FLAC__MIN_BLOCK_SIZE (16u)
/** The maximum block size, in samples, permitted by the format. */
#define FLAC__MAX_BLOCK_SIZE (65535u)
/** The maximum number of channels permitted by the format. */
#define FLAC__MAX_CHANNELS (8u)
/** The minimum sample resolution permitted by the format. */
#define FLAC__MIN_BITS_PER_SAMPLE (4u)
/** The maximum sample resolution permitted by the format. */
#define FLAC__MAX_BITS_PER_SAMPLE (32u)
/** The maximum sample resolution permitted by libFLAC.
*
* \warning
* FLAC__MAX_BITS_PER_SAMPLE is the limit of the FLAC format. However,
* the reference encoder/decoder is currently limited to 24 bits because
* of prevalent 32-bit math, so make sure and use this value when
* appropriate.
*/
#define FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE (24u)
/** The maximum sample rate permitted by the format. The value is
* ((2 ^ 16) - 1) * 10; see <A HREF="../format.html">FLAC format</A>
* as to why.
*/
#define FLAC__MAX_SAMPLE_RATE (655350u)
/** The maximum LPC order permitted by the format. */
#define FLAC__MAX_LPC_ORDER (32u)
/** The minimum quantized linear predictor coefficient precision
* permitted by the format.
*/
#define FLAC__MIN_QLP_COEFF_PRECISION (5u)
/** The maximum quantized linear predictor coefficient precision
* permitted by the format.
*/
#define FLAC__MAX_QLP_COEFF_PRECISION (15u)
/** The maximum order of the fixed predictors permitted by the format. */
#define FLAC__MAX_FIXED_ORDER (4u)
/** The maximum Rice partition order permitted by the format. */
#define FLAC__MAX_RICE_PARTITION_ORDER (15u)
/** The maximum Rice partition order permitted by the FLAC Subset. */
#define FLAC__SUBSET_MAX_RICE_PARTITION_ORDER (8u)
/** The version string of the release, stamped onto the libraries and binaries.
*
* \note
* This does not correspond to the shared library version number, which
* is used to determine binary compatibility.
*/
extern FLAC_API const char *FLAC__VERSION_STRING;
/** The vendor string inserted by the encoder into the VORBIS_COMMENT block.
* This is a nulL-terminated ASCII string; when inserted into the
* VORBIS_COMMENT the trailing null is stripped.
*/
extern FLAC_API const char *FLAC__VENDOR_STRING;
/** The byte string representation of the beginning of a FLAC stream. */
extern FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */
/** The 32-bit integer big-endian representation of the beginning of
* a FLAC stream.
*/
extern FLAC_API const unsigned FLAC__STREAM_SYNC; /* = 0x664C6143 */
/** The length of the FLAC signature in bits. */
extern FLAC_API const unsigned FLAC__STREAM_SYNC_LEN; /* = 32 bits */
/** The length of the FLAC signature in bytes. */
#define FLAC__STREAM_SYNC_LENGTH (4u)
/*****************************************************************************
*
* Subframe structures
*
*****************************************************************************/
/*****************************************************************************/
/** An enumeration of the available entropy coding methods. */
typedef enum {
FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = 0
/**< Residual is coded by partitioning into contexts, each with it's own
* Rice parameter. */
} FLAC__EntropyCodingMethodType;
/** Maps a FLAC__EntropyCodingMethodType to a C string.
*
* Using a FLAC__EntropyCodingMethodType as the index to this array will
* give the string equivalent. The contents should not be modified.
*/
extern FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[];
/** Contents of a Rice partitioned residual
*/
typedef struct {
unsigned *parameters;
/**< The Rice parameters for each context. */
unsigned *raw_bits;
/**< Widths for escape-coded partitions. */
unsigned capacity_by_order;
/**< The capacity of the \a parameters and \a raw_bits arrays
* specified as an order, i.e. the number of array elements
* allocated is 2 ^ \a capacity_by_order.
*/
} FLAC__EntropyCodingMethod_PartitionedRiceContents;
/** Header for a Rice partitioned residual. (c.f. <A HREF="../format.html#partitioned_rice">format specification</A>)
*/
typedef struct {
unsigned order;
/**< The partition order, i.e. # of contexts = 2 ^ \a order. */
const FLAC__EntropyCodingMethod_PartitionedRiceContents *contents;
/**< The context's Rice parameters and/or raw bits. */
} FLAC__EntropyCodingMethod_PartitionedRice;
extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /**< == 4 (bits) */
extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /**< == 4 (bits) */
extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN; /**< == 5 (bits) */
extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
/**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */
/** Header for the entropy coding method. (c.f. <A HREF="../format.html#residual">format specification</A>)
*/
typedef struct {
FLAC__EntropyCodingMethodType type;
union {
FLAC__EntropyCodingMethod_PartitionedRice partitioned_rice;
} data;
} FLAC__EntropyCodingMethod;
extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_TYPE_LEN; /**< == 2 (bits) */
/*****************************************************************************/
/** An enumeration of the available subframe types. */
typedef enum {
FLAC__SUBFRAME_TYPE_CONSTANT = 0, /**< constant signal */
FLAC__SUBFRAME_TYPE_VERBATIM = 1, /**< uncompressed signal */
FLAC__SUBFRAME_TYPE_FIXED = 2, /**< fixed polynomial prediction */
FLAC__SUBFRAME_TYPE_LPC = 3 /**< linear prediction */
} FLAC__SubframeType;
/** Maps a FLAC__SubframeType to a C string.
*
* Using a FLAC__SubframeType as the index to this array will
* give the string equivalent. The contents should not be modified.
*/
extern FLAC_API const char * const FLAC__SubframeTypeString[];
/** CONSTANT subframe. (c.f. <A HREF="../format.html#subframe_constant">format specification</A>)
*/
typedef struct {
FLAC__int32 value; /**< The constant signal value. */
} FLAC__Subframe_Constant;
/** VERBATIM subframe. (c.f. <A HREF="../format.html#subframe_verbatim">format specification</A>)
*/
typedef struct {
const FLAC__int32 *data; /**< A pointer to verbatim signal. */
} FLAC__Subframe_Verbatim;
/** FIXED subframe. (c.f. <A HREF="../format.html#subframe_fixed">format specification</A>)
*/
typedef struct {
FLAC__EntropyCodingMethod entropy_coding_method;
/**< The residual coding method. */
unsigned order;
/**< The polynomial order. */
FLAC__int32 warmup[FLAC__MAX_FIXED_ORDER];
/**< Warmup samples to prime the predictor, length == order. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -