Unverified Commit 0962cbe2 authored by Felicia Lim's avatar Felicia Lim Committed by Jean-Marc Valin

Support encoding 80/100/120 ms frame lengths

Signed-off-by: Jean-Marc Valin's avatarJean-Marc Valin <jmvalin@jmvalin.ca>
parent 8bca154b
......@@ -209,6 +209,9 @@ extern "C" {
#define OPUS_FRAMESIZE_20_MS 5004 /**< Use 20 ms frames */
#define OPUS_FRAMESIZE_40_MS 5005 /**< Use 40 ms frames */
#define OPUS_FRAMESIZE_60_MS 5006 /**< Use 60 ms frames */
#define OPUS_FRAMESIZE_80_MS 5007 /**< Use 80 ms frames */
#define OPUS_FRAMESIZE_100_MS 5008 /**< Use 100 ms frames */
#define OPUS_FRAMESIZE_120_MS 5009 /**< Use 120 ms frames */
/**@}*/
......@@ -567,6 +570,9 @@ extern "C" {
* <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd>
* <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd>
* <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd>
* <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd>
* <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd>
* <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd>
* <dt>OPUS_FRAMESIZE_VARIABLE</dt><dd>Optimize the frame size dynamically.</dd>
* </dl>
* @hideinitializer */
......@@ -582,6 +588,9 @@ extern "C" {
* <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd>
* <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd>
* <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd>
* <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd>
* <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd>
* <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd>
* <dt>OPUS_FRAMESIZE_VARIABLE</dt><dd>Optimize the frame size dynamically.</dd>
* </dl>
* @hideinitializer */
......
......@@ -57,7 +57,7 @@ void print_usage( char* argv[] )
fprintf(stderr, "-variable-duration : enable frames of variable duration (experimental, experts only); default: disabled\n" );
fprintf(stderr, "-delayed-decision : use look-ahead for speech/music detection (experts only); default: disabled\n" );
fprintf(stderr, "-bandwidth <NB|MB|WB|SWB|FB> : audio bandwidth (from narrowband to fullband); default: sampling rate\n" );
fprintf(stderr, "-framesize <2.5|5|10|20|40|60> : frame size in ms; default: 20 \n" );
fprintf(stderr, "-framesize <2.5|5|10|20|40|60|80|100|120> : frame size in ms; default: 20 \n" );
fprintf(stderr, "-max_payload <bytes> : maximum payload size in bytes, default: 1024\n" );
fprintf(stderr, "-complexity <comp> : complexity, 0 (lowest) ... 10 (highest); default: 10\n" );
fprintf(stderr, "-inbandfec : enable SILK inband FEC\n" );
......@@ -383,9 +383,15 @@ int main(int argc, char *argv[])
frame_size = sampling_rate/25;
else if (strcmp(argv[ args + 1 ], "60")==0)
frame_size = 3*sampling_rate/50;
else if (strcmp(argv[ args + 1 ], "80")==0)
frame_size = 4*sampling_rate/50;
else if (strcmp(argv[ args + 1 ], "100")==0)
frame_size = 5*sampling_rate/50;
else if (strcmp(argv[ args + 1 ], "120")==0)
frame_size = 6*sampling_rate/50;
else {
fprintf(stderr, "Unsupported frame size: %s ms. "
"Supported are 2.5, 5, 10, 20, 40, 60.\n",
"Supported are 2.5, 5, 10, 20, 40, 60, 80, 100, 120.\n",
argv[ args + 1 ]);
return EXIT_FAILURE;
}
......@@ -612,8 +618,14 @@ int main(int argc, char *argv[])
variable_duration = OPUS_FRAMESIZE_20_MS;
else if (frame_size==sampling_rate/25)
variable_duration = OPUS_FRAMESIZE_40_MS;
else
else if (frame_size==3*sampling_rate/50)
variable_duration = OPUS_FRAMESIZE_60_MS;
else if (frame_size==4*sampling_rate/50)
variable_duration = OPUS_FRAMESIZE_80_MS;
else if (frame_size==5*sampling_rate/50)
variable_duration = OPUS_FRAMESIZE_100_MS;
else
variable_duration = OPUS_FRAMESIZE_120_MS;
opus_encoder_ctl(enc, OPUS_SET_EXPERT_FRAME_DURATION(variable_duration));
}
frame_size = 2*48000;
......
This diff is collapsed.
......@@ -835,8 +835,8 @@ static opus_int32 rate_allocation(
return rate_sum;
}
/* Max size in case the encoder decides to return three frames */
#define MS_FRAME_TMP (3*1275+7)
/* Max size in case the encoder decides to return six frames (6 x 20 ms = 120 ms) */
#define MS_FRAME_TMP (6*1275+12)
static int opus_multistream_encode_native
(
OpusMSEncoder *st,
......@@ -903,9 +903,11 @@ static int opus_multistream_encode_native
}
/* Validate frame_size before using it to allocate stack space.
This mirrors the checks in opus_encode[_float](). */
if (400*frame_size != Fs && 200*frame_size != Fs &&
100*frame_size != Fs && 50*frame_size != Fs &&
25*frame_size != Fs && 50*frame_size != 3*Fs)
if (400*frame_size != Fs && 200*frame_size != Fs &&
100*frame_size != Fs && 50*frame_size != Fs &&
25*frame_size != Fs && 50*frame_size != 3*Fs &&
50*frame_size != 4*Fs && 50*frame_size != 5*Fs &&
50*frame_size != 6*Fs)
{
RESTORE_STACK;
return OPUS_BAD_ARG;
......
......@@ -1383,6 +1383,15 @@ opus_int32 test_enc_api(void)
err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_60_MS));
if(err!=OPUS_OK)test_failed();
cfgs++;
err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_80_MS));
if(err!=OPUS_OK)test_failed();
cfgs++;
err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_100_MS));
if(err!=OPUS_OK)test_failed();
cfgs++;
err=opus_encoder_ctl(enc,OPUS_SET_EXPERT_FRAME_DURATION(OPUS_FRAMESIZE_120_MS));
if(err!=OPUS_OK)test_failed();
cfgs++;
CHECK_SETGET(OPUS_SET_EXPERT_FRAME_DURATION(i),OPUS_GET_EXPERT_FRAME_DURATION(&i),0,-1,
OPUS_FRAMESIZE_60_MS,OPUS_FRAMESIZE_ARG,
" OPUS_SET_EXPERT_FRAME_DURATION ............... OK.\n",
......
......@@ -128,6 +128,12 @@ int get_frame_size_enum(int frame_size, int sampling_rate)
frame_size_enum = OPUS_FRAMESIZE_40_MS;
else if(frame_size==3*sampling_rate/50)
frame_size_enum = OPUS_FRAMESIZE_60_MS;
else if(frame_size==4*sampling_rate/50)
frame_size_enum = OPUS_FRAMESIZE_80_MS;
else if(frame_size==5*sampling_rate/50)
frame_size_enum = OPUS_FRAMESIZE_100_MS;
else if(frame_size==6*sampling_rate/50)
frame_size_enum = OPUS_FRAMESIZE_120_MS;
else
test_failed();
......@@ -189,14 +195,16 @@ void fuzz_encoder_settings(const int num_encoders, const int num_setting_changes
int use_vbr[3] = {0, 1, 1};
int vbr_constraints[3] = {0, 1, 1};
int complexities[11] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int max_bandwidths[6] = {OPUS_BANDWIDTH_NARROWBAND, OPUS_BANDWIDTH_MEDIUMBAND, OPUS_BANDWIDTH_WIDEBAND, OPUS_BANDWIDTH_SUPERWIDEBAND, OPUS_BANDWIDTH_FULLBAND, OPUS_BANDWIDTH_FULLBAND};
int max_bandwidths[6] = {OPUS_BANDWIDTH_NARROWBAND, OPUS_BANDWIDTH_MEDIUMBAND,
OPUS_BANDWIDTH_WIDEBAND, OPUS_BANDWIDTH_SUPERWIDEBAND,
OPUS_BANDWIDTH_FULLBAND, OPUS_BANDWIDTH_FULLBAND};
int signals[4] = {OPUS_AUTO, OPUS_AUTO, OPUS_SIGNAL_VOICE, OPUS_SIGNAL_MUSIC};
int inband_fecs[3] = {0, 0, 1};
int packet_loss_perc[4] = {0, 1, 2, 5};
int lsb_depths[2] = {8, 24};
int prediction_disabled[3] = {0, 0, 1};
int use_dtx[2] = {0, 1};
int frame_sizes_ms_x2[6] = {5, 10, 20, 40, 80, 120}; /* x2 to avoid 2.5 ms */
int frame_sizes_ms_x2[9] = {5, 10, 20, 40, 80, 120, 160, 200, 240}; /* x2 to avoid 2.5 ms */
char debug_info[512];
for (i=0; i<num_encoders; i++) {
......@@ -228,6 +236,12 @@ void fuzz_encoder_settings(const int num_encoders, const int num_setting_changes
int frame_size_enum = get_frame_size_enum(frame_size, sampling_rate);
force_channel = IMIN(force_channel, num_channels);
/* Todo: remove when a fix is available for coding SILK in DTX mode for >60 ms.
* Currently, SILK may internally adjust the bandwidth leading to mismatching
* bandwidths within a packet. */
if (frame_size_ms_x2 > 120)
dtx = 0;
sprintf(debug_info,
"fuzz_encoder_settings: %d kHz, %d ch, application: %d, "
"%d bps, force ch: %d, vbr: %d, vbr constraint: %d, complexity: %d, "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment