vp9,encoder: relocate setjmp
move to encoder_encode() as vp9_get_compressed_data() allocates data and
would require some modification to make its error return meaningful.
Change-Id: I8ddc390a1441afd0ff937842fa4ad1053c956133
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 0f4f93d..7cf5c97 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -4157,21 +4157,15 @@
int vp9_receive_raw_frame(VP9_COMP *cpi, unsigned int frame_flags,
YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
int64_t end_time) {
- VP9_COMMON *volatile const cm = &cpi->common;
+ VP9_COMMON *const cm = &cpi->common;
struct vpx_usec_timer timer;
- volatile int res = 0;
+ int res = 0;
const int subsampling_x = sd->subsampling_x;
const int subsampling_y = sd->subsampling_y;
#if CONFIG_VP9_HIGHBITDEPTH
const int use_highbitdepth = (sd->flags & YV12_FLAG_HIGHBITDEPTH) != 0;
#endif
- if (setjmp(cm->error.jmp)) {
- cm->error.setjmp = 0;
- return -1;
- }
- cm->error.setjmp = 1;
-
#if CONFIG_VP9_HIGHBITDEPTH
check_initial_width(cpi, use_highbitdepth, subsampling_x, subsampling_y);
#else
@@ -4205,7 +4199,6 @@
res = -1;
}
- cm->error.setjmp = 0;
return res;
}
diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c
index 466fa75..11df1e4 100644
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -14,6 +14,7 @@
#include "./vpx_config.h"
#include "vpx/vpx_encoder.h"
#include "vpx_ports/vpx_once.h"
+#include "vpx_ports/system_state.h"
#include "vpx/internal/vpx_codec_internal.h"
#include "./vpx_version.h"
#include "vp9/encoder/vp9_encoder.h"
@@ -967,9 +968,10 @@
const vpx_image_t *img,
vpx_codec_pts_t pts,
unsigned long duration,
- vpx_enc_frame_flags_t flags,
+ vpx_enc_frame_flags_t enc_flags,
unsigned long deadline) {
- vpx_codec_err_t res = VPX_CODEC_OK;
+ volatile vpx_codec_err_t res = VPX_CODEC_OK;
+ volatile vpx_enc_frame_flags_t flags = enc_flags;
VP9_COMP *const cpi = ctx->cpi;
const vpx_rational_t *const timebase = &ctx->cfg.g_timebase;
size_t data_sz;
@@ -1006,6 +1008,14 @@
return VPX_CODEC_INVALID_PARAM;
}
+ if (setjmp(cpi->common.error.jmp)) {
+ cpi->common.error.setjmp = 0;
+ res = update_error_state(ctx, &cpi->common.error);
+ vpx_clear_system_state();
+ return res;
+ }
+ cpi->common.error.setjmp = 1;
+
vp9_apply_encoding_flags(cpi, flags);
// Handle fixed keyframe intervals
@@ -1056,7 +1066,8 @@
* the buffer size anyway.
*/
if (cx_data_sz < ctx->cx_data_sz / 2) {
- ctx->base.err_detail = "Compressed data buffer too small";
+ vpx_internal_error(&cpi->common.error, VPX_CODEC_ERROR,
+ "Compressed data buffer too small");
return VPX_CODEC_ERROR;
}
}
@@ -1174,6 +1185,7 @@
}
}
+ cpi->common.error.setjmp = 0;
return res;
}