diff mbox series

[FFmpeg-devel,v4,1/8] avcodec/vvc/vvc_inter_template: move put/put_luma/put_chroma template to h2656_inter_template.c

Message ID TYWP286MB217273F359418CAFF7502105CA742@TYWP286MB2172.JPNP286.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel,v4,1/8] avcodec/vvc/vvc_inter_template: move put/put_luma/put_chroma template to h2656_inter_template.c | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Wu Jianhua Jan. 23, 2024, 6:17 p.m. UTC
From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/h26x/h2656_inter_template.c | 577 +++++++++++++++++++++++++
 libavcodec/vvc/vvc_inter_template.c    | 559 +-----------------------
 2 files changed, 578 insertions(+), 558 deletions(-)
 create mode 100644 libavcodec/h26x/h2656_inter_template.c

Comments

Nuo Mi Feb. 1, 2024, 12:15 p.m. UTC | #1
On Wed, Jan 24, 2024 at 2:17 AM <toqsxw@outlook.com> wrote:

> From: Wu Jianhua <toqsxw@outlook.com>
>
> Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
> ---
>  libavcodec/h26x/h2656_inter_template.c | 577 +++++++++++++++++++++++++
>  libavcodec/vvc/vvc_inter_template.c    | 559 +-----------------------
>  2 files changed, 578 insertions(+), 558 deletions(-)
>  create mode 100644 libavcodec/h26x/h2656_inter_template.c
>

Applied. Thank you, Jianhua.

Thank you, Michael and Andriy, for your great help
James Almer Feb. 1, 2024, 1:14 p.m. UTC | #2
On 2/1/2024 9:15 AM, Nuo Mi wrote:
> On Wed, Jan 24, 2024 at 2:17 AM <toqsxw@outlook.com> wrote:
> 
>> From: Wu Jianhua <toqsxw@outlook.com>
>>
>> Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
>> ---
>>   libavcodec/h26x/h2656_inter_template.c | 577 +++++++++++++++++++++++++
>>   libavcodec/vvc/vvc_inter_template.c    | 559 +-----------------------
>>   2 files changed, 578 insertions(+), 558 deletions(-)
>>   create mode 100644 libavcodec/h26x/h2656_inter_template.c
>>
> 
> Applied. Thank you, Jianhua.
> 
> Thank you, Michael and Andriy, for your great help

The latest push broke hevc tests under gcc ubsan
http://fate.ffmpeg.org/report.cgi?slot=x86_64-archlinux-gcc-ubsan&time=20240201125247
Nuo Mi Feb. 2, 2024, 1:40 p.m. UTC | #3
On Thu, Feb 1, 2024 at 9:14 PM James Almer <jamrial@gmail.com> wrote:

> On 2/1/2024 9:15 AM, Nuo Mi wrote:
> > On Wed, Jan 24, 2024 at 2:17 AM <toqsxw@outlook.com> wrote:
> >
> >> From: Wu Jianhua <toqsxw@outlook.com>
> >>
> >> Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
> >> ---
> >>   libavcodec/h26x/h2656_inter_template.c | 577 +++++++++++++++++++++++++
> >>   libavcodec/vvc/vvc_inter_template.c    | 559 +-----------------------
> >>   2 files changed, 578 insertions(+), 558 deletions(-)
> >>   create mode 100644 libavcodec/h26x/h2656_inter_template.c
> >>
> >
> > Applied. Thank you, Jianhua.
> >
> > Thank you, Michael and Andriy, for your great help
>
> The latest push broke hevc tests under gcc ubsan
>
> http://fate.ffmpeg.org/report.cgi?slot=x86_64-archlinux-gcc-ubsan&time=20240201125247

Thank you James, We will fix it.

>
>
> _______________________________________________
> 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".
>
Nuo Mi Feb. 11, 2024, 5:51 a.m. UTC | #4
On Fri, Feb 2, 2024 at 9:40 PM Nuo Mi <nuomi2021@gmail.com> wrote:

>
>
> On Thu, Feb 1, 2024 at 9:14 PM James Almer <jamrial@gmail.com> wrote:
>
>> On 2/1/2024 9:15 AM, Nuo Mi wrote:
>> > On Wed, Jan 24, 2024 at 2:17 AM <toqsxw@outlook.com> wrote:
>> >
>> >> From: Wu Jianhua <toqsxw@outlook.com>
>> >>
>> >> Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
>> >> ---
>> >>   libavcodec/h26x/h2656_inter_template.c | 577
>> +++++++++++++++++++++++++
>> >>   libavcodec/vvc/vvc_inter_template.c    | 559 +-----------------------
>> >>   2 files changed, 578 insertions(+), 558 deletions(-)
>> >>   create mode 100644 libavcodec/h26x/h2656_inter_template.c
>> >>
>> >
>> > Applied. Thank you, Jianhua.
>> >
>> > Thank you, Michael and Andriy, for your great help
>>
>> The latest push broke hevc tests under gcc ubsan
>>
>> http://fate.ffmpeg.org/report.cgi?slot=x86_64-archlinux-gcc-ubsan&time=20240201125247
>
> Thank you James, We will fix it.
>
Hi James,
Apologies for the delay
Fixed by
https://patchwork.ffmpeg.org/project/ffmpeg/patch/TYSPR06MB6433517914B4C4432D6799E5AA492@TYSPR06MB6433.apcprd06.prod.outlook.com/


