shithub: opus

Download patch

ref: d73c5a9618fb1c5fd9dd04a3e3314f183090e44a
parent: d74fa2785a7ca3d25767e90bbc09c11cfcf07349
author: Mark Harris <mark.hsj@gmail.com>
date: Sat Nov 5 18:01:52 EDT 2016

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.

--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -1105,12 +1105,7 @@
     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;
--- a/src/opus_multistream_encoder.c
+++ b/src/opus_multistream_encoder.c
@@ -864,26 +864,8 @@
    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;