diff mbox series

[FFmpeg-devel,1/4] avfilter/vf_normalize: move luts into private context

Message ID 20200112194847.15750-1-onemda@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/4] avfilter/vf_normalize: move luts into private context | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Paul B Mahol Jan. 12, 2020, 7:48 p.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/vf_normalize.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

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]];