From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 2B6214D10A for ; Sun, 9 Nov 2025 13:52:59 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'6uWkz28VMHt8s5KKA97hK5/vEuzRqq95qDQkca4VYnQ=', expected b'IQeV/C6/7PcWRCpYXUX+k5wtYsY/PPRgU62HhkSlv+s=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1762696368; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=6uWkz28VMHt8s5KKA97hK5/vEuzRqq95qDQkca4VYnQ=; b=bJhwNw+T+AeLZ7OCoS3HcbW36Tzv5PTUiXCW+wPT/piBfY4/Mvepz+44ztcUcyJxVxv/Q T0CXDWKLRU7Xcw+sF5CMFS5JFz+Ac4J+15U9rdLWue39pNiLocnC1JwQaR5kT0K7Kwwh/fh UhrAUO9ESafsLyuRtZSbu9wGmLGmd+SYlJdE+26PNyHhf1ym3xoBSjC4i4DMWTqmpBjDSt3 7wZ4A0oz+kQucb8aCTMygDcUVsCOlr7Sl/A7A6mF5glNwtU5qqfBI8ISB5VSRSAIiKrIisU srVAgaLH9rrWLBkVpUZv+3fd0cftMnzoBkmfxxrE1hjv3Y52/Wl0q2RaQ5BQ== Received: from [172.19.0.2] (unknown [172.19.0.2]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id A659D68FB8A; Sun, 9 Nov 2025 15:52:48 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1762696350; b=EqJUD7cAL1Jbs47ixCJEVBhYAIILfR3bevl/Mf2RmjOgdt1J9nSOA3McJjk7zwCrO8kkh m8VFCNm4aJl7Y/QJlFHPMg8jE0sDr/ENJVH0jU9SmlPqmTxWJ2N4ISIVfa5XteCwemZjSQx KdNbET+dmk9nWZzWZ8SzFpgaU13m6l0AjUsUguyE6y9zjJzdKuy6pgFtbEfg66xUKuPCi3c g5DMACoeBfGBxeEV2P+CDTAXPIMy1ArbMQvym3Vl43wLgepAD9dMXvkJWyT5SvyEcPpphqJ /lH76Fb33EoIHhb5NCbJhir3ETPoc8dzE4TVWlU1faJOv0RPiaakkQAXNC4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1762696350; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=g5BwC3MrPzWhPwVr2JHKsScD1jgGgcPqQ467Y5FuiPM=; b=YR8o5DEFi13cyACYpzH+sfK9Y6spyS5rhQnf61nFLiYb/lV9+JvlWDSslzQf71l5/DYmb 9wX+xa0HGln4qW89+n/kqZ3yZX/2LhdGCuJzu8t21pVwO/4TFQKI9V8WpBYKRlruNENIQAr aLuFNRu8EE2r/uJ6+M2nb6zRutzcGAJPqoofQe76jdj+esF7kggzArsuHbNjaPU9Lw9Fk2X lU5q4FaBGy55yp4iSewydWvuNbItr++VofX2tDLV2ugUTEV/tym4rk1R/tXL1F4kRPwwFIS kP6vM85yHxNo8JzorMJ2GdXb6uOMXof700Ccl14FhgOq1diZlXD8QKt1Ce7w== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1762696343; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=IQeV/C6/7PcWRCpYXUX+k5wtYsY/PPRgU62HhkSlv+s=; b=G1it3PvaIyKvtSWthYMTZZfsigFbHhcFKmVWU1wOLX/N3yr0VZ0dYcVvAKST/sqxemSeU K5Ix+8pD66AJgas8gz+YBiY/HJ9uUxejVrWUOi+u52uOOmVn0Vzk5mPUGORz/22LXTWPJeg xk1yO9WHDEw0kpWdjphGBScHAv0sspZlTyK/eoAZa5FSKvrT2Lr28M6B2PF6aVL1NmA0yPI UM3uRFpeFHF+zokN54PiNXtYcsPe/gvzhio5XF6DMwcvDnqcFP00ehzfTyTlW3e+o7F+fez BOdNO96C9VTzX7y7nQJufly8eFzWbu6Iv/ZTE85o4tI6TXcYoJ1QxPxjgofg== Received: from 188d6d40ca7a (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 4B7EF68F713 for ; Sun, 9 Nov 2025 15:52:23 +0200 (EET) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Sun, 09 Nov 2025 13:52:22 -0000 Message-ID: <176269634350.25.643446669966125103@2cb04c0e5124> Message-ID-Hash: 6C5I7ZCIUJMFJ2VO2UT23WVEFY4BDRHP X-Message-ID-Hash: 6C5I7ZCIUJMFJ2VO2UT23WVEFY4BDRHP X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avcodec/h264idct_template: Deduplicate h264_{luma,chroma}_dc_dequant_idct (PR #20874) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: mkver via ffmpeg-devel Cc: mkver Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #20874 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20874 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20874.patch >>From 0b211afaedb40de46b1fd871496b16ba0da3f6c1 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 9 Nov 2025 14:30:00 +0100 Subject: [PATCH 1/2] avcodec/bit_depth_template: Add PIXELSIZE Sometimes functions for bit depth 9..16 are the same (because they actually only depend on the underlying pixel type). The macros added here allow to support this usecase. Signed-off-by: Andreas Rheinhardt --- libavcodec/bit_depth_template.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/bit_depth_template.c b/libavcodec/bit_depth_template.c index ca5037148a..6a80cdaf32 100644 --- a/libavcodec/bit_depth_template.c +++ b/libavcodec/bit_depth_template.c @@ -43,11 +43,13 @@ # undef FUNCC # undef av_clip_pixel # undef PIXEL_SPLAT_X4 +# undef PIXELSIZE #else # define AVCODEC_BIT_DEPTH_TEMPLATE_C #endif #if BIT_DEPTH > 8 +# define PIXELSIZE 16 # define pixel uint16_t # define pixel2 uint32_t # define pixel4 uint64_t @@ -76,6 +78,7 @@ # define av_clip_pixel(a) av_clip_uintp2(a, BIT_DEPTH) # define CLIP(a) av_clip_uintp2(a, BIT_DEPTH) #else +# define PIXELSIZE 8 # define pixel uint8_t # define pixel2 uint16_t # define pixel4 uint32_t @@ -100,6 +103,7 @@ #define FUNC2(a, b, c) FUNC3(a, b, c) #define FUNC(a) FUNC2(a, BIT_DEPTH,) #define FUNCC(a) FUNC2(a, BIT_DEPTH, _c) +#define FUNCC2(a) FUNC2(a, PIXELSIZE, _c) #define FUNC4(a, b, c) a ## _int ## b ## _ ## c ## bit #define FUNC5(a, b, c) FUNC4(a, b, c) #define FUNC6(a) FUNC5(a, IN_IDCT_DEPTH, BIT_DEPTH) -- 2.49.1 >>From 5d99c5529ecade161610af37f9e4a9daa5aba2d5 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 9 Nov 2025 14:41:16 +0100 Subject: [PATCH 2/2] avcodec/h264idct_template: Deduplicate h264_{luma,chroma}_dc_dequant_idct All the high bit depth functions of these types are identical. Signed-off-by: Andreas Rheinhardt --- libavcodec/h264dsp.c | 16 ++++++++-------- libavcodec/h264idct.h | 11 ++++++++--- libavcodec/h264idct_template.c | 11 ++++++++--- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/libavcodec/h264dsp.c b/libavcodec/h264dsp.c index 1ba936be1c..8a6a3f5325 100644 --- a/libavcodec/h264dsp.c +++ b/libavcodec/h264dsp.c @@ -69,14 +69,19 @@ av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, #undef FUNC #define FUNC(a, depth) a ## _ ## depth ## _c -#define ADDPX_DSP(depth) \ +#define SET_PIXSIZE_FUNCS(depth) \ + c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\ + if (chroma_format_idc <= 1)\ + c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\ + else\ + c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\ c->h264_add_pixels4_clear = FUNC(ff_h264_add_pixels4, depth);\ c->h264_add_pixels8_clear = FUNC(ff_h264_add_pixels8, depth) if (bit_depth > 8 && bit_depth <= 16) { - ADDPX_DSP(16); + SET_PIXSIZE_FUNCS(16); } else { - ADDPX_DSP(8); + SET_PIXSIZE_FUNCS(8); } #define H264_DSP(depth) \ @@ -91,11 +96,6 @@ av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, else\ c->h264_idct_add8 = FUNC(ff_h264_idct_add8_422, depth);\ c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\ - c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\ - if (chroma_format_idc <= 1)\ - c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\ - else\ - c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\ \ c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16, depth);\ c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels8, depth);\ diff --git a/libavcodec/h264idct.h b/libavcodec/h264idct.h index 6f18df9e5f..42e93ed17a 100644 --- a/libavcodec/h264idct.h +++ b/libavcodec/h264idct.h @@ -31,9 +31,6 @@ 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_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); H264_IDCT( 8) H264_IDCT( 9) @@ -41,4 +38,12 @@ H264_IDCT(10) H264_IDCT(12) H264_IDCT(14) +#define H264_IDCT2(pixsize) \ +void ff_h264_luma_dc_dequant_idct_ ## pixsize ## _c(int16_t *output, int16_t *input, int qmul);\ +void ff_h264_chroma422_dc_dequant_idct_ ## pixsize ## _c(int16_t *block, int qmul);\ +void ff_h264_chroma_dc_dequant_idct_ ## pixsize ## _c(int16_t *block, int qmul); + +H264_IDCT2( 8) +H264_IDCT2(16) + #endif /* AVCODEC_H264IDCT_H */ diff --git a/libavcodec/h264idct_template.c b/libavcodec/h264idct_template.c index db19b5f9fb..64f5faddca 100644 --- a/libavcodec/h264idct_template.c +++ b/libavcodec/h264idct_template.c @@ -244,11 +244,13 @@ void FUNCC(ff_h264_idct_add8_422)(uint8_t **dest, const int *block_offset, int16 } } +#if BIT_DEPTH == 8 || BIT_DEPTH == 9 /** * 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 FUNCC2(ff_h264_luma_dc_dequant_idct)(int16_t *_output, int16_t *_input, int qmul) +{ #define stride 16 int i; int temp[16]; @@ -283,7 +285,8 @@ void FUNCC(ff_h264_luma_dc_dequant_idct)(int16_t *_output, int16_t *_input, int #undef stride } -void FUNCC(ff_h264_chroma422_dc_dequant_idct)(int16_t *_block, int qmul){ +void FUNCC2(ff_h264_chroma422_dc_dequant_idct)(int16_t *_block, int qmul) +{ const int stride= 16*2; const int xStride= 16; int i; @@ -310,7 +313,8 @@ void FUNCC(ff_h264_chroma422_dc_dequant_idct)(int16_t *_block, int qmul){ } } -void FUNCC(ff_h264_chroma_dc_dequant_idct)(int16_t *_block, int qmul){ +void FUNCC2(ff_h264_chroma_dc_dequant_idct)(int16_t *_block, int qmul) +{ const int stride= 16*2; const int xStride= 16; SUINT a,b,c,d,e; @@ -331,3 +335,4 @@ void FUNCC(ff_h264_chroma_dc_dequant_idct)(int16_t *_block, int qmul){ block[stride*1 + xStride*0]= (int)((a-c)*qmul) >> 7; block[stride*1 + xStride*1]= (int)((e-b)*qmul) >> 7; } +#endif -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org