]> granicus.if.org Git - libvpx/commitdiff
Report failure of vp9_alloc_motion_field_info
authorAngie Chiang <angiebird@google.com>
Fri, 30 Aug 2019 23:20:36 +0000 (16:20 -0700)
committerAngie Chiang <angiebird@google.com>
Fri, 30 Aug 2019 23:20:36 +0000 (16:20 -0700)
Change-Id: I87f2a8dbf4e89b1cc8526307e82812aea6ac137e

vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_non_greedy_mv.c

index 1357573d2f47ca0979f4cdeea4c0484338219ce5..25464b3b8d89aff0886e2a3f523bb4607a4bb56b 100644 (file)
@@ -7140,8 +7140,13 @@ static void init_tpl_buffer(VP9_COMP *cpi) {
 
   // 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.
index d21f4def27a2d72ae23fe611b11b857f57bc15be..4679d6c49c4b93aca9915f28986a30c7bbeec4df 100644 (file)
@@ -193,7 +193,6 @@ Status vp9_alloc_motion_field_info(MotionFieldInfo *motion_field_info,
         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 @@ Status vp9_alloc_motion_field(MotionField *motion_field, BLOCK_SIZE bsize,
   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;