summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/opus_decoder.c2
-rw-r--r--src/opus_demo.c9
-rw-r--r--src/opus_encoder.c31
3 files changed, 40 insertions, 2 deletions
diff --git a/src/opus_decoder.c b/src/opus_decoder.c
index 4c238a8a..670a898d 100644
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -658,6 +658,7 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data,
/* For FEC/PLC, frame_size has to be to have a multiple of 2.5 ms */
if ((decode_fec || len==0 || data==NULL) && frame_size%(st->Fs/400)!=0)
return OPUS_BAD_ARG;
+#ifdef ENABLE_NEURAL_FEC
if (decode_fec > 0 && st->nb_fec_frames > 0) {
int features_per_frame;
int needed_feature_frames;
@@ -674,6 +675,7 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data,
}
}
+#endif
if (len==0 || data==NULL)
{
int pcm_count=0;
diff --git a/src/opus_demo.c b/src/opus_demo.c
index 50a66db3..af5e30f3 100644
--- a/src/opus_demo.c
+++ b/src/opus_demo.c
@@ -64,6 +64,7 @@ void print_usage( char* argv[] )
fprintf(stderr, "-dtx : enable SILK DTX\n" );
fprintf(stderr, "-loss <perc> : optimize for loss percentage and simulate packet loss, in percent (0-100); default: 0\n" );
fprintf(stderr, "-lossfile <file> : simulate packet loss, reading loss from file\n" );
+ fprintf(stderr, "-dred <frames> : add Deep REDundancy (in units of 10-ms frames)\n" );
}
static void int_to_char(opus_uint32 i, unsigned char ch[4])
@@ -266,6 +267,7 @@ int main(int argc, char *argv[])
int ret = EXIT_FAILURE;
int lost_count=0;
FILE *packet_loss_file=NULL;
+ int dred_duration=0;
if (argc < 5 )
{
@@ -431,6 +433,9 @@ int main(int argc, char *argv[])
exit(1);
}
args += 2;
+ } else if( strcmp( argv[ args ], "-dred" ) == 0 ) {
+ dred_duration = atoi( argv[ args + 1 ] );
+ args += 2;
} else if( strcmp( argv[ args ], "-sweep" ) == 0 ) {
check_encoder_option(decode_only, "-sweep");
sweep_bps = atoi( argv[ args + 1 ] );
@@ -546,6 +551,10 @@ int main(int argc, char *argv[])
opus_encoder_ctl(enc, OPUS_GET_LOOKAHEAD(&skip));
opus_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(16));
opus_encoder_ctl(enc, OPUS_SET_EXPERT_FRAME_DURATION(variable_duration));
+ if (dred_duration > 0)
+ {
+ opus_encoder_ctl(enc, OPUS_SET_DRED_DURATION(dred_duration));
+ }
}
if (!encode_only)
{
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index 47a4d6eb..4d571c28 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -116,6 +116,9 @@ struct OpusEncoder {
int nb_no_activity_ms_Q1;
opus_val32 peak_signal_energy;
#endif
+#ifdef ENABLE_NEURAL_FEC
+ int dred_duration;
+#endif
int nonfinal_frame; /* current frame is not the final in a packet */
opus_uint32 rangeFinal;
};
@@ -2180,13 +2183,15 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
/* Count ToC and redundancy */
ret += 1+redundancy_bytes;
#ifdef ENABLE_NEURAL_FEC
- if (1) {
+ if (st->dred_duration > 0) {
opus_extension_data extension;
unsigned char buf[DRED_MAX_DATA_SIZE];
+ int dred_chunks;
int dred_bytes;
DREDEnc *dred = &((silk_encoder*)silk_enc)->state_Fxx[0].sCmn.dred_encoder;
+ dred_chunks = IMIN(st->dred_duration/4, DRED_NUM_REDUNDANCY_FRAMES/2);
dred_bytes = IMIN(DRED_MAX_DATA_SIZE, max_data_bytes-ret-2);
- dred_bytes = dred_encode_silk_frame(dred, buf, DRED_NUM_REDUNDANCY_FRAMES/2, dred_bytes);
+ dred_bytes = dred_encode_silk_frame(dred, buf, dred_chunks, dred_bytes);
extension.id = 127;
extension.frame = 0;
extension.data = buf;
@@ -2698,6 +2703,28 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...)
celt_encoder_ctl(celt_enc, OPUS_GET_PHASE_INVERSION_DISABLED(value));
}
break;
+#ifdef ENABLE_NEURAL_FEC
+ case OPUS_SET_DRED_DURATION_REQUEST:
+ {
+ opus_int32 value = va_arg(ap, opus_int32);
+ if(value<0 || value>DRED_MAX_FRAMES)
+ {
+ goto bad_arg;
+ }
+ st->dred_duration = value;
+ }
+ break;
+ case OPUS_GET_DRED_DURATION_REQUEST:
+ {
+ opus_int32 *value = va_arg(ap, opus_int32*);
+ if (!value)
+ {
+ goto bad_arg;
+ }
+ *value = st->dred_duration;
+ }
+ break;
+#endif
case OPUS_RESET_STATE:
{
void *silk_enc;