]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_signalstats.c
avfilter/vf_uspp: fix used pix_fmt
[ffmpeg] / libavfilter / vf_signalstats.c
index 014b87d96f3227a8ff0d7a28f2339d7391c053ad..8632761cc3003e433e150409d8aa9cf8bad09145 100644 (file)
@@ -132,8 +132,10 @@ static AVFrame *alloc_frame(enum AVPixelFormat pixfmt, int w, int h)
     frame->width  = w;
     frame->height = h;
 
-    if (av_frame_get_buffer(frame, 32) < 0)
+    if (av_frame_get_buffer(frame, 32) < 0) {
+        av_frame_free(&frame);
         return NULL;
+    }
 
     return frame;
 }
@@ -360,7 +362,6 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
     int i, j;
     int  w = 0,  cw = 0, // in
         pw = 0, cpw = 0; // prev
-    int yuv, yuvu, yuvv;
     int fil;
     char metabuf[128];
     unsigned int histy[DEPTH] = {0},
@@ -412,9 +413,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
     // Calculate luma histogram and difference with previous frame or field.
     for (j = 0; j < link->h; j++) {
         for (i = 0; i < link->w; i++) {
-            yuv = in->data[0][w + i];
+            const int yuv = in->data[0][w + i];
             histy[yuv]++;
-            dify += abs(in->data[0][w + i] - prev->data[0][pw + i]);
+            dify += abs(yuv - prev->data[0][pw + i]);
         }
         w  += in->linesize[0];
         pw += prev->linesize[0];
@@ -423,12 +424,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
     // Calculate chroma histogram and difference with previous frame or field.
     for (j = 0; j < s->chromah; j++) {
         for (i = 0; i < s->chromaw; i++) {
-            yuvu = in->data[1][cw+i];
-            yuvv = in->data[2][cw+i];
+            const int yuvu = in->data[1][cw+i];
+            const int yuvv = in->data[2][cw+i];
             histu[yuvu]++;
-            difu += abs(in->data[1][cw+i] - prev->data[1][cpw+i]);
+            difu += abs(yuvu - prev->data[1][cpw+i]);
             histv[yuvv]++;
-            difv += abs(in->data[2][cw+i] - prev->data[2][cpw+i]);
+            difv += abs(yuvv - prev->data[2][cpw+i]);
 
             histsat[p_sat[i]]++;
             histhue[((int16_t*)p_hue)[i]]++;