History

avfilter/vf_colorcorrect: calculate imax/max once at config stage

Paul B Mahol committed 5 years ago

Commit e0de0aa1 parent d42b49f1 file · +9 −11Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_colorcorrect.c+9−11
@@ -42,6 +42,7 @@ typedef struct ColorCorrectContext { · 41 unmodified lines
4242 int analyze;
4343
4444 int depth;
45+ float max, imax;
4546
4647 int chroma_w, chroma_h;
4748 int planeheight[4];
@@ -59,9 +60,7 @@ static int average_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_job · 11 unmodified lines
5960 {
6061 ColorCorrectContext *s = ctx->priv;
6162 AVFrame *frame = arg;
62− const int depth = s->depth;
63− const float max = (1 << depth) - 1;
64− const float imax = 1.f / max;
63+ const float imax = s->imax;
6564 const int width = s->planewidth[1];
6665 const int height = s->planeheight[1];
6766 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 · 24 unmodified lines
9291 {
9392 ColorCorrectContext *s = ctx->priv;
9493 AVFrame *frame = arg;
95− const int depth = s->depth;
96− const float max = (1 << depth) - 1;
97− const float imax = 1.f / max;
94+ const float imax = s->imax;
9895 const int width = s->planewidth[1];
9996 const int height = s->planeheight[1];
10097 const int slice_start = (height * jobnr) / nb_jobs;
@@ -134,9 +131,8 @@ static int colorcorrect_slice8(AVFilterContext *ctx, void *arg, int jobnr, int n · 33 unmodified lines
134131 {
135132 ColorCorrectContext *s = ctx->priv;
136133 AVFrame *frame = arg;
137− const int depth = s->depth;
138− const float max = (1 << depth) - 1;
139− const float imax = 1.f / max;
134+ const float max = s->max;
135+ const float imax = s->imax;
140136 const int chroma_w = s->chroma_w;
141137 const int chroma_h = s->chroma_h;
142138 const int width = s->planewidth[1];
@@ -176,8 +172,8 @@ static int colorcorrect_slice16(AVFilterContext *ctx, void *arg, int jobnr, int · 33 unmodified lines
176172 ColorCorrectContext *s = ctx->priv;
177173 AVFrame *frame = arg;
178174 const int depth = s->depth;
179− const float max = (1 << depth) - 1;
180− const float imax = 1.f / max;
175+ const float max = s->max;
176+ const float imax = s->imax;
181177 const int chroma_w = s->chroma_w;
182178 const int chroma_h = s->chroma_h;
183179 const int width = s->planewidth[1];
@@ -268,6 +264,8 @@ static av_cold int config_input(AVFilterLink *inlink) · 84 unmodified lines
268264 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
269265
270266 s->depth = desc->comp[0].depth;
267+ s->max = (1 << s->depth) - 1;
268+ s->imax = 1.f / s->max;
271269 s->do_slice = s->depth <= 8 ? colorcorrect_slice8 : colorcorrect_slice16;
272270
273271 s->analyzeret = av_calloc(inlink->h, sizeof(*s->analyzeret));

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