[FFmpeg-devel] [PATCH] avcodec/lpc: use ptrdiff_t for length parameters

James Almer jamrial at gmail.com
Thu Sep 22 19:42:18 EEST 2022


Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/lpc.c          | 4 ++--
 libavcodec/lpc.h          | 5 +++--
 libavcodec/x86/lpc.asm    | 1 -
 libavcodec/x86/lpc_init.c | 6 +++---
 tests/checkasm/lpc.c      | 2 +-
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c
index 4885d5cb06..8603bb9709 100644
--- a/libavcodec/lpc.c
+++ b/libavcodec/lpc.c
@@ -31,7 +31,7 @@
 /**
  * Apply Welch window function to audio block
  */
-static void lpc_apply_welch_window_c(const int32_t *data, int len,
+static void lpc_apply_welch_window_c(const int32_t *data, ptrdiff_t len,
                                      double *w_data)
 {
     int i, n2;
@@ -70,7 +70,7 @@ static void lpc_apply_welch_window_c(const int32_t *data, int len,
  * Calculate autocorrelation data from audio samples
  * A Welch window function is applied before calculation.
  */
-static void lpc_compute_autocorr_c(const double *data, int len, int lag,
+static void lpc_compute_autocorr_c(const double *data, ptrdiff_t len, int lag,
                                    double *autoc)
 {
     int i, j;
diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h
index e1b41bfd9b..467d0b2830 100644
--- a/libavcodec/lpc.h
+++ b/libavcodec/lpc.h
@@ -23,6 +23,7 @@
 #define AVCODEC_LPC_H
 
 #include <stdint.h>
+#include <stddef.h>
 #include "libavutil/avassert.h"
 #include "libavutil/lls.h"
 #include "aac_defines.h"
@@ -64,7 +65,7 @@ typedef struct LPCContext {
      * @param len     number of input samples
      * @param w_data  output samples
      */
-    void (*lpc_apply_welch_window)(const int32_t *data, int len,
+    void (*lpc_apply_welch_window)(const int32_t *data, ptrdiff_t len,
                                    double *w_data);
     /**
      * Perform autocorrelation on input samples with delay of 0 to lag.
@@ -79,7 +80,7 @@ typedef struct LPCContext {
      * @param autoc output autocorrelation coefficients.
      *              constraints: array size must be at least lag+1.
      */
-    void (*lpc_compute_autocorr)(const double *data, int len, int lag,
+    void (*lpc_compute_autocorr)(const double *data, ptrdiff_t len, int lag,
                                  double *autoc);
 
     // TODO: these should be allocated to reduce ABI compatibility issues
diff --git a/libavcodec/x86/lpc.asm b/libavcodec/x86/lpc.asm
index 731aa7e2d8..ad74f1d8ac 100644
--- a/libavcodec/x86/lpc.asm
+++ b/libavcodec/x86/lpc.asm
@@ -36,7 +36,6 @@ SECTION .text
 
 %macro APPLY_WELCH_FN 0
 cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2
-    movsxdifnidn lenq, lend
     cmp lenq, 0
     je .end
     cmp lenq, 2
diff --git a/libavcodec/x86/lpc_init.c b/libavcodec/x86/lpc_init.c
index df77c966c6..f2fca53799 100644
--- a/libavcodec/x86/lpc_init.c
+++ b/libavcodec/x86/lpc_init.c
@@ -24,16 +24,16 @@
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/lpc.h"
 
-void ff_lpc_apply_welch_window_sse2(const int32_t *data, int len,
+void ff_lpc_apply_welch_window_sse2(const int32_t *data, ptrdiff_t len,
                                     double *w_data);
-void ff_lpc_apply_welch_window_avx2(const int32_t *data, int len,
+void ff_lpc_apply_welch_window_avx2(const int32_t *data, ptrdiff_t len,
                                     double *w_data);
 
 DECLARE_ASM_CONST(16, double, pd_1)[2] = { 1.0, 1.0 };
 
 #if HAVE_SSE2_INLINE
 
-static void lpc_compute_autocorr_sse2(const double *data, int len, int lag,
+static void lpc_compute_autocorr_sse2(const double *data, ptrdiff_t len, int lag,
                                       double *autoc)
 {
     int j;
diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c
index e072599908..da5364def0 100644
--- a/tests/checkasm/lpc.c
+++ b/tests/checkasm/lpc.c
@@ -38,7 +38,7 @@ static void test_window(int len)
     LOCAL_ALIGNED(16, double, dst0, [5000]);
     LOCAL_ALIGNED(16, double, dst1, [5000]);
 
-    declare_func(void, int32_t *in, int len, double *out);
+    declare_func(void, const int32_t *in, ptrdiff_t len, double *out);
 
     randomize_int32(src, len);
 
-- 
2.37.3



More information about the ffmpeg-devel mailing list