diff mbox series

[FFmpeg-devel,07/11] avcodec/aacenc_quantization: Remove always-zero function parameter

Message ID DB6PR0101MB2214CCEE335CC34291F3471D8F9A9@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit 386990a955c55e06dac278ea4d6cef940fb58e12
Headers show
Series [FFmpeg-devel,01/11] avcodec/flacdsp: Remove unused function parameter | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Aug. 1, 2022, 12:23 p.m. UTC
rtz is only ever nonzero for quantize_and_encode_band().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
This commit touches aaccoder_mips.c, but honestly I was not able
to compile it at all (neither before nor after this change),
because all I got were errors like:
"{standard input}:1114: Error: float register should be even, was 1"

Furthermore, ff_aac_coder_init_mips() is crazy: It overwrites pointers
in ff_aac_coders; the latter is a const array with static lifetime.
Modifying it will crash on every system that uses relro.
This encoder should probably use an ordinary DSP context that is part
of the context and not static instead.
(Anyway, most coder functions are always the same for all coders,
so the function pointer is unnecessary.)

 libavcodec/aaccoder.c                 | 14 +++++++-------
 libavcodec/aaccoder_trellis.h         |  2 +-
 libavcodec/aacenc_is.c                |  6 +++---
 libavcodec/aacenc_ltp.c               |  4 ++--
 libavcodec/aacenc_quantization.h      |  8 ++++----
 libavcodec/aacenc_quantization_misc.h |  2 +-
 libavcodec/mips/aaccoder_mips.c       | 12 ++++++------
 7 files changed, 24 insertions(+), 24 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index f460479498..2988247a15 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -123,7 +123,7 @@  static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce
                     rd += quantize_band_cost(s, &sce->coeffs[start + w*128],
                                              &s->scoefs[start + w*128], size,
                                              sce->sf_idx[(win+w)*16+swb], aac_cb_out_map[cb],
-                                             lambda / band->threshold, INFINITY, NULL, NULL, 0);
+                                             lambda / band->threshold, INFINITY, NULL, NULL);
                 }
                 cost_stay_here = path[swb][cb].cost + rd;
                 cost_get_here  = minrd              + rd + run_bits + 4;
@@ -346,7 +346,7 @@  static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s,
                     for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
                         FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
                         dist += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g],
-                                                   q + q0, cb, lambda / band->threshold, INFINITY, NULL, NULL, 0);
+                                                   q + q0, cb, lambda / band->threshold, INFINITY, NULL, NULL);
                     }
                     minrd = FFMIN(minrd, dist);
 
@@ -658,7 +658,7 @@  static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChanne
                                             sce->ics.swb_sizes[g],
                                             sce->sf_idx[(w+w2)*16+g],
                                             sce->band_alt[(w+w2)*16+g],
-                                            lambda/band->threshold, INFINITY, NULL, NULL, 0);
+                                            lambda/band->threshold, INFINITY, NULL, NULL);
                 /* Estimate rd on average as 5 bits for SF, 4 for the CB, plus spread energy * lambda/thr */
                 dist2 += band->energy/(band->spread*band->spread)*lambda*dist_thresh/band->threshold;
             }
@@ -842,25 +842,25 @@  static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
                                                     sce0->ics.swb_sizes[g],
                                                     sce0->sf_idx[w*16+g],
                                                     sce0->band_type[w*16+g],
-                                                    lambda / (band0->threshold + FLT_MIN), INFINITY, &b1, NULL, 0);
+                                                    lambda / (band0->threshold + FLT_MIN), INFINITY, &b1, NULL);
                         dist1 += quantize_band_cost(s, &sce1->coeffs[start + (w+w2)*128],
                                                     R34,
                                                     sce1->ics.swb_sizes[g],
                                                     sce1->sf_idx[w*16+g],
                                                     sce1->band_type[w*16+g],
-                                                    lambda / (band1->threshold + FLT_MIN), INFINITY, &b2, NULL, 0);
+                                                    lambda / (band1->threshold + FLT_MIN), INFINITY, &b2, NULL);
                         dist2 += quantize_band_cost(s, M,
                                                     M34,
                                                     sce0->ics.swb_sizes[g],
                                                     mididx,
                                                     midcb,
-                                                    lambda / (minthr + FLT_MIN), INFINITY, &b3, NULL, 0);
+                                                    lambda / (minthr + FLT_MIN), INFINITY, &b3, NULL);
                         dist2 += quantize_band_cost(s, S,
                                                     S34,
                                                     sce1->ics.swb_sizes[g],
                                                     sididx,
                                                     sidcb,
-                                                    mslambda / (minthr * bmax + FLT_MIN), INFINITY, &b4, NULL, 0);
+                                                    mslambda / (minthr * bmax + FLT_MIN), INFINITY, &b4, NULL);
                         B0 += b1+b2;
                         B1 += b3+b4;
                         dist1 -= b1+b2;
