Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -50,6 +50,7 @@ typedef struct SignalstatsContext { · 49 unmodified lines | |||
| 50 | int nb_jobs; | 50 | int nb_jobs; |
| 51 | int *jobs_rets; | 51 | int *jobs_rets; |
| 52 | 52 | ||
| 53 | int maxsize; // history stats array size | ||
| 53 | int *histy, *histu, *histv, *histsat; | 54 | int *histy, *histu, *histv, *histsat; |
| 54 | 55 | ||
| 55 | AVFrame *frame_sat; | 56 | AVFrame *frame_sat; |
| @@ -166,11 +167,12 @@ static int config_output(AVFilterLink *outlink) · 110 unmodified lines | |||
| 166 | s->hsub = desc->log2_chroma_w; | 167 | s->hsub = desc->log2_chroma_w; |
| 167 | s->vsub = desc->log2_chroma_h; | 168 | s->vsub = desc->log2_chroma_h; |
| 168 | s->depth = desc->comp[0].depth; | 169 | s->depth = desc->comp[0].depth; |
| 170 | s->maxsize = 1 << s->depth; | ||
| 169 | if (s->depth > 8) { | 171 | if (s->depth > 8) { |
| 170 | s->histy = av_malloc_array(1 << s->depth, sizeof(*s->histy)); | 172 | s->histy = av_malloc_array(s->maxsize, sizeof(*s->histy)); |
| 171 | s->histu = av_malloc_array(1 << s->depth, sizeof(*s->histu)); | 173 | s->histu = av_malloc_array(s->maxsize, sizeof(*s->histu)); |
| 172 | s->histv = av_malloc_array(1 << s->depth, sizeof(*s->histv)); | 174 | s->histv = av_malloc_array(s->maxsize, sizeof(*s->histv)); |
| 173 | s->histsat = av_malloc_array(1 << s->depth, sizeof(*s->histsat)); | 175 | s->histsat = av_malloc_array(s->maxsize, sizeof(*s->histsat)); |
| 174 | 176 | ||
| 175 | if (!s->histy || !s->histu || !s->histv || !s->histsat) | 177 | if (!s->histy || !s->histu || !s->histv || !s->histsat) |
| 176 | return AVERROR(ENOMEM); | 178 | return AVERROR(ENOMEM); |
| @@ -823,7 +825,7 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in) · 646 unmodified lines | |||
| 823 | NULL, FFMIN(s->chromah, ff_filter_get_nb_threads(ctx))); | 825 | NULL, FFMIN(s->chromah, ff_filter_get_nb_threads(ctx))); |
| 824 | 826 | ||
| 825 | // Calculate luma histogram and difference with previous frame or field. | 827 | // 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)); |
| 827 | for (j = 0; j < link->h; j++) { | 829 | for (j = 0; j < link->h; j++) { |
| 828 | for (i = 0; i < link->w; i++) { | 830 | for (i = 0; i < link->w; i++) { |
| 829 | const int yuv = AV_RN16(in->data[0] + w + i * 2); | 831 | 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 | |||
| 837 | } | 839 | } |
| 838 | 840 | ||
| 839 | // Calculate chroma histogram and difference with previous frame or field. | 841 | // Calculate chroma histogram and difference with previous frame or field. |
| 840 | memset(s->histu, 0, (1 << s->depth) * sizeof(*s->histu)); | 842 | memset(s->histu, 0, s->maxsize * sizeof(*s->histu)); |
| 841 | memset(s->histv, 0, (1 << s->depth) * sizeof(*s->histv)); | 843 | memset(s->histv, 0, s->maxsize * sizeof(*s->histv)); |
| 842 | memset(s->histsat, 0, (1 << s->depth) * sizeof(*s->histsat)); | 844 | memset(s->histsat, 0, s->maxsize * sizeof(*s->histsat)); |
| 843 | for (j = 0; j < s->chromah; j++) { | 845 | for (j = 0; j < s->chromah; j++) { |
| 844 | for (i = 0; i < s->chromaw; i++) { | 846 | for (i = 0; i < s->chromaw; i++) { |
| 845 | const int yuvu = AV_RN16(in->data[1] + cw + i * 2); | 847 | 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 | |||
| 884 | chighp = lrint(s->cfs * 90 / 100.); | 886 | chighp = lrint(s->cfs * 90 / 100.); |
| 885 | 887 | ||
| 886 | accy = accu = accv = accsat = 0; | 888 | accy = accu = accv = accsat = 0; |
| 887 | for (fil = 0; fil < 1 << s->depth; fil++) { | 889 | for (fil = 0; fil < s->maxsize; fil++) { |
| 888 | if (miny < 0 && histy[fil]) miny = fil; | 890 | if (miny < 0 && histy[fil]) miny = fil; |
| 889 | if (minu < 0 && histu[fil]) minu = fil; | 891 | if (minu < 0 && histu[fil]) minu = fil; |
| 890 | if (minv < 0 && histv[fil]) minv = fil; | 892 | if (minv < 0 && histv[fil]) minv = fil; |