diff mbox series

[FFmpeg-devel,3/4] avcodec/siren: Factorize category 5 and 6 noise computation

Message ID 20201224232419.10369-3-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/4] avformat/mpc8: Check size before implicitly converting to int
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer Dec. 24, 2020, 11:24 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/siren.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/siren.c b/libavcodec/siren.c
index 0713ef25e7..1f37305bd1 100644
--- a/libavcodec/siren.c
+++ b/libavcodec/siren.c
@@ -624,7 +624,7 @@  static int decode_vector(SirenContext *s, int number_of_regions,
 
         coefs_ptr = coefs + (region * REGION_SIZE);
 
-        if (category == 5) {
+        if (category == 5 || category == 6) {
             i = 0;
             for (j = 0; j < REGION_SIZE; j++) {
                 if (*coefs_ptr != 0)
@@ -632,15 +632,10 @@  static int decode_vector(SirenContext *s, int number_of_regions,
                 coefs_ptr++;
             }
 
-            noise = decoder_standard_deviation[region] * noise_category5[i];
-        } else if (category == 6) {
-            i = 0;
-            for (j = 0; j < REGION_SIZE; j++) {
-                if (*coefs_ptr++ != 0)
-                    i++;
-            }
-
-            noise = decoder_standard_deviation[region] * noise_category6[i];
+            if (category == 5) {
+                noise = decoder_standard_deviation[region] * noise_category5[i];
+            } else
+                noise = decoder_standard_deviation[region] * noise_category6[i];
         } else if (category == 7) {
             noise = decoder_standard_deviation[region] * 0.70711f;
         } else {