diff --git a/libavcodec/aaccoder_trellis.h b/libavcodec/aaccoder_trellis.h
index 940ebf029d..4810ff3208 100644
--- a/libavcodec/aaccoder_trellis.h
+++ b/libavcodec/aaccoder_trellis.h
@@ -127,7 +127,7 @@  static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce,
                                                &s->scoefs[start + w*128], size,
                                                sce->sf_idx[win*16+swb],
                                                aac_cb_out_map[cb],
-                                               0, INFINITY, NULL, NULL, 0);
+                                               0, INFINITY, NULL, NULL);
                 }
                 cost_stay_here = path[swb][cb].cost + bits;
                 cost_get_here  = minbits            + bits + run_bits + 4;
diff --git a/libavcodec/aacenc_is.c b/libavcodec/aacenc_is.c
index 2f5b7eb8dc..1810790d88 100644
--- a/libavcodec/aacenc_is.c
+++ b/libavcodec/aacenc_is.c
@@ -68,15 +68,15 @@  struct AACISError ff_aac_is_encoding_err(AACEncContext *s, ChannelElement *cpe,
                                     sce0->ics.swb_sizes[g],
                                     sce0->sf_idx[w*16+g],
                                     sce0->band_type[w*16+g],
-                                    s->lambda / band0->threshold, INFINITY, NULL, NULL, 0);
+                                    s->lambda / band0->threshold, INFINITY, NULL, NULL);
         dist1 += quantize_band_cost(s, &R[start + (w+w2)*128], R34,
                                     sce1->ics.swb_sizes[g],
                                     sce1->sf_idx[w*16+g],
                                     sce1->band_type[w*16+g],
-                                    s->lambda / band1->threshold, INFINITY, NULL, NULL, 0);
+                                    s->lambda / band1->threshold, INFINITY, NULL, NULL);
         dist2 += quantize_band_cost(s, IS, I34, sce0->ics.swb_sizes[g],
                                     is_sf_idx, is_band_type,
-                                    s->lambda / minthr, INFINITY, NULL, NULL, 0);
+                                    s->lambda / minthr, INFINITY, NULL, NULL);
         for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
             dist_spec_err += (L34[i] - I34[i])*(L34[i] - I34[i]);
             dist_spec_err += (R34[i] - I34[i]*e01_34)*(R34[i] - I34[i]*e01_34);
diff --git a/libavcodec/aacenc_ltp.c b/libavcodec/aacenc_ltp.c
index f77f0b6a72..f7fb85bbf8 100644
--- a/libavcodec/aacenc_ltp.c
+++ b/libavcodec/aacenc_ltp.c
@@ -194,11 +194,11 @@  void ff_aac_search_for_ltp(AACEncContext *s, SingleChannelElement *sce,
                 s->abs_pow34(PCD34, PCD, sce->ics.swb_sizes[g]);
                 dist1 += quantize_band_cost(s, &sce->coeffs[start+(w+w2)*128], C34, sce->ics.swb_sizes[g],
                                             sce->sf_idx[(w+w2)*16+g], sce->band_type[(w+w2)*16+g],
-                                            s->lambda/band->threshold, INFINITY, &bits_tmp1, NULL, 0);
+                                            s->lambda/band->threshold, INFINITY, &bits_tmp1, NULL);
                 dist2 += quantize_band_cost(s, PCD, PCD34, sce->ics.swb_sizes[g],
                                             sce->sf_idx[(w+w2)*16+g],
                                             sce->band_type[(w+w2)*16+g],
-                                            s->lambda/band->threshold, INFINITY, &bits_tmp2, NULL, 0);
+                                            s->lambda/band->threshold, INFINITY, &bits_tmp2, NULL);
                 bits1 += bits_tmp1;
                 bits2 += bits_tmp2;
             }
