Commit e4118e25 authored by Dmitry Kovalev's avatar Dmitry Kovalev Committed by Gerrit Code Review

Merge "Adding vpx_sse_to_psnr() function."

parents b83b159e 7d5bffc4
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "vp8/common/alloccommon.h" #include "vp8/common/alloccommon.h"
#include "mcomp.h" #include "mcomp.h"
#include "firstpass.h" #include "firstpass.h"
#include "psnr.h" #include "vpx/internal/vpx_psnr.h"
#include "vpx_scale/vpx_scale.h" #include "vpx_scale/vpx_scale.h"
#include "vp8/common/extend.h" #include "vp8/common/extend.h"
#include "ratectrl.h" #include "ratectrl.h"
...@@ -2170,10 +2170,12 @@ void vp8_remove_compressor(VP8_COMP **ptr) ...@@ -2170,10 +2170,12 @@ void vp8_remove_compressor(VP8_COMP **ptr)
8.0 / 1000.0 / time_encoded; 8.0 / 1000.0 / time_encoded;
double samples = 3.0 / 2 * cpi->frames_in_layer[i] * double samples = 3.0 / 2 * cpi->frames_in_layer[i] *
lst_yv12->y_width * lst_yv12->y_height; lst_yv12->y_width * lst_yv12->y_height;
double total_psnr = vp8_mse2psnr(samples, 255.0, double total_psnr =
cpi->total_error2[i]); vpx_sse_to_psnr(samples, 255.0,
double total_psnr2 = vp8_mse2psnr(samples, 255.0, cpi->total_error2[i]);
cpi->total_error2_p[i]); double total_psnr2 =
vpx_sse_to_psnr(samples, 255.0,
cpi->total_error2_p[i]);
double total_ssim = 100 * pow(cpi->sum_ssim[i] / double total_ssim = 100 * pow(cpi->sum_ssim[i] /
cpi->sum_weights[i], 8.0); cpi->sum_weights[i], 8.0);
...@@ -2190,9 +2192,9 @@ void vp8_remove_compressor(VP8_COMP **ptr) ...@@ -2190,9 +2192,9 @@ void vp8_remove_compressor(VP8_COMP **ptr)
{ {
double samples = 3.0 / 2 * cpi->count * double samples = 3.0 / 2 * cpi->count *
lst_yv12->y_width * lst_yv12->y_height; lst_yv12->y_width * lst_yv12->y_height;
double total_psnr = vp8_mse2psnr(samples, 255.0, double total_psnr = vpx_sse_to_psnr(samples, 255.0,
cpi->total_sq_error); cpi->total_sq_error);
double total_psnr2 = vp8_mse2psnr(samples, 255.0, double total_psnr2 = vpx_sse_to_psnr(samples, 255.0,
cpi->total_sq_error2); cpi->total_sq_error2);
double total_ssim = 100 * pow(cpi->summed_quality / double total_ssim = 100 * pow(cpi->summed_quality /
cpi->summed_weights, 8.0); cpi->summed_weights, 8.0);
...@@ -2522,8 +2524,8 @@ static void generate_psnr_packet(VP8_COMP *cpi) ...@@ -2522,8 +2524,8 @@ static void generate_psnr_packet(VP8_COMP *cpi)
pkt.data.psnr.samples[3] = width * height; pkt.data.psnr.samples[3] = width * height;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
pkt.data.psnr.psnr[i] = vp8_mse2psnr(pkt.data.psnr.samples[i], 255.0, pkt.data.psnr.psnr[i] = vpx_sse_to_psnr(pkt.data.psnr.samples[i], 255.0,
(double)(pkt.data.psnr.sse[i])); (double)(pkt.data.psnr.sse[i]));
vpx_codec_pkt_list_add(cpi->output_pkt_list, &pkt); vpx_codec_pkt_list_add(cpi->output_pkt_list, &pkt);
} }
...@@ -5284,11 +5286,11 @@ int vp8_get_compressed_data(VP8_COMP *cpi, unsigned int *frame_flags, unsigned l ...@@ -5284,11 +5286,11 @@ int vp8_get_compressed_data(VP8_COMP *cpi, unsigned int *frame_flags, unsigned l
sq_error = (double)(ye + ue + ve); sq_error = (double)(ye + ue + ve);
frame_psnr = vp8_mse2psnr(t_samples, 255.0, sq_error); frame_psnr = vpx_sse_to_psnr(t_samples, 255.0, sq_error);
cpi->total_y += vp8_mse2psnr(y_samples, 255.0, (double)ye); cpi->total_y += vpx_sse_to_psnr(y_samples, 255.0, (double)ye);
cpi->total_u += vp8_mse2psnr(uv_samples, 255.0, (double)ue); cpi->total_u += vpx_sse_to_psnr(uv_samples, 255.0, (double)ue);
cpi->total_v += vp8_mse2psnr(uv_samples, 255.0, (double)ve); cpi->total_v += vpx_sse_to_psnr(uv_samples, 255.0, (double)ve);
cpi->total_sq_error += sq_error; cpi->total_sq_error += sq_error;
cpi->total += frame_psnr; cpi->total += frame_psnr;
#if CONFIG_POSTPROC #if CONFIG_POSTPROC
...@@ -5311,14 +5313,14 @@ int vp8_get_compressed_data(VP8_COMP *cpi, unsigned int *frame_flags, unsigned l ...@@ -5311,14 +5313,14 @@ int vp8_get_compressed_data(VP8_COMP *cpi, unsigned int *frame_flags, unsigned l
sq_error2 = (double)(ye + ue + ve); sq_error2 = (double)(ye + ue + ve);
frame_psnr2 = vp8_mse2psnr(t_samples, 255.0, sq_error2); frame_psnr2 = vpx_sse_to_psnr(t_samples, 255.0, sq_error2);
cpi->totalp_y += vp8_mse2psnr(y_samples, cpi->totalp_y += vpx_sse_to_psnr(y_samples,
255.0, (double)ye); 255.0, (double)ye);
cpi->totalp_u += vp8_mse2psnr(uv_samples, cpi->totalp_u += vpx_sse_to_psnr(uv_samples,
255.0, (double)ue); 255.0, (double)ue);
cpi->totalp_v += vp8_mse2psnr(uv_samples, cpi->totalp_v += vpx_sse_to_psnr(uv_samples,
255.0, (double)ve); 255.0, (double)ve);
cpi->total_sq_error2 += sq_error2; cpi->total_sq_error2 += sq_error2;
cpi->totalp += frame_psnr2; cpi->totalp += frame_psnr2;
......
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "vpx_scale/yv12config.h"
#include "math.h"
#include "vp8/common/systemdependent.h" /* for vp8_clear_system_state() */
#define MAX_PSNR 100
double vp8_mse2psnr(double Samples, double Peak, double Mse)
{
double psnr;
if ((double)Mse > 0.0)
psnr = 10.0 * log10(Peak * Peak * Samples / Mse);
else
psnr = MAX_PSNR; /* Limit to prevent / 0 */
if (psnr > MAX_PSNR)
psnr = MAX_PSNR;
return psnr;
}
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "vp8/common/alloccommon.h" #include "vp8/common/alloccommon.h"
#include "mcomp.h" #include "mcomp.h"
#include "firstpass.h" #include "firstpass.h"
#include "psnr.h"
#include "vpx_scale/vpx_scale.h" #include "vpx_scale/vpx_scale.h"
#include "vp8/common/extend.h" #include "vp8/common/extend.h"
#include "ratectrl.h" #include "ratectrl.h"
......
...@@ -50,7 +50,6 @@ VP8_CX_SRCS-yes += encoder/mcomp.h ...@@ -50,7 +50,6 @@ VP8_CX_SRCS-yes += encoder/mcomp.h
VP8_CX_SRCS-yes += encoder/modecosts.h VP8_CX_SRCS-yes += encoder/modecosts.h
VP8_CX_SRCS-yes += encoder/onyx_int.h VP8_CX_SRCS-yes += encoder/onyx_int.h
VP8_CX_SRCS-yes += encoder/pickinter.h VP8_CX_SRCS-yes += encoder/pickinter.h
VP8_CX_SRCS-yes += encoder/psnr.h
VP8_CX_SRCS-yes += encoder/quantize.h VP8_CX_SRCS-yes += encoder/quantize.h
VP8_CX_SRCS-yes += encoder/ratectrl.h VP8_CX_SRCS-yes += encoder/ratectrl.h
VP8_CX_SRCS-yes += encoder/rdopt.h VP8_CX_SRCS-yes += encoder/rdopt.h
...@@ -61,7 +60,6 @@ VP8_CX_SRCS-yes += encoder/modecosts.c ...@@ -61,7 +60,6 @@ VP8_CX_SRCS-yes += encoder/modecosts.c
VP8_CX_SRCS-yes += encoder/onyx_if.c VP8_CX_SRCS-yes += encoder/onyx_if.c
VP8_CX_SRCS-yes += encoder/pickinter.c VP8_CX_SRCS-yes += encoder/pickinter.c
VP8_CX_SRCS-yes += encoder/picklpf.c VP8_CX_SRCS-yes += encoder/picklpf.c
VP8_CX_SRCS-yes += encoder/psnr.c
VP8_CX_SRCS-yes += encoder/quantize.c VP8_CX_SRCS-yes += encoder/quantize.c
VP8_CX_SRCS-yes += encoder/ratectrl.c VP8_CX_SRCS-yes += encoder/ratectrl.c
VP8_CX_SRCS-yes += encoder/rdopt.c VP8_CX_SRCS-yes += encoder/rdopt.c
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "./vpx_config.h" #include "./vpx_config.h"
#include "./vpx_scale_rtcd.h" #include "./vpx_scale_rtcd.h"
#include "vpx/internal/vpx_psnr.h"
#include "vpx_ports/vpx_timer.h"
#include "vp9/common/vp9_alloccommon.h" #include "vp9/common/vp9_alloccommon.h"
#include "vp9/common/vp9_filter.h" #include "vp9/common/vp9_filter.h"
...@@ -30,7 +32,6 @@ ...@@ -30,7 +32,6 @@
#include "vp9/encoder/vp9_mbgraph.h" #include "vp9/encoder/vp9_mbgraph.h"
#include "vp9/encoder/vp9_onyx_int.h" #include "vp9/encoder/vp9_onyx_int.h"
#include "vp9/encoder/vp9_picklpf.h" #include "vp9/encoder/vp9_picklpf.h"
#include "vp9/encoder/vp9_psnr.h"
#include "vp9/encoder/vp9_ratectrl.h" #include "vp9/encoder/vp9_ratectrl.h"
#include "vp9/encoder/vp9_rdopt.h" #include "vp9/encoder/vp9_rdopt.h"
#include "vp9/encoder/vp9_segmentation.h" #include "vp9/encoder/vp9_segmentation.h"
...@@ -38,8 +39,6 @@ ...@@ -38,8 +39,6 @@
#include "vp9/encoder/vp9_vaq.h" #include "vp9/encoder/vp9_vaq.h"
#include "vp9/encoder/vp9_resize.h" #include "vp9/encoder/vp9_resize.h"
#include "vpx_ports/vpx_timer.h"
void vp9_entropy_mode_init(); void vp9_entropy_mode_init();
void vp9_coef_tree_initialize(); void vp9_coef_tree_initialize();
...@@ -2045,11 +2044,11 @@ void vp9_remove_compressor(VP9_PTR *ptr) { ...@@ -2045,11 +2044,11 @@ void vp9_remove_compressor(VP9_PTR *ptr) {
if (cpi->b_calculate_psnr) { if (cpi->b_calculate_psnr) {
const double total_psnr = const double total_psnr =
vp9_mse2psnr((double)cpi->total_samples, 255.0, vpx_sse_to_psnr((double)cpi->total_samples, 255.0,
(double)cpi->total_sq_error); (double)cpi->total_sq_error);
const double totalp_psnr = const double totalp_psnr =
vp9_mse2psnr((double)cpi->totalp_samples, 255.0, vpx_sse_to_psnr((double)cpi->totalp_samples, 255.0,
(double)cpi->totalp_sq_error); (double)cpi->totalp_sq_error);
const double total_ssim = 100 * pow(cpi->summed_quality / const double total_ssim = 100 * pow(cpi->summed_quality /
cpi->summed_weights, 8.0); cpi->summed_weights, 8.0);
const double totalp_ssim = 100 * pow(cpi->summedp_quality / const double totalp_ssim = 100 * pow(cpi->summedp_quality /
...@@ -2230,7 +2229,7 @@ static void calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b, ...@@ -2230,7 +2229,7 @@ static void calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b,
w, h); w, h);
psnr->sse[1 + i] = sse; psnr->sse[1 + i] = sse;
psnr->samples[1 + i] = samples; psnr->samples[1 + i] = samples;
psnr->psnr[1 + i] = vp9_mse2psnr(samples, 255.0, (double) sse); psnr->psnr[1 + i] = vpx_sse_to_psnr(samples, 255.0, (double)sse);
total_sse += sse; total_sse += sse;
total_samples += samples; total_samples += samples;
...@@ -2238,7 +2237,8 @@ static void calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b, ...@@ -2238,7 +2237,8 @@ static void calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b,
psnr->sse[0] = total_sse; psnr->sse[0] = total_sse;
psnr->samples[0] = total_samples; psnr->samples[0] = total_samples;
psnr->psnr[0] = vp9_mse2psnr((double)total_samples, 255.0, (double)total_sse); psnr->psnr[0] = vpx_sse_to_psnr((double)total_samples, 255.0,
(double)total_sse);
} }
static void generate_psnr_packet(VP9_COMP *cpi) { static void generate_psnr_packet(VP9_COMP *cpi) {
......
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VP9_ENCODER_VP9_PSNR_H_
#define VP9_ENCODER_VP9_PSNR_H_
#ifdef __cplusplus
extern "C" {
#endif
double vp9_mse2psnr(double samples, double peak, double mse);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VP9_ENCODER_VP9_PSNR_H_
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "vp9/encoder/vp9_firstpass.h" #include "vp9/encoder/vp9_firstpass.h"
#include "vp9/encoder/vp9_mcomp.h" #include "vp9/encoder/vp9_mcomp.h"
#include "vp9/encoder/vp9_onyx_int.h" #include "vp9/encoder/vp9_onyx_int.h"
#include "vp9/encoder/vp9_psnr.h"
#include "vp9/encoder/vp9_quantize.h" #include "vp9/encoder/vp9_quantize.h"
#include "vp9/encoder/vp9_ratectrl.h" #include "vp9/encoder/vp9_ratectrl.h"
#include "vp9/encoder/vp9_segmentation.h" #include "vp9/encoder/vp9_segmentation.h"
......
...@@ -38,7 +38,6 @@ VP9_CX_SRCS-yes += encoder/vp9_lookahead.c ...@@ -38,7 +38,6 @@ VP9_CX_SRCS-yes += encoder/vp9_lookahead.c
VP9_CX_SRCS-yes += encoder/vp9_lookahead.h VP9_CX_SRCS-yes += encoder/vp9_lookahead.h
VP9_CX_SRCS-yes += encoder/vp9_mcomp.h VP9_CX_SRCS-yes += encoder/vp9_mcomp.h
VP9_CX_SRCS-yes += encoder/vp9_onyx_int.h VP9_CX_SRCS-yes += encoder/vp9_onyx_int.h
VP9_CX_SRCS-yes += encoder/vp9_psnr.h
VP9_CX_SRCS-yes += encoder/vp9_quantize.h VP9_CX_SRCS-yes += encoder/vp9_quantize.h
VP9_CX_SRCS-yes += encoder/vp9_ratectrl.h VP9_CX_SRCS-yes += encoder/vp9_ratectrl.h
VP9_CX_SRCS-yes += encoder/vp9_rdopt.h VP9_CX_SRCS-yes += encoder/vp9_rdopt.h
...@@ -50,7 +49,6 @@ VP9_CX_SRCS-yes += encoder/vp9_mcomp.c ...@@ -50,7 +49,6 @@ VP9_CX_SRCS-yes += encoder/vp9_mcomp.c
VP9_CX_SRCS-yes += encoder/vp9_onyx_if.c VP9_CX_SRCS-yes += encoder/vp9_onyx_if.c
VP9_CX_SRCS-yes += encoder/vp9_picklpf.c VP9_CX_SRCS-yes += encoder/vp9_picklpf.c
VP9_CX_SRCS-yes += encoder/vp9_picklpf.h VP9_CX_SRCS-yes += encoder/vp9_picklpf.h
VP9_CX_SRCS-yes += encoder/vp9_psnr.c
VP9_CX_SRCS-yes += encoder/vp9_quantize.c VP9_CX_SRCS-yes += encoder/vp9_quantize.c
VP9_CX_SRCS-yes += encoder/vp9_ratectrl.c VP9_CX_SRCS-yes += encoder/vp9_ratectrl.c
VP9_CX_SRCS-yes += encoder/vp9_rdopt.c VP9_CX_SRCS-yes += encoder/vp9_rdopt.c
......
/* /*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved. * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
* *
* Use of this source code is governed by a BSD-style license * Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source * that can be found in the LICENSE file in the root of the source
...@@ -8,18 +8,27 @@ ...@@ -8,18 +8,27 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef VPX_INTERNAL_VPX_PSNR_H_
#ifndef VP8_ENCODER_PSNR_H_ #define VPX_INTERNAL_VPX_PSNR_H_
#define VP8_ENCODER_PSNR_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
extern double vp8_mse2psnr(double Samples, double Peak, double Mse); // TODO(dkovalev) change vpx_sse_to_psnr signature: double -> int64_t
/*!\brief Converts SSE to PSNR
*
* Converts sum of squared errros (SSE) to peak signal-to-noise ratio (PNSR).
*
* \param[in] samples Number of samples
* \param[in] peak Max sample value
* \param[in] sse Sum of squared errors
*/
double vpx_sse_to_psnr(double samples, double peak, double sse);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif
#endif // VP8_ENCODER_PSNR_H_ #endif // VPX_INTERNAL_VPX_PSNR_H_
/* /*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved. * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
* *
* Use of this source code is governed by a BSD-style license * Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source * that can be found in the LICENSE file in the root of the source
...@@ -10,20 +10,15 @@ ...@@ -10,20 +10,15 @@
#include <math.h> #include <math.h>
#include "vpx_scale/yv12config.h" #include "vpx/internal/vpx_psnr.h"
#define MAX_PSNR 100 #define MAX_PSNR 100.0
double vp9_mse2psnr(double samples, double peak, double mse) { double vpx_sse_to_psnr(double samples, double peak, double sse) {
double psnr; if (sse > 0.0) {
const double psnr = 10.0 * log10(samples * peak * peak / sse);
if (mse > 0.0) return psnr > MAX_PSNR ? MAX_PSNR : psnr;
psnr = 10.0 * log10(peak * peak * samples / mse); } else {
else return MAX_PSNR;
psnr = MAX_PSNR; // Limit to prevent / 0 }
if (psnr > MAX_PSNR)
psnr = MAX_PSNR;
return psnr;
} }
...@@ -34,8 +34,10 @@ API_SRCS-yes += vpx_decoder.h ...@@ -34,8 +34,10 @@ API_SRCS-yes += vpx_decoder.h
API_SRCS-yes += src/vpx_encoder.c API_SRCS-yes += src/vpx_encoder.c
API_SRCS-yes += vpx_encoder.h API_SRCS-yes += vpx_encoder.h
API_SRCS-yes += internal/vpx_codec_internal.h API_SRCS-yes += internal/vpx_codec_internal.h
API_SRCS-yes += internal/vpx_psnr.h
API_SRCS-yes += src/vpx_codec.c API_SRCS-yes += src/vpx_codec.c
API_SRCS-yes += src/vpx_image.c API_SRCS-yes += src/vpx_image.c
API_SRCS-yes += src/vpx_psnr.c
API_SRCS-yes += vpx_codec.h API_SRCS-yes += vpx_codec.h
API_SRCS-yes += vpx_codec.mk API_SRCS-yes += vpx_codec.mk
API_SRCS-yes += vpx_frame_buffer.h API_SRCS-yes += vpx_frame_buffer.h
......
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