History

avfilter/vf_chromashift: simplify handling of commands

Paul B Mahol committed 4 years ago

Commit 63d12a41 parent 7e7b3a41 file · +8 −24Browse files

Unified · Split

libavfilter/vf_chromashift.c+8−24
@@ -49,7 +49,7 @@ typedef struct ChromaShiftContext { · 48 unmodified lines
4949 AVFrame *in;
5050
5151 int is_rgbashift;
52− int (*filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
52+ int (*filter_slice[2])(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
5353 } ChromaShiftContext;
5454
5555 #define DEFINE_SMEAR(depth, type, div) \
@@ -326,7 +326,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 270 unmodified lines
326326 in->data[0], in->linesize[0],
327327 s->linesize[0], s->height[0]);
328328 }
329− ff_filter_execute(ctx, s->filter_slice, out, NULL,
329+ ff_filter_execute(ctx, s->filter_slice[s->edge], out, NULL,
330330 FFMIN3(s->height[1],
331331 s->height[2],
332332 ff_filter_get_nb_threads(ctx)));
@@ -345,15 +345,11 @@ static int config_input(AVFilterLink *inlink) · 12 unmodified lines
345345 s->depth = desc->comp[0].depth;
346346 s->nb_planes = desc->nb_components;
347347 if (s->is_rgbashift) {
348− if (s->edge)
349− s->filter_slice = s->depth > 8 ? rgbawrap_slice16 : rgbawrap_slice8;
350− else
351− s->filter_slice = s->depth > 8 ? rgbasmear_slice16 : rgbasmear_slice8;
348+ s->filter_slice[1] = s->depth > 8 ? rgbawrap_slice16 : rgbawrap_slice8;
349+ s->filter_slice[0] = s->depth > 8 ? rgbasmear_slice16 : rgbasmear_slice8;
352350 } else {
353− if (s->edge)
354− s->filter_slice = s->depth > 8 ? wrap_slice16 : wrap_slice8;
355− else
356− s->filter_slice = s->depth > 8 ? smear_slice16 : smear_slice8;
351+ s->filter_slice[1] = s->depth > 8 ? wrap_slice16 : wrap_slice8;
352+ s->filter_slice[0] = s->depth > 8 ? smear_slice16 : smear_slice8;
357353 }
358354 s->height[1] = s->height[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
359355 s->height[0] = s->height[3] = inlink->h;
@@ -363,18 +359,6 @@ static int config_input(AVFilterLink *inlink) · 3 unmodified lines
363359 return av_image_fill_linesizes(s->linesize, inlink->format, inlink->w);
364360 }
365361
366−static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
367− char *res, int res_len, int flags)
368−{
369− int ret;
370−
371− ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
372− if (ret < 0)
373− return ret;
374−
375− return config_input(ctx->inputs[0]);
376−}
377−
378362 #define OFFSET(x) offsetof(ChromaShiftContext, x)
379363 #define VFR AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
380364
@@ -431,7 +415,7 @@ const AVFilter ff_vf_chromashift = { · 50 unmodified lines
431415 FILTER_INPUTS(inputs),
432416 FILTER_PIXFMTS_ARRAY(yuv_pix_fmts),
433417 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
434− .process_command = process_command,
418+ .process_command = ff_filter_process_command,
435419 };
436420
437421 static const enum AVPixelFormat rgb_pix_fmts[] = {
@@ -468,5 +452,5 @@ const AVFilter ff_vf_rgbashift = { · 30 unmodified lines
468452 FILTER_INPUTS(inputs),
469453 FILTER_PIXFMTS_ARRAY(rgb_pix_fmts),
470454 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
471− .process_command = process_command,
455+ .process_command = ff_filter_process_command,
472456 };

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t