diff options
author | Limin Wang <lance.lmwang@gmail.com> | 2020-08-12 00:21:54 +0800 |
---|---|---|
committer | Limin Wang <lance.lmwang@gmail.com> | 2020-08-26 14:21:11 +0800 |
commit | 2a9b934675b9e2d3850b46f8a618c19b03f02551 (patch) | |
tree | d47efa1d64f2308ad067f6627631917692432078 /libavfilter/vf_yadif.c | |
parent | 9bb4707b1faea6b6efe64b546c2be4a608ca64c1 (diff) |
avfilter/yadif: simplify the code for better readability
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Diffstat (limited to 'libavfilter/vf_yadif.c')
-rw-r--r-- | libavfilter/vf_yadif.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 43dea67add..acc55a481f 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -192,7 +192,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) YADIFContext *s = ctx->priv; ThreadData *td = arg; int refs = s->cur->linesize[td->plane]; - int df = (s->csp->comp[td->plane].depth + 7) / 8; + int df = (s->depth + 7) / 8; int pix_3 = 3 * df; int slice_start = (td->h * jobnr ) / nb_jobs; int slice_end = (td->h * (jobnr+1)) / nb_jobs; @@ -233,13 +233,13 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic, ThreadData td = { .frame = dstpic, .parity = parity, .tff = tff }; int i; - for (i = 0; i < yadif->csp->nb_components; i++) { + for (i = 0; i < yadif->nb_components; i++) { int w = dstpic->width; int h = dstpic->height; if (i == 1 || i == 2) { - w = AV_CEIL_RSHIFT(w, yadif->csp->log2_chroma_w); - h = AV_CEIL_RSHIFT(h, yadif->csp->log2_chroma_h); + w = AV_CEIL_RSHIFT(w, yadif->hsub); + h = AV_CEIL_RSHIFT(h, yadif->vsub); } @@ -292,6 +292,7 @@ static int config_output(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; YADIFContext *s = ctx->priv; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format); outlink->time_base.num = ctx->inputs[0]->time_base.num; outlink->time_base.den = ctx->inputs[0]->time_base.den * 2; @@ -307,9 +308,12 @@ static int config_output(AVFilterLink *outlink) return AVERROR(EINVAL); } - s->csp = av_pix_fmt_desc_get(outlink->format); s->filter = filter; - if (s->csp->comp[0].depth > 8) { + s->depth = desc->comp[0].depth; + s->nb_components = desc->nb_components; + s->hsub = desc->log2_chroma_w; + s->vsub = desc->log2_chroma_h; + if (s->depth > 8) { s->filter_line = filter_line_c_16bit; s->filter_edges = filter_edges_16bit; } else { |