Commit 6dd6ffb0 authored by Ronald S. Bultje's avatar Ronald S. Bultje
Browse files

Calculate SSIM over both reconstruction as well as postproc buffer.

We used to calculate SSIM only over the postproc buffer, whereas we
calculate PSNR for both. Compared to postproc-SSIM, this is about 0.3%
higher for derf, 1.4% lower for hd and 0.5% lower for stdhd, although
it is highly variable on a per-clip basis.

Change-Id: I8dd491f0f5b4201dedfb15d288c854d5d4caa10f
parent 9eea9fa2
...@@ -1536,6 +1536,8 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) { ...@@ -1536,6 +1536,8 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
cpi->tot_recode_hits = 0; cpi->tot_recode_hits = 0;
cpi->summed_quality = 0; cpi->summed_quality = 0;
cpi->summed_weights = 0; cpi->summed_weights = 0;
cpi->summedp_quality = 0;
cpi->summedp_weights = 0;
} }
if (cpi->b_calculate_ssimg) { if (cpi->b_calculate_ssimg) {
...@@ -1731,18 +1733,25 @@ void vp9_remove_compressor(VP9_PTR *ptr) { ...@@ -1731,18 +1733,25 @@ void vp9_remove_compressor(VP9_PTR *ptr) {
if (cpi->b_calculate_psnr) { if (cpi->b_calculate_psnr) {
YV12_BUFFER_CONFIG *lst_yv12 = YV12_BUFFER_CONFIG *lst_yv12 =
&cpi->common.yv12_fb[cpi->common.ref_frame_map[cpi->lst_fb_idx]]; &cpi->common.yv12_fb[cpi->common.ref_frame_map[cpi->lst_fb_idx]];
double samples = 3.0 / 2 * cpi->count * lst_yv12->y_width * lst_yv12->y_height; double samples = 3.0 / 2 * cpi->count *
lst_yv12->y_width * lst_yv12->y_height;
double total_psnr = vp9_mse2psnr(samples, 255.0, cpi->total_sq_error); double total_psnr = vp9_mse2psnr(samples, 255.0, cpi->total_sq_error);
double total_psnr2 = vp9_mse2psnr(samples, 255.0, cpi->total_sq_error2); double total_psnr2 = vp9_mse2psnr(samples, 255.0, cpi->total_sq_error2);
double total_ssim = 100 * pow(cpi->summed_quality / cpi->summed_weights, 8.0); double total_ssim = 100 * pow(cpi->summed_quality /
cpi->summed_weights, 8.0);
fprintf(f, "Bitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\tGLPsnrP\tVPXSSIM\t Time(ms)\n"); double total_ssimp = 100 * pow(cpi->summedp_quality /
fprintf(f, "%7.2f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%8.0f\n", cpi->summedp_weights, 8.0);
dr, cpi->total / cpi->count, total_psnr, cpi->totalp / cpi->count, total_psnr2, total_ssim,
fprintf(f, "Bitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\tGLPsnrP\t"
"VPXSSIM\tVPSSIMP\t Time(ms)\n");
fprintf(f, "%7.2f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%8.0f\n",
dr, cpi->total / cpi->count, total_psnr,
cpi->totalp / cpi->count, total_psnr2, total_ssim, total_ssimp,
total_encode_time); total_encode_time);
// fprintf(f, "%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%8.0f %10ld\n", // fprintf(f, "%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%8.0f %10ld\n",
// dr, cpi->total / cpi->count, total_psnr, cpi->totalp / cpi->count, total_psnr2, total_ssim, // dr, cpi->total / cpi->count, total_psnr,
// total_encode_time, cpi->tot_recode_hits); // cpi->totalp / cpi->count, total_psnr2, total_ssim,
// total_encode_time, cpi->tot_recode_hits);
} }
if (cpi->b_calculate_ssimg) { if (cpi->b_calculate_ssimg) {
...@@ -3988,10 +3997,16 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, ...@@ -3988,10 +3997,16 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags,
cpi->totalp += frame_psnr2; cpi->totalp += frame_psnr2;
frame_ssim2 = vp9_calc_ssim(cpi->Source, frame_ssim2 = vp9_calc_ssim(cpi->Source,
&cm->post_proc_buffer, 1, &weight); recon, 1, &weight);
cpi->summed_quality += frame_ssim2 * weight; cpi->summed_quality += frame_ssim2 * weight;
cpi->summed_weights += weight; cpi->summed_weights += weight;
frame_ssim2 = vp9_calc_ssim(cpi->Source,
&cm->post_proc_buffer, 1, &weight);
cpi->summedp_quality += frame_ssim2 * weight;
cpi->summedp_weights += weight;
#if 0 #if 0
{ {
FILE *f = fopen("q_used.stt", "a"); FILE *f = fopen("q_used.stt", "a");
......
...@@ -640,6 +640,8 @@ typedef struct VP9_COMP { ...@@ -640,6 +640,8 @@ typedef struct VP9_COMP {
int bytes; int bytes;
double summed_quality; double summed_quality;
double summed_weights; double summed_weights;
double summedp_quality;
double summedp_weights;
unsigned int tot_recode_hits; unsigned int tot_recode_hits;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment