Always enable OPUS_TEST_RANGE_CODER_STATE.
This removes the configurability of the OPUS_TEST_RANGE_CODER_STATE consistency check, in favour of always running it. The performance penalty is low, and it's an important check on correctness for the reference encoder to provide.
This commit is contained in:
parent
fce4323e15
commit
3f0962cc1e
6 changed files with 2 additions and 21 deletions
|
@ -61,8 +61,6 @@ extern "C" {
|
||||||
/** Memory allocation has failed */
|
/** Memory allocation has failed */
|
||||||
#define OPUS_ALLOC_FAIL -7
|
#define OPUS_ALLOC_FAIL -7
|
||||||
|
|
||||||
#define OPUS_TEST_RANGE_CODER_STATE 1
|
|
||||||
|
|
||||||
#define OPUS_BITRATE_AUTO -1
|
#define OPUS_BITRATE_AUTO -1
|
||||||
|
|
||||||
#define OPUS_APPLICATION_VOIP 2000
|
#define OPUS_APPLICATION_VOIP 2000
|
||||||
|
@ -221,10 +219,8 @@ OPUS_EXPORT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsign
|
||||||
OPUS_EXPORT const char *opus_strerror(int error);
|
OPUS_EXPORT const char *opus_strerror(int error);
|
||||||
|
|
||||||
/* For testing purposes: the encoder and decoder state should always be identical after coding a payload */
|
/* For testing purposes: the encoder and decoder state should always be identical after coding a payload */
|
||||||
#if OPUS_TEST_RANGE_CODER_STATE
|
|
||||||
OPUS_EXPORT int opus_encoder_get_final_range(OpusEncoder *st);
|
OPUS_EXPORT int opus_encoder_get_final_range(OpusEncoder *st);
|
||||||
OPUS_EXPORT int opus_decoder_get_final_range(OpusDecoder *st);
|
OPUS_EXPORT int opus_decoder_get_final_range(OpusDecoder *st);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -383,9 +383,8 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
|
||||||
pcm+st->channels*F2_5, F2_5,
|
pcm+st->channels*F2_5, F2_5,
|
||||||
st->channels, window, st->Fs);
|
st->channels, window, st->Fs);
|
||||||
}
|
}
|
||||||
#if OPUS_TEST_RANGE_CODER_STATE
|
|
||||||
st->rangeFinal = dec.rng;
|
st->rangeFinal = dec.rng;
|
||||||
#endif
|
|
||||||
|
|
||||||
st->prev_mode = mode;
|
st->prev_mode = mode;
|
||||||
st->prev_redundancy = redundancy;
|
st->prev_redundancy = redundancy;
|
||||||
|
@ -569,13 +568,10 @@ void opus_decoder_destroy(OpusDecoder *st)
|
||||||
free(st);
|
free(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OPUS_TEST_RANGE_CODER_STATE
|
|
||||||
int opus_decoder_get_final_range(OpusDecoder *st)
|
int opus_decoder_get_final_range(OpusDecoder *st)
|
||||||
{
|
{
|
||||||
return st->rangeFinal;
|
return st->rangeFinal;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
int opus_packet_get_bandwidth(const unsigned char *data)
|
int opus_packet_get_bandwidth(const unsigned char *data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,9 +45,7 @@ struct OpusDecoder {
|
||||||
int frame_size;
|
int frame_size;
|
||||||
int prev_redundancy;
|
int prev_redundancy;
|
||||||
|
|
||||||
#ifdef OPUS_TEST_RANGE_CODER_STATE
|
|
||||||
int rangeFinal;
|
int rangeFinal;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline short SAT16(int x) {
|
static inline short SAT16(int x) {
|
||||||
|
|
|
@ -622,9 +622,8 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
|
||||||
data[0] |= (st->stream_channels==2)<<2;
|
data[0] |= (st->stream_channels==2)<<2;
|
||||||
/*printf ("%x\n", (int)data[0]);*/
|
/*printf ("%x\n", (int)data[0]);*/
|
||||||
|
|
||||||
#if OPUS_TEST_RANGE_CODER_STATE
|
|
||||||
st->rangeFinal = enc.rng;
|
st->rangeFinal = enc.rng;
|
||||||
#endif
|
|
||||||
if (to_celt)
|
if (to_celt)
|
||||||
st->prev_mode = MODE_CELT_ONLY;
|
st->prev_mode = MODE_CELT_ONLY;
|
||||||
else
|
else
|
||||||
|
@ -827,9 +826,7 @@ void opus_encoder_destroy(OpusEncoder *st)
|
||||||
free(st);
|
free(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OPUS_TEST_RANGE_CODER_STATE
|
|
||||||
int opus_encoder_get_final_range(OpusEncoder *st)
|
int opus_encoder_get_final_range(OpusEncoder *st)
|
||||||
{
|
{
|
||||||
return st->rangeFinal;
|
return st->rangeFinal;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -62,9 +62,7 @@ struct OpusEncoder {
|
||||||
int first;
|
int first;
|
||||||
short delay_buffer[MAX_ENCODER_BUFFER*2];
|
short delay_buffer[MAX_ENCODER_BUFFER*2];
|
||||||
|
|
||||||
#ifdef OPUS_TEST_RANGE_CODER_STATE
|
|
||||||
int rangeFinal;
|
int rangeFinal;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -350,9 +350,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
len[toggle] = opus_encode(enc, in, frame_size, data[toggle], max_payload_bytes);
|
len[toggle] = opus_encode(enc, in, frame_size, data[toggle], max_payload_bytes);
|
||||||
#if OPUS_TEST_RANGE_CODER_STATE
|
|
||||||
enc_final_range[toggle] = opus_encoder_get_final_range( enc );
|
enc_final_range[toggle] = opus_encoder_get_final_range( enc );
|
||||||
#endif
|
|
||||||
if (len[toggle] < 0)
|
if (len[toggle] < 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "opus_encode() returned %d\n", len[toggle]);
|
fprintf (stderr, "opus_encode() returned %d\n", len[toggle]);
|
||||||
|
@ -398,14 +396,12 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OPUS_TEST_RANGE_CODER_STATE
|
|
||||||
/* compare final range encoder rng values of encoder and decoder */
|
/* compare final range encoder rng values of encoder and decoder */
|
||||||
if( !encode_only && !lost && !lost_prev
|
if( !encode_only && !lost && !lost_prev
|
||||||
&& opus_decoder_get_final_range( dec ) != enc_final_range[toggle^use_inbandfec] ) {
|
&& opus_decoder_get_final_range( dec ) != enc_final_range[toggle^use_inbandfec] ) {
|
||||||
fprintf (stderr, "Error: Range coder state mismatch between encoder and decoder in frame %d.\n", count);
|
fprintf (stderr, "Error: Range coder state mismatch between encoder and decoder in frame %d.\n", count);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
lost_prev = lost;
|
lost_prev = lost;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue