[FFmpeg-devel] [PATCH 2/4] avcodec/siren: remove constant region_size

Michael Niedermayer michael at niedermayer.cc
Fri Dec 25 01:24:17 EET 2020


Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/siren.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavcodec/siren.c b/libavcodec/siren.c
index b1b4944562..0713ef25e7 100644
--- a/libavcodec/siren.c
+++ b/libavcodec/siren.c
@@ -352,6 +352,7 @@ static const float noise_category6[20] = {
 };
 
 #define FRAME_SIZE 320
+#define REGION_SIZE 20
 
 typedef struct SirenContext {
     GetBitContext gb;
@@ -361,7 +362,6 @@ typedef struct SirenContext {
     int number_of_regions;
     int scale_factor;
     int sample_rate_bits;
-    int region_size;
 
     unsigned dw1, dw2, dw3, dw4;
 
@@ -402,7 +402,6 @@ static av_cold int siren_init(AVCodecContext *avctx)
     s->esf_adjustment = 7;
     s->number_of_regions = 14;
     s->scale_factor = 22;
-    s->region_size = 20;
     s->dw1 = s->dw2 = s->dw3 = s->dw4 = 1;
 
     for (i = 0; i < 64; i++) {
@@ -574,7 +573,7 @@ static int decode_vector(SirenContext *s, int number_of_regions,
 
     for (region = 0; region < number_of_regions; region++) {
         category = power_categories[region];
-        coefs_ptr = coefs + (region * s->region_size);
+        coefs_ptr = coefs + (region * REGION_SIZE);
 
         if (category >= 0 && category < 7) {
             decoder_tree = decoder_tables[category];
@@ -623,11 +622,11 @@ static int decode_vector(SirenContext *s, int number_of_regions,
             }
         }
 
-        coefs_ptr = coefs + (region * s->region_size);
+        coefs_ptr = coefs + (region * REGION_SIZE);
 
         if (category == 5) {
             i = 0;
-            for (j = 0; j < s->region_size; j++) {
+            for (j = 0; j < REGION_SIZE; j++) {
                 if (*coefs_ptr != 0)
                     i++;
                 coefs_ptr++;
@@ -636,7 +635,7 @@ static int decode_vector(SirenContext *s, int number_of_regions,
             noise = decoder_standard_deviation[region] * noise_category5[i];
         } else if (category == 6) {
             i = 0;
-            for (j = 0; j < s->region_size; j++) {
+            for (j = 0; j < REGION_SIZE; j++) {
                 if (*coefs_ptr++ != 0)
                     i++;
             }
@@ -648,7 +647,7 @@ static int decode_vector(SirenContext *s, int number_of_regions,
             noise = 0;
         }
 
-        coefs_ptr = coefs + (region * s->region_size);
+        coefs_ptr = coefs + (region * REGION_SIZE);
 
         if (category == 5 || category == 6 || category == 7) {
             dw1 = get_dw(s);
-- 
2.17.1



More information about the ffmpeg-devel mailing list