[FFmpeg-devel] [PATCH] avcodec/dcadsp: replace intptr_t with ptrdiff_t

Hendrik Leppkes h.leppkes at gmail.com
Fri Feb 5 09:30:11 CET 2016


On Sun, Jan 31, 2016 at 9:41 PM, James Almer <jamrial at gmail.com> wrote:
> This is more consistent with the rest of the codebase
>
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
>  libavcodec/dcadsp.c | 46 +++++++++++++++++++++++-----------------------
>  libavcodec/dcadsp.h | 34 +++++++++++++++++-----------------
>  2 files changed, 40 insertions(+), 40 deletions(-)
>
> diff --git a/libavcodec/dcadsp.c b/libavcodec/dcadsp.c
> index cee3d60..787d7b8 100644
> --- a/libavcodec/dcadsp.c
> +++ b/libavcodec/dcadsp.c
> @@ -27,8 +27,8 @@ static void decode_hf_c(int32_t **dst,
>                          const int32_t *vq_index,
>                          const int8_t hf_vq[1024][32],
>                          int32_t scale_factors[32][2],
> -                        intptr_t sb_start, intptr_t sb_end,
> -                        intptr_t ofs, intptr_t len)
> +                        ptrdiff_t sb_start, ptrdiff_t sb_end,
> +                        ptrdiff_t ofs, ptrdiff_t len)
>  {
>      int i, j;
>
> @@ -42,8 +42,8 @@ static void decode_hf_c(int32_t **dst,
>
>  static void decode_joint_c(int32_t **dst, int32_t **src,
>                             const int32_t *scale_factors,
> -                           intptr_t sb_start, intptr_t sb_end,
> -                           intptr_t ofs, intptr_t len)
> +                           ptrdiff_t sb_start, ptrdiff_t sb_end,
> +                           ptrdiff_t ofs, ptrdiff_t len)
>  {
>      int i, j;
>
> @@ -55,7 +55,7 @@ static void decode_joint_c(int32_t **dst, int32_t **src,
>  }
>
>  static void lfe_fir_float_c(float *pcm_samples, int32_t *lfe_samples,
> -                            const float *filter_coeff, intptr_t npcmblocks,
> +                            const float *filter_coeff, ptrdiff_t npcmblocks,
>                              int dec_select)
>  {
>      // Select decimation factor
> @@ -85,19 +85,19 @@ static void lfe_fir_float_c(float *pcm_samples, int32_t *lfe_samples,
>  }
>
>  static void lfe_fir1_float_c(float *pcm_samples, int32_t *lfe_samples,
> -                             const float *filter_coeff, intptr_t npcmblocks)
> +                             const float *filter_coeff, ptrdiff_t npcmblocks)
>  {
>      lfe_fir_float_c(pcm_samples, lfe_samples, filter_coeff, npcmblocks, 0);
>  }
>
>  static void lfe_fir2_float_c(float *pcm_samples, int32_t *lfe_samples,
> -                             const float *filter_coeff, intptr_t npcmblocks)
> +                             const float *filter_coeff, ptrdiff_t npcmblocks)
>  {
>      lfe_fir_float_c(pcm_samples, lfe_samples, filter_coeff, npcmblocks, 1);
>  }
>
>  static void lfe_x96_float_c(float *dst, const float *src,
> -                            float *hist, intptr_t len)
> +                            float *hist, ptrdiff_t len)
>  {
>      float prev = *hist;
>      int i;
> @@ -119,7 +119,7 @@ static void sub_qmf32_float_c(SynthFilterContext *synth,
>                                int32_t **subband_samples_lo,
>                                int32_t **subband_samples_hi,
>                                float *hist1, int *offset, float *hist2,
> -                              const float *filter_coeff, intptr_t npcmblocks,
> +                              const float *filter_coeff, ptrdiff_t npcmblocks,
>                                float scale)
>  {
>      LOCAL_ALIGNED(32, float, input, [32]);
> @@ -148,7 +148,7 @@ static void sub_qmf64_float_c(SynthFilterContext *synth,
>                                int32_t **subband_samples_lo,
>                                int32_t **subband_samples_hi,
>                                float *hist1, int *offset, float *hist2,
> -                              const float *filter_coeff, intptr_t npcmblocks,
> +                              const float *filter_coeff, ptrdiff_t npcmblocks,
>                                float scale)
>  {
>      LOCAL_ALIGNED(32, float, input, [64]);
> @@ -192,7 +192,7 @@ static void sub_qmf64_float_c(SynthFilterContext *synth,
>  }
>
>  static void lfe_fir_fixed_c(int32_t *pcm_samples, int32_t *lfe_samples,
> -                            const int32_t *filter_coeff, intptr_t npcmblocks)
> +                            const int32_t *filter_coeff, ptrdiff_t npcmblocks)
>  {
>      // Select decimation factor
>      int nlfesamples = npcmblocks >> 1;
> @@ -219,7 +219,7 @@ static void lfe_fir_fixed_c(int32_t *pcm_samples, int32_t *lfe_samples,
>  }
>
>  static void lfe_x96_fixed_c(int32_t *dst, const int32_t *src,
> -                            int32_t *hist, intptr_t len)
> +                            int32_t *hist, ptrdiff_t len)
>  {
>      int32_t prev = *hist;
>      int i;
> @@ -241,7 +241,7 @@ static void sub_qmf32_fixed_c(SynthFilterContext *synth,
>                                int32_t **subband_samples_lo,
>                                int32_t **subband_samples_hi,
>                                int32_t *hist1, int *offset, int32_t *hist2,
> -                              const int32_t *filter_coeff, intptr_t npcmblocks)
> +                              const int32_t *filter_coeff, ptrdiff_t npcmblocks)
>  {
>      LOCAL_ALIGNED(32, int32_t, input, [32]);
>      int i, j;
> @@ -265,7 +265,7 @@ static void sub_qmf64_fixed_c(SynthFilterContext *synth,
>                                int32_t **subband_samples_lo,
>                                int32_t **subband_samples_hi,
>                                int32_t *hist1, int *offset, int32_t *hist2,
> -                              const int32_t *filter_coeff, intptr_t npcmblocks)
> +                              const int32_t *filter_coeff, ptrdiff_t npcmblocks)
>  {
>      LOCAL_ALIGNED(32, int32_t, input, [64]);
>      int i, j;
> @@ -295,7 +295,7 @@ static void sub_qmf64_fixed_c(SynthFilterContext *synth,
>      }
>  }
>
> -static void decor_c(int32_t *dst, const int32_t *src, intptr_t coeff, intptr_t len)
> +static void decor_c(int32_t *dst, const int32_t *src, int coeff, ptrdiff_t len)
>  {
>      int i;
>
> @@ -304,7 +304,7 @@ static void decor_c(int32_t *dst, const int32_t *src, intptr_t coeff, intptr_t l
>  }
>
>  static void dmix_sub_xch_c(int32_t *dst1, int32_t *dst2,
> -                           const int32_t *src, intptr_t len)
> +                           const int32_t *src, ptrdiff_t len)
>  {
>      int i;
>
> @@ -315,7 +315,7 @@ static void dmix_sub_xch_c(int32_t *dst1, int32_t *dst2,
>      }
>  }
>
> -static void dmix_sub_c(int32_t *dst, const int32_t *src, intptr_t coeff, intptr_t len)
> +static void dmix_sub_c(int32_t *dst, const int32_t *src, int coeff, ptrdiff_t len)
>  {
>      int i;
>
> @@ -323,7 +323,7 @@ static void dmix_sub_c(int32_t *dst, const int32_t *src, intptr_t coeff, intptr_
>          dst[i] -= mul15(src[i], coeff);
>  }
>
> -static void dmix_add_c(int32_t *dst, const int32_t *src, intptr_t coeff, intptr_t len)
> +static void dmix_add_c(int32_t *dst, const int32_t *src, int coeff, ptrdiff_t len)
>  {
>      int i;
>
> @@ -331,7 +331,7 @@ static void dmix_add_c(int32_t *dst, const int32_t *src, intptr_t coeff, intptr_
>          dst[i] += mul15(src[i], coeff);
>  }
>
> -static void dmix_scale_c(int32_t *dst, intptr_t scale, intptr_t len)
> +static void dmix_scale_c(int32_t *dst, int scale, ptrdiff_t len)
>  {
>      int i;
>
> @@ -339,7 +339,7 @@ static void dmix_scale_c(int32_t *dst, intptr_t scale, intptr_t len)
>          dst[i] = mul15(dst[i], scale);
>  }
>
> -static void dmix_scale_inv_c(int32_t *dst, intptr_t scale_inv, intptr_t len)
> +static void dmix_scale_inv_c(int32_t *dst, int scale_inv, ptrdiff_t len)
>  {
>      int i;
>
> @@ -347,7 +347,7 @@ static void dmix_scale_inv_c(int32_t *dst, intptr_t scale_inv, intptr_t len)
>          dst[i] = mul16(dst[i], scale_inv);
>  }
>
> -static void filter0(int32_t *dst, const int32_t *src, int32_t coeff, intptr_t len)
> +static void filter0(int32_t *dst, const int32_t *src, int32_t coeff, ptrdiff_t len)
>  {
>      int i;
>
> @@ -355,7 +355,7 @@ static void filter0(int32_t *dst, const int32_t *src, int32_t coeff, intptr_t le
>          dst[i] -= mul22(src[i], coeff);
>  }
>
> -static void filter1(int32_t *dst, const int32_t *src, int32_t coeff, intptr_t len)
> +static void filter1(int32_t *dst, const int32_t *src, int32_t coeff, ptrdiff_t len)
>  {
>      int i;
>
> @@ -364,7 +364,7 @@ static void filter1(int32_t *dst, const int32_t *src, int32_t coeff, intptr_t le
>  }
>
>  static void assemble_freq_bands_c(int32_t *dst, int32_t *src0, int32_t *src1,
> -                                  const int32_t *coeff, intptr_t len)
> +                                  const int32_t *coeff, ptrdiff_t len)
>  {
>      int i;
>
> diff --git a/libavcodec/dcadsp.h b/libavcodec/dcadsp.h
> index d8acf37..9c7630f 100644
> --- a/libavcodec/dcadsp.h
> +++ b/libavcodec/dcadsp.h
> @@ -32,19 +32,19 @@ typedef struct DCADSPContext {
>                        const int32_t *vq_index,
>                        const int8_t hf_vq[1024][32],
>                        int32_t scale_factors[32][2],
> -                      intptr_t sb_start, intptr_t sb_end,
> -                      intptr_t ofs, intptr_t len);
> +                      ptrdiff_t sb_start, ptrdiff_t sb_end,
> +                      ptrdiff_t ofs, ptrdiff_t len);
>
>      void (*decode_joint)(int32_t **dst, int32_t **src,
>                           const int32_t *scale_factors,
> -                         intptr_t sb_start, intptr_t sb_end,
> -                         intptr_t ofs, intptr_t len);
> +                         ptrdiff_t sb_start, ptrdiff_t sb_end,
> +                         ptrdiff_t ofs, ptrdiff_t len);
>
>      void (*lfe_fir_float[2])(float *pcm_samples, int32_t *lfe_samples,
> -                             const float *filter_coeff, intptr_t npcmblocks);
> +                             const float *filter_coeff, ptrdiff_t npcmblocks);
>
>      void (*lfe_x96_float)(float *dst, const float *src,
> -                          float *hist, intptr_t len);
> +                          float *hist, ptrdiff_t len);
>
>      void (*sub_qmf_float[2])(SynthFilterContext *synth,
>                               FFTContext *imdct,
> @@ -52,14 +52,14 @@ typedef struct DCADSPContext {
>                               int32_t **subband_samples_lo,
>                               int32_t **subband_samples_hi,
>                               float *hist1, int *offset, float *hist2,
> -                             const float *filter_coeff, intptr_t npcmblocks,
> +                             const float *filter_coeff, ptrdiff_t npcmblocks,
>                               float scale);
>
>      void (*lfe_fir_fixed)(int32_t *pcm_samples, int32_t *lfe_samples,
> -                          const int32_t *filter_coeff, intptr_t npcmblocks);
> +                          const int32_t *filter_coeff, ptrdiff_t npcmblocks);
>
>      void (*lfe_x96_fixed)(int32_t *dst, const int32_t *src,
> -                          int32_t *hist, intptr_t len);
> +                          int32_t *hist, ptrdiff_t len);
>
>      void (*sub_qmf_fixed[2])(SynthFilterContext *synth,
>                               DCADCTContext *imdct,
> @@ -67,23 +67,23 @@ typedef struct DCADSPContext {
>                               int32_t **subband_samples_lo,
>                               int32_t **subband_samples_hi,
>                               int32_t *hist1, int *offset, int32_t *hist2,
> -                             const int32_t *filter_coeff, intptr_t npcmblocks);
> +                             const int32_t *filter_coeff, ptrdiff_t npcmblocks);
>
> -    void (*decor)(int32_t *dst, const int32_t *src, intptr_t coeff, intptr_t len);
> +    void (*decor)(int32_t *dst, const int32_t *src, ptrdiff_t coeff, ptrdiff_t len);
>
>      void (*dmix_sub_xch)(int32_t *dst1, int32_t *dst2,
> -                         const int32_t *src, intptr_t len);
> +                         const int32_t *src, ptrdiff_t len);
>
> -    void (*dmix_sub)(int32_t *dst, const int32_t *src, intptr_t coeff, intptr_t len);
> +    void (*dmix_sub)(int32_t *dst, const int32_t *src, ptrdiff_t coeff, ptrdiff_t len);
>
> -    void (*dmix_add)(int32_t *dst, const int32_t *src, intptr_t coeff, intptr_t len);
> +    void (*dmix_add)(int32_t *dst, const int32_t *src, ptrdiff_t coeff, ptrdiff_t len);

coeff in decor and dmix_sub/add works similar to scale in dmix_scale,
any reason it was kept as ptrdiff_t here, and converted to int below?

>
> -    void (*dmix_scale)(int32_t *dst, intptr_t scale, intptr_t len);
> +    void (*dmix_scale)(int32_t *dst, int scale, ptrdiff_t len);
>
> -    void (*dmix_scale_inv)(int32_t *dst, intptr_t scale_inv, intptr_t len);
> +    void (*dmix_scale_inv)(int32_t *dst, int scale_inv, ptrdiff_t len);
>
>      void (*assemble_freq_bands)(int32_t *dst, int32_t *src0, int32_t *src1,
> -                                const int32_t *coeff, intptr_t len);
> +                                const int32_t *coeff, ptrdiff_t len);
>  } DCADSPContext;
>
>  av_cold void ff_dcadsp_init(DCADSPContext *s);

The others look fine, its mostly size constraints which we like to
pass as ptrdiff_t to avoid zero extending them in asm.

- Hendrik


More information about the ffmpeg-devel mailing list