1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avfilter/bwdif: Add proper BWDIFDSPContext

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>
This commit is contained in:
Andreas Rheinhardt 2023-09-25 16:32:21 +02:00
parent 7f685d0f49
commit 80afcc8539
5 changed files with 29 additions and 29 deletions

View File

@ -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();

View File

@ -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 */

View File

@ -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) {

View File

@ -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();

View File

@ -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);