Skip to content
Snippets Groups Projects
Commit be96201e authored by Clément Bœsch's avatar Clément Bœsch
Browse files

avfilter/xbr: use function pointers for xbr[234]x

parent c4fb79a3
No related branches found
No related tags found
No related merge requests found
...@@ -40,9 +40,12 @@ ...@@ -40,9 +40,12 @@
#define RED_BLUE_MASK 0x00FF00FF #define RED_BLUE_MASK 0x00FF00FF
#define GREEN_MASK 0x0000FF00 #define GREEN_MASK 0x0000FF00
typedef void (*xbrfunc_t)(AVFrame *input, AVFrame *output, const uint32_t *r2y);
typedef struct { typedef struct {
const AVClass *class; const AVClass *class;
int n; int n;
xbrfunc_t func;
uint32_t rgbtoyuv[1<<24]; uint32_t rgbtoyuv[1<<24];
} XBRContext; } XBRContext;
...@@ -392,12 +395,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) ...@@ -392,12 +395,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
} }
av_frame_copy_props(out, in); av_frame_copy_props(out, in);
if (xbr->n == 4) xbr->func(in, out, r2y);
xbr4x(in, out, r2y);
else if (xbr->n == 3)
xbr3x(in, out, r2y);
else
xbr2x(in, out, r2y);
out->width = outlink->w; out->width = outlink->w;
out->height = outlink->h; out->height = outlink->h;
...@@ -409,6 +407,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) ...@@ -409,6 +407,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int init(AVFilterContext *ctx) static int init(AVFilterContext *ctx)
{ {
XBRContext *xbr = ctx->priv; XBRContext *xbr = ctx->priv;
static const xbrfunc_t xbrfuncs[] = {xbr2x, xbr3x, xbr4x};
uint32_t c; uint32_t c;
int bg, rg, g; int bg, rg, g;
...@@ -427,6 +427,7 @@ static int init(AVFilterContext *ctx) ...@@ -427,6 +427,7 @@ static int init(AVFilterContext *ctx)
} }
} }
xbr->func = xbrfuncs[xbr->n - 2];
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment