shithub: libvpx

Download patch

ref: d49700e25b280eba27ab3804cc769aed68ffb3e5
parent: d890579a2ec8a8a36b1e75b3fe6662faa99608e5
author: Angie Chiang <angiebird@google.com>
date: Tue Jan 19 13:18:20 EST 2021

Add return to vp9_extrc_update_encodeframe_result

Bug: webm:1716
Change-Id: Ib016ab5a49c765971366cc8d2b75bcca3ed5bd0f

--- a/vp9/encoder/vp9_ext_ratectrl.c
+++ b/vp9/encoder/vp9_ext_ratectrl.c
@@ -164,14 +164,17 @@
   return VPX_CODEC_OK;
 }
 
-void vp9_extrc_update_encodeframe_result(EXT_RATECTRL *ext_ratectrl,
-                                         int64_t bit_count,
-                                         const YV12_BUFFER_CONFIG *source_frame,
-                                         const YV12_BUFFER_CONFIG *coded_frame,
-                                         uint32_t bit_depth,
-                                         uint32_t input_bit_depth) {
+vpx_codec_err_t vp9_extrc_update_encodeframe_result(
+    EXT_RATECTRL *ext_ratectrl, int64_t bit_count,
+    const YV12_BUFFER_CONFIG *source_frame,
+    const YV12_BUFFER_CONFIG *coded_frame, uint32_t bit_depth,
+    uint32_t input_bit_depth) {
+  if (ext_ratectrl == NULL) {
+    return VPX_CODEC_ERROR;
+  }
   if (ext_ratectrl->ready) {
     PSNR_STATS psnr;
+    vpx_rc_status_t rc_status;
     vpx_rc_encodeframe_result_t encode_frame_result;
     encode_frame_result.bit_count = bit_count;
     encode_frame_result.pixel_count =
@@ -186,7 +189,11 @@
     vpx_calc_psnr(source_frame, coded_frame, &psnr);
 #endif
     encode_frame_result.sse = psnr.sse[0];
-    ext_ratectrl->funcs.update_encodeframe_result(ext_ratectrl->model,
-                                                  &encode_frame_result);
+    rc_status = ext_ratectrl->funcs.update_encodeframe_result(
+        ext_ratectrl->model, &encode_frame_result);
+    if (rc_status == VPX_RC_ERROR) {
+      return VPX_CODEC_ERROR;
+    }
   }
+  return VPX_CODEC_OK;
 }
--- a/vp9/encoder/vp9_ext_ratectrl.h
+++ b/vp9/encoder/vp9_ext_ratectrl.h
@@ -39,11 +39,10 @@
     RefCntBuffer *ref_frame_bufs[MAX_INTER_REF_FRAMES], int ref_frame_flags,
     vpx_rc_encodeframe_decision_t *encode_frame_decision);
 
-void vp9_extrc_update_encodeframe_result(EXT_RATECTRL *ext_ratectrl,
-                                         int64_t bit_count,
-                                         const YV12_BUFFER_CONFIG *source_frame,
-                                         const YV12_BUFFER_CONFIG *coded_frame,
-                                         uint32_t bit_depth,
-                                         uint32_t input_bit_depth);
+vpx_codec_err_t vp9_extrc_update_encodeframe_result(
+    EXT_RATECTRL *ext_ratectrl, int64_t bit_count,
+    const YV12_BUFFER_CONFIG *source_frame,
+    const YV12_BUFFER_CONFIG *coded_frame, uint32_t bit_depth,
+    uint32_t input_bit_depth);
 
 #endif  // VPX_VP9_ENCODER_VP9_EXT_RATECTRL_H_