Bug: webm:1707
Unified · Split
| @@ -5479,6 +5479,13 @@ static void encode_frame_to_data_rate( · 5478 unmodified lines | ||
| 5479 | 5479 | // build the bitstream |
| 5480 | 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 | 5489 | #if CONFIG_REALTIME_ONLY |
| 5483 | 5490 | (void)encode_frame_result; |
| 5484 | 5491 | assert(encode_frame_result == NULL); |
| @@ -7541,7 +7548,7 @@ static void update_encode_frame_result( · 2056 unmodified lines | ||
| 7541 | 7548 | #if CONFIG_RATE_CTRL |
| 7542 | 7549 | PSNR_STATS psnr; |
| 7543 | 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 | 7552 | input_bit_depth); |
| 7546 | 7553 | #else // CONFIG_VP9_HIGHBITDEPTH |
| 7547 | 7554 | (void)bit_depth; |
| @@ -10,6 +10,7 @@ · 9 unmodified lines | ||
| 10 | 10 | |
| 11 | 11 | #include "vp9/encoder/vp9_ext_ratectrl.h" |
| 12 | 12 | #include "vp9/common/vp9_common.h" |
| 13 | +#include "vpx_dsp/psnr.h" | |
| 13 | 14 | |
| 14 | 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 | 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 | 36 | EXT_RATECTRL *ext_ratectrl, const GF_GROUP *gf_group, int show_index, |
| 37 | 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 | 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 | 134 | typedef int (*vpx_rc_update_encodeframe_result_cb_fn_t)( |
| 135 | 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 | 138 | /*!\brief Delete the external rate control model callback prototype |
| 139 | 139 | * |