From: Nuo Mi <nuomi2021@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Nuo Mi <nuomi2021@gmail.com> Subject: [FFmpeg-devel] [PATCH 11/18] avcodec/vvcdec: add RPR dsp Date: Sun, 19 May 2024 21:27:42 +0800 Message-ID: <TYSPR06MB6433567DBBC4B0CA2066883CAAE82@TYSPR06MB6433.apcprd06.prod.outlook.com> (raw) In-Reply-To: <20240519132749.790832-1-nuomi2021@gmail.com> --- libavcodec/vvc/ctu.h | 2 + libavcodec/vvc/dsp.h | 13 +++ libavcodec/vvc/inter_template.c | 168 ++++++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+) diff --git a/libavcodec/vvc/ctu.h b/libavcodec/vvc/ctu.h index 337d0e7c28..50109154aa 100644 --- a/libavcodec/vvc/ctu.h +++ b/libavcodec/vvc/ctu.h @@ -58,6 +58,8 @@ #define BILINEAR_EXTRA_AFTER 1 #define BILINEAR_EXTRA 1 +#define SCALED_INT(pos) ((pos) >> 10) + #define MAX_CONTROL_POINTS 3 #define AFFINE_MIN_BLOCK_SIZE 4 diff --git a/libavcodec/vvc/dsp.h b/libavcodec/vvc/dsp.h index 9810ac314c..1f14096c41 100644 --- a/libavcodec/vvc/dsp.h +++ b/libavcodec/vvc/dsp.h @@ -57,6 +57,19 @@ typedef struct VVCInterDSPContext { uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, int height, int denom, int wx, int ox, const int8_t *hf, const int8_t *vf, int width); + 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); + + 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); + + 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); + 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_template.c b/libavcodec/vvc/inter_template.c index e2fbfd4fc0..a8068f4ba8 100644 --- a/libavcodec/vvc/inter_template.c +++ b/libavcodec/vvc/inter_template.c @@ -22,6 +22,165 @@ #include "libavcodec/h26x/h2656_inter_template.c" +#define TMP_STRIDE EDGE_EMU_BUFFER_STRIDE +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) +{ + int16_t tmp_array[TMP_STRIDE * MAX_PB_SIZE]; + int16_t *tmp = tmp_array; + pixel *dst = (pixel*)_dst; + int16_t *dst16 = (int16_t*)_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); + const int offset = 1 << (shift - 1); + 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 shift2 = 4 + is_chroma; + const int x0 = SCALED_INT(_x); + const int y0 = SCALED_INT(_y); + + for (int i = 0; i < width; i++) { + const int tx = _x + dx * i; + const int x = SCALED_INT(tx) - x0; + const int mx = av_mod_uintp2(tx >> shift1, 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); + src += src_stride; + } + tmp += TMP_STRIDE; + } + + for (int i = 0; i < height; i++) { + const int ty = _y + dy * i; + const int x = SCALED_INT(ty) - y0; + const int mx = av_mod_uintp2(ty >> shift1, shift2); + const int8_t *filter = vf + mx * taps; + + tmp = tmp_array + extra_before; + for (int j = 0; j < width; j++) { + const int val = (is_chroma ? CHROMA_FILTER(tmp, 1) : LUMA_FILTER(tmp, 1)) >> 6; + if (is_uni) + dst[j] = av_clip_pixel((val + offset) >> shift); + else + dst16[j] = val; + tmp += TMP_STRIDE; + } + if (is_uni) + dst += dst_stride; + else + dst16 += dst_stride; + } +} + +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) +{ + 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); +} + +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) +{ + 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); +} + +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) +{ + FUNC(put_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 1, 0); +} + +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) +{ + FUNC(put_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 1, 1); +} + +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) +{ + int16_t tmp_array[TMP_STRIDE * MAX_PB_SIZE]; + int16_t *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); + const int shift = FFMAX(2, 14 - BIT_DEPTH); + const int offset = 1 << (shift - 1); + const int ox = _ox * (1 << (BIT_DEPTH - 8)); + 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 shift2 = 4 + is_chroma; + const int x0 = SCALED_INT(_x); + const int y0 = SCALED_INT(_y); + + for (int i = 0; i < width; i++) { + const int tx = _x + dx * i; + const int x = SCALED_INT(tx) - x0; + const int mx = av_mod_uintp2(tx >> shift1, 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); + src += src_stride; + } + tmp += TMP_STRIDE; + } + + for (int i = 0; i < height; i++) { + const int ty = _y + dy * i; + const int x = SCALED_INT(ty) - y0; + const int mx = av_mod_uintp2(ty >> shift1, shift2); + const int8_t *filter = vf + mx * taps; + + tmp = tmp_array + extra_before; + for (int j = 0; j < width; j++) { + const int val = (is_chroma ? CHROMA_FILTER(tmp, 1) : LUMA_FILTER(tmp, 1)) >> 6; + dst[j] = av_clip_pixel(((wx * val + offset) >> shift) + ox); + tmp += TMP_STRIDE; + } + dst += dst_stride; + } +} + +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 denom, const int wx, const int ox, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + 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); +} + +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 denom, const int wx, const int ox, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + 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); +} + +#undef TMP_STRIDE + static void FUNC(avg)(uint8_t *_dst, const ptrdiff_t _dst_stride, const int16_t *src0, const int16_t *src1, const int width, const int height) { @@ -440,6 +599,15 @@ static void FUNC(ff_vvc_inter_dsp_init)(VVCInterDSPContext *const inter) FUNCS(LUMA, luma); FUNCS(CHROMA, chroma); + for (int i = 0; i < FF_ARRAY_ELEMS(inter->put_scaled[LUMA]); i++) { + inter->put_scaled[LUMA][i] = FUNC(put_luma_scaled); + inter->put_scaled[CHROMA][i] = FUNC(put_chroma_scaled); + inter->put_uni_scaled[LUMA][i] = FUNC(put_uni_luma_scaled); + inter->put_uni_scaled[CHROMA][i] = FUNC(put_uni_chroma_scaled); + inter->put_uni_w_scaled[LUMA][i] = FUNC(put_uni_luma_w_scaled); + inter->put_uni_w_scaled[CHROMA][i] = FUNC(put_uni_chroma_w_scaled); + } + inter->avg = FUNC(avg); inter->w_avg = FUNC(w_avg); -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2024-05-19 13:41 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <20240519132749.790832-1-nuomi2021@gmail.com> 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 02/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc to mc Nuo Mi 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 03/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc_uni to mc_uni Nuo Mi 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 04/18] avcodec/vvcdec: refact, unify {luma, chroma}_mc_bi to mc_bi Nuo Mi 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 05/18] avcodec/vvcdec: misc, remove unused EMULATED_EDGE_{LUMA, CHROMA}, EMULATED_EDGE_DMVR_{LUAM, CHROMA} Nuo Mi 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 06/18] avcodec/vvcdec: refact, unify pred_regular_{luma, chroma} to pred_regular Nuo Mi 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 07/18] avcodec/vvcdec: refact out VVCRefPic from RefPicList Nuo Mi 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 08/18] avcodec/vvcdec: refact, pred_get_refs return VVCRefPic instead of VVCFrame Nuo Mi 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 09/18] avcodec/vvcdec: add vvc inter filters for RPR Nuo Mi 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 10/18] avcodec/vvcdec: emulated_edge, use reference frame's sps and pps Nuo Mi 2024-05-19 13:27 ` Nuo Mi [this message] 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 12/18] avcodec/vvcdec: inter, wait reference with a diffrent resolution Nuo Mi 2024-05-19 15:20 ` Jean-Baptiste Kempf 2024-05-20 13:25 ` Nuo Mi 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 13/18] avcodec/vvcdec: fix dmvr, bdof, cb_prof for RPR Nuo Mi 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 14/18] avcodec/vvcdec: refact out luma_prof from luma_prof_bi Nuo Mi 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 15/18] avcodec/vvcdec: refact, remove hf_idx and vf_idx from mc_xxx's param list Nuo Mi 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 16/18] avcodec/vvcdec: increase edge_emu_buffer for RPR Nuo Mi 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 17/18] avcodec/vvcdec: support Reference Picture Resampling Nuo Mi 2024-05-19 13:27 ` [FFmpeg-devel] [PATCH 18/18] Changelog: add DVB compatible information for VVC decoder Nuo Mi 2024-05-21 12:32 ` Nuo Mi
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=TYSPR06MB6433567DBBC4B0CA2066883CAAE82@TYSPR06MB6433.apcprd06.prod.outlook.com \ --to=nuomi2021@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git