diff --git a/libavcodec/aacenc_quantization.h b/libavcodec/aacenc_quantization.h
index fc5a46b875..f3c3553886 100644
--- a/libavcodec/aacenc_quantization.h
+++ b/libavcodec/aacenc_quantization.h
@@ -250,20 +250,20 @@  static float (*const quantize_and_encode_band_cost_rtz_arr[])(
 static inline float quantize_band_cost(struct AACEncContext *s, const float *in,
                                 const float *scaled, int size, int scale_idx,
                                 int cb, const float lambda, const float uplim,
-                                int *bits, float *energy, int rtz)
+                                int *bits, float *energy)
 {
     return quantize_and_encode_band_cost(s, NULL, in, NULL, scaled, size, scale_idx,
-                                         cb, lambda, uplim, bits, energy, rtz);
+                                         cb, lambda, uplim, bits, energy, 0);
 }
 
 static inline int quantize_band_cost_bits(struct AACEncContext *s, const float *in,
                                 const float *scaled, int size, int scale_idx,
                                 int cb, const float lambda, const float uplim,
-                                int *bits, float *energy, int rtz)
+                                int *bits, float *energy)
 {
     int auxbits;
     quantize_and_encode_band_cost(s, NULL, in, NULL, scaled, size, scale_idx,
-                                         cb, 0.0f, uplim, &auxbits, energy, rtz);
+                                         cb, 0.0f, uplim, &auxbits, energy, 0);
     if (bits) {
         *bits = auxbits;
     }
diff --git a/libavcodec/aacenc_quantization_misc.h b/libavcodec/aacenc_quantization_misc.h
index 28676ca8d5..c789754f4f 100644
--- a/libavcodec/aacenc_quantization_misc.h
+++ b/libavcodec/aacenc_quantization_misc.h
@@ -38,7 +38,7 @@  static inline float quantize_band_cost_cached(struct AACEncContext *s, int w, in
     entry = &s->quantize_band_cost_cache[scale_idx][w*16+g];
     if (entry->generation != s->quantize_band_cost_cache_generation || entry->cb != cb || entry->rtz != rtz) {
         entry->rd = quantize_band_cost(s, in, scaled, size, scale_idx,
-                                       cb, lambda, uplim, &entry->bits, &entry->energy, rtz);
+                                       cb, lambda, uplim, &entry->bits, &entry->energy);
         entry->cb = cb;
         entry->rtz = rtz;
         entry->generation = s->quantize_band_cost_cache_generation;
diff --git a/libavcodec/mips/aaccoder_mips.c b/libavcodec/mips/aaccoder_mips.c
index d690c8c24a..bf27a2a5da 100644
--- a/libavcodec/mips/aaccoder_mips.c
+++ b/libavcodec/mips/aaccoder_mips.c
@@ -1472,7 +1472,7 @@  static float (*const get_band_numbits_arr[])(struct AACEncContext *s,
 static float quantize_band_cost_bits(struct AACEncContext *s, const float *in,
                                      const float *scaled, int size, int scale_idx,
                                      int cb, const float lambda, const float uplim,
-                                     int *bits, float *energy, int rtz)
+                                     int *bits, float *energy)
 {
     return get_band_numbits(s, NULL, in, scaled, size, scale_idx, cb, lambda, uplim, bits);
 }
@@ -2326,7 +2326,7 @@  static float (*const get_band_cost_arr[])(struct AACEncContext *s,
 static float quantize_band_cost(struct AACEncContext *s, const float *in,
                                 const float *scaled, int size, int scale_idx,
                                 int cb, const float lambda, const float uplim,
-                                int *bits, float *energy, int rtz)
+                                int *bits, float *energy)
 {
     return get_band_cost(s, NULL, in, scaled, size, scale_idx, cb, lambda, uplim, bits, energy);
 }
@@ -2424,25 +2424,25 @@  static void search_for_ms_mips(AACEncContext *s, ChannelElement *cpe)
                                                     sce0->ics.swb_sizes[g],
                                                     sce0->sf_idx[w*16+g],
                                                     sce0->band_type[w*16+g],
-                                                    lambda / band0->threshold, INFINITY, &b1, NULL, 0);
+                                                    lambda / band0->threshold, INFINITY, &b1, NULL);
                         dist1 += quantize_band_cost(s, &sce1->coeffs[start + (w+w2)*128],
                                                     R34,
                                                     sce1->ics.swb_sizes[g],
                                                     sce1->sf_idx[w*16+g],
                                                     sce1->band_type[w*16+g],
-                                                    lambda / band1->threshold, INFINITY, &b2, NULL, 0);
+                                                    lambda / band1->threshold, INFINITY, &b2, NULL);
                         dist2 += quantize_band_cost(s, M,
                                                     M34,
                                                     sce0->ics.swb_sizes[g],
                                                     mididx,
                                                     midcb,
-                                                    lambda / minthr, INFINITY, &b3, NULL, 0);
+                                                    lambda / minthr, INFINITY, &b3, NULL);
                         dist2 += quantize_band_cost(s, S,
                                                     S34,
                                                     sce1->ics.swb_sizes[g],
                                                     sididx,
                                                     sidcb,
-                                                    mslambda / (minthr * bmax), INFINITY, &b4, NULL, 0);
+                                                    mslambda / (minthr * bmax), INFINITY, &b4, NULL);
                         B0 += b1+b2;
                         B1 += b3+b4;
                         dist1 -= b1+b2;