This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 61222377809ca681a26194eda7672cea0c9796da Author: Wu Jianhua <[email protected]> AuthorDate: Fri May 30 02:55:58 2025 +0800 Commit: jianhuaw <[email protected]> CommitDate: Sun Nov 29 10:42:10 2026 +0000 avcodec/vvc/inter_template: fix put_scaled function for high bitdepth Signed-off-by: Wu Jianhua <[email protected]> --- libavcodec/vvc/ctu.h | 2 ++ libavcodec/vvc/dsp.h | 8 +++--- libavcodec/vvc/inter.c | 7 ++--- libavcodec/vvc/inter_template.c | 60 ++++++++++++++++++++++------------------- 4 files changed, 43 insertions(+), 34 deletions(-) diff --git a/libavcodec/vvc/ctu.h b/libavcodec/vvc/ctu.h index 59366a1756..3fe4277723 100644 --- a/libavcodec/vvc/ctu.h +++ b/libavcodec/vvc/ctu.h @@ -443,6 +443,8 @@ typedef struct VVCLocalContext { struct { /* *2 for high bit depths */ DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[EDGE_EMU_BUFFER_STRIDE * EDGE_EMU_BUFFER_STRIDE * 2]; + /* *4: tpixel is int for bit depths greater than 12 */ + DECLARE_ALIGNED(32, uint8_t, scaled_tmp)[EDGE_EMU_BUFFER_STRIDE * MAX_PB_SIZE * sizeof(int)]; DECLARE_ALIGNED(32, int16_t, tmp)[MAX_PB_SIZE * MAX_PB_SIZE]; DECLARE_ALIGNED(32, int16_t, tmp1)[MAX_PB_SIZE * MAX_PB_SIZE]; union { diff --git a/libavcodec/vvc/dsp.h b/libavcodec/vvc/dsp.h index 29cdd7e8f4..e0953f2e01 100644 --- a/libavcodec/vvc/dsp.h +++ b/libavcodec/vvc/dsp.h @@ -59,16 +59,18 @@ typedef struct VVCInterDSPContext { void (*put_scaled[2 /* luma, chroma */][7 /* log2(width) - 1 */])( int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, int src_height, - int x, int y, int dx, int dy, int height, const int8_t *hf, const int8_t *vf, int width); + int x, int y, int dx, int dy, int height, const int8_t *hf, const int8_t *vf, int width, + uint8_t *tmp); void (*put_uni_scaled[2 /* luma, chroma */][7 /* log2(width) - 1 */])( uint8_t *dst, const ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, int src_height, - int x, int y, int dx, int dy, int height, const int8_t *hf, const int8_t *vf, int width); + int x, int y, int dx, int dy, int height, const int8_t *hf, const int8_t *vf, int width, + uint8_t *tmp); void (*put_uni_w_scaled[2 /* luma, chroma */][7 /* log2(width) - 1 */])( uint8_t *dst, const ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, int src_height, int x, int y, int dx, int dy, int height, int denom, int wx, int ox, const int8_t *hf, const int8_t *vf, - int width); + int width, uint8_t *tmp); void (*avg)(uint8_t *dst, ptrdiff_t dst_stride, const int16_t *src0, const int16_t *src1, int width, int height); diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c index fd2508dbb1..670625f5e4 100644 --- a/libavcodec/vvc/inter.c +++ b/libavcodec/vvc/inter.c @@ -435,7 +435,8 @@ static void mc_scaled(VVCLocalContext *lc, int16_t *dst, const VVCRefPic *refp, scaled_ref_pos_and_step(lc, refp, mv, x_off, y_off, c_idx, &x, &y, &dx, &dy); emulated_edge_scaled(lc, &src, &src_stride, &src_height, refp->ref, x, y, dx, dy, block_w, block_h, is_chroma); - fc->vvcdsp.inter.put_scaled[is_chroma][idx](dst, src, src_stride, src_height, x, y, dx, dy, block_h, hf, vf, block_w); + fc->vvcdsp.inter.put_scaled[is_chroma][idx](dst, src, src_stride, src_height, x, y, dx, dy, block_h, hf, vf, + block_w, lc->pred.scaled_tmp); } static void mc_uni_scaled(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, const VVCRefPic *refp, @@ -459,10 +460,10 @@ static void mc_uni_scaled(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst if (derive_weight_uni(&denom, &wx, &ox, lc, mvf, c_idx)) { fc->vvcdsp.inter.put_uni_w_scaled[is_chroma][idx](dst, dst_stride, src, src_stride, src_height, - x, y, dx, dy, block_h, denom, wx, ox, hf, vf, block_w); + x, y, dx, dy, block_h, denom, wx, ox, hf, vf, block_w, lc->pred.scaled_tmp); } else { fc->vvcdsp.inter.put_uni_scaled[is_chroma][idx](dst, dst_stride, src, src_stride, src_height, - x, y, dx, dy, block_h, hf, vf, block_w); + x, y, dx, dy, block_h, hf, vf, block_w, lc->pred.scaled_tmp); } } diff --git a/libavcodec/vvc/inter_template.c b/libavcodec/vvc/inter_template.c index 815c03ac91..71eaa43195 100644 --- a/libavcodec/vvc/inter_template.c +++ b/libavcodec/vvc/inter_template.c @@ -27,12 +27,13 @@ static void av_always_inline FUNC(put_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *const _src, ptrdiff_t _src_stride, const int src_height, const int _x, const int _y, const int dx, const int dy, - const int height, const int8_t *hf, const int8_t *vf, const int width, const int is_uni, const int is_chroma) + const int height, const int8_t *hf, const int8_t *vf, const int width, const int is_uni, const int is_chroma, + uint8_t *_tmp_array) { - int16_t tmp_array[TMP_STRIDE * MAX_PB_SIZE]; - int16_t *tmp = tmp_array; - pixel *dst = (pixel*)_dst; - int16_t *dst16 = (int16_t*)_dst; + tpixel *tmp_array = (tpixel *)_tmp_array; + tpixel *tmp = tmp_array; + pixel *dst = (pixel *)_dst; + tpixel *dst16 = (tpixel *)_dst; const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); const ptrdiff_t src_stride = _src_stride / sizeof(pixel); const int shift = FFMAX(2, 14 - BIT_DEPTH); @@ -40,7 +41,8 @@ static void av_always_inline FUNC(put_scaled)(uint8_t *_dst, const ptrdiff_t _ds const int taps = is_chroma ? VVC_INTER_CHROMA_TAPS : VVC_INTER_LUMA_TAPS; const int extra = is_chroma ? CHROMA_EXTRA : LUMA_EXTRA; const int extra_before = is_chroma ? CHROMA_EXTRA_BEFORE : LUMA_EXTRA_BEFORE; - const int shift1 = 6 - is_chroma; + const int shift1 = FFMIN(4, BIT_DEPTH - 8); + const int shift_x = 6 - is_chroma; const int shift2 = 4 + is_chroma; const int x0 = SCALED_INT(_x); const int y0 = SCALED_INT(_y); @@ -48,12 +50,12 @@ static void av_always_inline FUNC(put_scaled)(uint8_t *_dst, const ptrdiff_t _ds for (int i = 0; i < width; i++) { const int tx = _x + dx * i; const int x = SCALED_INT(tx) - x0; - const int mx = av_zero_extend(tx >> shift1, shift2); + const int mx = av_zero_extend(tx >> shift_x, shift2); const int8_t *filter = hf + mx * taps; const pixel *src = (pixel*)_src - extra_before * src_stride; for (int j = 0; j < src_height + extra; j++) { - tmp[j] = (is_chroma ? CHROMA_FILTER(src, 1) : LUMA_FILTER(src, 1)) >> (BIT_DEPTH - 8); + tmp[j] = (is_chroma ? CHROMA_FILTER(src, 1) : LUMA_FILTER(src, 1)) >> shift1; src += src_stride; } tmp += TMP_STRIDE; @@ -62,7 +64,7 @@ static void av_always_inline FUNC(put_scaled)(uint8_t *_dst, const ptrdiff_t _ds for (int i = 0; i < height; i++) { const int ty = _y + dy * i; const int x = SCALED_INT(ty) - y0; - const int mx = av_zero_extend(ty >> shift1, shift2); + const int mx = av_zero_extend(ty >> shift_x, shift2); const int8_t *filter = vf + mx * taps; tmp = tmp_array + extra_before; @@ -84,42 +86,43 @@ static void av_always_inline FUNC(put_scaled)(uint8_t *_dst, const ptrdiff_t _ds static void FUNC(put_luma_scaled)(int16_t *_dst, const uint8_t *_src, ptrdiff_t _src_stride, const int src_height, const int x, const int y, const int dx, const int dy, - const int height, const int8_t *hf, const int8_t *vf, const int width) + const int height, const int8_t *hf, const int8_t *vf, const int width, uint8_t *tmp_array) { - FUNC(put_scaled)((uint8_t *)_dst, MAX_PB_SIZE * sizeof(pixel), _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 0, 0); + FUNC(put_scaled)((uint8_t *)_dst, MAX_PB_SIZE * sizeof(pixel), _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 0, 0, tmp_array); } static void FUNC(put_chroma_scaled)(int16_t *_dst, const uint8_t *_src, ptrdiff_t _src_stride, const int src_height, const int x, const int y, const int dx, const int dy, - const int height, const int8_t *hf, const int8_t *vf, const int width) + const int height, const int8_t *hf, const int8_t *vf, const int width, uint8_t *tmp_array) { - FUNC(put_scaled)((uint8_t *)_dst, MAX_PB_SIZE * sizeof(pixel), _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 0, 1); + FUNC(put_scaled)((uint8_t *)_dst, MAX_PB_SIZE * sizeof(pixel), _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 0, 1, tmp_array); } static void FUNC(put_uni_luma_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, ptrdiff_t _src_stride, const int src_height, const int x, const int y, const int dx, const int dy, - const int height, const int8_t *hf, const int8_t *vf, const int width) + const int height, const int8_t *hf, const int8_t *vf, const int width, uint8_t *tmp_array) { - FUNC(put_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 1, 0); + FUNC(put_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 1, 0, tmp_array); } static void FUNC(put_uni_chroma_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, ptrdiff_t _src_stride, const int src_height, const int x, const int y, const int dx, const int dy, - const int height, const int8_t *hf, const int8_t *vf, const int width) + const int height, const int8_t *hf, const int8_t *vf, const int width, uint8_t *tmp_array) { - FUNC(put_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 1, 1); + FUNC(put_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 1, 1, tmp_array); } static void av_always_inline FUNC(put_uni_w_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *const _src, ptrdiff_t _src_stride, const int src_height, const int _x, const int _y, const int dx, const int dy, const int denom, const int wx, const int _ox, - const int height, const int8_t *hf, const int8_t *vf, const int width, const int is_chroma) + const int height, const int8_t *hf, const int8_t *vf, const int width, const int is_chroma, + uint8_t *_tmp_array) { - int16_t tmp_array[TMP_STRIDE * MAX_PB_SIZE]; - int16_t *tmp = tmp_array; + tpixel *tmp_array = (tpixel *)_tmp_array; + tpixel *tmp = tmp_array; pixel *dst = (pixel*)_dst; const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); const ptrdiff_t src_stride = _src_stride / sizeof(pixel); @@ -129,7 +132,8 @@ static void av_always_inline FUNC(put_uni_w_scaled)(uint8_t *_dst, const ptrdiff const int taps = is_chroma ? VVC_INTER_CHROMA_TAPS : VVC_INTER_LUMA_TAPS; const int extra = is_chroma ? CHROMA_EXTRA : LUMA_EXTRA; const int extra_before = is_chroma ? CHROMA_EXTRA_BEFORE : LUMA_EXTRA_BEFORE; - const int shift1 = 6 - is_chroma; + const int shift1 = FFMIN(4, BIT_DEPTH - 8); + const int shift_x = 6 - is_chroma; const int shift2 = 4 + is_chroma; const int x0 = SCALED_INT(_x); const int y0 = SCALED_INT(_y); @@ -137,12 +141,12 @@ static void av_always_inline FUNC(put_uni_w_scaled)(uint8_t *_dst, const ptrdiff for (int i = 0; i < width; i++) { const int tx = _x + dx * i; const int x = SCALED_INT(tx) - x0; - const int mx = av_zero_extend(tx >> shift1, shift2); + const int mx = av_zero_extend(tx >> shift_x, shift2); const int8_t *filter = hf + mx * taps; const pixel *src = (pixel*)_src - extra_before * src_stride; for (int j = 0; j < src_height + extra; j++) { - tmp[j] = (is_chroma ? CHROMA_FILTER(src, 1) : LUMA_FILTER(src, 1)) >> (BIT_DEPTH - 8); + tmp[j] = (is_chroma ? CHROMA_FILTER(src, 1) : LUMA_FILTER(src, 1)) >> shift1; src += src_stride; } tmp += TMP_STRIDE; @@ -151,7 +155,7 @@ static void av_always_inline FUNC(put_uni_w_scaled)(uint8_t *_dst, const ptrdiff for (int i = 0; i < height; i++) { const int ty = _y + dy * i; const int x = SCALED_INT(ty) - y0; - const int mx = av_zero_extend(ty >> shift1, shift2); + const int mx = av_zero_extend(ty >> shift_x, shift2); const int8_t *filter = vf + mx * taps; tmp = tmp_array + extra_before; @@ -167,17 +171,17 @@ static void av_always_inline FUNC(put_uni_w_scaled)(uint8_t *_dst, const ptrdiff static void FUNC(put_uni_luma_w_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, ptrdiff_t _src_stride, const int src_height, const int x, const int y, const int dx, const int dy, const int height, - const int denom, const int wx, const int ox, const int8_t *hf, const int8_t *vf, const int width) + const int denom, const int wx, const int ox, const int8_t *hf, const int8_t *vf, const int width, uint8_t *tmp_array) { - FUNC(put_uni_w_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, denom, wx, ox, height, hf, vf, width, 0); + FUNC(put_uni_w_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, denom, wx, ox, height, hf, vf, width, 0, tmp_array); } static void FUNC(put_uni_chroma_w_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride, const uint8_t *_src, ptrdiff_t _src_stride, const int src_height, const int x, const int y, const int dx, const int dy, const int height, - const int denom, const int wx, const int ox, const int8_t *hf, const int8_t *vf, const int width) + const int denom, const int wx, const int ox, const int8_t *hf, const int8_t *vf, const int width, uint8_t *tmp_array) { - FUNC(put_uni_w_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, denom, wx, ox, height, hf, vf, width, 1); + FUNC(put_uni_w_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, denom, wx, ox, height, hf, vf, width, 1, tmp_array); } #undef TMP_STRIDE -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
