Commit fdc977af authored by James Zern's avatar James Zern

vp10,encoder: relocate setjmp

move to encoder_encode() as vp10_get_compressed_data() allocates data and
would require some modification to make its error return meaningful.

Change-Id: Ia5267c35d16ccd42b6da6d2136402b13e28f9159
parent 73f45fcf
......@@ -3808,21 +3808,15 @@ static void setup_denoiser_buffer(VP10_COMP *cpi) {
int vp10_receive_raw_frame(VP10_COMP *cpi, unsigned int frame_flags,
YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
int64_t end_time) {
VP10_COMMON *volatile const cm = &cpi->common;
VP10_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
......@@ -3856,7 +3850,6 @@ int vp10_receive_raw_frame(VP10_COMP *cpi, unsigned int frame_flags,
res = -1;
}
cm->error.setjmp = 0;
return res;
}
......
......@@ -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 "vp10/encoder/encoder.h"
......@@ -885,9 +886,10 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
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;
VP10_COMP *const cpi = ctx->cpi;
const vpx_rational_t *const timebase = &ctx->cfg.g_timebase;
size_t data_sz;
......@@ -926,6 +928,14 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
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;
vp10_apply_encoding_flags(cpi, flags);
// Handle fixed keyframe intervals
......@@ -976,7 +986,8 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
* 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;
}
}
......@@ -1065,6 +1076,7 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
}
}
cpi->common.error.setjmp = 0;
return res;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment