Bug: webm:1707
Unified · Split
| @@ -5479,6 +5479,13 @@ static void encode_frame_to_data_rate( · 5478 unmodified lines | |||
| 5479 | // build the bitstream | 5479 | // build the bitstream |
| 5480 | vp9_pack_bitstream(cpi, dest, size); | 5480 | vp9_pack_bitstream(cpi, dest, size); |
| 5481 | 5481 | ||
| 5482 | { | ||
| 5483 | const RefCntBuffer *coded_frame_buf = | ||
| 5484 | get_ref_cnt_buffer(cm, cm->new_fb_idx); | ||
| 5485 | vp9_extrc_update_encodeframe_result(&cpi->ext_ratectrl, (*size) << 3, | ||
| 5486 | cpi->Source, &coded_frame_buf->buf, | ||
| 5487 | cpi->oxcf.input_bit_depth); | ||
| 5488 | } | ||
| 5482 | #if CONFIG_REALTIME_ONLY | 5489 | #if CONFIG_REALTIME_ONLY |
| 5483 | (void)encode_frame_result; | 5490 | (void)encode_frame_result; |
| 5484 | assert(encode_frame_result == NULL); | 5491 | assert(encode_frame_result == NULL); |
| @@ -7541,7 +7548,7 @@ static void update_encode_frame_result( · 2056 unmodified lines | |||
| 7541 | #if CONFIG_RATE_CTRL | 7548 | #if CONFIG_RATE_CTRL |
| 7542 | PSNR_STATS psnr; | 7549 | PSNR_STATS psnr; |
| 7543 | #if CONFIG_VP9_HIGHBITDEPTH | 7550 | #if CONFIG_VP9_HIGHBITDEPTH |
| 7544 | vpx_calc_highbd_psnr(source_frame, coded_frame_buf->buf, &psnr, bit_depth, | 7551 | vpx_calc_highbd_psnr(source_frame, &coded_frame_buf->buf, &psnr, bit_depth, |
| 7545 | input_bit_depth); | 7552 | input_bit_depth); |
| 7546 | #else // CONFIG_VP9_HIGHBITDEPTH | 7553 | #else // CONFIG_VP9_HIGHBITDEPTH |
| 7547 | (void)bit_depth; | 7554 | (void)bit_depth; |
| @@ -10,6 +10,7 @@ · 9 unmodified lines | |||
| 10 | 10 | ||
| 11 | #include "vp9/encoder/vp9_ext_ratectrl.h" | 11 | #include "vp9/encoder/vp9_ext_ratectrl.h" |
| 12 | #include "vp9/common/vp9_common.h" | 12 | #include "vp9/common/vp9_common.h" |
| 13 | #include "vpx_dsp/psnr.h" | ||
| 13 | 14 | ||
| 14 | void vp9_extrc_init(EXT_RATECTRL *ext_ratectrl) { vp9_zero(*ext_ratectrl); } | 15 | void vp9_extrc_init(EXT_RATECTRL *ext_ratectrl) { vp9_zero(*ext_ratectrl); } |
| 15 | 16 | ||
| @@ -112,3 +113,28 @@ void vp9_extrc_get_encodeframe_decision( · 96 unmodified lines | |||
| 112 | ext_ratectrl->model, &encode_frame_info, encode_frame_decision); | 113 | ext_ratectrl->model, &encode_frame_info, encode_frame_decision); |
| 113 | } | 114 | } |
| 114 | } | 115 | } |
| 116 | |||
| 117 | void vp9_extrc_update_encodeframe_result(EXT_RATECTRL *ext_ratectrl, | ||
| 118 | int64_t bit_count, | ||
| 119 | const YV12_BUFFER_CONFIG *source_frame, | ||
| 120 | const YV12_BUFFER_CONFIG *coded_frame, | ||
| 121 | uint32_t input_bit_depth) { | ||
| 122 | if (ext_ratectrl->ready) { | ||
| 123 | PSNR_STATS psnr; | ||
| 124 | vpx_rc_encodeframe_result_t encode_frame_result; | ||
| 125 | encode_frame_result.bit_count = bit_count; | ||
| 126 | encode_frame_result.pixel_count = | ||
| 127 | source_frame->y_width * source_frame->y_height + | ||
| 128 | 2 * source_frame->uv_width * source_frame->uv_height; | ||
| 129 | #if CONFIG_VP9_HIGHBITDEPTH | ||
| 130 | vpx_calc_highbd_psnr(source_frame, coded_frame, &psnr, | ||
| 131 | source_frame->bit_depth, input_bit_depth); | ||
| 132 | #else | ||
| 133 | (void)input_bit_depth; | ||
| 134 | vpx_calc_psnr(source_frame, coded_frame, &psnr); | ||
| 135 | #endif | ||
| 136 | encode_frame_result.sse = psnr.sse[0]; | ||
| 137 | ext_ratectrl->funcs.update_encodeframe_result(ext_ratectrl->model, | ||
| 138 | &encode_frame_result); | ||
| 139 | } | ||
| 140 | } | ||
| @@ -36,4 +36,10 @@ void vp9_extrc_get_encodeframe_decision( · 35 unmodified lines | |||
| 36 | EXT_RATECTRL *ext_ratectrl, const GF_GROUP *gf_group, int show_index, | 36 | EXT_RATECTRL *ext_ratectrl, const GF_GROUP *gf_group, int show_index, |
| 37 | int coding_index, vpx_rc_encodeframe_decision_t *encode_frame_decision); | 37 | int coding_index, vpx_rc_encodeframe_decision_t *encode_frame_decision); |
| 38 | 38 | ||
| 39 | void vp9_extrc_update_encodeframe_result(EXT_RATECTRL *ext_ratectrl, | ||
| 40 | int64_t bit_count, | ||
| 41 | const YV12_BUFFER_CONFIG *source_frame, | ||
| 42 | const YV12_BUFFER_CONFIG *coded_frame, | ||
| 43 | uint32_t input_bit_depth); | ||
| 44 | |||
| 39 | #endif // VPX_VP9_ENCODER_VP9_EXT_RATECTRL_H_ | 45 | #endif // VPX_VP9_ENCODER_VP9_EXT_RATECTRL_H_ |
| @@ -133,7 +133,7 @@ typedef int (*vpx_rc_get_encodeframe_decision_cb_fn_t)( · 132 unmodified lines | |||
| 133 | */ | 133 | */ |
| 134 | typedef int (*vpx_rc_update_encodeframe_result_cb_fn_t)( | 134 | typedef int (*vpx_rc_update_encodeframe_result_cb_fn_t)( |
| 135 | vpx_rc_model_t rate_ctrl_model, | 135 | vpx_rc_model_t rate_ctrl_model, |
| 136 | vpx_rc_encodeframe_result_t *encode_frame_result); | 136 | const vpx_rc_encodeframe_result_t *encode_frame_result); |
| 137 | 137 | ||
| 138 | /*!\brief Delete the external rate control model callback prototype | 138 | /*!\brief Delete the external rate control model callback prototype |
| 139 | * | 139 | * |