shithub: libvpx

Download patch

ref: 576e0801f9281fd54e2c69ad5be5fef7af656011
parent: 3a38edea2cd114d53914cab017cab2e43a600031
author: Hui Su <[email protected]>
date: Wed Jan 13 05:51:39 EST 2021

vpxenc: initalize the image object

Otherwise it would cause problem when calling vpx_img_free() at the end
if no frame is read.

Change-Id: Ide0ed28eeb142d65d04703442cc4f098ac8edb34

--- a/vpxenc.c
+++ b/vpxenc.c
@@ -1636,6 +1636,7 @@
   int res = 0;
 
   memset(&input, 0, sizeof(input));
+  memset(&raw, 0, sizeof(raw));
   exec_name = argv_[0];
 
   /* Setup default input stream settings */
@@ -1781,14 +1782,10 @@
       FOREACH_STREAM(show_stream_config(stream, &global, &input));
 
     if (pass == (global.pass ? global.pass - 1 : 0)) {
-      if (input.file_type == FILE_TYPE_Y4M)
-        /*The Y4M reader does its own allocation.
-          Just initialize this here to avoid problems if we never read any
-           frames.*/
-        memset(&raw, 0, sizeof(raw));
-      else
+      // The Y4M reader does its own allocation.
+      if (input.file_type != FILE_TYPE_Y4M) {
         vpx_img_alloc(&raw, input.fmt, input.width, input.height, 32);
-
+      }
       FOREACH_STREAM(stream->rate_hist = init_rate_histogram(
                          &stream->config.cfg, &global.framerate));
     }