[FFmpeg-devel] [PATCH] h264dsp: h264_luma_dc_dequant_idct: constify input

Tristan Matthews httamt at protonmail.com
Fri Jun 20 20:50:48 EEST 2025


On Friday, June 13th, 2025 at 4:03 PM, Tristan Matthews <tmatth at videolan.org> wrote:

> ---
> libavcodec/h264dsp.h | 2 +-
> libavcodec/h264idct.h | 2 +-
> libavcodec/h264idct_template.c | 2 +-
> libavcodec/loongarch/h264dsp_loongarch.h | 2 +-
> libavcodec/loongarch/h264idct.S | 2 +-
> libavcodec/mips/h264dsp_mips.h | 2 +-
> libavcodec/mips/h264dsp_mmi.c | 2 +-
> libavcodec/x86/h264_idct.asm | 2 +-
> libavcodec/x86/h264dsp_init.c | 2 +-
> 9 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/libavcodec/h264dsp.h b/libavcodec/h264dsp.h
> index 4a9cb1568d..4733288b4a 100644
> --- a/libavcodec/h264dsp.h
> +++ b/libavcodec/h264dsp.h
> @@ -100,7 +100,7 @@ typedef struct H264DSPContext {
> int16_t *block /align 16/,
> int stride, const uint8_t nnzc[5 * 8]);
> void (*h264_luma_dc_dequant_idct)(int16_t *output,
> - int16_t *input /align 16/, int qmul);
> + const int16_t *input /align 16/, int qmul);
> void (*h264_chroma_dc_dequant_idct)(int16_t block, int qmul);
> 
> / bypass-transform */
> diff --git a/libavcodec/h264idct.h b/libavcodec/h264idct.h
> index 6f18df9e5f..8e0b21561a 100644
> --- a/libavcodec/h264idct.h
> +++ b/libavcodec/h264idct.h
> @@ -31,7 +31,7 @@ void ff_h264_idct_add16intra_ ## depth ## c(uint8_t *dst, const int *blockoffse
> void ff_h264_idct8_add4 ## depth ## c(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[5 * 8]);\
> void ff_h264_idct_add8_422 ## depth ## c(uint8_t **dest, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 * 8]);\
> void ff_h264_idct_add8 ## depth ## c(uint8_t **dest, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 * 8]);\
> -void ff_h264_luma_dc_dequant_idct ## depth ## c(int16_t *output, int16_t *input, int qmul);\
> +void ff_h264_luma_dc_dequant_idct ## depth ## c(int16_t *output, const int16_t *input, int qmul);\
> void ff_h264_chroma422_dc_dequant_idct ## depth ## c(int16_t *block, int qmul);\
> void ff_h264_chroma_dc_dequant_idct ## depth ## _c(int16_t block, int qmul);
> 
> diff --git a/libavcodec/h264idct_template.c b/libavcodec/h264idct_template.c
> index db19b5f9fb..72fec8253b 100644
> --- a/libavcodec/h264idct_template.c
> +++ b/libavcodec/h264idct_template.c
> @@ -248,7 +248,7 @@ void FUNCC(ff_h264_idct_add8_422)(uint8_t dest, const int *block_offset, int16
> * IDCT transforms the 16 dc values and dequantizes them.
> * @param qmul quantization parameter
> */
> -void FUNCC(ff_h264_luma_dc_dequant_idct)(int16_t *_output, int16_t *_input, int qmul){
> +void FUNCC(ff_h264_luma_dc_dequant_idct)(int16_t *_output, const int16_t *_input, int qmul){
> #define stride 16
> int i;
> int temp[16];
> diff --git a/libavcodec/loongarch/h264dsp_loongarch.h b/libavcodec/loongarch/h264dsp_loongarch.h
> index e17522dfe0..d51d27fe17 100644
> --- a/libavcodec/loongarch/h264dsp_loongarch.h
> +++ b/libavcodec/loongarch/h264dsp_loongarch.h
> @@ -30,7 +30,7 @@ void ff_h264_idct_add_8_lsx(uint8_t *dst, int16_t *src, int dst_stride);
> void ff_h264_idct8_add_8_lsx(uint8_t *dst, int16_t *src, int dst_stride);
> void ff_h264_idct_dc_add_8_lsx(uint8_t *dst, int16_t *src, int dst_stride);
> void ff_h264_idct8_dc_add_8_lsx(uint8_t *dst, int16_t *src, int dst_stride);
> -void ff_h264_luma_dc_dequant_idct_8_lsx(int16_t *_output, int16_t *_input, int qmul);
> +void ff_h264_luma_dc_dequant_idct_8_lsx(int16_t *_output, const int16_t *_input, int qmul);
> void ff_h264_idct_add16_8_lsx(uint8_t *dst, const int32_t blk_offset,
> int16_t block, int32_t dst_stride,
> const uint8_t nzc[15 * 8]);
> diff --git a/libavcodec/loongarch/h264idct.S b/libavcodec/loongarch/h264idct.S
> index f504cfb714..0c9082e20c 100644
> --- a/libavcodec/loongarch/h264idct.S
> +++ b/libavcodec/loongarch/h264idct.S
> @@ -612,7 +612,7 @@ endfunc
> /
> * IDCT transforms the 16 dc values and dequantizes them.
> * @param qmul quantization parameter
> - * void FUNCC(ff_h264_luma_dc_dequant_idct)(int16_t *_output, int16_t *_input, int qmul){
> + * void FUNCC(ff_h264_luma_dc_dequant_idct)(int16_t *_output, const int16_t *_input, int qmul){
> * LSX optimization is enough for this function.
> */
> function ff_h264_luma_dc_dequant_idct_8_lsx
> diff --git a/libavcodec/mips/h264dsp_mips.h b/libavcodec/mips/h264dsp_mips.h
> index 4a2a2c2559..0edfad4434 100644
> --- a/libavcodec/mips/h264dsp_mips.h
> +++ b/libavcodec/mips/h264dsp_mips.h
> @@ -338,7 +338,7 @@ void ff_h264_idct_add8_8_mmi(uint8_t dest, const int *block_offset,
> int16_t block, int stride, const uint8_t nnzc[158]);
> void ff_h264_idct_add8_422_8_mmi(uint8_t dest, const int *block_offset,
> int16_t block, int stride, const uint8_t nnzc[158]);
> -void ff_h264_luma_dc_dequant_idct_8_mmi(int16_t *output, int16_t *input,
> +void ff_h264_luma_dc_dequant_idct_8_mmi(int16_t *output, const int16_t *input,
> int qmul);
> 
> void ff_h264_weight_pixels16_8_mmi(uint8_t *block, ptrdiff_t stride, int height,
> diff --git a/libavcodec/mips/h264dsp_mmi.c b/libavcodec/mips/h264dsp_mmi.c
> index bae1052dcf..c1c17867fe 100644
> --- a/libavcodec/mips/h264dsp_mmi.c
> +++ b/libavcodec/mips/h264dsp_mmi.c
> @@ -857,7 +857,7 @@ void ff_h264_idct_add8_422_8_mmi(uint8_t dest, const int *block_offset,
> }
> }
> 
> -void ff_h264_luma_dc_dequant_idct_8_mmi(int16_t *output, int16_t *input,
> +void ff_h264_luma_dc_dequant_idct_8_mmi(int16_t *output, const int16_t *input,
> int qmul)
> {
> double ftmp[10];
> diff --git a/libavcodec/x86/h264_idct.asm b/libavcodec/x86/h264_idct.asm
> index d9c3c9c862..a8160b4ccc 100644
> --- a/libavcodec/x86/h264_idct.asm
> +++ b/libavcodec/x86/h264_idct.asm
> @@ -612,7 +612,7 @@ cglobal h264_idct_add8_8, 5, 7 + ARCH_X86_64, 8
> add8_sse2_cycle 3, 0x64
> RET
> 
> -;void ff_h264_luma_dc_dequant_idct_mmx(int16_t *output, int16_t *input, int qmul)
> +;void ff_h264_luma_dc_dequant_idct_mmx(int16_t *output, const int16_t *input, int qmul)
> 
> %macro WALSH4_1D 5
> SUMSUB_BADC w, %4, %3, %2, %1, %5
> diff --git a/libavcodec/x86/h264dsp_init.c b/libavcodec/x86/h264dsp_init.c
> index dc8fc4f720..f8cfeb965f 100644
> --- a/libavcodec/x86/h264dsp_init.c
> +++ b/libavcodec/x86/h264dsp_init.c
> @@ -76,7 +76,7 @@ IDCT_ADD_REP_FUNC2(, 8_422, 8, mmx)
> IDCT_ADD_REP_FUNC2(, 8_422, 10, sse2)
> IDCT_ADD_REP_FUNC2(, 8_422, 10, avx)
> 
> -void ff_h264_luma_dc_dequant_idct_sse2(int16_t *output, int16_t *input, int qmul);
> +void ff_h264_luma_dc_dequant_idct_sse2(int16_t *output, const int16_t *input, int qmul);
> 
> /***************************/
> / deblocking */
> --
> 2.48.1
> 

On second thought maybe this should be dropped as some ASM implementations may want to use the input buffer as scratch space.


More information about the ffmpeg-devel mailing list