Commit 73f45fcf authored by James Zern's avatar James Zern

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
parent b5029a25
......@@ -4157,21 +4157,15 @@ static void check_initial_width(VP9_COMP *cpi,
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 @@ int vp9_receive_raw_frame(VP9_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 "vp9/encoder/vp9_encoder.h"
......@@ -967,9 +968,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;
VP9_COMP *const cpi = ctx->cpi;
const vpx_rational_t *const timebase = &ctx->cfg.g_timebase;
size_t data_sz;
......@@ -1006,6 +1008,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;
vp9_apply_encoding_flags(cpi, flags);
// Handle fixed keyframe intervals
......@@ -1056,7 +1066,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;
}
}
......@@ -1174,6 +1185,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