Bug: webm:1716
Unified · Split
| @@ -13,31 +13,56 @@ · 12 unmodified lines | ||
| 13 | 13 | #include "vp9/common/vp9_common.h" |
| 14 | 14 | #include "vpx_dsp/psnr.h" |
| 15 | 15 | |
| 16 | −void vp9_extrc_init(EXT_RATECTRL *ext_ratectrl) { vp9_zero(*ext_ratectrl); } | |
| 16 | +vpx_codec_err_t vp9_extrc_init(EXT_RATECTRL *ext_ratectrl) { | |
| 17 | + if (ext_ratectrl == NULL) { | |
| 18 | + return VPX_CODEC_ERROR; | |
| 19 | + } | |
| 20 | + vp9_zero(*ext_ratectrl); | |
| 21 | + return VPX_CODEC_OK; | |
| 22 | +} | |
| 17 | 23 | |
| 18 | −void vp9_extrc_create(vpx_rc_funcs_t funcs, vpx_rc_config_t ratectrl_config, | |
| 19 | − EXT_RATECTRL *ext_ratectrl) { | |
| 24 | +vpx_codec_err_t vp9_extrc_create(vpx_rc_funcs_t funcs, | |
| 25 | + vpx_rc_config_t ratectrl_config, | |
| 26 | + EXT_RATECTRL *ext_ratectrl) { | |
| 27 | + vpx_rc_status_t rc_status; | |
| 20 | 28 | vpx_rc_firstpass_stats_t *rc_firstpass_stats; |
| 29 | + if (ext_ratectrl == NULL) { | |
| 30 | + return VPX_CODEC_ERROR; | |
| 31 | + } | |
| 21 | 32 | vp9_extrc_delete(ext_ratectrl); |
| 22 | 33 | ext_ratectrl->funcs = funcs; |
| 23 | 34 | ext_ratectrl->ratectrl_config = ratectrl_config; |
| 24 | − ext_ratectrl->funcs.create_model(ext_ratectrl->funcs.priv, | |
| 25 | − &ext_ratectrl->ratectrl_config, | |
| 26 | − &ext_ratectrl->model); | |
| 35 | + rc_status = ext_ratectrl->funcs.create_model(ext_ratectrl->funcs.priv, | |
| 36 | + &ext_ratectrl->ratectrl_config, | |
| 37 | + &ext_ratectrl->model); | |
| 38 | + if (rc_status == VPX_RC_ERROR) { | |
| 39 | + return VPX_CODEC_ERROR; | |
| 40 | + } | |
| 27 | 41 | rc_firstpass_stats = &ext_ratectrl->rc_firstpass_stats; |
| 28 | 42 | rc_firstpass_stats->num_frames = ratectrl_config.show_frame_count; |
| 29 | 43 | rc_firstpass_stats->frame_stats = |
| 30 | 44 | vpx_malloc(sizeof(*rc_firstpass_stats->frame_stats) * |
| 31 | 45 | rc_firstpass_stats->num_frames); |
| 46 | + if (rc_firstpass_stats->frame_stats == NULL) { | |
| 47 | + return VPX_CODEC_MEM_ERROR; | |
| 48 | + } | |
| 32 | 49 | ext_ratectrl->ready = 1; |
| 50 | + return VPX_CODEC_OK; | |
| 33 | 51 | } |
| 34 | 52 | |
| 35 | −void vp9_extrc_delete(EXT_RATECTRL *ext_ratectrl) { | |
| 53 | +vpx_codec_err_t vp9_extrc_delete(EXT_RATECTRL *ext_ratectrl) { | |
| 54 | + if (ext_ratectrl == NULL) { | |
| 55 | + return VPX_CODEC_ERROR; | |
| 56 | + } | |
| 36 | 57 | if (ext_ratectrl->ready) { |
| 37 | − ext_ratectrl->funcs.delete_model(ext_ratectrl->model); | |
| 58 | + vpx_rc_status_t rc_status = | |
| 59 | + ext_ratectrl->funcs.delete_model(ext_ratectrl->model); | |
| 60 | + if (rc_status == VPX_RC_ERROR) { | |
| 61 | + return VPX_CODEC_ERROR; | |
| 62 | + } | |
| 38 | 63 | vpx_free(ext_ratectrl->rc_firstpass_stats.frame_stats); |
| 39 | 64 | } |
| 40 | − vp9_extrc_init(ext_ratectrl); | |
| 65 | + return vp9_extrc_init(ext_ratectrl); | |
| 41 | 66 | } |
| 42 | 67 | |
| 43 | 68 | static void gen_rc_firstpass_stats(const FIRSTPASS_STATS *stats, |
| @@ -22,12 +22,13 @@ typedef struct EXT_RATECTRL { · 21 unmodified lines | ||
| 22 | 22 | vpx_rc_firstpass_stats_t rc_firstpass_stats; |
| 23 | 23 | } EXT_RATECTRL; |
| 24 | 24 | |
| 25 | −void vp9_extrc_init(EXT_RATECTRL *ext_ratectrl); | |
| 25 | +vpx_codec_err_t vp9_extrc_init(EXT_RATECTRL *ext_ratectrl); | |
| 26 | 26 | |
| 27 | −void vp9_extrc_create(vpx_rc_funcs_t funcs, vpx_rc_config_t ratectrl_config, | |
| 28 | − EXT_RATECTRL *ext_ratectrl); | |
| 27 | +vpx_codec_err_t vp9_extrc_create(vpx_rc_funcs_t funcs, | |
| 28 | + vpx_rc_config_t ratectrl_config, | |
| 29 | + EXT_RATECTRL *ext_ratectrl); | |
| 29 | 30 | |
| 30 | −void vp9_extrc_delete(EXT_RATECTRL *ext_ratectrl); | |
| 31 | +vpx_codec_err_t vp9_extrc_delete(EXT_RATECTRL *ext_ratectrl); | |
| 31 | 32 | |
| 32 | 33 | void vp9_extrc_send_firstpass_stats(EXT_RATECTRL *ext_ratectrl, |
| 33 | 34 | const FIRST_PASS_INFO *first_pass_info); |