Remove redundant code

frame_size_select() ensures that frame_size is a valid size or -1,
!st->variable_duration is always false, and delay_compensation is
no longer needed to choose the frame size.
This commit is contained in:
Mark Harris 2016-11-05 22:01:52 -07:00
parent d74fa2785a
commit d73c5a9618
No known key found for this signature in database
GPG key ID: 92293B4D0118BDB0
2 changed files with 3 additions and 26 deletions

View file

@ -1105,12 +1105,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
max_data_bytes = IMIN(1276, out_data_bytes);
st->rangeFinal = 0;
if ((!st->variable_duration && 400*frame_size != st->Fs && 200*frame_size != st->Fs && 100*frame_size != st->Fs &&
50*frame_size != st->Fs && 25*frame_size != st->Fs && 50*frame_size != 3*st->Fs && 50*frame_size != 4*st->Fs &&
50*frame_size != 5*st->Fs && 50*frame_size != 6*st->Fs)
|| (400*frame_size < st->Fs)
|| max_data_bytes<=0
)
if (frame_size <= 0 || max_data_bytes <= 0)
{
RESTORE_STACK;
return OPUS_BAD_ARG;

View file

@ -864,26 +864,8 @@ static int opus_multistream_encode_native
opus_encoder_ctl((OpusEncoder*)ptr, OPUS_GET_VBR(&vbr));
opus_encoder_ctl((OpusEncoder*)ptr, CELT_GET_MODE(&celt_mode));
{
opus_int32 delay_compensation;
opus_encoder_ctl((OpusEncoder*)ptr, OPUS_GET_LOOKAHEAD(&delay_compensation));
delay_compensation -= Fs/400;
frame_size = frame_size_select(analysis_frame_size, st->variable_duration, Fs);
}
if (400*frame_size < Fs)
{
RESTORE_STACK;
return OPUS_BAD_ARG;
}
/* 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 &&
50*frame_size != 4*Fs && 50*frame_size != 5*Fs &&
50*frame_size != 6*Fs)
frame_size = frame_size_select(analysis_frame_size, st->variable_duration, Fs);
if (frame_size <= 0)
{
RESTORE_STACK;
return OPUS_BAD_ARG;