From: angiebird Date: Thu, 10 Oct 2019 00:59:56 +0000 (-0700) Subject: Refactor calc_frame_boost() X-Git-Tag: v1.8.2~91 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=412547ad4b759e139b626f523b313c87debc6639;p=libvpx Refactor calc_frame_boost() Replace detect_flash() by detect_flash_from_frame_stats() Change-Id: I31862820926b5167ff70cebe2009c04aa745a019 --- diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index b8777cd12..6f91836e7 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -1839,7 +1839,7 @@ static int detect_flash_from_frame_stats(const FIRSTPASS_STATS *frame_stats) { // The recovery after a flash is indicated by a high pcnt_second_ref // useage or a second ref coded error notabley lower than the last // frame coded error. - if (frame_stats == 0) { + if (frame_stats == NULL) { return 0; } return (frame_stats->sr_coded_error < frame_stats->coded_error) || @@ -1972,6 +1972,7 @@ static int calc_arf_boost(VP9_COMP *cpi, int f_frames, int b_frames) { // Search forward from the proposed arf/next gf position. for (i = 0; i < f_frames; ++i) { const FIRSTPASS_STATS *this_frame = read_frame_stats(twopass, i); + const FIRSTPASS_STATS *next_frame = read_frame_stats(twopass, i + 1); if (this_frame == NULL) break; // Update the motion related elements to the boost calculation. @@ -1981,7 +1982,8 @@ static int calc_arf_boost(VP9_COMP *cpi, int f_frames, int b_frames) { // We want to discount the flash frame itself and the recovery // frame that follows as both will have poor scores. - flash_detected = detect_flash(twopass, i) || detect_flash(twopass, i + 1); + flash_detected = detect_flash_from_frame_stats(this_frame) || + detect_flash_from_frame_stats(next_frame); // Accumulate the effect of prediction quality decay. if (!flash_detected) { @@ -2008,6 +2010,7 @@ static int calc_arf_boost(VP9_COMP *cpi, int f_frames, int b_frames) { // Search backward towards last gf position. for (i = -1; i >= -b_frames; --i) { const FIRSTPASS_STATS *this_frame = read_frame_stats(twopass, i); + const FIRSTPASS_STATS *next_frame = read_frame_stats(twopass, i + 1); if (this_frame == NULL) break; // Update the motion related elements to the boost calculation. @@ -2017,7 +2020,8 @@ static int calc_arf_boost(VP9_COMP *cpi, int f_frames, int b_frames) { // We want to discount the the flash frame itself and the recovery // frame that follows as both will have poor scores. - flash_detected = detect_flash(twopass, i) || detect_flash(twopass, i + 1); + flash_detected = detect_flash_from_frame_stats(this_frame) || + detect_flash_from_frame_stats(next_frame); // Cumulative effect of prediction quality decay. if (!flash_detected) {