diff mbox series

[FFmpeg-devel,1/6] avcodec/g723_1enc: Remove unnecessary av_clipl_int32()

Message ID GV1P250MB07375B940CCAEBC469BD60EE8F549@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit e47f3e366bc0760dbd44b5d555c1bb601a1d5011
Headers show
Series [FFmpeg-devel,1/6] avcodec/g723_1enc: Remove unnecessary av_clipl_int32() | expand

Commit Message

Andreas Rheinhardt Sept. 28, 2022, 6:56 p.m. UTC
partial_corr is an int16_t and so the av_clipl_int32()
never clips and can be removed. This also avoids
undefined left-shifts of negative numbers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/g723_1enc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Andreas Rheinhardt Oct. 2, 2022, 5:17 p.m. UTC | #1
Andreas Rheinhardt:
> partial_corr is an int16_t and so the av_clipl_int32()
> never clips and can be removed. This also avoids
> undefined left-shifts of negative numbers.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/g723_1enc.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavcodec/g723_1enc.c b/libavcodec/g723_1enc.c
> index f3baf7b4ec..a22985ca44 100644
> --- a/libavcodec/g723_1enc.c
> +++ b/libavcodec/g723_1enc.c
> @@ -200,8 +200,7 @@ static void levinson_durbin(int16_t *lpc, int16_t *autocorr, int16_t error)
>  
>          partial_corr = temp / (error << 1);
>  
> -        lpc[i] = av_clipl_int32((int64_t) (partial_corr << 14) +
> -                                (1 << 15)) >> 16;
> +        lpc[i] = (partial_corr + (1 << 1)) >> 2;
>  
>          /* Update the prediction error */
>          temp  = MULL2(temp, partial_corr);

Will apply the remaining patches of this patchset tomorrow unless there
are objections.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/g723_1enc.c b/libavcodec/g723_1enc.c
index f3baf7b4ec..a22985ca44 100644
--- a/libavcodec/g723_1enc.c
+++ b/libavcodec/g723_1enc.c
@@ -200,8 +200,7 @@  static void levinson_durbin(int16_t *lpc, int16_t *autocorr, int16_t error)
 
         partial_corr = temp / (error << 1);
 
-        lpc[i] = av_clipl_int32((int64_t) (partial_corr << 14) +
-                                (1 << 15)) >> 16;
+        lpc[i] = (partial_corr + (1 << 1)) >> 2;
 
         /* Update the prediction error */
         temp  = MULL2(temp, partial_corr);