History

avfilter/vf_signalstats: add SignalstatsContext.maxsize variable

Limin Wang committed 6 years ago

Commit 764efda1 parent a8c762a1 file · +11 −9Browse files

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

Unified · Split

libavfilter/vf_signalstats.c+11−9
@@ -50,6 +50,7 @@ typedef struct SignalstatsContext { · 49 unmodified lines
5050 int nb_jobs;
5151 int *jobs_rets;
5252
53+ int maxsize; // history stats array size
5354 int *histy, *histu, *histv, *histsat;
5455
5556 AVFrame *frame_sat;
@@ -166,11 +167,12 @@ static int config_output(AVFilterLink *outlink) · 110 unmodified lines
166167 s->hsub = desc->log2_chroma_w;
167168 s->vsub = desc->log2_chroma_h;
168169 s->depth = desc->comp[0].depth;
170+ s->maxsize = 1 << s->depth;
169171 if (s->depth > 8) {
170− s->histy = av_malloc_array(1 << s->depth, sizeof(*s->histy));
171− s->histu = av_malloc_array(1 << s->depth, sizeof(*s->histu));
172− s->histv = av_malloc_array(1 << s->depth, sizeof(*s->histv));
173− s->histsat = av_malloc_array(1 << s->depth, sizeof(*s->histsat));
172+ s->histy = av_malloc_array(s->maxsize, sizeof(*s->histy));
173+ s->histu = av_malloc_array(s->maxsize, sizeof(*s->histu));
174+ s->histv = av_malloc_array(s->maxsize, sizeof(*s->histv));
175+ s->histsat = av_malloc_array(s->maxsize, sizeof(*s->histsat));
174176
175177 if (!s->histy || !s->histu || !s->histv || !s->histsat)
176178 return AVERROR(ENOMEM);
@@ -823,7 +825,7 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in) · 646 unmodified lines
823825 NULL, FFMIN(s->chromah, ff_filter_get_nb_threads(ctx)));
824826
825827 // Calculate luma histogram and difference with previous frame or field.
826− memset(s->histy, 0, (1 << s->depth) * sizeof(*s->histy));
828+ memset(s->histy, 0, s->maxsize * sizeof(*s->histy));
827829 for (j = 0; j < link->h; j++) {
828830 for (i = 0; i < link->w; i++) {
829831 const int yuv = AV_RN16(in->data[0] + w + i * 2);
@@ -837,9 +839,9 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in) · 7 unmodified lines
837839 }
838840
839841 // Calculate chroma histogram and difference with previous frame or field.
840− memset(s->histu, 0, (1 << s->depth) * sizeof(*s->histu));
841− memset(s->histv, 0, (1 << s->depth) * sizeof(*s->histv));
842− memset(s->histsat, 0, (1 << s->depth) * sizeof(*s->histsat));
842+ memset(s->histu, 0, s->maxsize * sizeof(*s->histu));
843+ memset(s->histv, 0, s->maxsize * sizeof(*s->histv));
844+ memset(s->histsat, 0, s->maxsize * sizeof(*s->histsat));
843845 for (j = 0; j < s->chromah; j++) {
844846 for (i = 0; i < s->chromaw; i++) {
845847 const int yuvu = AV_RN16(in->data[1] + cw + i * 2);
@@ -884,7 +886,7 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in) · 38 unmodified lines
884886 chighp = lrint(s->cfs * 90 / 100.);
885887
886888 accy = accu = accv = accsat = 0;
887− for (fil = 0; fil < 1 << s->depth; fil++) {
889+ for (fil = 0; fil < s->maxsize; fil++) {
888890 if (miny < 0 && histy[fil]) miny = fil;
889891 if (minu < 0 && histu[fil]) minu = fil;
890892 if (minv < 0 && histv[fil]) minv = fil;

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