diff options
Diffstat (limited to 'src/opus_demo.c')
-rw-r--r-- | src/opus_demo.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/opus_demo.c b/src/opus_demo.c index a448065a..a0acb0cd 100644 --- a/src/opus_demo.c +++ b/src/opus_demo.c @@ -245,6 +245,7 @@ int main(int argc, char *argv[]) int nb_encoded; int remaining=0; int variable_duration=OPUS_FRAMESIZE_ARG; + int delayed_decision=0; if (argc < 5 ) { @@ -313,7 +314,7 @@ int main(int argc, char *argv[]) forcechannels = OPUS_AUTO; use_dtx = 0; packet_loss_perc = 0; - max_frame_size = 48000; + max_frame_size = 2*48000; curr_read=0; while( args < argc - 2 ) { @@ -385,6 +386,10 @@ int main(int argc, char *argv[]) check_encoder_option(decode_only, "-variable-duration"); variable_duration = OPUS_FRAMESIZE_VARIABLE; args++; + } else if( strcmp( argv[ args ], "-delayed-decision" ) == 0 ) { + check_encoder_option(decode_only, "-delayed-decision"); + delayed_decision = 1; + args++; } else if( strcmp( argv[ args ], "-dtx") == 0 ) { check_encoder_option(decode_only, "-dtx"); use_dtx = 1; @@ -566,7 +571,26 @@ int main(int argc, char *argv[]) if ( use_inbandfec ) { data[1] = (unsigned char*)calloc(max_payload_bytes,sizeof(char)); } - frame_size = 48000; + if(delayed_decision) + { + if (variable_duration!=OPUS_FRAMESIZE_VARIABLE) + { + if (frame_size==sampling_rate/400) + variable_duration = OPUS_FRAMESIZE_2_5_MS; + else if (frame_size==sampling_rate/200) + variable_duration = OPUS_FRAMESIZE_5_MS; + else if (frame_size==sampling_rate/100) + variable_duration = OPUS_FRAMESIZE_10_MS; + else if (frame_size==sampling_rate/50) + variable_duration = OPUS_FRAMESIZE_20_MS; + else if (frame_size==sampling_rate/25) + variable_duration = OPUS_FRAMESIZE_40_MS; + else + variable_duration = OPUS_FRAMESIZE_60_MS; + opus_encoder_ctl(enc, OPUS_SET_EXPERT_FRAME_DURATION(variable_duration)); + } + frame_size = 2*48000; + } while (!stop) { if (delayed_celt) |