diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2013-02-20 03:55:35 -0500 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2013-02-20 03:55:35 -0500 |
commit | 5a6912d46449cb77e799f6c18f31b3108c5b3780 (patch) | |
tree | e963338c7c0b091ed7d03512fb6d7b62d096ccc0 | |
parent | ff0f40827bf175b37eeedd98d83e1b1f5da071eb (diff) | |
download | opus-exp_delayed_decision.tar.gz |
Updates opus_demoexp_delayed_decision
-rw-r--r-- | src/opus_demo.c | 28 | ||||
-rw-r--r-- | src/opus_encoder.c | 2 |
2 files changed, 27 insertions, 3 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) diff --git a/src/opus_encoder.c b/src/opus_encoder.c index f189689d..3cee88b3 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -776,7 +776,7 @@ opus_int32 frame_size_select(opus_int32 frame_size, int variable_duration, opus_ new_size = IMAX(3*Fs/50, (Fs/400)<<(variable_duration-OPUS_FRAMESIZE_2_5_MS)); else return -1; - if (new_size<frame_size) + if (new_size>frame_size) return -1; if (400*new_size!=Fs && 200*new_size!=Fs && 100*new_size!=Fs && 50*new_size!=Fs && 25*new_size!=Fs && 50*new_size!=3*Fs) |