summaryrefslogtreecommitdiff
path: root/libavfilter/vf_normalize.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2020-01-12 19:31:24 +0100
committerPaul B Mahol <onemda@gmail.com>2020-01-18 17:28:23 +0100
commit1908818e7bda615485272cf40380221478f9d957 (patch)
treec6363855be7feaabe69522b88bf0c6dea1840c43 /libavfilter/vf_normalize.c
parent273886fa60c347e07c57ec2b927f70ad94fc84bb (diff)
avfilter/vf_normalize: move luts into private context
Diffstat (limited to 'libavfilter/vf_normalize.c')
-rw-r--r--libavfilter/vf_normalize.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavfilter/vf_normalize.c b/libavfilter/vf_normalize.c
index 2e1b274f8c..ef97aecc0e 100644
--- a/libavfilter/vf_normalize.c
+++ b/libavfilter/vf_normalize.c
@@ -112,6 +112,7 @@ typedef struct NormalizeContext {
NormalizeHistory min[3], max[3]; // Min and max for each channel in {R,G,B}.
uint8_t *history_mem; // Single allocation for above history entries
+ uint8_t lut[3][256]; // Lookup table
} NormalizeContext;
#define OFFSET(x) offsetof(NormalizeContext, x)
@@ -139,7 +140,6 @@ static void normalize(NormalizeContext *s, AVFrame *in, AVFrame *out)
float rgb_min_smoothed; // Min input range for linked normalization
float rgb_max_smoothed; // Max input range for linked normalization
- uint8_t lut[3][256]; // Lookup table
int x, y, c;
// First, scan the input frame to find, for each channel, the minimum
@@ -216,7 +216,7 @@ static void normalize(NormalizeContext *s, AVFrame *in, AVFrame *out)
if (min[c].smoothed == max[c].smoothed) {
// There is no dynamic range to expand. No mapping for this channel.
for (in_val = min[c].in; in_val <= max[c].in; in_val++)
- lut[c][in_val] = min[c].out;
+ s->lut[c][in_val] = min[c].out;
} else {
// We must set lookup values for all values in the original input
// range [min.in,max.in]. Since the original input range may be
@@ -227,7 +227,7 @@ static void normalize(NormalizeContext *s, AVFrame *in, AVFrame *out)
int out_val = (in_val - min[c].smoothed) * scale + min[c].out + 0.5f;
out_val = FFMAX(out_val, 0);
out_val = FFMIN(out_val, 255);
- lut[c][in_val] = out_val;
+ s->lut[c][in_val] = out_val;
}
}
}
@@ -238,7 +238,7 @@ static void normalize(NormalizeContext *s, AVFrame *in, AVFrame *out)
uint8_t *outp = out->data[0] + y * out->linesize[0];
for (x = 0; x < in->width; x++) {
for (c = 0; c < 3; c++)
- outp[s->co[c]] = lut[c][inp[s->co[c]]];
+ outp[s->co[c]] = s->lut[c][inp[s->co[c]]];
if (s->num_components == 4)
// Copy alpha as-is.
outp[s->co[3]] = inp[s->co[3]];