Skip to content

Commit

Permalink
Clarify the comment for update_error_state()
Browse files Browse the repository at this point in the history
Explain why the encoder init functions cannot call update_error_state().

In vp8/vp8_cx_iface.c, this comment should have been added in
https://chromium-review.googlesource.com/c/webm/libvpx/+/4506609.

Rewrite update_error_state() in vp8/vp8_cx_iface.c to look like the
versions in vp9/vp9_cx_iface.c and av1/av1_cx_iface.c (in libaom).

Change-Id: I3f153d67b8c549ca5ac8ea0cfbcaad4ae705c8e6
  • Loading branch information
wantehchang committed Dec 13, 2023
1 parent 4fe07a0 commit df655cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions vp8/vp8_cx_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,16 @@ struct vpx_codec_alg_priv {
vpx_enc_frame_flags_t control_frame_flags;
};

// Called by vp8e_set_config() and vp8e_encode() only. Must not be called
// by vp8e_init() because the `error` paramerer (cpi->common.error) will be
// destroyed by vpx_codec_enc_init_ver() after vp8e_init() returns an error.
// See the "IMPORTANT" comment in vpx_codec_enc_init_ver().
static vpx_codec_err_t update_error_state(
vpx_codec_alg_priv_t *ctx, const struct vpx_internal_error_info *error) {
vpx_codec_err_t res;
const vpx_codec_err_t res = error->error_code;

if ((res = error->error_code)) {
if (res != VPX_CODEC_OK)
ctx->base.err_detail = error->has_detail ? error->detail : NULL;
}

return res;
}
Expand Down
4 changes: 3 additions & 1 deletion vp9/vp9_cx_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ struct vpx_codec_alg_priv {
};

// Called by encoder_set_config() and encoder_encode() only. Must not be called
// by encoder_init().
// by encoder_init() because the `error` paramerer (cpi->common.error) will be
// destroyed by vpx_codec_enc_init_ver() after encoder_init() returns an error.
// See the "IMPORTANT" comment in vpx_codec_enc_init_ver().
static vpx_codec_err_t update_error_state(
vpx_codec_alg_priv_t *ctx, const struct vpx_internal_error_info *error) {
const vpx_codec_err_t res = error->error_code;
Expand Down

0 comments on commit df655cf

Please sign in to comment.