]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/asrc_sine: Fix invalid left shift of negative number
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 22 Jan 2020 01:05:10 +0000 (02:05 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Sun, 28 Mar 2021 16:45:20 +0000 (18:45 +0200)
by using a multiplication instead. The multiplication can never overflow
an int because the sin-factor is only an int16_t.

Affected the FATE-tests filter-concat and filter-concat-vfr.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavfilter/asrc_sine.c

index 6fe080efb69744d9e31d35997f4a205c0f1a0493..3b7d2e6d0072ea7f220f79158df6b3a07e844f10 100644 (file)
@@ -247,7 +247,7 @@ static int request_frame(AVFilterLink *outlink)
         samples[i] = sine->sin[sine->phi >> (32 - LOG_PERIOD)];
         sine->phi += sine->dphi;
         if (sine->beep_index < sine->beep_length) {
-            samples[i] += sine->sin[sine->phi_beep >> (32 - LOG_PERIOD)] << 1;
+            samples[i] += sine->sin[sine->phi_beep >> (32 - LOG_PERIOD)] * 2;
             sine->phi_beep += sine->dphi_beep;
         }
         if (++sine->beep_index == sine->beep_period)