3
* Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
5
* This file is part of libde265.
7
* libde265 is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU Lesser General Public License as
9
* published by the Free Software Foundation, either version 3 of
10
* the License, or (at your option) any later version.
12
* libde265 is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public License
18
* along with libde265. If not, see <http://www.gnu.org/licenses/>.
25
uint32_t SSD(const uint8_t* img, int imgStride,
26
const uint8_t* ref, int refStride,
27
int width, int height)
31
const uint8_t* iPtr = img;
32
const uint8_t* rPtr = ref;
34
for (int y=0;y<height;y++) {
35
for (int x=0;x<width;x++) {
36
int diff = iPtr[x] - rPtr[x];
48
uint32_t SAD(const uint8_t* img, int imgStride,
49
const uint8_t* ref, int refStride,
50
int width, int height)
54
const uint8_t* iPtr = img;
55
const uint8_t* rPtr = ref;
57
for (int y=0;y<height;y++) {
58
for (int x=0;x<width;x++) {
59
int diff = iPtr[x] - rPtr[x];
60
sum += abs_value(diff);
71
double MSE(const uint8_t* img, int imgStride,
72
const uint8_t* ref, int refStride,
73
int width, int height)
77
const uint8_t* iPtr = img;
78
const uint8_t* rPtr = ref;
80
for (int y=0;y<height;y++) {
83
for (int x=0;x<width;x++) {
84
int diff = iPtr[x] - rPtr[x];
88
sum += ((double)lineSum)/width;
98
double PSNR(double mse)
100
if (mse==0) { return 99.99999; }
102
return 10*log10(255.0*255.0/mse);
105
uint32_t compute_distortion_ssd(const de265_image* img1, const de265_image* img2,
106
int x0, int y0, int log2size, int cIdx)
108
return SSD(img1->get_image_plane_at_pos(cIdx,x0,y0), img1->get_image_stride(cIdx),
109
img2->get_image_plane_at_pos(cIdx,x0,y0), img2->get_image_stride(cIdx),
110
1<<log2size, 1<<log2size);