mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
add bps checks so we can use miroslav's mmx versions of some routines
This commit is contained in:
@@ -77,6 +77,7 @@ typedef struct FLAC__EncoderPrivate {
|
|||||||
unsigned (*local_fixed_compute_best_predictor)(const int32 data[], unsigned data_len, real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
unsigned (*local_fixed_compute_best_predictor)(const int32 data[], unsigned data_len, real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||||
void (*local_lpc_compute_autocorrelation)(const real data[], unsigned data_len, unsigned lag, real autoc[]);
|
void (*local_lpc_compute_autocorrelation)(const real data[], unsigned data_len, unsigned lag, real autoc[]);
|
||||||
void (*local_lpc_compute_residual_from_qlp_coefficients)(const int32 data[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 residual[]);
|
void (*local_lpc_compute_residual_from_qlp_coefficients)(const int32 data[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 residual[]);
|
||||||
|
void (*local_lpc_compute_residual_from_qlp_coefficients_16bit)(const int32 data[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 residual[]);
|
||||||
bool use_slow; /* use slow 64-bit versions of some functions */
|
bool use_slow; /* use slow 64-bit versions of some functions */
|
||||||
FLAC__EncoderWriteStatus (*write_callback)(const FLAC__Encoder *encoder, const byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
|
FLAC__EncoderWriteStatus (*write_callback)(const FLAC__Encoder *encoder, const byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
|
||||||
void (*metadata_callback)(const FLAC__Encoder *encoder, const FLAC__StreamMetaData *metadata, void *client_data);
|
void (*metadata_callback)(const FLAC__Encoder *encoder, const FLAC__StreamMetaData *metadata, void *client_data);
|
||||||
@@ -329,6 +330,7 @@ FLAC__EncoderState FLAC__encoder_init(FLAC__Encoder *encoder, FLAC__EncoderWrite
|
|||||||
encoder->guts->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation;
|
encoder->guts->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation;
|
||||||
encoder->guts->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor;
|
encoder->guts->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor;
|
||||||
encoder->guts->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients;
|
encoder->guts->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients;
|
||||||
|
encoder->guts->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients;
|
||||||
/* now override with asm where appropriate */
|
/* now override with asm where appropriate */
|
||||||
#ifndef FLAC__NO_ASM
|
#ifndef FLAC__NO_ASM
|
||||||
FLAC__ASSERT(encoder->guts->cpuinfo.use_asm);
|
FLAC__ASSERT(encoder->guts->cpuinfo.use_asm);
|
||||||
@@ -364,17 +366,16 @@ fprintf(stderr,"@@@ got _asm_i386 of lpc_compute_autocorrelation()\n");}
|
|||||||
{//@@@
|
{//@@@
|
||||||
encoder->guts->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_asm_i386_mmx_cmov;
|
encoder->guts->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_asm_i386_mmx_cmov;
|
||||||
fprintf(stderr,"@@@ got _asm_i386_mmx_cmov of fixed_compute_best_predictor()\n");}
|
fprintf(stderr,"@@@ got _asm_i386_mmx_cmov of fixed_compute_best_predictor()\n");}
|
||||||
#if 0
|
if(encoder->guts->cpuinfo.data.ia32.mmx) {
|
||||||
/* @@@ MMX version needs bps check */
|
|
||||||
if(encoder->guts->cpuinfo.data.ia32.mmx && @@@bps check here@@@)
|
|
||||||
{//@@@
|
|
||||||
encoder->guts->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_i386_mmx;
|
|
||||||
fprintf(stderr,"@@@ got _asm_i386_mmx of lpc_compute_residual_from_qlp_coefficients()\n");}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{//@@@
|
|
||||||
encoder->guts->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_i386;
|
encoder->guts->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_i386;
|
||||||
fprintf(stderr,"@@@ got _asm_i386 of lpc_compute_residual_from_qlp_coefficients()\n");}
|
encoder->guts->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_i386_mmx;
|
||||||
|
fprintf(stderr,"@@@ got _asm_i386_mmx of lpc_compute_residual_from_qlp_coefficients()\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
encoder->guts->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_i386;
|
||||||
|
encoder->guts->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_i386;
|
||||||
|
fprintf(stderr,"@@@ got _asm_i386 of lpc_compute_residual_from_qlp_coefficients()\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -1101,6 +1102,9 @@ unsigned encoder_evaluate_lpc_subframe_(FLAC__Encoder *encoder, const int32 sign
|
|||||||
if(ret != 0)
|
if(ret != 0)
|
||||||
return 0; /* this is a hack to indicate to the caller that we can't do lp at this order on this subframe */
|
return 0; /* this is a hack to indicate to the caller that we can't do lp at this order on this subframe */
|
||||||
|
|
||||||
|
if(subframe_bps <= 16 && qlp_coeff_precision <= 16)
|
||||||
|
encoder->guts->local_lpc_compute_residual_from_qlp_coefficients_16bit(signal+order, residual_samples, qlp_coeff, order, quantization, residual);
|
||||||
|
else
|
||||||
encoder->guts->local_lpc_compute_residual_from_qlp_coefficients(signal+order, residual_samples, qlp_coeff, order, quantization, residual);
|
encoder->guts->local_lpc_compute_residual_from_qlp_coefficients(signal+order, residual_samples, qlp_coeff, order, quantization, residual);
|
||||||
|
|
||||||
subframe->type = FLAC__SUBFRAME_TYPE_LPC;
|
subframe->type = FLAC__SUBFRAME_TYPE_LPC;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ typedef struct FLAC__StreamDecoderPrivate {
|
|||||||
void (*metadata_callback)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data);
|
void (*metadata_callback)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data);
|
||||||
void (*error_callback)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
|
void (*error_callback)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
|
||||||
void (*local_lpc_restore_signal)(const int32 residual[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 data[]);
|
void (*local_lpc_restore_signal)(const int32 residual[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 data[]);
|
||||||
|
void (*local_lpc_restore_signal_16bit)(const int32 residual[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 data[]);
|
||||||
void *client_data;
|
void *client_data;
|
||||||
FLAC__BitBuffer input;
|
FLAC__BitBuffer input;
|
||||||
int32 *output[FLAC__MAX_CHANNELS];
|
int32 *output[FLAC__MAX_CHANNELS];
|
||||||
@@ -166,23 +167,23 @@ FLAC__StreamDecoderState FLAC__stream_decoder_init(
|
|||||||
FLAC__cpu_info(&decoder->guts->cpuinfo);
|
FLAC__cpu_info(&decoder->guts->cpuinfo);
|
||||||
/* first default to the non-asm routines */
|
/* first default to the non-asm routines */
|
||||||
decoder->guts->local_lpc_restore_signal = FLAC__lpc_restore_signal;
|
decoder->guts->local_lpc_restore_signal = FLAC__lpc_restore_signal;
|
||||||
|
decoder->guts->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal;
|
||||||
/* now override with asm where appropriate */
|
/* now override with asm where appropriate */
|
||||||
#ifndef FLAC__NO_ASM
|
#ifndef FLAC__NO_ASM
|
||||||
FLAC__ASSERT(decoder->guts->cpuinfo.use_asm);
|
FLAC__ASSERT(decoder->guts->cpuinfo.use_asm);
|
||||||
#ifdef FLAC__CPU_IA32
|
#ifdef FLAC__CPU_IA32
|
||||||
FLAC__ASSERT(decoder->guts->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32);
|
FLAC__ASSERT(decoder->guts->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32);
|
||||||
#ifdef FLAC__HAS_NASM
|
#ifdef FLAC__HAS_NASM
|
||||||
#if 0
|
if(decoder->guts->cpuinfo.data.ia32.mmx) {
|
||||||
/* @@@ MMX version needs bps check */
|
|
||||||
if(decoder->guts->cpuinfo.data.ia32.mmx && @@@bps check here@@@)
|
|
||||||
{//@@@
|
|
||||||
decoder->guts->local_lpc_restore_signal = FLAC__lpc_restore_signal_asm_i386_mmx;
|
|
||||||
fprintf(stderr,"@@@ got _asm_i386_mmx of lpc_restore_signal()\n");}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{//@@@
|
|
||||||
decoder->guts->local_lpc_restore_signal = FLAC__lpc_restore_signal_asm_i386;
|
decoder->guts->local_lpc_restore_signal = FLAC__lpc_restore_signal_asm_i386;
|
||||||
fprintf(stderr,"@@@ got _asm_i386 of lpc_restore_signal()\n");}
|
decoder->guts->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_asm_i386_mmx;
|
||||||
|
fprintf(stderr,"@@@ got _asm_i386_mmx of lpc_restore_signal()\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
decoder->guts->local_lpc_restore_signal = FLAC__lpc_restore_signal_asm_i386;
|
||||||
|
decoder->guts->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_asm_i386;
|
||||||
|
fprintf(stderr,"@@@ got _asm_i386 of lpc_restore_signal()\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -1301,6 +1302,9 @@ bool stream_decoder_read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned ch
|
|||||||
|
|
||||||
/* decode the subframe */
|
/* decode the subframe */
|
||||||
memcpy(decoder->guts->output[channel], subframe->warmup, sizeof(int32) * order);
|
memcpy(decoder->guts->output[channel], subframe->warmup, sizeof(int32) * order);
|
||||||
|
if(bps <= 16 && subframe->qlp_coeff_precision <= 16)
|
||||||
|
decoder->guts->local_lpc_restore_signal_16bit(decoder->guts->residual[channel], decoder->guts->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->guts->output[channel]+order);
|
||||||
|
else
|
||||||
decoder->guts->local_lpc_restore_signal(decoder->guts->residual[channel], decoder->guts->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->guts->output[channel]+order);
|
decoder->guts->local_lpc_restore_signal(decoder->guts->residual[channel], decoder->guts->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->guts->output[channel]+order);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user