Commit 0a81d36a authored by Jingning Han's avatar Jingning Han
Browse files

Replace vp10_ssim functions with vpx_ssim versions

Remove the ssim files from vp10 folder.

Change-Id: Icc1d9d61a0878d53584328b278dfa090aa070035
parent 54d66ef1
...@@ -261,17 +261,6 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") { ...@@ -261,17 +261,6 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
specialize qw/vp10_fdct8x8_quant sse2 ssse3 neon/; specialize qw/vp10_fdct8x8_quant sse2 ssse3 neon/;
} }
#
# Structured Similarity (SSIM)
#
if (vpx_config("CONFIG_INTERNAL_STATS") eq "yes") {
add_proto qw/void vp10_ssim_parms_8x8/, "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";
specialize qw/vp10_ssim_parms_8x8/, "$sse2_x86_64";
add_proto qw/void vp10_ssim_parms_16x16/, "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";
specialize qw/vp10_ssim_parms_16x16/, "$sse2_x86_64";
}
# fdct functions # fdct functions
if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") { if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
...@@ -330,14 +319,6 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") { ...@@ -330,14 +319,6 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
add_proto qw/void vp10_highbd_quantize_fp_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan"; add_proto qw/void vp10_highbd_quantize_fp_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
specialize qw/vp10_highbd_quantize_fp_32x32/; specialize qw/vp10_highbd_quantize_fp_32x32/;
#
# Structured Similarity (SSIM)
#
if (vpx_config("CONFIG_INTERNAL_STATS") eq "yes") {
add_proto qw/void vp10_highbd_ssim_parms_8x8/, "uint16_t *s, int sp, 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";
specialize qw/vp10_highbd_ssim_parms_8x8/;
}
# fdct functions # fdct functions
add_proto qw/void vp10_highbd_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, int tx_type"; add_proto qw/void vp10_highbd_fht4x4/, "const int16_t *input, tran_low_t *output, int stride, int tx_type";
specialize qw/vp10_highbd_fht4x4/; specialize qw/vp10_highbd_fht4x4/;
......
...@@ -54,8 +54,8 @@ static int variance(int sum, int sum_squared, int size) { ...@@ -54,8 +54,8 @@ static int variance(int sum, int sum_squared, int size) {
// var_1 = (r0^2+r1^2+r2^2+r3^2) - ((r0 + r1 + r2 + r3) / 4 )^2 // var_1 = (r0^2+r1^2+r2^2+r3^2) - ((r0 + r1 + r2 + r3) / 4 )^2
// The returned blockiness is the scaled value // The returned blockiness is the scaled value
// Reconstructed blockiness / ( 1 + var_0 + var_1 ) ; // Reconstructed blockiness / ( 1 + var_0 + var_1 ) ;
int blockiness_vertical(const uint8_t *s, int sp, const uint8_t *r, int rp, static int blockiness_vertical(const uint8_t *s, int sp, const uint8_t *r,
int size) { int rp, int size) {
int s_blockiness = 0; int s_blockiness = 0;
int r_blockiness = 0; int r_blockiness = 0;
int sum_0 = 0; int sum_0 = 0;
...@@ -86,8 +86,8 @@ int blockiness_vertical(const uint8_t *s, int sp, const uint8_t *r, int rp, ...@@ -86,8 +86,8 @@ int blockiness_vertical(const uint8_t *s, int sp, const uint8_t *r, int rp,
// Calculate a blockiness level for a horizontal block edge // Calculate a blockiness level for a horizontal block edge
// same as above. // same as above.
int blockiness_horizontal(const uint8_t *s, int sp, const uint8_t *r, int rp, static int blockiness_horizontal(const uint8_t *s, int sp, const uint8_t *r,
int size) { int rp, int size) {
int s_blockiness = 0; int s_blockiness = 0;
int r_blockiness = 0; int r_blockiness = 0;
int sum_0 = 0; int sum_0 = 0;
......
...@@ -12,15 +12,7 @@ ...@@ -12,15 +12,7 @@
#include <stdio.h> #include <stdio.h>
#include <limits.h> #include <limits.h>
#include "./vp10_rtcd.h"
#include "./vpx_config.h" #include "./vpx_config.h"
#include "./vpx_dsp_rtcd.h"
#include "./vpx_scale_rtcd.h"
#include "vpx/internal/vpx_psnr.h"
#include "vpx_dsp/vpx_filter.h"
#include "vpx_ports/mem.h"
#include "vpx_ports/vpx_timer.h"
#include "vpx_scale/vpx_scale.h"
#include "vp10/common/alloccommon.h" #include "vp10/common/alloccommon.h"
#include "vp10/common/filter.h" #include "vp10/common/filter.h"
...@@ -51,12 +43,21 @@ ...@@ -51,12 +43,21 @@
#include "vp10/encoder/segmentation.h" #include "vp10/encoder/segmentation.h"
#include "vp10/encoder/skin_detection.h" #include "vp10/encoder/skin_detection.h"
#include "vp10/encoder/speed_features.h" #include "vp10/encoder/speed_features.h"
#if CONFIG_INTERNAL_STATS
#include "vp10/encoder/ssim.h"
#endif
#include "vp10/encoder/svc_layercontext.h" #include "vp10/encoder/svc_layercontext.h"
#include "vp10/encoder/temporal_filter.h" #include "vp10/encoder/temporal_filter.h"
#include "./vp10_rtcd.h"
#include "./vpx_dsp_rtcd.h"
#include "./vpx_scale_rtcd.h"
#include "vpx/internal/vpx_psnr.h"
#if CONFIG_INTERNAL_STATS
#include "vpx_dsp/ssim.h"
#endif
#include "vpx_dsp/vpx_filter.h"
#include "vpx_ports/mem.h"
#include "vpx_ports/vpx_timer.h"
#include "vpx_scale/vpx_scale.h"
#define AM_SEGMENT_ID_INACTIVE 7 #define AM_SEGMENT_ID_INACTIVE 7
#define AM_SEGMENT_ID_ACTIVE 0 #define AM_SEGMENT_ID_ACTIVE 0
...@@ -4416,13 +4417,13 @@ int vp10_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, ...@@ -4416,13 +4417,13 @@ int vp10_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
if (cm->use_highbitdepth) { if (cm->use_highbitdepth) {
frame_ssim2 = vp10_highbd_calc_ssim(orig, recon, &weight, frame_ssim2 = vpx_highbd_calc_ssim(orig, recon, &weight,
(int)cm->bit_depth); (int)cm->bit_depth);
} else { } else {
frame_ssim2 = vp10_calc_ssim(orig, recon, &weight); frame_ssim2 = vpx_calc_ssim(orig, recon, &weight);
} }
#else #else
frame_ssim2 = vp10_calc_ssim(orig, recon, &weight); frame_ssim2 = vpx_calc_ssim(orig, recon, &weight);
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
cpi->worst_ssim= MIN(cpi->worst_ssim, frame_ssim2); cpi->worst_ssim= MIN(cpi->worst_ssim, frame_ssim2);
...@@ -4431,13 +4432,13 @@ int vp10_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, ...@@ -4431,13 +4432,13 @@ int vp10_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
if (cm->use_highbitdepth) { if (cm->use_highbitdepth) {
frame_ssim2 = vp10_highbd_calc_ssim( frame_ssim2 = vpx_highbd_calc_ssim(
orig, &cm->post_proc_buffer, &weight, (int)cm->bit_depth); orig, &cm->post_proc_buffer, &weight, (int)cm->bit_depth);
} else { } else {
frame_ssim2 = vp10_calc_ssim(orig, &cm->post_proc_buffer, &weight); frame_ssim2 = vpx_calc_ssim(orig, &cm->post_proc_buffer, &weight);
} }
#else #else
frame_ssim2 = vp10_calc_ssim(orig, &cm->post_proc_buffer, &weight); frame_ssim2 = vpx_calc_ssim(orig, &cm->post_proc_buffer, &weight);
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
cpi->summedp_quality += frame_ssim2 * weight; cpi->summedp_quality += frame_ssim2 * weight;
...@@ -4472,7 +4473,7 @@ int vp10_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, ...@@ -4472,7 +4473,7 @@ int vp10_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
if (!cm->use_highbitdepth) if (!cm->use_highbitdepth)
#endif #endif
{ {
double this_inconsistency = vp10_get_ssim_metrics( double this_inconsistency = vpx_get_ssim_metrics(
cpi->Source->y_buffer, cpi->Source->y_stride, cpi->Source->y_buffer, cpi->Source->y_stride,
cm->frame_to_show->y_buffer, cm->frame_to_show->y_stride, cm->frame_to_show->y_buffer, cm->frame_to_show->y_stride,
cpi->Source->y_width, cpi->Source->y_height, cpi->ssim_vars, cpi->Source->y_width, cpi->Source->y_height, cpi->ssim_vars,
...@@ -4492,14 +4493,14 @@ int vp10_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, ...@@ -4492,14 +4493,14 @@ int vp10_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
double y, u, v, frame_all; double y, u, v, frame_all;
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
if (cm->use_highbitdepth) { if (cm->use_highbitdepth) {
frame_all = vp10_highbd_calc_ssimg(cpi->Source, cm->frame_to_show, &y, frame_all = vpx_highbd_calc_ssimg(cpi->Source, cm->frame_to_show, &y,
&u, &v, (int)cm->bit_depth); &u, &v, (int)cm->bit_depth);
} else { } else {
frame_all = vp10_calc_ssimg(cpi->Source, cm->frame_to_show, &y, &u, frame_all = vpx_calc_ssimg(cpi->Source, cm->frame_to_show, &y, &u,
&v); &v);
} }
#else #else
frame_all = vp10_calc_ssimg(cpi->Source, cm->frame_to_show, &y, &u, &v); frame_all = vpx_calc_ssimg(cpi->Source, cm->frame_to_show, &y, &u, &v);
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
adjust_image_stat(y, u, v, frame_all, &cpi->ssimg); adjust_image_stat(y, u, v, frame_all, &cpi->ssimg);
} }
...@@ -4508,7 +4509,7 @@ int vp10_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, ...@@ -4508,7 +4509,7 @@ int vp10_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
#endif #endif
{ {
double y, u, v, frame_all; double y, u, v, frame_all;
frame_all = vp10_calc_fastssim(cpi->Source, cm->frame_to_show, &y, &u, frame_all = vpx_calc_fastssim(cpi->Source, cm->frame_to_show, &y, &u,
&v); &v);
adjust_image_stat(y, u, v, frame_all, &cpi->fastssim); adjust_image_stat(y, u, v, frame_all, &cpi->fastssim);
/* TODO(JBB): add 10/12 bit support */ /* TODO(JBB): add 10/12 bit support */
...@@ -4518,12 +4519,11 @@ int vp10_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, ...@@ -4518,12 +4519,11 @@ int vp10_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
#endif #endif
{ {
double y, u, v, frame_all; double y, u, v, frame_all;
frame_all = vp10_psnrhvs(cpi->Source, cm->frame_to_show, &y, &u, &v); frame_all = vpx_psnrhvs(cpi->Source, cm->frame_to_show, &y, &u, &v);
adjust_image_stat(y, u, v, frame_all, &cpi->psnrhvs); adjust_image_stat(y, u, v, frame_all, &cpi->psnrhvs);
} }
} }
} }
#endif #endif
if (is_two_pass_svc(cpi)) { if (is_two_pass_svc(cpi)) {
......
...@@ -14,9 +14,7 @@ ...@@ -14,9 +14,7 @@
#include <stdio.h> #include <stdio.h>
#include "./vpx_config.h" #include "./vpx_config.h"
#include "vpx/internal/vpx_codec_internal.h"
#include "vpx/vp8cx.h" #include "vpx/vp8cx.h"
#include "vpx_util/vpx_thread.h"
#include "vp10/common/alloccommon.h" #include "vp10/common/alloccommon.h"
#include "vp10/common/ppflags.h" #include "vp10/common/ppflags.h"
...@@ -34,18 +32,21 @@ ...@@ -34,18 +32,21 @@
#include "vp10/encoder/quantize.h" #include "vp10/encoder/quantize.h"
#include "vp10/encoder/ratectrl.h" #include "vp10/encoder/ratectrl.h"
#include "vp10/encoder/rd.h" #include "vp10/encoder/rd.h"
#if CONFIG_INTERNAL_STATS
#include "vp10/encoder/ssim.h"
#endif
#include "vp10/encoder/speed_features.h" #include "vp10/encoder/speed_features.h"
#include "vp10/encoder/svc_layercontext.h" #include "vp10/encoder/svc_layercontext.h"
#include "vp10/encoder/tokenize.h" #include "vp10/encoder/tokenize.h"
#include "vpx_dsp/variance.h"
#if CONFIG_VP9_TEMPORAL_DENOISING #if CONFIG_VP9_TEMPORAL_DENOISING
#include "vp10/encoder/denoiser.h" #include "vp10/encoder/denoiser.h"
#endif #endif
#if CONFIG_INTERNAL_STATS
#include "vpx_dsp/ssim.h"
#endif
#include "vpx_dsp/variance.h"
#include "vpx/internal/vpx_codec_internal.h"
#include "vpx_util/vpx_thread.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
......
/*
* 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.
*
* This code was originally written by: Nathan E. Egge, at the Daala
* project.
*/
#include <math.h>
#include <string.h>
#include "./vpx_config.h"
#include "./vp10_rtcd.h"
#include "vp10/encoder/ssim.h"
/* TODO(jbb): High bit depth version of this code needed */
typedef struct fs_level fs_level;
typedef struct fs_ctx fs_ctx;
#define SSIM_C1 (255 * 255 * 0.01 * 0.01)
#define SSIM_C2 (255 * 255 * 0.03 * 0.03)
#define FS_MINI(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define FS_MAXI(_a, _b) ((_a) > (_b) ? (_a) : (_b))
struct fs_level {
uint16_t *im1;
uint16_t *im2;
double *ssim;
int w;
int h;
};
struct fs_ctx {
fs_level *level;
int nlevels;
unsigned *col_buf;
};
static void fs_ctx_init(fs_ctx *_ctx, int _w, int _h, int _nlevels) {
unsigned char *data;
size_t data_size;
int lw;
int lh;
int l;
lw = (_w + 1) >> 1;
lh = (_h + 1) >> 1;
data_size = _nlevels * sizeof(fs_level)
+ 2 * (lw + 8) * 8 * sizeof(*_ctx->col_buf);
for (l = 0; l < _nlevels; l++) {
size_t im_size;
size_t level_size;
im_size = lw * (size_t) lh;
level_size = 2 * im_size * sizeof(*_ctx->level[l].im1);
level_size += sizeof(*_ctx->level[l].ssim) - 1;
level_size /= sizeof(*_ctx->level[l].ssim);
level_size += im_size;
level_size *= sizeof(*_ctx->level[l].ssim);
data_size += level_size;
lw = (lw + 1) >> 1;
lh = (lh + 1) >> 1;
}
data = (unsigned char *) malloc(data_size);
_ctx->level = (fs_level *) data;
_ctx->nlevels = _nlevels;
data += _nlevels * sizeof(*_ctx->level);
lw = (_w + 1) >> 1;
lh = (_h + 1) >> 1;
for (l = 0; l < _nlevels; l++) {
size_t im_size;
size_t level_size;
_ctx->level[l].w = lw;
_ctx->level[l].h = lh;
im_size = lw * (size_t) lh;
level_size = 2 * im_size * sizeof(*_ctx->level[l].im1);
level_size += sizeof(*_ctx->level[l].ssim) - 1;
level_size /= sizeof(*_ctx->level[l].ssim);
level_size *= sizeof(*_ctx->level[l].ssim);
_ctx->level[l].im1 = (uint16_t *) data;
_ctx->level[l].im2 = _ctx->level[l].im1 + im_size;
data += level_size;
_ctx->level[l].ssim = (double *) data;
data += im_size * sizeof(*_ctx->level[l].ssim);
lw = (lw + 1) >> 1;
lh = (lh + 1) >> 1;
}
_ctx->col_buf = (unsigned *) data;
}
static void fs_ctx_clear(fs_ctx *_ctx) {
free(_ctx->level);
}
static void fs_downsample_level(fs_ctx *_ctx, int _l) {
const uint16_t *src1;
const uint16_t *src2;
uint16_t *dst1;
uint16_t *dst2;
int w2;
int h2;
int w;
int h;
int i;
int j;
w = _ctx->level[_l].w;
h = _ctx->level[_l].h;
dst1 = _ctx->level[_l].im1;
dst2 = _ctx->level[_l].im2;
w2 = _ctx->level[_l - 1].w;
h2 = _ctx->level[_l - 1].h;
src1 = _ctx->level[_l - 1].im1;
src2 = _ctx->level[_l - 1].im2;
for (j = 0; j < h; j++) {
int j0offs;
int j1offs;
j0offs = 2 * j * w2;
j1offs = FS_MINI(2 * j + 1, h2) * w2;
for (i = 0; i < w; i++) {
int i0;
int i1;
i0 = 2 * i;
i1 = FS_MINI(i0 + 1, w2);
dst1[j * w + i] = src1[j0offs + i0] + src1[j0offs + i1]
+ src1[j1offs + i0] + src1[j1offs + i1];
dst2[j * w + i] = src2[j0offs + i0] + src2[j0offs + i1]
+ src2[j1offs + i0] + src2[j1offs + i1];
}
}
}
static void fs_downsample_level0(fs_ctx *_ctx, const unsigned char *_src1,
int _s1ystride, const unsigned char *_src2,
int _s2ystride, int _w, int _h) {
uint16_t *dst1;
uint16_t *dst2;
int w;
int h;
int i;
int j;
w = _ctx->level[0].w;
h = _ctx->level[0].h;
dst1 = _ctx->level[0].im1;
dst2 = _ctx->level[0].im2;
for (j = 0; j < h; j++) {
int j0;
int j1;
j0 = 2 * j;
j1 = FS_MINI(j0 + 1, _h);
for (i = 0; i < w; i++) {
int i0;
int i1;
i0 = 2 * i;
i1 = FS_MINI(i0 + 1, _w);
dst1[j * w + i] = _src1[j0 * _s1ystride + i0]
+ _src1[j0 * _s1ystride + i1] + _src1[j1 * _s1ystride + i0]
+ _src1[j1 * _s1ystride + i1];
dst2[j * w + i] = _src2[j0 * _s2ystride + i0]
+ _src2[j0 * _s2ystride + i1] + _src2[j1 * _s2ystride + i0]
+ _src2[j1 * _s2ystride + i1];
}
}
}
static void fs_apply_luminance(fs_ctx *_ctx, int _l) {
unsigned *col_sums_x;
unsigned *col_sums_y;
uint16_t *im1;
uint16_t *im2;
double *ssim;
double c1;
int w;
int h;
int j0offs;
int j1offs;
int i;
int j;
w = _ctx->level[_l].w;
h = _ctx->level[_l].h;
col_sums_x = _ctx->col_buf;
col_sums_y = col_sums_x + w;
im1 = _ctx->level[_l].im1;
im2 = _ctx->level[_l].im2;
for (i = 0; i < w; i++)
col_sums_x[i] = 5 * im1[i];
for (i = 0; i < w; i++)
col_sums_y[i] = 5 * im2[i];
for (j = 1; j < 4; j++) {
j1offs = FS_MINI(j, h - 1) * w;
for (i = 0; i < w; i++)
col_sums_x[i] += im1[j1offs + i];
for (i = 0; i < w; i++)
col_sums_y[i] += im2[j1offs + i];
}
ssim = _ctx->level[_l].ssim;
c1 = (double) (SSIM_C1 * 4096 * (1 << 4 * _l));
for (j = 0; j < h; j++) {
unsigned mux;
unsigned muy;
int i0;
int i1;
mux = 5 * col_sums_x[0];
muy = 5 * col_sums_y[0];
for (i = 1; i < 4; i++) {
i1 = FS_MINI(i, w - 1);
mux += col_sums_x[i1];
muy += col_sums_y[i1];
}
for (i = 0; i < w; i++) {
ssim[j * w + i] *= (2 * mux * (double) muy + c1)
/ (mux * (double) mux + muy * (double) muy + c1);
if (i + 1 < w) {
i0 = FS_MAXI(0, i - 4);
i1 = FS_MINI(i + 4, w - 1);
mux += col_sums_x[i1] - col_sums_x[i0];
muy += col_sums_x[i1] - col_sums_x[i0];
}
}
if (j + 1 < h) {
j0offs = FS_MAXI(0, j - 4) * w;
for (i = 0; i < w; i++)
col_sums_x[i] -= im1[j0offs + i];
for (i = 0; i < w; i++)
col_sums_y[i] -= im2[j0offs + i];
j1offs = FS_MINI(j + 4, h - 1) * w;
for (i = 0; i < w; i++)
col_sums_x[i] += im1[j1offs + i];
for (i = 0; i < w; i++)
col_sums_y[i] += im2[j1offs + i];
}
}
}
#define FS_COL_SET(_col, _joffs, _ioffs) \
do { \
unsigned gx; \
unsigned gy; \
gx = gx_buf[((j + (_joffs)) & 7) * stride + i + (_ioffs)]; \
gy = gy_buf[((j + (_joffs)) & 7) * stride + i + (_ioffs)]; \
col_sums_gx2[(_col)] = gx * (double)gx; \
col_sums_gy2[(_col)] = gy * (double)gy; \
col_sums_gxgy[(_col)] = gx * (double)gy; \
} \
while (0)
#define FS_COL_ADD(_col, _joffs, _ioffs) \
do { \
unsigned gx; \
unsigned gy; \
gx = gx_buf[((j + (_joffs)) & 7) * stride + i + (_ioffs)]; \
gy = gy_buf[((j + (_joffs)) & 7) * stride + i + (_ioffs)]; \
col_sums_gx2[(_col)] += gx * (double)gx; \
col_sums_gy2[(_col)] += gy * (double)gy; \
col_sums_gxgy[(_col)] += gx * (double)gy; \
} \
while (0)
#define FS_COL_SUB(_col, _joffs, _ioffs) \
do { \
unsigned gx; \
unsigned gy; \
gx = gx_buf[((j + (_joffs)) & 7) * stride + i + (_ioffs)]; \
gy = gy_buf[((j + (_joffs)) & 7) * stride + i + (_ioffs)]; \
col_sums_gx2[(_col)] -= gx * (double)gx; \
col_sums_gy2[(_col)] -= gy * (double)gy; \
col_sums_gxgy[(_col)] -= gx * (double)gy; \
} \
while (0)
#define FS_COL_COPY(_col1, _col2) \
do { \
col_sums_gx2[(_col1)] = col_sums_gx2[(_col2)]; \
col_sums_gy2[(_col1)] = col_sums_gy2[(_col2)]; \
col_sums_gxgy[(_col1)] = col_sums_gxgy[(_col2)]; \
} \
while (0)
#define FS_COL_HALVE(_col1, _col2) \
do { \
col_sums_gx2[(_col1)] = col_sums_gx2[(_col2)] * 0.5; \
col_sums_gy2[(_col1)] = col_sums_gy2[(_col2)] * 0.5; \
col_sums_gxgy[(_col1)] = col_sums_gxgy[(_col2)] * 0.5; \
} \
while (0)
#define FS_COL_DOUBLE(_col1, _col2) \
do { \
col_sums_gx2[(_col1)] = col_sums_gx2[(_col2)] * 2; \
col_sums_gy2[(_col1)] = col_sums_gy2[(_col2)] * 2; \
col_sums_gxgy[(_col1)] = col_sums_gxgy[(_col2)] * 2; \
} \
while (0)
static void fs_calc_structure(fs_ctx *_ctx, int _l) {
uint16_t *im1;
uint16_t *im2;
unsigned *gx_buf;
unsigned *gy_buf;
double *ssim;
double col_sums_gx2[8];
double col_sums_gy2[8];
double col_sums_gxgy[8];
double c2;
int stride;
int w;
int h;
int i;
int j;
w = _ctx->level[_l].w;
h = _ctx->level[_l].h;