Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: source/libvpx/vpx_dsp/ssim.c

Issue 1302353004: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/vpx_dsp/ssim.h ('k') | source/libvpx/vpx_dsp/variance.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/vpx_dsp/ssim.c
diff --git a/source/libvpx/vp9/encoder/vp9_ssim.c b/source/libvpx/vpx_dsp/ssim.c
similarity index 82%
rename from source/libvpx/vp9/encoder/vp9_ssim.c
rename to source/libvpx/vpx_dsp/ssim.c
index 172de5d1daa6ce66a66581149a2b49bc3f6b4666..cfe5bb331cea8925fe8532b52fc3de5a701fa79e 100644
--- a/source/libvpx/vp9/encoder/vp9_ssim.c
+++ b/source/libvpx/vpx_dsp/ssim.c
@@ -9,14 +9,15 @@
*/
#include <math.h>
-#include "./vp9_rtcd.h"
+#include "./vpx_dsp_rtcd.h"
+#include "vpx_dsp/ssim.h"
#include "vpx_ports/mem.h"
-#include "vp9/encoder/vp9_ssim.h"
+#include "vpx_ports/system_state.h"
-void vp9_ssim_parms_16x16_c(uint8_t *s, int sp, uint8_t *r,
- int rp, unsigned long *sum_s, unsigned long *sum_r,
- unsigned long *sum_sq_s, unsigned long *sum_sq_r,
- unsigned long *sum_sxr) {
+void vpx_ssim_parms_16x16_c(const uint8_t *s, int sp, const uint8_t *r,
+ int rp, uint32_t *sum_s, uint32_t *sum_r,
+ uint32_t *sum_sq_s, uint32_t *sum_sq_r,
+ uint32_t *sum_sxr) {
int i, j;
for (i = 0; i < 16; i++, s += sp, r += rp) {
for (j = 0; j < 16; j++) {
@@ -28,10 +29,10 @@ void vp9_ssim_parms_16x16_c(uint8_t *s, int sp, uint8_t *r,
}
}
}
-void vp9_ssim_parms_8x8_c(uint8_t *s, int sp, uint8_t *r, int rp,
- unsigned long *sum_s, unsigned long *sum_r,
- unsigned long *sum_sq_s, unsigned long *sum_sq_r,
- unsigned long *sum_sxr) {
+void vpx_ssim_parms_8x8_c(const uint8_t *s, int sp, const uint8_t *r, int rp,
+ uint32_t *sum_s, uint32_t *sum_r,
+ uint32_t *sum_sq_s, uint32_t *sum_sq_r,
+ uint32_t *sum_sxr) {
int i, j;
for (i = 0; i < 8; i++, s += sp, r += rp) {
for (j = 0; j < 8; j++) {
@@ -45,7 +46,8 @@ void vp9_ssim_parms_8x8_c(uint8_t *s, int sp, uint8_t *r, int rp,
}
#if CONFIG_VP9_HIGHBITDEPTH
-void vp9_highbd_ssim_parms_8x8_c(uint16_t *s, int sp, uint16_t *r, int rp,
+void vpx_highbd_ssim_parms_8x8_c(const uint16_t *s, int sp,
+ const uint16_t *r, int rp,
uint32_t *sum_s, uint32_t *sum_r,
uint32_t *sum_sq_s, uint32_t *sum_sq_r,
uint32_t *sum_sxr) {
@@ -65,9 +67,9 @@ void vp9_highbd_ssim_parms_8x8_c(uint16_t *s, int sp, uint16_t *r, int rp,
static const int64_t cc1 = 26634; // (64^2*(.01*255)^2
static const int64_t cc2 = 239708; // (64^2*(.03*255)^2
-static double similarity(unsigned long sum_s, unsigned long sum_r,
- unsigned long sum_sq_s, unsigned long sum_sq_r,
- unsigned long sum_sxr, int count) {
+static double similarity(uint32_t sum_s, uint32_t sum_r,
+ uint32_t sum_sq_s, uint32_t sum_sq_r,
+ uint32_t sum_sxr, int count) {
int64_t ssim_n, ssim_d;
int64_t c1, c2;
@@ -85,19 +87,19 @@ static double similarity(unsigned long sum_s, unsigned long sum_r,
return ssim_n * 1.0 / ssim_d;
}
-static double ssim_8x8(uint8_t *s, int sp, uint8_t *r, int rp) {
- unsigned long sum_s = 0, sum_r = 0, sum_sq_s = 0, sum_sq_r = 0, sum_sxr = 0;
- vp9_ssim_parms_8x8(s, sp, r, rp, &sum_s, &sum_r, &sum_sq_s, &sum_sq_r,
+static double ssim_8x8(const uint8_t *s, int sp, const uint8_t *r, int rp) {
+ uint32_t sum_s = 0, sum_r = 0, sum_sq_s = 0, sum_sq_r = 0, sum_sxr = 0;
+ vpx_ssim_parms_8x8(s, sp, r, rp, &sum_s, &sum_r, &sum_sq_s, &sum_sq_r,
&sum_sxr);
return similarity(sum_s, sum_r, sum_sq_s, sum_sq_r, sum_sxr, 64);
}
#if CONFIG_VP9_HIGHBITDEPTH
-static double highbd_ssim_8x8(uint16_t *s, int sp, uint16_t *r, int rp,
- unsigned int bd) {
+static double highbd_ssim_8x8(const uint16_t *s, int sp, const uint16_t *r,
+ int rp, unsigned int bd) {
uint32_t sum_s = 0, sum_r = 0, sum_sq_s = 0, sum_sq_r = 0, sum_sxr = 0;
const int oshift = bd - 8;
- vp9_highbd_ssim_parms_8x8(s, sp, r, rp, &sum_s, &sum_r, &sum_sq_s, &sum_sq_r,
+ vpx_highbd_ssim_parms_8x8(s, sp, r, rp, &sum_s, &sum_r, &sum_sq_s, &sum_sq_r,
&sum_sxr);
return similarity(sum_s >> oshift,
sum_r >> oshift,
@@ -111,8 +113,9 @@ static double highbd_ssim_8x8(uint16_t *s, int sp, uint16_t *r, int rp,
// We are using a 8x8 moving window with starting location of each 8x8 window
// on the 4x4 pixel grid. Such arrangement allows the windows to overlap
// block boundaries to penalize blocking artifacts.
-double vp9_ssim2(uint8_t *img1, uint8_t *img2, int stride_img1,
- int stride_img2, int width, int height) {
+static double vpx_ssim2(const uint8_t *img1, const uint8_t *img2,
+ int stride_img1, int stride_img2, int width,
+ int height) {
int i, j;
int samples = 0;
double ssim_total = 0;
@@ -131,9 +134,9 @@ double vp9_ssim2(uint8_t *img1, uint8_t *img2, int stride_img1,
}
#if CONFIG_VP9_HIGHBITDEPTH
-double vp9_highbd_ssim2(uint8_t *img1, uint8_t *img2, int stride_img1,
- int stride_img2, int width, int height,
- unsigned int bd) {
+static double vpx_highbd_ssim2(const uint8_t *img1, const uint8_t *img2,
+ int stride_img1, int stride_img2, int width,
+ int height, unsigned int bd) {
int i, j;
int samples = 0;
double ssim_total = 0;
@@ -154,20 +157,21 @@ double vp9_highbd_ssim2(uint8_t *img1, uint8_t *img2, int stride_img1,
}
#endif // CONFIG_VP9_HIGHBITDEPTH
-double vp9_calc_ssim(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest,
+double vpx_calc_ssim(const YV12_BUFFER_CONFIG *source,
+ const YV12_BUFFER_CONFIG *dest,
double *weight) {
double a, b, c;
double ssimv;
- a = vp9_ssim2(source->y_buffer, dest->y_buffer,
+ a = vpx_ssim2(source->y_buffer, dest->y_buffer,
source->y_stride, dest->y_stride,
source->y_crop_width, source->y_crop_height);
- b = vp9_ssim2(source->u_buffer, dest->u_buffer,
+ b = vpx_ssim2(source->u_buffer, dest->u_buffer,
source->uv_stride, dest->uv_stride,
source->uv_crop_width, source->uv_crop_height);
- c = vp9_ssim2(source->v_buffer, dest->v_buffer,
+ c = vpx_ssim2(source->v_buffer, dest->v_buffer,
source->uv_stride, dest->uv_stride,
source->uv_crop_width, source->uv_crop_height);
@@ -178,20 +182,21 @@ double vp9_calc_ssim(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest,
return ssimv;
}
-double vp9_calc_ssimg(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest,
+double vpx_calc_ssimg(const YV12_BUFFER_CONFIG *source,
+ const YV12_BUFFER_CONFIG *dest,
double *ssim_y, double *ssim_u, double *ssim_v) {
double ssim_all = 0;
double a, b, c;
- a = vp9_ssim2(source->y_buffer, dest->y_buffer,
+ a = vpx_ssim2(source->y_buffer, dest->y_buffer,
source->y_stride, dest->y_stride,
source->y_crop_width, source->y_crop_height);
- b = vp9_ssim2(source->u_buffer, dest->u_buffer,
+ b = vpx_ssim2(source->u_buffer, dest->u_buffer,
source->uv_stride, dest->uv_stride,
source->uv_crop_width, source->uv_crop_height);
- c = vp9_ssim2(source->v_buffer, dest->v_buffer,
+ c = vpx_ssim2(source->v_buffer, dest->v_buffer,
source->uv_stride, dest->uv_stride,
source->uv_crop_width, source->uv_crop_height);
*ssim_y = a;
@@ -231,7 +236,7 @@ double vp9_calc_ssimg(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest,
// Replace c1 with n*n * c1 for the final step that leads to this code:
// The final step scales by 12 bits so we don't lose precision in the constants.
-double ssimv_similarity(Ssimv *sv, int64_t n) {
+static double ssimv_similarity(const Ssimv *sv, int64_t n) {
// Scale the constants by number of pixels.
const int64_t c1 = (cc1 * n * n) >> 12;
const int64_t c2 = (cc2 * n * n) >> 12;
@@ -262,7 +267,7 @@ double ssimv_similarity(Ssimv *sv, int64_t n) {
//
// 255 * 255 - (sum_s - sum_r) / count * (sum_s - sum_r) / count
//
-double ssimv_similarity2(Ssimv *sv, int64_t n) {
+static double ssimv_similarity2(const Ssimv *sv, int64_t n) {
// Scale the constants by number of pixels.
const int64_t c1 = (cc1 * n * n) >> 12;
const int64_t c2 = (cc2 * n * n) >> 12;
@@ -278,14 +283,14 @@ double ssimv_similarity2(Ssimv *sv, int64_t n) {
return l * v;
}
-void ssimv_parms(uint8_t *img1, int img1_pitch, uint8_t *img2, int img2_pitch,
- Ssimv *sv) {
- vp9_ssim_parms_8x8(img1, img1_pitch, img2, img2_pitch,
+static void ssimv_parms(uint8_t *img1, int img1_pitch, uint8_t *img2,
+ int img2_pitch, Ssimv *sv) {
+ vpx_ssim_parms_8x8(img1, img1_pitch, img2, img2_pitch,
&sv->sum_s, &sv->sum_r, &sv->sum_sq_s, &sv->sum_sq_r,
&sv->sum_sxr);
}
-double vp9_get_ssim_metrics(uint8_t *img1, int img1_pitch,
+double vpx_get_ssim_metrics(uint8_t *img1, int img1_pitch,
uint8_t *img2, int img2_pitch,
int width, int height,
Ssimv *sv2, Metrics *m,
@@ -298,7 +303,7 @@ double vp9_get_ssim_metrics(uint8_t *img1, int img1_pitch,
int c = 0;
double norm;
double old_ssim_total = 0;
- vp9_clear_system_state();
+ vpx_clear_system_state();
// We can sample points as frequently as we like start with 1 per 4x4.
for (i = 0; i < height; i += 4,
img1 += img1_pitch * 4, img2 += img2_pitch * 4) {
@@ -448,21 +453,21 @@ double vp9_get_ssim_metrics(uint8_t *img1, int img1_pitch,
#if CONFIG_VP9_HIGHBITDEPTH
-double vp9_highbd_calc_ssim(YV12_BUFFER_CONFIG *source,
- YV12_BUFFER_CONFIG *dest,
+double vpx_highbd_calc_ssim(const YV12_BUFFER_CONFIG *source,
+ const YV12_BUFFER_CONFIG *dest,
double *weight, unsigned int bd) {
double a, b, c;
double ssimv;
- a = vp9_highbd_ssim2(source->y_buffer, dest->y_buffer,
+ a = vpx_highbd_ssim2(source->y_buffer, dest->y_buffer,
source->y_stride, dest->y_stride,
source->y_crop_width, source->y_crop_height, bd);
- b = vp9_highbd_ssim2(source->u_buffer, dest->u_buffer,
+ b = vpx_highbd_ssim2(source->u_buffer, dest->u_buffer,
source->uv_stride, dest->uv_stride,
source->uv_crop_width, source->uv_crop_height, bd);
- c = vp9_highbd_ssim2(source->v_buffer, dest->v_buffer,
+ c = vpx_highbd_ssim2(source->v_buffer, dest->v_buffer,
source->uv_stride, dest->uv_stride,
source->uv_crop_width, source->uv_crop_height, bd);
@@ -473,21 +478,21 @@ double vp9_highbd_calc_ssim(YV12_BUFFER_CONFIG *source,
return ssimv;
}
-double vp9_highbd_calc_ssimg(YV12_BUFFER_CONFIG *source,
- YV12_BUFFER_CONFIG *dest, double *ssim_y,
+double vpx_highbd_calc_ssimg(const YV12_BUFFER_CONFIG *source,
+ const YV12_BUFFER_CONFIG *dest, double *ssim_y,
double *ssim_u, double *ssim_v, unsigned int bd) {
double ssim_all = 0;
double a, b, c;
- a = vp9_highbd_ssim2(source->y_buffer, dest->y_buffer,
+ a = vpx_highbd_ssim2(source->y_buffer, dest->y_buffer,
source->y_stride, dest->y_stride,
source->y_crop_width, source->y_crop_height, bd);
- b = vp9_highbd_ssim2(source->u_buffer, dest->u_buffer,
+ b = vpx_highbd_ssim2(source->u_buffer, dest->u_buffer,
source->uv_stride, dest->uv_stride,
source->uv_crop_width, source->uv_crop_height, bd);
- c = vp9_highbd_ssim2(source->v_buffer, dest->v_buffer,
+ c = vpx_highbd_ssim2(source->v_buffer, dest->v_buffer,
source->uv_stride, dest->uv_stride,
source->uv_crop_width, source->uv_crop_height, bd);
*ssim_y = a;
« no previous file with comments | « source/libvpx/vpx_dsp/ssim.h ('k') | source/libvpx/vpx_dsp/variance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698