diff options
author | Jingning Han <jingning@google.com> | 2019-03-13 12:06:39 -0700 |
---|---|---|
committer | Jingning Han <jingning@google.com> | 2019-03-13 12:11:04 -0700 |
commit | e2435ff1f85679d8d67e1f9bb62835fdb948cbeb (patch) | |
tree | 00a5520be128ffa7e917df70589d84a7881fd37c /vp9 | |
parent | 1c07e79ef18efbab652b9296af67503885606663 (diff) | |
download | libvpx-e2435ff1f85679d8d67e1f9bb62835fdb948cbeb.tar libvpx-e2435ff1f85679d8d67e1f9bb62835fdb948cbeb.tar.gz libvpx-e2435ff1f85679d8d67e1f9bb62835fdb948cbeb.tar.bz2 libvpx-e2435ff1f85679d8d67e1f9bb62835fdb948cbeb.zip |
Safe guard zero median filter outcome case
In case median filter returns 0 value, bypass the Wiener filter
stage. This avoids potential divided by 0 case.
In the same place use a temp variable to take the Wiener filter
output instead of returning to the coeff array.
Change-Id: I45f57c515b4062a0aa1f312eda852462cb655d8e
Diffstat (limited to 'vp9')
-rw-r--r-- | vp9/encoder/vp9_encoder.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index f3f05d8b6..fb462c0cb 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -4793,9 +4793,12 @@ static void set_mb_wiener_variance(VP9_COMP *cpi) { // Wiener filter for (idx = 1; idx < coeff_count; ++idx) { int64_t sqr_coeff = (int64_t)coeff[idx] * coeff[idx]; - coeff[idx] = (int16_t)((sqr_coeff * coeff[idx]) / - (sqr_coeff + (int64_t)median_val * median_val)); - wiener_variance += (int64_t)coeff[idx] * coeff[idx]; + int64_t tmp_coeff = (int64_t)coeff[idx]; + if (median_val) { + tmp_coeff = (sqr_coeff * coeff[idx]) / + (sqr_coeff + (int64_t)median_val * median_val); + } + wiener_variance += tmp_coeff * tmp_coeff; } cpi->mb_wiener_variance[mb_row * cm->mb_cols + mb_col] = wiener_variance / coeff_count; |