diff mbox series

[FFmpeg-devel,1/9] avfilter/bwdif: Add proper BWDIFDSPContext

Message ID AS8P250MB0744D7FEB3A2719DC2D9F0EA8FFCA@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 80afcc85390819c8d35da5971840b762a40875af
Headers show
Series [FFmpeg-devel,1/9] avfilter/bwdif: Add proper BWDIFDSPContext | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 25, 2023, 5:53 p.m. UTC
This already avoids unnecessary indirectly included headers
in the arch-specific vf_bwdif_init.c files; it is also in
preparation for splitting the actual functions out of vf_bwdif.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavfilter/aarch64/vf_bwdif_init_aarch64.c |  4 ++--
 libavfilter/{bwdif.h => bwdifdsp.h}         | 22 +++++++-------------
 libavfilter/vf_bwdif.c                      | 23 ++++++++++++++-------
 libavfilter/x86/vf_bwdif_init.c             |  4 ++--
 tests/checkasm/vf_bwdif.c                   |  5 ++---
 5 files changed, 29 insertions(+), 29 deletions(-)
 rename libavfilter/{bwdif.h => bwdifdsp.h} (85%)

Comments

Andreas Rheinhardt Sept. 26, 2023, 10:11 p.m. UTC | #1
Andreas Rheinhardt:
> This already avoids unnecessary indirectly included headers
> in the arch-specific vf_bwdif_init.c files; it is also in
> preparation for splitting the actual functions out of vf_bwdif.c.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavfilter/aarch64/vf_bwdif_init_aarch64.c |  4 ++--
>  libavfilter/{bwdif.h => bwdifdsp.h}         | 22 +++++++-------------
>  libavfilter/vf_bwdif.c                      | 23 ++++++++++++++-------
>  libavfilter/x86/vf_bwdif_init.c             |  4 ++--
>  tests/checkasm/vf_bwdif.c                   |  5 ++---
>  5 files changed, 29 insertions(+), 29 deletions(-)
>  rename libavfilter/{bwdif.h => bwdifdsp.h} (85%)
> 
> diff --git a/libavfilter/aarch64/vf_bwdif_init_aarch64.c b/libavfilter/aarch64/vf_bwdif_init_aarch64.c
> index f52bc4b9b4..2b8d212de6 100644
> --- a/libavfilter/aarch64/vf_bwdif_init_aarch64.c
> +++ b/libavfilter/aarch64/vf_bwdif_init_aarch64.c
> @@ -21,7 +21,7 @@
>   */
>  
>  #include "libavutil/common.h"
> -#include "libavfilter/bwdif.h"
> +#include "libavfilter/bwdifdsp.h"
>  #include "libavutil/aarch64/cpu.h"
>  
>  void ff_bwdif_filter_edge_neon(void *dst1, void *prev1, void *cur1, void *next1,
> @@ -107,7 +107,7 @@ static void filter_intra_helper(void *dst1, void *cur1, int w, int prefs, int mr
>  }
>  
>  void
> -ff_bwdif_init_aarch64(BWDIFContext *s, int bit_depth)
> +ff_bwdif_init_aarch64(BWDIFDSPContext *s, int bit_depth)
>  {
>      const int cpu_flags = av_get_cpu_flags();
>  
> diff --git a/libavfilter/bwdif.h b/libavfilter/bwdifdsp.h
> similarity index 85%
> rename from libavfilter/bwdif.h
> rename to libavfilter/bwdifdsp.h
> index 496cec72ef..1ff810719f 100644
> --- a/libavfilter/bwdif.h
> +++ b/libavfilter/bwdifdsp.h
> @@ -16,16 +16,10 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>   */
>  
> -#ifndef AVFILTER_BWDIF_H
> -#define AVFILTER_BWDIF_H
> -
> -#include "libavutil/pixdesc.h"
> -#include "avfilter.h"
> -#include "yadif.h"
> -
> -typedef struct BWDIFContext {
> -    YADIFContext yadif;
> +#ifndef AVFILTER_BWDIFDSP_H
> +#define AVFILTER_BWDIFDSP_H
>  
> +typedef struct BWDIFDSPContext {
>      void (*filter_intra)(void *dst1, void *cur1, int w, int prefs, int mrefs,
>                           int prefs3, int mrefs3, int parity, int clip_max);
>      void (*filter_line)(void *dst, void *prev, void *cur, void *next,
> @@ -38,11 +32,11 @@ typedef struct BWDIFContext {
>      void (*filter_line3)(void *dst, int dstride,
>                           const void *prev, const void *cur, const void *next, int prefs,
>                           int w, int parity, int clip_max);
> -} BWDIFContext;
> +} BWDIFDSPContext;
>  
> -void ff_bwdif_init_filter_line(BWDIFContext *bwdif, int bit_depth);
> -void ff_bwdif_init_x86(BWDIFContext *bwdif, int bit_depth);
> -void ff_bwdif_init_aarch64(BWDIFContext *bwdif, int bit_depth);
> +void ff_bwdif_init_filter_line(BWDIFDSPContext *bwdif, int bit_depth);
> +void ff_bwdif_init_x86(BWDIFDSPContext *bwdif, int bit_depth);
> +void ff_bwdif_init_aarch64(BWDIFDSPContext *bwdif, int bit_depth);
>  
>  void ff_bwdif_filter_edge_c(void *dst1, void *prev1, void *cur1, void *next1,
>                              int w, int prefs, int mrefs, int prefs2, int mrefs2,
> @@ -60,4 +54,4 @@ void ff_bwdif_filter_line3_c(void * dst1, int d_stride,
>                               const void * prev1, const void * cur1, const void * next1, int s_stride,
>                               int w, int parity, int clip_max);
>  
> -#endif /* AVFILTER_BWDIF_H */
> +#endif /* AVFILTER_BWDIFDSP_H */
> diff --git a/libavfilter/vf_bwdif.c b/libavfilter/vf_bwdif.c
> index 6195e6cb64..282aef5698 100644
> --- a/libavfilter/vf_bwdif.c
> +++ b/libavfilter/vf_bwdif.c
> @@ -32,8 +32,10 @@
>  #include "libavutil/opt.h"
>  #include "libavutil/pixdesc.h"
>  #include "avfilter.h"
> +#include "bwdifdsp.h"
> +#include "ccfifo.h"
>  #include "internal.h"
> -#include "bwdif.h"
> +#include "yadif.h"
>  
>  /*
>   * Filter coefficients coef_lf and coef_hf taken from BBC PH-2071 (Weston 3 Field Deinterlacer).
> @@ -45,6 +47,11 @@ static const uint16_t coef_lf[2] = { 4309, 213 };
>  static const uint16_t coef_hf[3] = { 5570, 3801, 1016 };
>  static const uint16_t coef_sp[2] = { 5077, 981 };
>  
> +typedef struct BWDIFContext {
> +    YADIFContext yadif;
> +    BWDIFDSPContext dsp;
> +} BWDIFContext;
> +
>  typedef struct ThreadData {
>      AVFrame *frame;
>      int plane;
> @@ -261,25 +268,25 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
>              uint8_t *next = &yadif->next->data[td->plane][y * linesize];
>              uint8_t *dst  = &td->frame->data[td->plane][y * td->frame->linesize[td->plane]];
>              if (yadif->current_field == YADIF_FIELD_END) {
> -                s->filter_intra(dst, cur, td->w, (y + df) < td->h ? refs : -refs,
> +                s->dsp.filter_intra(dst, cur, td->w, (y + df) < td->h ? refs : -refs,
>                                  y > (df - 1) ? -refs : refs,
>                                  (y + 3*df) < td->h ? 3 * refs : -refs,
>                                  y > (3*df - 1) ? -3 * refs : refs,
>                                  td->parity ^ td->tff, clip_max);
>              } else if ((y < 4) || ((y + 5) > td->h)) {
> -                s->filter_edge(dst, prev, cur, next, td->w,
> +                s->dsp.filter_edge(dst, prev, cur, next, td->w,
>                                 (y + df) < td->h ? refs : -refs,
>                                 y > (df - 1) ? -refs : refs,
>                                 refs << 1, -(refs << 1),
>                                 td->parity ^ td->tff, clip_max,
>                                 (y < 2) || ((y + 3) > td->h) ? 0 : 1);
> -            } else if (s->filter_line3 && y + 2 < slice_end && y + 6 < td->h) {
> -                s->filter_line3(dst, td->frame->linesize[td->plane],
> +            } else if (s->dsp.filter_line3 && y + 2 < slice_end && y + 6 < td->h) {
> +                s->dsp.filter_line3(dst, td->frame->linesize[td->plane],
>                                  prev, cur, next, linesize, td->w,
>                                  td->parity ^ td->tff, clip_max);
>                  y += 2;
>              } else {
> -                s->filter_line(dst, prev, cur, next, td->w,
> +                s->dsp.filter_line(dst, prev, cur, next, td->w,
>                                 refs, -refs, refs << 1, -(refs << 1),
>                                 3 * refs, -3 * refs, refs << 2, -(refs << 2),
>                                 td->parity ^ td->tff, clip_max);
> @@ -382,12 +389,12 @@ static int config_props(AVFilterLink *link)
>  
>      yadif->csp = av_pix_fmt_desc_get(link->format);
>      yadif->filter = filter;
> -    ff_bwdif_init_filter_line(s, yadif->csp->comp[0].depth);
> +    ff_bwdif_init_filter_line(&s->dsp, yadif->csp->comp[0].depth);
>  
>      return 0;
>  }
>  
> -av_cold void ff_bwdif_init_filter_line(BWDIFContext *s, int bit_depth)
> +av_cold void ff_bwdif_init_filter_line(BWDIFDSPContext *s, int bit_depth)
>  {
>      s->filter_line3 = 0;
>      if (bit_depth > 8) {
> diff --git a/libavfilter/x86/vf_bwdif_init.c b/libavfilter/x86/vf_bwdif_init.c
> index 57f908a8ef..b1d1d6a91c 100644
> --- a/libavfilter/x86/vf_bwdif_init.c
> +++ b/libavfilter/x86/vf_bwdif_init.c
> @@ -22,7 +22,7 @@
>  #include "libavutil/cpu.h"
>  #include "libavutil/x86/asm.h"
>  #include "libavutil/x86/cpu.h"
> -#include "libavfilter/bwdif.h"
> +#include "libavfilter/bwdifdsp.h"
>  
>  void ff_bwdif_filter_line_sse2(void *dst, void *prev, void *cur, void *next,
>                                 int w, int prefs, int mrefs, int prefs2,
> @@ -50,7 +50,7 @@ void ff_bwdif_filter_line_12bit_avx2(void *dst, void *prev, void *cur, void *nex
>                                       int mrefs2, int prefs3, int mrefs3, int prefs4,
>                                       int mrefs4, int parity, int clip_max);
>  
> -av_cold void ff_bwdif_init_x86(BWDIFContext *bwdif, int bit_depth)
> +av_cold void ff_bwdif_init_x86(BWDIFDSPContext *bwdif, int bit_depth)
>  {
>      int cpu_flags = av_get_cpu_flags();
>  
> diff --git a/tests/checkasm/vf_bwdif.c b/tests/checkasm/vf_bwdif.c
> index 3399cacdf7..fae61b62e4 100644
> --- a/tests/checkasm/vf_bwdif.c
> +++ b/tests/checkasm/vf_bwdif.c
> @@ -18,8 +18,7 @@
>  
>  #include <string.h>
>  #include "checkasm.h"
> -#include "libavcodec/internal.h"
> -#include "libavfilter/bwdif.h"
> +#include "libavfilter/bwdifdsp.h"
>  #include "libavutil/mem_internal.h"
>  
>  #define WIDTH 256
> @@ -72,7 +71,7 @@
>  
>  void checkasm_check_vf_bwdif(void)
>  {
> -    BWDIFContext ctx_8, ctx_10;
> +    BWDIFDSPContext ctx_8, ctx_10;
>  
>      ff_bwdif_init_filter_line(&ctx_8, 8);
>      ff_bwdif_init_filter_line(&ctx_10, 10);

Will apply this patchset tomorrow unless there are objections.

- Andreas
diff mbox series

Patch

diff --git a/libavfilter/aarch64/vf_bwdif_init_aarch64.c b/libavfilter/aarch64/vf_bwdif_init_aarch64.c
index f52bc4b9b4..2b8d212de6 100644
--- a/libavfilter/aarch64/vf_bwdif_init_aarch64.c
+++ b/libavfilter/aarch64/vf_bwdif_init_aarch64.c
@@ -21,7 +21,7 @@ 
  */
 
 #include "libavutil/common.h"
-#include "libavfilter/bwdif.h"
+#include "libavfilter/bwdifdsp.h"
 #include "libavutil/aarch64/cpu.h"
 
 void ff_bwdif_filter_edge_neon(void *dst1, void *prev1, void *cur1, void *next1,
@@ -107,7 +107,7 @@  static void filter_intra_helper(void *dst1, void *cur1, int w, int prefs, int mr
 }
 
 void
-ff_bwdif_init_aarch64(BWDIFContext *s, int bit_depth)
+ff_bwdif_init_aarch64(BWDIFDSPContext *s, int bit_depth)
 {
     const int cpu_flags = av_get_cpu_flags();
 
diff --git a/libavfilter/bwdif.h b/libavfilter/bwdifdsp.h
similarity index 85%
rename from libavfilter/bwdif.h
rename to libavfilter/bwdifdsp.h
index 496cec72ef..1ff810719f 100644
--- a/libavfilter/bwdif.h
+++ b/libavfilter/bwdifdsp.h
@@ -16,16 +16,10 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVFILTER_BWDIF_H
-#define AVFILTER_BWDIF_H
-
-#include "libavutil/pixdesc.h"
-#include "avfilter.h"
-#include "yadif.h"
-
-typedef struct BWDIFContext {
-    YADIFContext yadif;
+#ifndef AVFILTER_BWDIFDSP_H
+#define AVFILTER_BWDIFDSP_H
 
+typedef struct BWDIFDSPContext {
     void (*filter_intra)(void *dst1, void *cur1, int w, int prefs, int mrefs,
                          int prefs3, int mrefs3, int parity, int clip_max);
     void (*filter_line)(void *dst, void *prev, void *cur, void *next,
@@ -38,11 +32,11 @@  typedef struct BWDIFContext {
     void (*filter_line3)(void *dst, int dstride,
                          const void *prev, const void *cur, const void *next, int prefs,
                          int w, int parity, int clip_max);
-} BWDIFContext;
+} BWDIFDSPContext;
 
-void ff_bwdif_init_filter_line(BWDIFContext *bwdif, int bit_depth);
-void ff_bwdif_init_x86(BWDIFContext *bwdif, int bit_depth);
-void ff_bwdif_init_aarch64(BWDIFContext *bwdif, int bit_depth);
+void ff_bwdif_init_filter_line(BWDIFDSPContext *bwdif, int bit_depth);
+void ff_bwdif_init_x86(BWDIFDSPContext *bwdif, int bit_depth);
+void ff_bwdif_init_aarch64(BWDIFDSPContext *bwdif, int bit_depth);
 
 void ff_bwdif_filter_edge_c(void *dst1, void *prev1, void *cur1, void *next1,
                             int w, int prefs, int mrefs, int prefs2, int mrefs2,
@@ -60,4 +54,4 @@  void ff_bwdif_filter_line3_c(void * dst1, int d_stride,
                              const void * prev1, const void * cur1, const void * next1, int s_stride,
                              int w, int parity, int clip_max);
 
-#endif /* AVFILTER_BWDIF_H */
+#endif /* AVFILTER_BWDIFDSP_H */
diff --git a/libavfilter/vf_bwdif.c b/libavfilter/vf_bwdif.c
index 6195e6cb64..282aef5698 100644
--- a/libavfilter/vf_bwdif.c
+++ b/libavfilter/vf_bwdif.c
@@ -32,8 +32,10 @@ 
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
+#include "bwdifdsp.h"
+#include "ccfifo.h"
 #include "internal.h"
-#include "bwdif.h"
+#include "yadif.h"
 
 /*
  * Filter coefficients coef_lf and coef_hf taken from BBC PH-2071 (Weston 3 Field Deinterlacer).
@@ -45,6 +47,11 @@  static const uint16_t coef_lf[2] = { 4309, 213 };
 static const uint16_t coef_hf[3] = { 5570, 3801, 1016 };
 static const uint16_t coef_sp[2] = { 5077, 981 };
 
+typedef struct BWDIFContext {
+    YADIFContext yadif;
+    BWDIFDSPContext dsp;
+} BWDIFContext;
+
 typedef struct ThreadData {
     AVFrame *frame;
     int plane;
@@ -261,25 +268,25 @@  static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
             uint8_t *next = &yadif->next->data[td->plane][y * linesize];
             uint8_t *dst  = &td->frame->data[td->plane][y * td->frame->linesize[td->plane]];
             if (yadif->current_field == YADIF_FIELD_END) {
-                s->filter_intra(dst, cur, td->w, (y + df) < td->h ? refs : -refs,
+                s->dsp.filter_intra(dst, cur, td->w, (y + df) < td->h ? refs : -refs,
                                 y > (df - 1) ? -refs : refs,
                                 (y + 3*df) < td->h ? 3 * refs : -refs,
                                 y > (3*df - 1) ? -3 * refs : refs,
                                 td->parity ^ td->tff, clip_max);
             } else if ((y < 4) || ((y + 5) > td->h)) {
-                s->filter_edge(dst, prev, cur, next, td->w,
+                s->dsp.filter_edge(dst, prev, cur, next, td->w,
                                (y + df) < td->h ? refs : -refs,
                                y > (df - 1) ? -refs : refs,
                                refs << 1, -(refs << 1),
                                td->parity ^ td->tff, clip_max,
                                (y < 2) || ((y + 3) > td->h) ? 0 : 1);
-            } else if (s->filter_line3 && y + 2 < slice_end && y + 6 < td->h) {
-                s->filter_line3(dst, td->frame->linesize[td->plane],
+            } else if (s->dsp.filter_line3 && y + 2 < slice_end && y + 6 < td->h) {
+                s->dsp.filter_line3(dst, td->frame->linesize[td->plane],
                                 prev, cur, next, linesize, td->w,
                                 td->parity ^ td->tff, clip_max);
                 y += 2;
             } else {
-                s->filter_line(dst, prev, cur, next, td->w,
+                s->dsp.filter_line(dst, prev, cur, next, td->w,
                                refs, -refs, refs << 1, -(refs << 1),
                                3 * refs, -3 * refs, refs << 2, -(refs << 2),
                                td->parity ^ td->tff, clip_max);
@@ -382,12 +389,12 @@  static int config_props(AVFilterLink *link)
 
     yadif->csp = av_pix_fmt_desc_get(link->format);
     yadif->filter = filter;
-    ff_bwdif_init_filter_line(s, yadif->csp->comp[0].depth);
+    ff_bwdif_init_filter_line(&s->dsp, yadif->csp->comp[0].depth);
 
     return 0;
 }
 
-av_cold void ff_bwdif_init_filter_line(BWDIFContext *s, int bit_depth)
+av_cold void ff_bwdif_init_filter_line(BWDIFDSPContext *s, int bit_depth)
 {
     s->filter_line3 = 0;
     if (bit_depth > 8) {
diff --git a/libavfilter/x86/vf_bwdif_init.c b/libavfilter/x86/vf_bwdif_init.c
index 57f908a8ef..b1d1d6a91c 100644
--- a/libavfilter/x86/vf_bwdif_init.c
+++ b/libavfilter/x86/vf_bwdif_init.c
@@ -22,7 +22,7 @@ 
 #include "libavutil/cpu.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
-#include "libavfilter/bwdif.h"
+#include "libavfilter/bwdifdsp.h"
 
 void ff_bwdif_filter_line_sse2(void *dst, void *prev, void *cur, void *next,
                                int w, int prefs, int mrefs, int prefs2,
@@ -50,7 +50,7 @@  void ff_bwdif_filter_line_12bit_avx2(void *dst, void *prev, void *cur, void *nex
                                      int mrefs2, int prefs3, int mrefs3, int prefs4,
                                      int mrefs4, int parity, int clip_max);
 
-av_cold void ff_bwdif_init_x86(BWDIFContext *bwdif, int bit_depth)
+av_cold void ff_bwdif_init_x86(BWDIFDSPContext *bwdif, int bit_depth)
 {
     int cpu_flags = av_get_cpu_flags();
 
diff --git a/tests/checkasm/vf_bwdif.c b/tests/checkasm/vf_bwdif.c
index 3399cacdf7..fae61b62e4 100644
--- a/tests/checkasm/vf_bwdif.c
+++ b/tests/checkasm/vf_bwdif.c
@@ -18,8 +18,7 @@ 
 
 #include <string.h>
 #include "checkasm.h"
-#include "libavcodec/internal.h"
-#include "libavfilter/bwdif.h"
+#include "libavfilter/bwdifdsp.h"
 #include "libavutil/mem_internal.h"
 
 #define WIDTH 256
@@ -72,7 +71,7 @@ 
 
 void checkasm_check_vf_bwdif(void)
 {
-    BWDIFContext ctx_8, ctx_10;
+    BWDIFDSPContext ctx_8, ctx_10;
 
     ff_bwdif_init_filter_line(&ctx_8, 8);
     ff_bwdif_init_filter_line(&ctx_10, 10);