shithub: libvpx

Download patch

ref: f57fa3f1df45ea80049ff831a054ac66a12aebdc
parent: 3aecf4a0ba219d0b92f765c59a89df55ce628da7
author: Angie Chiang <angiebird@google.com>
date: Tue Jan 19 13:45:38 EST 2021

Handle vp9_extrc functions' return status properly

Bug: webm:1716
Change-Id: I204cd3ab35b493759808500b799da3b9e55686d4

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -2464,7 +2464,12 @@
 
   cpi->allow_encode_breakout = ENCODE_BREAKOUT_ENABLED;
 
-  vp9_extrc_init(&cpi->ext_ratectrl);
+  {
+    vpx_codec_err_t codec_status = vp9_extrc_init(&cpi->ext_ratectrl);
+    if (codec_status != VPX_CODEC_OK) {
+      vpx_internal_error(&cm->error, codec_status, "vp9_extrc_init() failed");
+    }
+  }
 
 #if !CONFIG_REALTIME_ONLY
   if (oxcf->pass == 1) {
@@ -4503,6 +4508,7 @@
     }
 #endif
     if (cpi->ext_ratectrl.ready) {
+      vpx_codec_err_t codec_status;
       const GF_GROUP *gf_group = &cpi->twopass.gf_group;
       vpx_rc_encodeframe_decision_t encode_frame_decision;
       FRAME_UPDATE_TYPE update_type = gf_group->update_type[gf_group->index];
@@ -4511,10 +4517,14 @@
       const RefCntBuffer *curr_frame_buf =
           get_ref_cnt_buffer(cm, cm->new_fb_idx);
       get_ref_frame_bufs(cpi, ref_frame_bufs);
-      vp9_extrc_get_encodeframe_decision(
+      codec_status = vp9_extrc_get_encodeframe_decision(
           &cpi->ext_ratectrl, curr_frame_buf->frame_index,
           cm->current_frame_coding_index, gf_group->index, update_type,
           ref_frame_bufs, ref_frame_flags, &encode_frame_decision);
+      if (codec_status != VPX_CODEC_OK) {
+        vpx_internal_error(&cm->error, codec_status,
+                           "vp9_extrc_get_encodeframe_decision() failed");
+      }
       q = encode_frame_decision.q_index;
     }
 
@@ -5489,9 +5499,13 @@
   {
     const RefCntBuffer *coded_frame_buf =
         get_ref_cnt_buffer(cm, cm->new_fb_idx);
-    vp9_extrc_update_encodeframe_result(
+    vpx_codec_err_t codec_status = vp9_extrc_update_encodeframe_result(
         &cpi->ext_ratectrl, (*size) << 3, cpi->Source, &coded_frame_buf->buf,
         cm->bit_depth, cpi->oxcf.input_bit_depth);
+    if (codec_status != VPX_CODEC_OK) {
+      vpx_internal_error(&cm->error, codec_status,
+                         "vp9_extrc_update_encodeframe_result() failed");
+    }
   }
 #if CONFIG_REALTIME_ONLY
   (void)encode_frame_result;
@@ -5682,8 +5696,13 @@
   cpi->allow_encode_breakout = ENCODE_BREAKOUT_ENABLED;
 
   if (cpi->common.current_frame_coding_index == 0) {
-    vp9_extrc_send_firstpass_stats(&cpi->ext_ratectrl,
-                                   &cpi->twopass.first_pass_info);
+    VP9_COMMON *cm = &cpi->common;
+    const vpx_codec_err_t codec_status = vp9_extrc_send_firstpass_stats(
+        &cpi->ext_ratectrl, &cpi->twopass.first_pass_info);
+    if (codec_status != VPX_CODEC_OK) {
+      vpx_internal_error(&cm->error, codec_status,
+                         "vp9_extrc_send_firstpass_stats() failed");
+    }
   }
 #if CONFIG_MISMATCH_DEBUG
   mismatch_move_frame_idx_w();
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -1744,6 +1744,7 @@
   if (oxcf->pass == 2) {
     const FRAME_INFO *frame_info = &cpi->frame_info;
     vpx_rc_config_t ratectrl_config;
+    vpx_codec_err_t codec_status;
 
     ratectrl_config.frame_width = frame_info->frame_width;
     ratectrl_config.frame_height = frame_info->frame_height;
@@ -1755,7 +1756,10 @@
     ratectrl_config.frame_rate_num = oxcf->g_timebase.den;
     ratectrl_config.frame_rate_den = oxcf->g_timebase.num;
 
-    vp9_extrc_create(funcs, ratectrl_config, ext_ratectrl);
+    codec_status = vp9_extrc_create(funcs, ratectrl_config, ext_ratectrl);
+    if (codec_status != VPX_CODEC_OK) {
+      return codec_status;
+    }
   }
   return VPX_CODEC_OK;
 }