diff mbox

[FFmpeg-devel,1/2] avcodec/g729postfilter: Fix left shift of negative value

Message ID 20191017095956.5486-1-michael@niedermayer.cc
State Accepted
Commit 5f0acc5064ed501cb40d4aaccae2b3ce5c4552fd
Headers show

Commit Message

Michael Niedermayer Oct. 17, 2019, 9:59 a.m. UTC
Fixes: Ticket8176

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/g729postfilter.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Paul B Mahol Oct. 17, 2019, 10:28 a.m. UTC | #1
lgtm

On 10/17/19, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: Ticket8176
>
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/g729postfilter.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/g729postfilter.c b/libavcodec/g729postfilter.c
> index ef4fec4c95..fc9a8d54cc 100644
> --- a/libavcodec/g729postfilter.c
> +++ b/libavcodec/g729postfilter.c
> @@ -346,7 +346,7 @@ static int16_t long_term_filter(AudioDSPContext *adsp,
> int pitch_delay_int,
>          L_temp1 = gain_long_num * gain_long_num;
>          L_temp1 = MULL(L_temp1, gain_den, FRAC_BITS);
>
> -        tmp = ((sh_gain_long_num - sh_gain_num) << 1) - (sh_gain_long_den -
> sh_gain_den);
> +        tmp = ((sh_gain_long_num - sh_gain_num) * 2) - (sh_gain_long_den -
> sh_gain_den);
>          if (tmp > 0)
>              L_temp0 >>= tmp;
>          else
> @@ -367,7 +367,7 @@ static int16_t long_term_filter(AudioDSPContext *adsp,
> int pitch_delay_int,
>          /* Rescale selected signal to original value. */
>          if (shift > 0)
>              for (i = 0; i < subframe_size; i++)
> -                selected_signal[i] <<= shift;
> +                selected_signal[i] *= 1 << shift;
>          else
>              for (i = 0; i < subframe_size; i++)
>                  selected_signal[i] >>= -shift;
> @@ -464,7 +464,7 @@ static int16_t get_tilt_comp(AudioDSPContext *adsp,
> int16_t *lp_gn,
>              speech[i] = (speech[i] * temp + 0x4000) >> 15;
>      }
>
> -    return -(rh1 << 15) / rh0;
> +    return -(rh1 * (1 << 15)) / rh0;
>  }
>
>  /**
> --
> 2.23.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer Oct. 19, 2019, 4:01 p.m. UTC | #2
On Thu, Oct 17, 2019 at 12:28:18PM +0200, Paul B Mahol wrote:
> lgtm

will apply

thx


[...]
diff mbox

Patch

diff --git a/libavcodec/g729postfilter.c b/libavcodec/g729postfilter.c
index ef4fec4c95..fc9a8d54cc 100644
--- a/libavcodec/g729postfilter.c
+++ b/libavcodec/g729postfilter.c
@@ -346,7 +346,7 @@  static int16_t long_term_filter(AudioDSPContext *adsp, int pitch_delay_int,
         L_temp1 = gain_long_num * gain_long_num;
         L_temp1 = MULL(L_temp1, gain_den, FRAC_BITS);
 
-        tmp = ((sh_gain_long_num - sh_gain_num) << 1) - (sh_gain_long_den - sh_gain_den);
+        tmp = ((sh_gain_long_num - sh_gain_num) * 2) - (sh_gain_long_den - sh_gain_den);
         if (tmp > 0)
             L_temp0 >>= tmp;
         else
@@ -367,7 +367,7 @@  static int16_t long_term_filter(AudioDSPContext *adsp, int pitch_delay_int,
         /* Rescale selected signal to original value. */
         if (shift > 0)
             for (i = 0; i < subframe_size; i++)
-                selected_signal[i] <<= shift;
+                selected_signal[i] *= 1 << shift;
         else
             for (i = 0; i < subframe_size; i++)
                 selected_signal[i] >>= -shift;
@@ -464,7 +464,7 @@  static int16_t get_tilt_comp(AudioDSPContext *adsp, int16_t *lp_gn,
             speech[i] = (speech[i] * temp + 0x4000) >> 15;
     }
 
-    return -(rh1 << 15) / rh0;
+    return -(rh1 * (1 << 15)) / rh0;
 }
 
 /**