shithub: libvpx

Download patch

ref: 101f370a426884e9a1fe2b327b437218a1d1de33
parent: dbe5a1a11117ba8f355b05615e6a1cabcbbeb602
author: Angie Chiang <angiebird@google.com>
date: Fri Aug 30 12:20:36 EDT 2019

Report failure of vp9_alloc_motion_field_info

Change-Id: I87f2a8dbf4e89b1cc8526307e82812aea6ac137e

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -7140,8 +7140,13 @@
 
   // TODO(angiebird): This probably needs further modifications to support
   // frame scaling later on.
-  vp9_alloc_motion_field_info(&cpi->motion_field_info, MAX_ARF_GOP_SIZE,
-                              mi_rows, mi_cols);
+  Status status = vp9_alloc_motion_field_info(
+      &cpi->motion_field_info, MAX_ARF_GOP_SIZE, mi_rows, mi_cols);
+  if (status == STATUS_FAILED) {
+    vpx_internal_error(&(cm)->error, VPX_CODEC_MEM_ERROR,
+                       "vp9_alloc_motion_field_info failed");
+  }
+
   if (cpi->feature_score_loc_alloc == 0) {
     // The smallest block size of motion field is 4x4, but the mi_unit is 8x8,
     // therefore the number of units is "mi_rows * mi_cols * 4" here.
--- a/vp9/encoder/vp9_non_greedy_mv.c
+++ b/vp9/encoder/vp9_non_greedy_mv.c
@@ -193,7 +193,6 @@
         Status status =
             vp9_alloc_motion_field(motion_field, bsize, block_rows, block_cols);
         if (status == STATUS_FAILED) {
-          assert(0);
           return STATUS_FAILED;
         }
       }
@@ -214,19 +213,22 @@
   motion_field->mf =
       vpx_calloc(motion_field->block_num, sizeof(*motion_field->mf));
   if (motion_field->mf == NULL) {
-    assert(0);
     status = STATUS_FAILED;
   }
   motion_field->set_mv =
       vpx_calloc(motion_field->block_num, sizeof(*motion_field->set_mv));
   if (motion_field->set_mv == NULL) {
-    assert(0);
+    vpx_free(motion_field->mf);
+    motion_field->mf = NULL;
     status = STATUS_FAILED;
   }
   motion_field->local_structure = vpx_calloc(
       motion_field->block_num, sizeof(*motion_field->local_structure));
   if (motion_field->local_structure == NULL) {
-    assert(0);
+    vpx_free(motion_field->mf);
+    motion_field->mf = NULL;
+    vpx_free(motion_field->set_mv);
+    motion_field->set_mv = NULL;
     status = STATUS_FAILED;
   }
   return status;