add functions/switches for disabling certain subframe types for use by the test suite
This commit is contained in:
parent
deb4132f88
commit
e6b3bbefb2
@ -94,6 +94,19 @@ static FLAC__int32 in_[FLAC__MAX_CHANNELS][CHUNK_OF_SAMPLES];
|
||||
static FLAC__int32 *input_[FLAC__MAX_CHANNELS];
|
||||
|
||||
|
||||
/*
|
||||
* unpublished debug routines from the FLAC libs
|
||||
*/
|
||||
extern FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
extern FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
extern FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
extern FLAC__bool FLAC__file_encoder_disable_constant_subframes(FLAC__FileEncoder *encoder, FLAC__bool value);
|
||||
extern FLAC__bool FLAC__file_encoder_disable_fixed_subframes(FLAC__FileEncoder *encoder, FLAC__bool value);
|
||||
extern FLAC__bool FLAC__file_encoder_disable_verbatim_subframes(FLAC__FileEncoder *encoder, FLAC__bool value);
|
||||
extern FLAC__bool OggFLAC__stream_encoder_disable_constant_subframes(OggFLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
extern FLAC__bool OggFLAC__stream_encoder_disable_fixed_subframes(OggFLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
extern FLAC__bool OggFLAC__stream_encoder_disable_verbatim_subframes(OggFLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
|
||||
/*
|
||||
* local routines
|
||||
*/
|
||||
@ -1205,6 +1218,10 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
|
||||
OggFLAC__stream_encoder_set_write_callback(e->encoder.ogg.stream, ogg_stream_encoder_write_callback);
|
||||
OggFLAC__stream_encoder_set_client_data(e->encoder.ogg.stream, e);
|
||||
|
||||
OggFLAC__stream_encoder_disable_constant_subframes(e->encoder.ogg.stream, options.debug.disable_constant_subframes);
|
||||
OggFLAC__stream_encoder_disable_fixed_subframes(e->encoder.ogg.stream, options.debug.disable_fixed_subframes);
|
||||
OggFLAC__stream_encoder_disable_verbatim_subframes(e->encoder.ogg.stream, options.debug.disable_verbatim_subframes);
|
||||
|
||||
if(OggFLAC__stream_encoder_init(e->encoder.ogg.stream) != FLAC__STREAM_ENCODER_OK) {
|
||||
print_error_with_state(e, "ERROR initializing encoder");
|
||||
return false;
|
||||
@ -1235,6 +1252,10 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
|
||||
FLAC__stream_encoder_set_metadata_callback(e->encoder.flac.stream, flac_stream_encoder_metadata_callback);
|
||||
FLAC__stream_encoder_set_client_data(e->encoder.flac.stream, e);
|
||||
|
||||
FLAC__stream_encoder_disable_constant_subframes(e->encoder.flac.stream, options.debug.disable_constant_subframes);
|
||||
FLAC__stream_encoder_disable_fixed_subframes(e->encoder.flac.stream, options.debug.disable_fixed_subframes);
|
||||
FLAC__stream_encoder_disable_verbatim_subframes(e->encoder.flac.stream, options.debug.disable_verbatim_subframes);
|
||||
|
||||
if(FLAC__stream_encoder_init(e->encoder.flac.stream) != FLAC__STREAM_ENCODER_OK) {
|
||||
print_error_with_state(e, "ERROR initializing encoder");
|
||||
return false;
|
||||
@ -1263,6 +1284,10 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
|
||||
FLAC__file_encoder_set_progress_callback(e->encoder.flac.file, flac_file_encoder_progress_callback);
|
||||
FLAC__file_encoder_set_client_data(e->encoder.flac.file, e);
|
||||
|
||||
FLAC__file_encoder_disable_constant_subframes(e->encoder.flac.file, options.debug.disable_constant_subframes);
|
||||
FLAC__file_encoder_disable_fixed_subframes(e->encoder.flac.file, options.debug.disable_fixed_subframes);
|
||||
FLAC__file_encoder_disable_verbatim_subframes(e->encoder.flac.file, options.debug.disable_verbatim_subframes);
|
||||
|
||||
if(FLAC__file_encoder_init(e->encoder.flac.file) != FLAC__FILE_ENCODER_OK) {
|
||||
print_error_with_state(e, "ERROR initializing encoder");
|
||||
return false;
|
||||
|
@ -53,6 +53,12 @@ typedef struct {
|
||||
FLAC__bool sector_align;
|
||||
|
||||
FLAC__StreamMetadata *vorbis_comment;
|
||||
|
||||
struct {
|
||||
FLAC__bool disable_constant_subframes;
|
||||
FLAC__bool disable_fixed_subframes;
|
||||
FLAC__bool disable_verbatim_subframes;
|
||||
} debug;
|
||||
} encode_options_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -171,6 +171,12 @@ static struct FLAC__share__option long_options_[] = {
|
||||
{ "no-verify", 0, 0, 0 },
|
||||
{ "no-residual-gnuplot", 0, 0, 0 },
|
||||
{ "no-residual-text", 0, 0, 0 },
|
||||
/*
|
||||
* undocumented debugging options for the test suite
|
||||
*/
|
||||
{ "disable-constant-subframes", 0, 0, 0 },
|
||||
{ "disable-fixed-subframes", 0, 0, 0 },
|
||||
{ "disable-verbatim-subframes", 0, 0, 0 },
|
||||
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
@ -226,6 +232,12 @@ static struct {
|
||||
char **filenames;
|
||||
|
||||
FLAC__StreamMetadata *vorbis_comment;
|
||||
|
||||
struct {
|
||||
FLAC__bool disable_constant_subframes;
|
||||
FLAC__bool disable_fixed_subframes;
|
||||
FLAC__bool disable_verbatim_subframes;
|
||||
} debug;
|
||||
} option_values;
|
||||
|
||||
|
||||
@ -489,6 +501,10 @@ FLAC__bool init_options()
|
||||
if(0 == (option_values.vorbis_comment = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT)))
|
||||
return false;
|
||||
|
||||
option_values.debug.disable_constant_subframes = false;
|
||||
option_values.debug.disable_fixed_subframes = false;
|
||||
option_values.debug.disable_verbatim_subframes = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -673,6 +689,15 @@ int parse_option(int short_option, const char *long_option, const char *option_a
|
||||
else if(0 == strcmp(long_option, "no-residual-text")) {
|
||||
option_values.aopts.do_residual_text = false;
|
||||
}
|
||||
else if(0 == strcmp(long_option, "disable-constant-subframes")) {
|
||||
option_values.debug.disable_constant_subframes = true;
|
||||
}
|
||||
else if(0 == strcmp(long_option, "disable-fixed-subframes")) {
|
||||
option_values.debug.disable_fixed_subframes = true;
|
||||
}
|
||||
else if(0 == strcmp(long_option, "disable-verbatim-subframes")) {
|
||||
option_values.debug.disable_verbatim_subframes = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const char *violation;
|
||||
@ -1359,6 +1384,9 @@ int encode_file(const char *infilename, const char *forced_outfilename, FLAC__bo
|
||||
common_options.align_reservoir_samples = &align_reservoir_samples;
|
||||
common_options.sector_align = option_values.sector_align;
|
||||
common_options.vorbis_comment = option_values.vorbis_comment;
|
||||
common_options.debug.disable_constant_subframes = option_values.debug.disable_constant_subframes;
|
||||
common_options.debug.disable_fixed_subframes = option_values.debug.disable_fixed_subframes;
|
||||
common_options.debug.disable_verbatim_subframes = option_values.debug.disable_verbatim_subframes;
|
||||
|
||||
if(fmt == RAW) {
|
||||
raw_encode_options_t options;
|
||||
|
@ -30,6 +30,11 @@
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
/* unpublished debug routines */
|
||||
extern FLAC__bool FLAC__seekable_stream_encoder_disable_constant_subframes(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
|
||||
extern FLAC__bool FLAC__seekable_stream_encoder_disable_fixed_subframes(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
|
||||
extern FLAC__bool FLAC__seekable_stream_encoder_disable_verbatim_subframes(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
|
||||
|
||||
static void set_defaults_(FLAC__FileEncoder *encoder);
|
||||
static FLAC__SeekableStreamEncoderSeekStatus seek_callback_(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
|
||||
static FLAC__StreamEncoderWriteStatus write_callback_(const FLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
|
||||
@ -444,6 +449,40 @@ FLAC__bool FLAC__file_encoder_set_client_data(FLAC__FileEncoder *encoder, void *
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* These three functions are not static, but not publically exposed in
|
||||
* include/FLAC/ either. They are used by the test suite.
|
||||
*/
|
||||
FLAC__bool FLAC__file_encoder_disable_constant_subframes(FLAC__FileEncoder *encoder, FLAC__bool value)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
FLAC__ASSERT(0 != encoder->private_);
|
||||
FLAC__ASSERT(0 != encoder->protected_);
|
||||
if(encoder->protected_->state != FLAC__FILE_ENCODER_UNINITIALIZED)
|
||||
return false;
|
||||
return FLAC__seekable_stream_encoder_disable_constant_subframes(encoder->private_->seekable_stream_encoder, value);
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__file_encoder_disable_fixed_subframes(FLAC__FileEncoder *encoder, FLAC__bool value)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
FLAC__ASSERT(0 != encoder->private_);
|
||||
FLAC__ASSERT(0 != encoder->protected_);
|
||||
if(encoder->protected_->state != FLAC__FILE_ENCODER_UNINITIALIZED)
|
||||
return false;
|
||||
return FLAC__seekable_stream_encoder_disable_fixed_subframes(encoder->private_->seekable_stream_encoder, value);
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__file_encoder_disable_verbatim_subframes(FLAC__FileEncoder *encoder, FLAC__bool value)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
FLAC__ASSERT(0 != encoder->private_);
|
||||
FLAC__ASSERT(0 != encoder->protected_);
|
||||
if(encoder->protected_->state != FLAC__FILE_ENCODER_UNINITIALIZED)
|
||||
return false;
|
||||
return FLAC__seekable_stream_encoder_disable_verbatim_subframes(encoder->private_->seekable_stream_encoder, value);
|
||||
}
|
||||
|
||||
FLAC__FileEncoderState FLAC__file_encoder_get_state(const FLAC__FileEncoder *encoder)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
|
@ -35,6 +35,11 @@
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
/* unpublished debug routines */
|
||||
extern FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
extern FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
extern FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
|
||||
static void set_defaults_(FLAC__SeekableStreamEncoder *encoder);
|
||||
static FLAC__StreamEncoderWriteStatus write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
|
||||
static void metadata_callback_(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data);
|
||||
@ -449,6 +454,40 @@ FLAC__bool FLAC__seekable_stream_encoder_set_client_data(FLAC__SeekableStreamEnc
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* These three functions are not static, but not publically exposed in
|
||||
* include/FLAC/ either. They are used by the test suite.
|
||||
*/
|
||||
FLAC__bool FLAC__seekable_stream_encoder_disable_constant_subframes(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
FLAC__ASSERT(0 != encoder->private_);
|
||||
FLAC__ASSERT(0 != encoder->protected_);
|
||||
if(encoder->protected_->state != FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED)
|
||||
return false;
|
||||
return FLAC__stream_encoder_disable_constant_subframes(encoder->private_->stream_encoder, value);
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__seekable_stream_encoder_disable_fixed_subframes(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
FLAC__ASSERT(0 != encoder->private_);
|
||||
FLAC__ASSERT(0 != encoder->protected_);
|
||||
if(encoder->protected_->state != FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED)
|
||||
return false;
|
||||
return FLAC__stream_encoder_disable_fixed_subframes(encoder->private_->stream_encoder, value);
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__seekable_stream_encoder_disable_verbatim_subframes(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
FLAC__ASSERT(0 != encoder->private_);
|
||||
FLAC__ASSERT(0 != encoder->protected_);
|
||||
if(encoder->protected_->state != FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED)
|
||||
return false;
|
||||
return FLAC__stream_encoder_disable_verbatim_subframes(encoder->private_->stream_encoder, value);
|
||||
}
|
||||
|
||||
FLAC__SeekableStreamEncoderState FLAC__seekable_stream_encoder_get_state(const FLAC__SeekableStreamEncoder *encoder)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
|
@ -17,6 +17,7 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* for malloc() */
|
||||
#include <string.h> /* for memcpy() */
|
||||
@ -80,7 +81,6 @@ static FLAC__bool process_subframe_(
|
||||
unsigned min_partition_order,
|
||||
unsigned max_partition_order,
|
||||
FLAC__bool precompute_partition_sums,
|
||||
FLAC__bool verbatim_only,
|
||||
const FLAC__FrameHeader *frame_header,
|
||||
unsigned subframe_bps,
|
||||
const FLAC__int32 integer_signal[],
|
||||
@ -339,6 +339,9 @@ typedef struct FLAC__StreamEncoderPrivate {
|
||||
FLAC__bool use_wide_by_partition; /* use slow 64-bit versions of some functions because of the min partition order and blocksize */
|
||||
FLAC__bool use_wide_by_order; /* use slow 64-bit versions of some functions because of the lpc order */
|
||||
FLAC__bool precompute_partition_sums; /* our initial guess as to whether precomputing the partitions sums will be a speed improvement */
|
||||
FLAC__bool disable_constant_subframes;
|
||||
FLAC__bool disable_fixed_subframes;
|
||||
FLAC__bool disable_verbatim_subframes;
|
||||
FLAC__StreamEncoderWriteCallback write_callback;
|
||||
FLAC__StreamEncoderMetadataCallback metadata_callback;
|
||||
void *client_data;
|
||||
@ -1135,6 +1138,37 @@ FLAC__bool FLAC__stream_encoder_set_client_data(FLAC__StreamEncoder *encoder, vo
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* These three functions are not static, but not publically exposed in
|
||||
* include/FLAC/ either. They are used by the test suite.
|
||||
*/
|
||||
FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
|
||||
return false;
|
||||
encoder->private_->disable_constant_subframes = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
|
||||
return false;
|
||||
encoder->private_->disable_fixed_subframes = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
|
||||
return false;
|
||||
encoder->private_->disable_verbatim_subframes = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncoder *encoder)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
@ -1419,6 +1453,9 @@ void set_defaults_(FLAC__StreamEncoder *encoder)
|
||||
encoder->protected_->metadata = 0;
|
||||
encoder->protected_->num_metadata_blocks = 0;
|
||||
|
||||
encoder->private_->disable_constant_subframes = false;
|
||||
encoder->private_->disable_fixed_subframes = false;
|
||||
encoder->private_->disable_verbatim_subframes = false;
|
||||
encoder->private_->write_callback = 0;
|
||||
encoder->private_->metadata_callback = 0;
|
||||
encoder->private_->client_data = 0;
|
||||
@ -1728,7 +1765,6 @@ FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_last_f
|
||||
min_partition_order,
|
||||
max_partition_order,
|
||||
precompute_partition_sums,
|
||||
false,
|
||||
&frame_header,
|
||||
encoder->private_->subframe_bps[channel],
|
||||
encoder->private_->integer_signal[channel],
|
||||
@ -1757,7 +1793,6 @@ FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_last_f
|
||||
min_partition_order,
|
||||
max_partition_order,
|
||||
precompute_partition_sums,
|
||||
false,
|
||||
&frame_header,
|
||||
encoder->private_->subframe_bps_mid_side[channel],
|
||||
encoder->private_->integer_signal_mid_side[channel],
|
||||
@ -1892,7 +1927,6 @@ FLAC__bool process_subframe_(
|
||||
unsigned min_partition_order,
|
||||
unsigned max_partition_order,
|
||||
FLAC__bool precompute_partition_sums,
|
||||
FLAC__bool verbatim_only,
|
||||
const FLAC__FrameHeader *frame_header,
|
||||
unsigned subframe_bps,
|
||||
const FLAC__int32 integer_signal[],
|
||||
@ -1917,20 +1951,26 @@ FLAC__bool process_subframe_(
|
||||
|
||||
/* verbatim subframe is the baseline against which we measure other compressed subframes */
|
||||
_best_subframe = 0;
|
||||
if(encoder->private_->disable_verbatim_subframes && frame_header->blocksize >= FLAC__MAX_FIXED_ORDER)
|
||||
_best_bits = UINT_MAX;
|
||||
else
|
||||
_best_bits = evaluate_verbatim_subframe_(integer_signal, frame_header->blocksize, subframe_bps, subframe[_best_subframe]);
|
||||
|
||||
if(!verbatim_only && frame_header->blocksize >= FLAC__MAX_FIXED_ORDER) {
|
||||
/* check for constant subframe */
|
||||
if(frame_header->blocksize >= FLAC__MAX_FIXED_ORDER) {
|
||||
unsigned signal_is_constant = false;
|
||||
guess_fixed_order = encoder->private_->local_fixed_compute_best_predictor(integer_signal+FLAC__MAX_FIXED_ORDER, frame_header->blocksize-FLAC__MAX_FIXED_ORDER, fixed_residual_bits_per_sample);
|
||||
if(fixed_residual_bits_per_sample[1] == 0.0) {
|
||||
/* check for constant subframe */
|
||||
if(!encoder->private_->disable_constant_subframes && fixed_residual_bits_per_sample[1] == 0.0) {
|
||||
/* the above means integer_signal+FLAC__MAX_FIXED_ORDER is constant, now we just have to check the warmup samples */
|
||||
unsigned i, signal_is_constant = true;
|
||||
unsigned i;
|
||||
signal_is_constant = true;
|
||||
for(i = 1; i <= FLAC__MAX_FIXED_ORDER; i++) {
|
||||
if(integer_signal[0] != integer_signal[i]) {
|
||||
signal_is_constant = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(signal_is_constant) {
|
||||
_candidate_bits = evaluate_constant_subframe_(integer_signal[0], subframe_bps, subframe[!_best_subframe]);
|
||||
if(_candidate_bits < _best_bits) {
|
||||
@ -1938,8 +1978,8 @@ FLAC__bool process_subframe_(
|
||||
_best_bits = _candidate_bits;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!encoder->private_->disable_fixed_subframes || (encoder->protected_->max_lpc_order == 0 && _best_bits == UINT_MAX)) {
|
||||
/* encode fixed */
|
||||
if(encoder->protected_->do_exhaustive_model_search) {
|
||||
min_fixed_order = 0;
|
||||
@ -1986,6 +2026,7 @@ FLAC__bool process_subframe_(
|
||||
_best_bits = _candidate_bits;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* encode lpc */
|
||||
if(encoder->protected_->max_lpc_order > 0) {
|
||||
@ -2067,6 +2108,8 @@ FLAC__bool process_subframe_(
|
||||
}
|
||||
}
|
||||
|
||||
FLAC__ASSERT(_best_bits < UINT_MAX);
|
||||
|
||||
*best_subframe = _best_subframe;
|
||||
*best_bits = _best_bits;
|
||||
|
||||
@ -2083,24 +2126,28 @@ FLAC__bool add_subframe_(
|
||||
{
|
||||
switch(subframe->type) {
|
||||
case FLAC__SUBFRAME_TYPE_CONSTANT:
|
||||
//@@@@fprintf(stderr,"@@@@ add CONSTANT, bps=%u\n",subframe_bps);
|
||||
if(!FLAC__subframe_add_constant(&(subframe->data.constant), subframe_bps, subframe->wasted_bits, frame)) {
|
||||
encoder->protected_->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_ENCODING;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case FLAC__SUBFRAME_TYPE_FIXED:
|
||||
//@@@@fprintf(stderr,"@@@@ add FIXED, bps=%u, order=%u\n",subframe_bps,subframe->data.fixed.order);
|
||||
if(!FLAC__subframe_add_fixed(&(subframe->data.fixed), frame_header->blocksize - subframe->data.fixed.order, subframe_bps, subframe->wasted_bits, frame)) {
|
||||
encoder->protected_->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_ENCODING;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case FLAC__SUBFRAME_TYPE_LPC:
|
||||
//@@@@fprintf(stderr,"@@@@ add LPC, bps=%u, order=%u, prec=%u, shift=%d\n",subframe_bps,subframe->data.lpc.order,subframe->data.lpc.qlp_coeff_precision,subframe->data.lpc.quantization_level);
|
||||
if(!FLAC__subframe_add_lpc(&(subframe->data.lpc), frame_header->blocksize - subframe->data.lpc.order, subframe_bps, subframe->wasted_bits, frame)) {
|
||||
encoder->protected_->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_ENCODING;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case FLAC__SUBFRAME_TYPE_VERBATIM:
|
||||
//@@@@fprintf(stderr,"@@@@ add VERBATIM, bps=%u\n",subframe_bps);
|
||||
if(!FLAC__subframe_add_verbatim(&(subframe->data.verbatim), frame_header->blocksize, subframe_bps, subframe->wasted_bits, frame)) {
|
||||
encoder->protected_->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_ENCODING;
|
||||
return false;
|
||||
|
@ -31,6 +31,11 @@
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
/* unpublished debug routines */
|
||||
extern FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
extern FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
extern FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
|
||||
static void set_defaults_(OggFLAC__StreamEncoder *encoder);
|
||||
static FLAC__StreamEncoderWriteStatus write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
|
||||
static void metadata_callback_(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data);
|
||||
@ -420,6 +425,40 @@ FLAC__bool OggFLAC__stream_encoder_set_client_data(OggFLAC__StreamEncoder *encod
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* These three functions are not static, but not publically exposed in
|
||||
* include/FLAC/ either. They are used by the test suite.
|
||||
*/
|
||||
FLAC__bool OggFLAC__stream_encoder_disable_constant_subframes(OggFLAC__StreamEncoder *encoder, FLAC__bool value)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
FLAC__ASSERT(0 != encoder->private_);
|
||||
FLAC__ASSERT(0 != encoder->protected_);
|
||||
if(encoder->protected_->state != OggFLAC__STREAM_ENCODER_UNINITIALIZED)
|
||||
return false;
|
||||
return FLAC__stream_encoder_disable_constant_subframes(encoder->private_->FLAC_stream_encoder, value);
|
||||
}
|
||||
|
||||
FLAC__bool OggFLAC__stream_encoder_disable_fixed_subframes(OggFLAC__StreamEncoder *encoder, FLAC__bool value)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
FLAC__ASSERT(0 != encoder->private_);
|
||||
FLAC__ASSERT(0 != encoder->protected_);
|
||||
if(encoder->protected_->state != OggFLAC__STREAM_ENCODER_UNINITIALIZED)
|
||||
return false;
|
||||
return FLAC__stream_encoder_disable_fixed_subframes(encoder->private_->FLAC_stream_encoder, value);
|
||||
}
|
||||
|
||||
FLAC__bool OggFLAC__stream_encoder_disable_verbatim_subframes(OggFLAC__StreamEncoder *encoder, FLAC__bool value)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
FLAC__ASSERT(0 != encoder->private_);
|
||||
FLAC__ASSERT(0 != encoder->protected_);
|
||||
if(encoder->protected_->state != OggFLAC__STREAM_ENCODER_UNINITIALIZED)
|
||||
return false;
|
||||
return FLAC__stream_encoder_disable_verbatim_subframes(encoder->private_->FLAC_stream_encoder, value);
|
||||
}
|
||||
|
||||
OggFLAC__StreamEncoderState OggFLAC__stream_encoder_get_state(const OggFLAC__StreamEncoder *encoder)
|
||||
{
|
||||
FLAC__ASSERT(0 != encoder);
|
||||
|
Loading…
Reference in New Issue
Block a user