Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config.cmake.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
/* Set FLAC__BYTES_PER_WORD to 8 (4 is the default) */
#cmakedefine01 ENABLE_64_BIT_WORDS

/* Enable experimental feature to encode & decode 32-bit float (IEEE 754 standard) samples */
#cmakedefine01 ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING

/* define to align allocated memory on 32-byte boundaries */
#cmakedefine FLAC__ALIGN_MALLOC_DATA

Expand Down
12 changes: 12 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,18 @@ else
fi
AC_SUBST(ENABLE_64_BIT_WORDS)

AC_ARG_ENABLE(experimental-float-sample-coding,
AS_HELP_STRING([--enable-experimental-float-sample-coding],[Enable experimental feature to encode & decode 32-bit float (IEEE 754 standard) samples]))
AM_CONDITIONAL([ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING],
[test "x$enable_experimental_float_sample_coding" = xyes])
if test "x$enable_experimental_float_sample_coding" = xyes ; then
AC_DEFINE_UNQUOTED([ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING],1)
else
AC_DEFINE_UNQUOTED([ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING],0,[Disable the feature (this is the default)])
fi
AH_TEMPLATE(ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING, [define to enable experimental float sample coding])
AC_SUBST(ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING)

AC_ARG_ENABLE(valgrind-testing,
AS_HELP_STRING([--enable-valgrind-testing],[Run all tests inside Valgrind]),
[case "${enableval}" in
Expand Down
3 changes: 3 additions & 0 deletions include/FLAC++/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ namespace FLAC {
virtual FLAC__uint64 get_total_samples() const; ///< See FLAC__stream_decoder_get_total_samples()
virtual FLAC__uint64 find_total_samples(); ///< See FLAC__stream_decoder_find_total_samples()
virtual uint32_t get_channels() const; ///< See FLAC__stream_decoder_get_channels()
#if ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING
virtual SampleType get_sample_type() const; ///< See FLAC__stream_decoder_get_is_float_samples()
#endif
virtual ::FLAC__ChannelAssignment get_channel_assignment() const; ///< See FLAC__stream_decoder_get_channel_assignment()
virtual uint32_t get_bits_per_sample() const; ///< See FLAC__stream_decoder_get_bits_per_sample()
virtual uint32_t get_sample_rate() const; ///< See FLAC__stream_decoder_get_sample_rate()
Expand Down
6 changes: 6 additions & 0 deletions include/FLAC++/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ namespace FLAC {
virtual bool set_verify(bool value); ///< See FLAC__stream_encoder_set_verify()
virtual bool set_streamable_subset(bool value); ///< See FLAC__stream_encoder_set_streamable_subset()
virtual bool set_channels(uint32_t value); ///< See FLAC__stream_encoder_set_channels()
#if ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING
virtual bool set_sample_type(SampleType value); ///< See FLAC__stream_encoder_set_sample_type()
#endif
virtual bool set_bits_per_sample(uint32_t value); ///< See FLAC__stream_encoder_set_bits_per_sample()
virtual bool set_sample_rate(uint32_t value); ///< See FLAC__stream_encoder_set_sample_rate()
virtual bool set_compression_level(uint32_t value); ///< See FLAC__stream_encoder_set_compression_level()
Expand Down Expand Up @@ -159,6 +162,9 @@ namespace FLAC {
virtual bool get_do_mid_side_stereo() const; ///< See FLAC__stream_encoder_get_do_mid_side_stereo()
virtual bool get_loose_mid_side_stereo() const; ///< See FLAC__stream_encoder_get_loose_mid_side_stereo()
virtual uint32_t get_channels() const; ///< See FLAC__stream_encoder_get_channels()
#if ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING
virtual SampleType get_sample_type() const; ///< See FLAC__stream_encoder_get_is_float_samples()
#endif
virtual uint32_t get_bits_per_sample() const; ///< See FLAC__stream_encoder_get_bits_per_sample()
virtual uint32_t get_sample_rate() const; ///< See FLAC__stream_encoder_get_sample_rate()
virtual uint32_t get_blocksize() const; ///< See FLAC__stream_encoder_get_blocksize()
Expand Down
6 changes: 6 additions & 0 deletions include/FLAC++/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ namespace FLAC {
uint32_t get_max_framesize() const;
uint32_t get_sample_rate() const;
uint32_t get_channels() const;
#if ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING
SampleType get_sample_type() const;
#endif
uint32_t get_bits_per_sample() const;
FLAC__uint64 get_total_samples() const;
const FLAC__byte *get_md5sum() const;
Expand All @@ -340,6 +343,9 @@ namespace FLAC {
void set_max_framesize(uint32_t value);
void set_sample_rate(uint32_t value);
void set_channels(uint32_t value);
#if ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING
void set_sample_type(SampleType value);
#endif
void set_bits_per_sample(uint32_t value);
void set_total_samples(FLAC__uint64 value);
void set_md5sum(const FLAC__byte value[16]);
Expand Down
11 changes: 11 additions & 0 deletions include/FLAC/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ extern FLAC_API const uint32_t FLAC__STREAM_SYNC_LEN; /* = 32 bits */
/** The length of the FLAC signature in bytes. */
#define FLAC__STREAM_SYNC_LENGTH (4u)

typedef enum { NOT_SPECIFIED = -1,
INT = 0,
FLOAT = 1 } SampleType; // TODO: merge with endian & unsigned

/*****************************************************************************
*
Expand Down Expand Up @@ -431,6 +434,11 @@ typedef struct {
uint32_t bits_per_sample;
/**< The sample resolution. */

#if ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING
SampleType sample_type;
/**< FLOAT if the samples are IEEE 754 binary32 (32-bit floating point) */
#endif

FLAC__FrameNumberType number_type;
/**< The numbering scheme used for the frame. As a convenience, the
* decoder will always convert a frame number to a sample number because
Expand Down Expand Up @@ -539,6 +547,9 @@ typedef struct {
uint32_t sample_rate;
uint32_t channels;
uint32_t bits_per_sample;
#if ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING
SampleType sample_type;
#endif
FLAC__uint64 total_samples;
FLAC__byte md5sum[16];
} FLAC__StreamMetadata_StreamInfo;
Expand Down
14 changes: 14 additions & 0 deletions include/FLAC/stream_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,20 @@ FLAC_API FLAC__uint64 FLAC__stream_decoder_find_total_samples(FLAC__StreamDecode
*/
FLAC_API uint32_t FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder);

#if ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING
/** Get the current sample type in the stream being decoded.
* Will only be valid after decoding has started and will contain the
* value from the most recently decoded frame header.
*
* \param decoder A decoder instance to query.
* \assert
* \code decoder != NULL \endcode
* \retval SampleType
* FLOAT if samples are in IEEE 754 binary32 format, INT otherwise.
*/
FLAC_API SampleType FLAC__stream_decoder_get_sample_type(const FLAC__StreamDecoder *decoder);
#endif

/** Get the current channel assignment in the stream being decoded.
* Will only be valid after decoding has started and will contain the
* value from the most recently decoded frame header.
Expand Down
26 changes: 26 additions & 0 deletions include/FLAC/stream_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,20 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_streamable_subset(FLAC__StreamEncod
*/
FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, uint32_t value);

#if ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING
/** Set the sample type of the input to be encoded.
*
* \default \c false
* \param encoder An encoder instance to set.
* \param value FLOAT for IEEE 754 binary32, INT otherwise.
* \assert
* \code encoder != NULL \endcode
* \retval FLAC__bool
* \c false if the encoder is already initialized, else \c true.
*/
FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_type(FLAC__StreamEncoder *encoder, SampleType value);
#endif

/** Set the sample resolution of the input to be encoded.
*
* \warning
Expand Down Expand Up @@ -1372,6 +1386,18 @@ FLAC_API FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__Strea
*/
FLAC_API uint32_t FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder);

#if ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING
/** Get the input sample type setting.
*
* \param encoder An encoder instance to query.
* \assert
* \code encoder != NULL \endcode
* \retval SampleType
* FLOAT if samples are in IEEE 754 binary32 format, INT otherwise.
*/
FLAC_API SampleType FLAC__stream_encoder_get_sample_type(const FLAC__StreamEncoder *encoder);
#endif

/** Get the input sample resolution setting.
*
* \param encoder An encoder instance to query.
Expand Down
3 changes: 3 additions & 0 deletions man/flac.md
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,9 @@ When encoding from or decoding to raw PCM, format must be specified.
**\--endian**={big\|little}
: Specify the byte order for samples

**\--sample-type**={int\|float}
: Specify the sample types.

**\--channels**=\#
: (Input only) specify number of channels. The channels must be
interleaved, and in the order of the FLAC format (see the format
Expand Down
3 changes: 3 additions & 0 deletions man/metaflac.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ modification time is set to the current time):
**\--show-channels**
: Show the number of channels from the STREAMINFO block.

**\--show-sample-type**
: Show if the audio samples are integer or floating-point from the STREAMINFO block.

**\--show-bps**
: Show the \# of bits per sample from the STREAMINFO block.

Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
option(ENABLE_64_BIT_WORDS "Set FLAC__BYTES_PER_WORD to 8, for 64-bit machines. For 32-bit machines, turning this off might give a tiny speed improvement" ON)
option(ENABLE_EXPERIMENTAL_FLOAT_SAMPLE_CODING "Enable experimental feature to encode & decode 32-bit float (IEEE 754 standard) samples" ON)
option(BUILD_UTILS "Build utils" OFF)

add_subdirectory("libFLAC")
Expand Down
Loading