diff mbox

[FFmpeg-devel,2/2] avcodec/g729dec: Avoid computing invalid temporary pointers for ff_acelp_weighted_vector_sum()

Message ID 20191017095956.5486-2-michael@niedermayer.cc
State Accepted
Commit 2c78a76cb0443f8a12a5eadc3b58373aa2f4ab22
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/g729dec.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Paul B Mahol Oct. 17, 2019, 10:27 a.m. UTC | #1
probably ok

On 10/17/19, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: Ticket8176
>
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/g729dec.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c
> index 25951716ef..67054b71df 100644
> --- a/libavcodec/g729dec.c
> +++ b/libavcodec/g729dec.c
> @@ -557,12 +557,13 @@ static int decode_frame(AVCodecContext *avctx, void
> *data, int *got_frame_ptr,
>                fc_v[i] = <
>                           \ fc_v[i] + gain_pitch * fc_v[i-pitch_delay], i >=
> pitch_delay
>              */
> -            ff_acelp_weighted_vector_sum(fc + pitch_delay_int[i],
> -                                         fc + pitch_delay_int[i],
> -                                         fc, 1 << 14,
> -                                         av_clip(ctx->past_gain_pitch[0],
> SHARP_MIN, SHARP_MAX),
> -                                         0, 14,
> -                                         SUBFRAME_SIZE -
> pitch_delay_int[i]);
> +            if (SUBFRAME_SIZE > pitch_delay_int[i])
> +                ff_acelp_weighted_vector_sum(fc + pitch_delay_int[i],
> +                                             fc + pitch_delay_int[i],
> +                                             fc, 1 << 14,
> +
> av_clip(ctx->past_gain_pitch[0], SHARP_MIN, SHARP_MAX),
> +                                             0, 14,
> +                                             SUBFRAME_SIZE -
> pitch_delay_int[i]);
>
>              memmove(ctx->past_gain_pitch+1, ctx->past_gain_pitch, 5 *
> sizeof(int16_t));
>              ctx->past_gain_code[1] = ctx->past_gain_code[0];
> --
> 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:02 p.m. UTC | #2
On Thu, Oct 17, 2019 at 12:27:39PM +0200, Paul B Mahol wrote:
> probably ok

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c
index 25951716ef..67054b71df 100644
--- a/libavcodec/g729dec.c
+++ b/libavcodec/g729dec.c
@@ -557,12 +557,13 @@  static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
               fc_v[i] = <
                          \ fc_v[i] + gain_pitch * fc_v[i-pitch_delay], i >= pitch_delay
             */
-            ff_acelp_weighted_vector_sum(fc + pitch_delay_int[i],
-                                         fc + pitch_delay_int[i],
-                                         fc, 1 << 14,
-                                         av_clip(ctx->past_gain_pitch[0], SHARP_MIN, SHARP_MAX),
-                                         0, 14,
-                                         SUBFRAME_SIZE - pitch_delay_int[i]);
+            if (SUBFRAME_SIZE > pitch_delay_int[i])
+                ff_acelp_weighted_vector_sum(fc + pitch_delay_int[i],
+                                             fc + pitch_delay_int[i],
+                                             fc, 1 << 14,
+                                             av_clip(ctx->past_gain_pitch[0], SHARP_MIN, SHARP_MAX),
+                                             0, 14,
+                                             SUBFRAME_SIZE - pitch_delay_int[i]);
 
             memmove(ctx->past_gain_pitch+1, ctx->past_gain_pitch, 5 * sizeof(int16_t));
             ctx->past_gain_code[1] = ctx->past_gain_code[0];