[FFmpeg-cvslog] avfilter/vf_normalize: move luts into private context

Paul B Mahol git at videolan.org
Sat Jan 18 18:29:19 EET 2020


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Jan 12 19:31:24 2020 +0100| [1908818e7bda615485272cf40380221478f9d957] | committer: Paul B Mahol

avfilter/vf_normalize: move luts into private context

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1908818e7bda615485272cf40380221478f9d957
---

 libavfilter/vf_normalize.c | 8 ++++----
 1 file 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]];



More information about the ffmpeg-cvslog mailing list