]> git.sesse.net Git - nageru/commitdiff
Fix a leak in the H.264 encoder.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 14 Nov 2015 17:10:42 +0000 (18:10 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 14 Nov 2015 17:21:53 +0000 (18:21 +0100)
h264encode.cpp

index 44867cc6d1eda148f80fb09ece9911bc842b830a..a16a5ea0b376dc4ed5678a48b7c4417ef433533e 100644 (file)
@@ -1469,6 +1469,12 @@ static int render_picture(void)
     va_status = vaRenderPicture(va_dpy, context_id, &pic_param_buf, 1);
     CHECK_VASTATUS(va_status, "vaRenderPicture");
 
+    // Supposedly vaRenderPicture() is supposed to destroy the buffer implicitly,
+    // but if we don't delete it here, we get leaks. The GStreamer implementation
+    // does the same.
+    va_status = vaDestroyBuffer(va_dpy, pic_param_buf);
+    CHECK_VASTATUS(va_status, "vaDestroyBuffer");
+
     return 0;
 }
 
@@ -1635,11 +1641,17 @@ static int render_slice(void)
 
     va_status = vaCreateBuffer(va_dpy, context_id, VAEncSliceParameterBufferType,
                                sizeof(slice_param), 1, &slice_param, &slice_param_buf);
-    CHECK_VASTATUS(va_status, "vaCreateBuffer");;
+    CHECK_VASTATUS(va_status, "vaCreateBuffer");
 
     va_status = vaRenderPicture(va_dpy, context_id, &slice_param_buf, 1);
     CHECK_VASTATUS(va_status, "vaRenderPicture");
-    
+
+    // Supposedly vaRenderPicture() is supposed to destroy the buffer implicitly,
+    // but if we don't delete it here, we get leaks. The GStreamer implementation
+    // does the same.
+    va_status = vaDestroyBuffer(va_dpy, slice_param_buf);
+    CHECK_VASTATUS(va_status, "vaDestroyBuffer");
+
     return 0;
 }