diff options
author | Paul B Mahol <onemda@gmail.com> | 2021-08-15 23:58:05 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2021-08-16 01:19:19 +0200 |
commit | e0de0aa5856c337e79eccab600cfa46ef522f6a9 (patch) | |
tree | ec2762d8d7586714fb5016f04c3b0acc6f058cfb /libavfilter | |
parent | d42b49fc87e97bf0d95232868b69295333bd818f (diff) | |
download | ffmpeg-e0de0aa5856c337e79eccab600cfa46ef522f6a9.tar.gz |
avfilter/vf_colorcorrect: calculate imax/max once at config stage
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/vf_colorcorrect.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/libavfilter/vf_colorcorrect.c b/libavfilter/vf_colorcorrect.c index 1019d431ce..3fb2798256 100644 --- a/libavfilter/vf_colorcorrect.c +++ b/libavfilter/vf_colorcorrect.c @@ -42,6 +42,7 @@ typedef struct ColorCorrectContext { int analyze; int depth; + float max, imax; int chroma_w, chroma_h; int planeheight[4]; @@ -59,9 +60,7 @@ static int average_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_job { ColorCorrectContext *s = ctx->priv; AVFrame *frame = arg; - const int depth = s->depth; - const float max = (1 << depth) - 1; - const float imax = 1.f / max; + const float imax = s->imax; const int width = s->planewidth[1]; const int height = s->planeheight[1]; const int slice_start = (height * jobnr) / nb_jobs; @@ -92,9 +91,7 @@ static int average_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo { ColorCorrectContext *s = ctx->priv; AVFrame *frame = arg; - const int depth = s->depth; - const float max = (1 << depth) - 1; - const float imax = 1.f / max; + const float imax = s->imax; const int width = s->planewidth[1]; const int height = s->planeheight[1]; const int slice_start = (height * jobnr) / nb_jobs; @@ -134,9 +131,8 @@ static int colorcorrect_slice8(AVFilterContext *ctx, void *arg, int jobnr, int n { ColorCorrectContext *s = ctx->priv; AVFrame *frame = arg; - const int depth = s->depth; - const float max = (1 << depth) - 1; - const float imax = 1.f / max; + const float max = s->max; + const float imax = s->imax; const int chroma_w = s->chroma_w; const int chroma_h = s->chroma_h; const int width = s->planewidth[1]; @@ -176,8 +172,8 @@ static int colorcorrect_slice16(AVFilterContext *ctx, void *arg, int jobnr, int ColorCorrectContext *s = ctx->priv; AVFrame *frame = arg; const int depth = s->depth; - const float max = (1 << depth) - 1; - const float imax = 1.f / max; + const float max = s->max; + const float imax = s->imax; const int chroma_w = s->chroma_w; const int chroma_h = s->chroma_h; const int width = s->planewidth[1]; @@ -268,6 +264,8 @@ static av_cold int config_input(AVFilterLink *inlink) const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); s->depth = desc->comp[0].depth; + s->max = (1 << s->depth) - 1; + s->imax = 1.f / s->max; s->do_slice = s->depth <= 8 ? colorcorrect_slice8 : colorcorrect_slice16; s->analyzeret = av_calloc(inlink->h, sizeof(*s->analyzeret)); |