>>
>> _______________________________________________
>> 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".
>>
>
diff mbox series

Patch

diff --git a/libavcodec/h26x/h2656_inter_template.c b/libavcodec/h26x/h2656_inter_template.c
new file mode 100644
index 0000000000..864f6c7e7d
--- /dev/null
+++ b/libavcodec/h26x/h2656_inter_template.c
@@ -0,0 +1,577 @@ 
+/*
+ * inter prediction template for HEVC/VVC
+ *
+ * Copyright (C) 2022 Nuo Mi
+ * Copyright (C) 2024 Wu Jianhua
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define CHROMA_EXTRA_BEFORE     1
+#define CHROMA_EXTRA            3
+#define LUMA_EXTRA_BEFORE       3
+#define LUMA_EXTRA              7
+
+static void FUNC(put_pixels)(int16_t *dst,
+    const uint8_t *_src, const ptrdiff_t _src_stride,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    const pixel *src            = (const pixel *)_src;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++)
+            dst[x] = src[x] << (14 - BIT_DEPTH);
+        src += src_stride;
+        dst += MAX_PB_SIZE;
+    }
+}
+
+static void FUNC(put_uni_pixels)(uint8_t *_dst, const ptrdiff_t _dst_stride,
+    const uint8_t *_src, const ptrdiff_t _src_stride, const int height,
+     const int8_t *hf, const int8_t *vf, const int width)
+{
+    const pixel *src            = (const pixel *)_src;
+    pixel *dst                  = (pixel *)_dst;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
+
+    for (int y = 0; y < height; y++) {
+        memcpy(dst, src, width * sizeof(pixel));
+        src += src_stride;
+        dst += dst_stride;
+    }
+}
+
+static void FUNC(put_uni_w_pixels)(uint8_t *_dst, const ptrdiff_t _dst_stride,
+    const uint8_t *_src, const ptrdiff_t _src_stride, const int height,
+    const int denom, const int wx, const int _ox,  const int8_t *hf, const int8_t *vf,
+    const int width)
+{
+    const pixel *src            = (const pixel *)_src;
+    pixel *dst                  = (pixel *)_dst;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
+    const int shift             = denom + 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+    const int offset            = 1 << (shift - 1);
+#else
+    const int offset            = 0;
+#endif
+    const int ox                = _ox * (1 << (BIT_DEPTH - 8));
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++) {
+            const int v = (src[x] << (14 - BIT_DEPTH));
+            dst[x] = av_clip_pixel(((v * wx + offset) >> shift) + ox);
+        }
+        src += src_stride;
+        dst += dst_stride;
+    }
+}
+
+#define LUMA_FILTER(src, stride)                                               \
+    (filter[0] * src[x - 3 * stride] +                                         \
+     filter[1] * src[x - 2 * stride] +                                         \
+     filter[2] * src[x -     stride] +                                         \
+     filter[3] * src[x             ] +                                         \
+     filter[4] * src[x +     stride] +                                         \
+     filter[5] * src[x + 2 * stride] +                                         \
+     filter[6] * src[x + 3 * stride] +                                         \
+     filter[7] * src[x + 4 * stride])
+
+static void FUNC(put_luma_h)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    const pixel *src           = (const pixel*)_src;
+    const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
+    const int8_t *filter       = hf;
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++)
+            dst[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
+        src += src_stride;
+        dst += MAX_PB_SIZE;
+    }
+}
+
+static void FUNC(put_luma_v)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    const pixel *src           = (pixel*)_src;
+    const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
+    const int8_t *filter       = vf;
+
+    for (int y = 0; y < height; y++)  {
+        for (int x = 0; x < width; x++)
+            dst[x] = LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8);
+        src += src_stride;
+        dst += MAX_PB_SIZE;
+    }
+}
+
+static void FUNC(put_luma_hv)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE];
+    int16_t *tmp                = tmp_array;
+    const pixel *src            = (const pixel*)_src;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const int8_t *filter        = hf;
+
+    src   -= LUMA_EXTRA_BEFORE * src_stride;
+    for (int y = 0; y < height + LUMA_EXTRA; y++) {
+        for (int x = 0; x < width; x++)
+            tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
+        src += src_stride;
+        tmp += MAX_PB_SIZE;
+    }
+
+    tmp    = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE;
+    filter = vf;
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++)
+            dst[x] = LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6;
+        tmp += MAX_PB_SIZE;
+        dst += MAX_PB_SIZE;
+    }
+}
+
+static void FUNC(put_uni_luma_h)(uint8_t *_dst,  const ptrdiff_t _dst_stride,
+    const uint8_t *_src, const ptrdiff_t _src_stride,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    const pixel *src           = (const pixel*)_src;
+    pixel *dst                 = (pixel *)_dst;
+    const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
+    const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
+    const int8_t *filter       = hf;
+    const int shift            = 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+    const int offset           = 1 << (shift - 1);
+#else
+    const int offset           = 0;
+#endif
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++) {
+            const int val = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
+            dst[x]        = av_clip_pixel((val + offset) >> shift);
+        }
+        src   += src_stride;
+        dst   += dst_stride;
+    }
+}
+
+static void FUNC(put_uni_luma_v)(uint8_t *_dst,  const ptrdiff_t _dst_stride,
+    const uint8_t *_src, const ptrdiff_t _src_stride,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+
+    const pixel *src            = (const pixel*)_src;
+    pixel *dst                  = (pixel *)_dst;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
+    const int8_t *filter        = vf;
+    const int shift             = 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+    const int offset            = 1 << (shift - 1);
+#else
+    const int offset            = 0;
+#endif
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++) {
+            const int val = LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8);
+            dst[x]        = av_clip_pixel((val + offset) >> shift);
+        }
+        src   += src_stride;
+        dst   += dst_stride;
+    }
+}
+
+static void FUNC(put_uni_luma_hv)(uint8_t *_dst, const ptrdiff_t _dst_stride,
+    const uint8_t *_src, const ptrdiff_t _src_stride,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE];
+    int16_t *tmp                = tmp_array;
+    const pixel *src            = (const pixel*)_src;
+    pixel *dst                  = (pixel *)_dst;
+    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const int8_t *filter        = hf;
+    const int shift             =  14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+    const int offset            = 1 << (shift - 1);
+#else
+    const int offset            = 0;
+#endif
+
+    src   -= LUMA_EXTRA_BEFORE * src_stride;
+    for (int y = 0; y < height + LUMA_EXTRA; y++) {
+        for (int x = 0; x < width; x++)
+            tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
+        src += src_stride;
+        tmp += MAX_PB_SIZE;
+    }
+
+    tmp    = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE;
+    filter = vf;
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++) {
+            const int val = LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6;
+            dst[x]  = av_clip_pixel((val  + offset) >> shift);
+        }
+        tmp += MAX_PB_SIZE;
+        dst += dst_stride;
+    }
+
+}
+
+static void FUNC(put_uni_luma_w_h)(uint8_t *_dst,  const ptrdiff_t _dst_stride,
+    const uint8_t *_src, const ptrdiff_t _src_stride, int height,
+    const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf,
+    const int width)
+{
+    const pixel *src            = (const pixel*)_src;
+    pixel *dst                  = (pixel *)_dst;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
+    const int8_t *filter        = hf;
+    const int ox                = _ox * (1 << (BIT_DEPTH - 8));
+    const int shift             = denom + 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+    const int offset            = 1 << (shift - 1);
+#else
+    const int offset            = 0;
+#endif
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++)
+            dst[x] = av_clip_pixel((((LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
+        src += src_stride;
+        dst += dst_stride;
+    }
+}
+
+static void FUNC(put_uni_luma_w_v)(uint8_t *_dst,  const ptrdiff_t _dst_stride,
+    const uint8_t *_src, const ptrdiff_t _src_stride, const int height,
+    const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf,
+    const int width)
+{
+    const pixel *src            = (const pixel*)_src;
+    pixel *dst                  = (pixel *)_dst;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
+    const int8_t *filter        = vf;
+    const int ox                = _ox * (1 << (BIT_DEPTH - 8));
+    const int shift             = denom + 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+    const int offset            = 1 << (shift - 1);
+#else
+    const int offset            = 0;
+#endif
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++)
+            dst[x] = av_clip_pixel((((LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
+        src += src_stride;
+        dst += dst_stride;
+    }
+}
+
+static void FUNC(put_uni_luma_w_hv)(uint8_t *_dst,  const ptrdiff_t _dst_stride,
+    const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int denom,
+    const int wx, const int _ox, const int8_t *hf, const int8_t *vf, const int width)
+{
+    int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE];
+    int16_t *tmp                = tmp_array;
+    const pixel *src            = (const pixel*)_src;
+    pixel *dst                  = (pixel *)_dst;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
+    const int8_t *filter        = hf;
+    const int ox                = _ox * (1 << (BIT_DEPTH - 8));
+    const int shift             = denom + 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+    const int offset            = 1 << (shift - 1);
+#else
+    const int offset            = 0;
+#endif
+
+    src   -= LUMA_EXTRA_BEFORE * src_stride;
+    for (int y = 0; y < height + LUMA_EXTRA; y++) {
+        for (int x = 0; x < width; x++)
+            tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
+        src += src_stride;
+        tmp += MAX_PB_SIZE;
+    }
+
+    tmp    = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE;
+    filter = vf;
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++)
+            dst[x] = av_clip_pixel((((LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx + offset) >> shift) + ox);
+        tmp += MAX_PB_SIZE;
+        dst += dst_stride;
+    }
+}
+
+#define CHROMA_FILTER(src, stride)                                             \
+    (filter[0] * src[x - stride] +                                             \
+     filter[1] * src[x]          +                                             \
+     filter[2] * src[x + stride] +                                             \
+     filter[3] * src[x + 2 * stride])
+
+static void FUNC(put_chroma_h)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    const pixel *src            = (const pixel *)_src;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const int8_t *filter        = hf;
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++)
+            dst[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
+        src += src_stride;
+        dst += MAX_PB_SIZE;
+    }
+}
+
+static void FUNC(put_chroma_v)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    const pixel *src            = (const pixel *)_src;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const int8_t *filter        = vf;
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++)
+            dst[x] = CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8);
+        src += src_stride;
+        dst += MAX_PB_SIZE;
+    }
+}
+
+static void FUNC(put_chroma_hv)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE];
+    int16_t *tmp                = tmp_array;
+    const pixel *src            = (const pixel *)_src;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const int8_t *filter        = hf;
+
+    src -= CHROMA_EXTRA_BEFORE * src_stride;
+
+    for (int y = 0; y < height + CHROMA_EXTRA; y++) {
+        for (int x = 0; x < width; x++)
+            tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
+        src += src_stride;
+        tmp += MAX_PB_SIZE;
+    }
+
+    tmp    = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE;
+    filter = vf;
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++)
+            dst[x] = CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6;
+        tmp += MAX_PB_SIZE;
+        dst += MAX_PB_SIZE;
+    }
+}
+
+static void FUNC(put_uni_chroma_h)(uint8_t *_dst, const ptrdiff_t _dst_stride,
+    const uint8_t *_src, const ptrdiff_t _src_stride,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    const pixel *src            = (const pixel *)_src;
+    pixel *dst                  = (pixel *)_dst;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
+    const int8_t *filter        = hf;
+    const int shift             = 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+    const int offset            = 1 << (shift - 1);
+#else
+    const int offset            = 0;
+#endif
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++)
+            dst[x] = av_clip_pixel(((CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) + offset) >> shift);
+        src += src_stride;
+        dst += dst_stride;
+    }
+}
+
+static void FUNC(put_uni_chroma_v)(uint8_t *_dst, const ptrdiff_t _dst_stride,
+    const uint8_t *_src, const ptrdiff_t _src_stride,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    const pixel *src            = (const pixel *)_src;
+    pixel *dst                  = (pixel *)_dst;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
+    const int8_t *filter        = vf;
+    const int shift             = 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+    const int offset            = 1 << (shift - 1);
+#else
+    const int offset            = 0;
+#endif
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++)
+            dst[x] = av_clip_pixel(((CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) + offset) >> shift);
+        src += src_stride;
+        dst += dst_stride;
+    }
+}
+
+static void FUNC(put_uni_chroma_hv)(uint8_t *_dst, const ptrdiff_t _dst_stride,
+    const uint8_t *_src, const ptrdiff_t _src_stride,
+    const int height, const int8_t *hf, const int8_t *vf, const int width)
+{
+    int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE];
+    int16_t *tmp                = tmp_array;
+    const pixel *src            = (const pixel *)_src;
+    pixel *dst                  = (pixel *)_dst;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
+    const int8_t *filter        = hf;
+    const int shift             = 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+    const int offset            = 1 << (shift - 1);
+#else
+    const int offset            = 0;
+#endif
+
+    src -= CHROMA_EXTRA_BEFORE * src_stride;
+
+    for (int y = 0; y < height + CHROMA_EXTRA; y++) {
+        for (int x = 0; x < width; x++)
+            tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
+        src += src_stride;
+        tmp += MAX_PB_SIZE;
+    }
+
+    tmp    = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE;
+    filter = vf;
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++)
+            dst[x] = av_clip_pixel(((CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6) + offset) >> shift);
+        tmp += MAX_PB_SIZE;
+        dst += dst_stride;
+    }
+}
+
+static void FUNC(put_uni_chroma_w_h)(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)
+{
+    const pixel *src            = (const pixel *)_src;
+    pixel *dst                  = (pixel *)_dst;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
+    const int8_t *filter        = hf;
+    const int shift             = denom + 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+    const int offset            = 1 << (shift - 1);
+#else
+    const int offset            = 0;
+#endif
+
+    ox     = ox * (1 << (BIT_DEPTH - 8));
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++) {
+            dst[x] = av_clip_pixel((((CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
+        }
+        dst += dst_stride;
+        src += src_stride;
+    }
+}
+
+static void FUNC(put_uni_chroma_w_v)(uint8_t *_dst, const ptrdiff_t _dst_stride,
+    const uint8_t *_src, const ptrdiff_t _src_stride, const int height,
+    const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf,
+    const int width)
+{
+    const pixel *src            = (const pixel *)_src;
+    pixel *dst                  = (pixel *)_dst;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
+    const int8_t *filter        = vf;
+    const int shift             = denom + 14 - BIT_DEPTH;
+    const int ox                = _ox * (1 << (BIT_DEPTH - 8));
+#if BIT_DEPTH < 14
+    int offset                  = 1 << (shift - 1);
+#else
+    int offset                  = 0;
+#endif
+
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++) {
+            dst[x] = av_clip_pixel((((CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
+        }
+        dst += dst_stride;
+        src += src_stride;
+    }
+}
+
+static void FUNC(put_uni_chroma_w_hv)(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)
+{
+    int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE];
+    int16_t *tmp                = tmp_array;
+    const pixel *src            = (const pixel *)_src;
+    pixel *dst                  = (pixel *)_dst;
+    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
+    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
+    const int8_t *filter        = hf;
+    const int shift             = denom + 14 - BIT_DEPTH;
+#if BIT_DEPTH < 14
+    const int offset            = 1 << (shift - 1);
+#else
+    const int offset            = 0;
+#endif
+
+    src -= CHROMA_EXTRA_BEFORE * src_stride;
+
+    for (int y = 0; y < height + CHROMA_EXTRA; y++) {
+        for (int x = 0; x < width; x++)
+            tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
+        src += src_stride;
+        tmp += MAX_PB_SIZE;
+    }
+
+    tmp    = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE;
+    filter = vf;
+
+    ox     = ox * (1 << (BIT_DEPTH - 8));
+    for (int y = 0; y < height; y++) {
+        for (int x = 0; x < width; x++)
+            dst[x] = av_clip_pixel((((CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx + offset) >> shift) + ox);
+        tmp += MAX_PB_SIZE;
+        dst += dst_stride;
+    }
+}
diff --git a/libavcodec/vvc/vvc_inter_template.c b/libavcodec/vvc/vvc_inter_template.c
index 7160907778..e5cff079fb 100644
--- a/libavcodec/vvc/vvc_inter_template.c
+++ b/libavcodec/vvc/vvc_inter_template.c
@@ -20,564 +20,7 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-////////////////////////////////////////////////////////////////////////////////
-//
-////////////////////////////////////////////////////////////////////////////////
-static void FUNC(put_pixels)(int16_t *dst,
-    const uint8_t *_src, const ptrdiff_t _src_stride,
-    const int height, const int8_t *hf, const int8_t *vf, const int width)
-{
-    const pixel *src            = (const pixel *)_src;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = src[x] << (14 - BIT_DEPTH);
-        src += src_stride;
-        dst += MAX_PB_SIZE;
-    }
-}
-
-static void FUNC(put_uni_pixels)(uint8_t *_dst, const ptrdiff_t _dst_stride,
-    const uint8_t *_src, const ptrdiff_t _src_stride, const int height,
-     const int8_t *hf, const int8_t *vf, const int width)
-{
-    const pixel *src            = (const pixel *)_src;
-    pixel *dst                  = (pixel *)_dst;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
-
-    for (int y = 0; y < height; y++) {
-        memcpy(dst, src, width * sizeof(pixel));
-        src += src_stride;
-        dst += dst_stride;
-    }
-}
-
-static void FUNC(put_uni_w_pixels)(uint8_t *_dst, const ptrdiff_t _dst_stride,
-    const uint8_t *_src, const ptrdiff_t _src_stride, const int height,
-    const int denom, const int wx, const int _ox,  const int8_t *hf, const int8_t *vf,
-    const int width)
-{
-    const pixel *src            = (const pixel *)_src;
-    pixel *dst                  = (pixel *)_dst;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
-    const int shift             = denom + 14 - BIT_DEPTH;
-#if BIT_DEPTH < 14
-    const int offset            = 1 << (shift - 1);
-#else
-    const int offset            = 0;
-#endif
-    const int ox                = _ox * (1 << (BIT_DEPTH - 8));
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++) {
-            const int v = (src[x] << (14 - BIT_DEPTH));
-            dst[x] = av_clip_pixel(((v * wx + offset) >> shift) + ox);
-        }
-        src += src_stride;
-        dst += dst_stride;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-////////////////////////////////////////////////////////////////////////////////
-#define LUMA_FILTER(src, stride)                                               \
-    (filter[0] * src[x - 3 * stride] +                                         \
-     filter[1] * src[x - 2 * stride] +                                         \
-     filter[2] * src[x -     stride] +                                         \
-     filter[3] * src[x             ] +                                         \
-     filter[4] * src[x +     stride] +                                         \
-     filter[5] * src[x + 2 * stride] +                                         \
-     filter[6] * src[x + 3 * stride] +                                         \
-     filter[7] * src[x + 4 * stride])
-
-static void FUNC(put_luma_h)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
-    const int height, const int8_t *hf, const int8_t *vf, const int width)
-{
-    const pixel *src           = (const pixel*)_src;
-    const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
-    const int8_t *filter       = hf;
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
-        src += src_stride;
-        dst += MAX_PB_SIZE;
-    }
-}
-
-static void FUNC(put_luma_v)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
-    const int height, const int8_t *hf, const int8_t *vf, const int width)
-{
-    const pixel *src           = (pixel*)_src;
-    const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
-    const int8_t *filter       = vf;
-
-    for (int y = 0; y < height; y++)  {
-        for (int x = 0; x < width; x++)
-            dst[x] = LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8);
-        src += src_stride;
-        dst += MAX_PB_SIZE;
-    }
-}
-
-static void FUNC(put_luma_hv)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
-    const int height, const int8_t *hf, const int8_t *vf, const int width)
-{
-    int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE];
-    int16_t *tmp                = tmp_array;
-    const pixel *src            = (const pixel*)_src;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const int8_t *filter        = hf;
-
-    src   -= LUMA_EXTRA_BEFORE * src_stride;
-    for (int y = 0; y < height + LUMA_EXTRA; y++) {
-        for (int x = 0; x < width; x++)
-            tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
-        src += src_stride;
-        tmp += MAX_PB_SIZE;
-    }
-
-    tmp    = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE;
-    filter = vf;
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6;
-        tmp += MAX_PB_SIZE;
-        dst += MAX_PB_SIZE;
-    }
-}
-
-static void FUNC(put_uni_luma_h)(uint8_t *_dst,  const ptrdiff_t _dst_stride,
-    const uint8_t *_src, const ptrdiff_t _src_stride,
-    const int height, const int8_t *hf, const int8_t *vf, const int width)
-{
-    const pixel *src           = (const pixel*)_src;
-    pixel *dst                 = (pixel *)_dst;
-    const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
-    const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
-    const int8_t *filter       = hf;
-    const int shift            = 14 - BIT_DEPTH;
-#if BIT_DEPTH < 14
-    const int offset           = 1 << (shift - 1);
-#else
-    const int offset           = 0;
-#endif
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++) {
-            const int val = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
-            dst[x]        = av_clip_pixel((val + offset) >> shift);
-        }
-        src   += src_stride;
-        dst   += dst_stride;
-    }
-}
-
-static void FUNC(put_uni_luma_v)(uint8_t *_dst,  const ptrdiff_t _dst_stride,
-    const uint8_t *_src, const ptrdiff_t _src_stride,
-    const int height, const int8_t *hf, const int8_t *vf, const int width)
-{
-
-    const pixel *src            = (const pixel*)_src;
-    pixel *dst                  = (pixel *)_dst;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
-    const int8_t *filter        = vf;
-    const int shift             = 14 - BIT_DEPTH;
-#if BIT_DEPTH < 14
-    const int offset            = 1 << (shift - 1);
-#else
-    const int offset            = 0;
-#endif
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++) {
-            const int val = LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8);
-            dst[x]        = av_clip_pixel((val + offset) >> shift);
-        }
-        src   += src_stride;
-        dst   += dst_stride;
-    }
-}
-
-static void FUNC(put_uni_luma_hv)(uint8_t *_dst, const ptrdiff_t _dst_stride,
-    const uint8_t *_src, const ptrdiff_t _src_stride,
-    const int height, const int8_t *hf, const int8_t *vf, const int width)
-{
-    int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE];
-    int16_t *tmp                = tmp_array;
-    const pixel *src            = (const pixel*)_src;
-    pixel *dst                  = (pixel *)_dst;
-    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const int8_t *filter        = hf;
-    const int shift             =  14 - BIT_DEPTH;
-#if BIT_DEPTH < 14
-    const int offset            = 1 << (shift - 1);
-#else
-    const int offset            = 0;
-#endif
-
-    src   -= LUMA_EXTRA_BEFORE * src_stride;
-    for (int y = 0; y < height + LUMA_EXTRA; y++) {
-        for (int x = 0; x < width; x++)
-            tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
-        src += src_stride;
-        tmp += MAX_PB_SIZE;
-    }
-
-    tmp    = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE;
-    filter = vf;
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++) {
-            const int val = LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6;
-            dst[x]  = av_clip_pixel((val  + offset) >> shift);
-        }
-        tmp += MAX_PB_SIZE;
-        dst += dst_stride;
-    }
-
-}
-
-static void FUNC(put_uni_luma_w_h)(uint8_t *_dst,  const ptrdiff_t _dst_stride,
-    const uint8_t *_src, const ptrdiff_t _src_stride, int height,
-    const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf,
-    const int width)
-{
-    const pixel *src            = (const pixel*)_src;
-    pixel *dst                  = (pixel *)_dst;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
-    const int8_t *filter        = hf;
-    const int ox                = _ox * (1 << (BIT_DEPTH - 8));
-    const int shift             = denom + 14 - BIT_DEPTH;
-#if BIT_DEPTH < 14
-    const int offset            = 1 << (shift - 1);
-#else
-    const int offset            = 0;
-#endif
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = av_clip_pixel((((LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
-        src += src_stride;
-        dst += dst_stride;
-    }
-}
-
-static void FUNC(put_uni_luma_w_v)(uint8_t *_dst,  const ptrdiff_t _dst_stride,
-    const uint8_t *_src, const ptrdiff_t _src_stride, const int height,
-    const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf,
-    const int width)
-{
-    const pixel *src            = (const pixel*)_src;
-    pixel *dst                  = (pixel *)_dst;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
-    const int8_t *filter        = vf;
-    const int ox                = _ox * (1 << (BIT_DEPTH - 8));
-    const int shift             = denom + 14 - BIT_DEPTH;
-#if BIT_DEPTH < 14
-    const int offset            = 1 << (shift - 1);
-#else
-    const int offset            = 0;
-#endif
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = av_clip_pixel((((LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
-        src += src_stride;
-        dst += dst_stride;
-    }
-}
-
-static void FUNC(put_uni_luma_w_hv)(uint8_t *_dst,  const ptrdiff_t _dst_stride,
-    const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int denom,
-    const int wx, const int _ox, const int8_t *hf, const int8_t *vf, const int width)
-{
-    int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE];
-    int16_t *tmp                = tmp_array;
-    const pixel *src            = (const pixel*)_src;
-    pixel *dst                  = (pixel *)_dst;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
-    const int8_t *filter        = hf;
-    const int ox                = _ox * (1 << (BIT_DEPTH - 8));
-    const int shift             = denom + 14 - BIT_DEPTH;
-#if BIT_DEPTH < 14
-    const int offset            = 1 << (shift - 1);
-#else
-    const int offset            = 0;
-#endif
-
-    src   -= LUMA_EXTRA_BEFORE * src_stride;
-    for (int y = 0; y < height + LUMA_EXTRA; y++) {
-        for (int x = 0; x < width; x++)
-            tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
-        src += src_stride;
-        tmp += MAX_PB_SIZE;
-    }
-
-    tmp    = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE;
-    filter = vf;
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = av_clip_pixel((((LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx + offset) >> shift) + ox);
-        tmp += MAX_PB_SIZE;
-        dst += dst_stride;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-////////////////////////////////////////////////////////////////////////////////
-#define CHROMA_FILTER(src, stride)                                               \
-    (filter[0] * src[x - stride] +                                             \
-     filter[1] * src[x]          +                                             \
-     filter[2] * src[x + stride] +                                             \
-     filter[3] * src[x + 2 * stride])
-
-static void FUNC(put_chroma_h)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
-    const int height, const int8_t *hf, const int8_t *vf, const int width)
-{
-    const pixel *src            = (const pixel *)_src;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const int8_t *filter        = hf;
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
-        src += src_stride;
-        dst += MAX_PB_SIZE;
-    }
-}
-
-static void FUNC(put_chroma_v)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
-    const int height, const int8_t *hf, const int8_t *vf, const int width)
-{
-    const pixel *src            = (const pixel *)_src;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const int8_t *filter        = vf;
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8);
-        src += src_stride;
-        dst += MAX_PB_SIZE;
-    }
-}
-
-static void FUNC(put_chroma_hv)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
-    const int height, const int8_t *hf, const int8_t *vf, const int width)
-{
-    int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE];
-    int16_t *tmp                = tmp_array;
-    const pixel *src            = (const pixel *)_src;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const int8_t *filter        = hf;
-
-    src -= CHROMA_EXTRA_BEFORE * src_stride;
-
-    for (int y = 0; y < height + CHROMA_EXTRA; y++) {
-        for (int x = 0; x < width; x++)
-            tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
-        src += src_stride;
-        tmp += MAX_PB_SIZE;
-    }
-
-    tmp    = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE;
-    filter = vf;
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6;
-        tmp += MAX_PB_SIZE;
-        dst += MAX_PB_SIZE;
-    }
-}
-
-static void FUNC(put_uni_chroma_h)(uint8_t *_dst, const ptrdiff_t _dst_stride,
-    const uint8_t *_src, const ptrdiff_t _src_stride,
-    const int height, const int8_t *hf, const int8_t *vf, const int width)
-{
-    const pixel *src            = (const pixel *)_src;
-    pixel *dst                  = (pixel *)_dst;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
-    const int8_t *filter        = hf;
-    const int shift             = 14 - BIT_DEPTH;
-#if BIT_DEPTH < 14
-    const int offset            = 1 << (shift - 1);
-#else
-    const int offset            = 0;
-#endif
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = av_clip_pixel(((CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) + offset) >> shift);
-        src += src_stride;
-        dst += dst_stride;
-    }
-}
-
-static void FUNC(put_uni_chroma_v)(uint8_t *_dst, const ptrdiff_t _dst_stride,
-    const uint8_t *_src, const ptrdiff_t _src_stride,
-    const int height, const int8_t *hf, const int8_t *vf, const int width)
-{
-    const pixel *src            = (const pixel *)_src;
-    pixel *dst                  = (pixel *)_dst;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
-    const int8_t *filter        = vf;
-    const int shift             = 14 - BIT_DEPTH;
-#if BIT_DEPTH < 14
-    const int offset            = 1 << (shift - 1);
-#else
-    const int offset            = 0;
-#endif
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = av_clip_pixel(((CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) + offset) >> shift);
-        src += src_stride;
-        dst += dst_stride;
-    }
-}
-
-static void FUNC(put_uni_chroma_hv)(uint8_t *_dst, const ptrdiff_t _dst_stride,
-    const uint8_t *_src, const ptrdiff_t _src_stride,
-    const int height, const int8_t *hf, const int8_t *vf, const int width)
-{
-    int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE];
-    int16_t *tmp                = tmp_array;
-    const pixel *src            = (const pixel *)_src;
-    pixel *dst                  = (pixel *)_dst;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
-    const int8_t *filter        = hf;
-    const int shift             = 14 - BIT_DEPTH;
-#if BIT_DEPTH < 14
-    const int offset            = 1 << (shift - 1);
-#else
-    const int offset            = 0;
-#endif
-
-    src -= CHROMA_EXTRA_BEFORE * src_stride;
-
-    for (int y = 0; y < height + CHROMA_EXTRA; y++) {
-        for (int x = 0; x < width; x++)
-            tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
-        src += src_stride;
-        tmp += MAX_PB_SIZE;
-    }
-
-    tmp    = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE;
-    filter = vf;
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = av_clip_pixel(((CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6) + offset) >> shift);
-        tmp += MAX_PB_SIZE;
-        dst += dst_stride;
-    }
-}
-
-static void FUNC(put_uni_chroma_w_h)(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)
-{
-    const pixel *src            = (const pixel *)_src;
-    pixel *dst                  = (pixel *)_dst;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
-    const int8_t *filter        = hf;
-    const int shift             = denom + 14 - BIT_DEPTH;
-#if BIT_DEPTH < 14
-    const int offset            = 1 << (shift - 1);
-#else
-    const int offset            = 0;
-#endif
-
-    ox     = ox * (1 << (BIT_DEPTH - 8));
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++) {
-            dst[x] = av_clip_pixel((((CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
-        }
-        dst += dst_stride;
-        src += src_stride;
-    }
-}
-
-static void FUNC(put_uni_chroma_w_v)(uint8_t *_dst, const ptrdiff_t _dst_stride,
-    const uint8_t *_src, const ptrdiff_t _src_stride, const int height,
-    const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf,
-    const int width)
-{
-    const pixel *src            = (const pixel *)_src;
-    pixel *dst                  = (pixel *)_dst;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
-    const int8_t *filter        = vf;
-    const int shift             = denom + 14 - BIT_DEPTH;
-    const int ox                = _ox * (1 << (BIT_DEPTH - 8));
-#if BIT_DEPTH < 14
-    int offset                  = 1 << (shift - 1);
-#else
-    int offset                  = 0;
-#endif
-
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++) {
-            dst[x] = av_clip_pixel((((CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
-        }
-        dst += dst_stride;
-        src += src_stride;
-    }
-}
-
-static void FUNC(put_uni_chroma_w_hv)(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)
-{
-    int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE];
-    int16_t *tmp                = tmp_array;
-    const pixel *src            = (const pixel *)_src;
-    pixel *dst                  = (pixel *)_dst;
-    const ptrdiff_t src_stride  = _src_stride / sizeof(pixel);
-    const ptrdiff_t dst_stride  = _dst_stride / sizeof(pixel);
-    const int8_t *filter        = hf;
-    const int shift             = denom + 14 - BIT_DEPTH;
-#if BIT_DEPTH < 14
-    const int offset            = 1 << (shift - 1);
-#else
-    const int offset            = 0;
-#endif
-
-    src -= CHROMA_EXTRA_BEFORE * src_stride;
-
-    for (int y = 0; y < height + CHROMA_EXTRA; y++) {
-        for (int x = 0; x < width; x++)
-            tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8);
-        src += src_stride;
-        tmp += MAX_PB_SIZE;
-    }
-
-    tmp    = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE;
-    filter = vf;
-
-    ox     = ox * (1 << (BIT_DEPTH - 8));
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++)
-            dst[x] = av_clip_pixel((((CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx + offset) >> shift) + ox);
-        tmp += MAX_PB_SIZE;
-        dst += dst_stride;
-    }
-}
+#include "libavcodec/h26x/h2656_inter_template.c"
 
 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)