summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/libwebp/src/enc/picture_psnr_enc.c
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2019-11-21 13:50:25 +0100
committerEirik Aavitsland <eirik.aavitsland@qt.io>2019-11-29 09:57:36 +0100
commit218e5a342b289edeac82dbebf9ab62f893964dc2 (patch)
tree4f37d3c2b3866e18700765316805f0fd2ede7960 /src/3rdparty/libwebp/src/enc/picture_psnr_enc.c
parent35382896a4c8f155d45a02ecfc5479b5d6e0db47 (diff)
Update bundled libwebp to version 1.0.3
[ChangeLog][Third-Party Code] Update bundled libwebp to version 1.0.3 (This is a squashed cherry pick from 5.12 branch) Change-Id: I177a6818c5e073298fc565f91d4126af628b7639 Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'src/3rdparty/libwebp/src/enc/picture_psnr_enc.c')
-rw-r--r--src/3rdparty/libwebp/src/enc/picture_psnr_enc.c55
1 files changed, 50 insertions, 5 deletions
diff --git a/src/3rdparty/libwebp/src/enc/picture_psnr_enc.c b/src/3rdparty/libwebp/src/enc/picture_psnr_enc.c
index 9c0b229..1a2f0be 100644
--- a/src/3rdparty/libwebp/src/enc/picture_psnr_enc.c
+++ b/src/3rdparty/libwebp/src/enc/picture_psnr_enc.c
@@ -11,11 +11,16 @@
//
// Author: Skal (pascal.massimino@gmail.com)
+#include "src/webp/encode.h"
+
+#if !(defined(WEBP_DISABLE_STATS) || defined(WEBP_REDUCE_SIZE))
+
#include <math.h>
#include <stdlib.h>
-#include "./vp8i_enc.h"
-#include "../utils/utils.h"
+#include "src/dsp/dsp.h"
+#include "src/enc/vp8i_enc.h"
+#include "src/utils/utils.h"
typedef double (*AccumulateFunc)(const uint8_t* src, int src_stride,
const uint8_t* ref, int ref_stride,
@@ -165,6 +170,12 @@ int WebPPlaneDistortion(const uint8_t* src, size_t src_stride,
return 1;
}
+#ifdef WORDS_BIGENDIAN
+#define BLUE_OFFSET 3 // uint32_t 0x000000ff is 0x00,00,00,ff in memory
+#else
+#define BLUE_OFFSET 0 // uint32_t 0x000000ff is 0xff,00,00,00 in memory
+#endif
+
int WebPPictureDistortion(const WebPPicture* src, const WebPPicture* ref,
int type, float results[5]) {
int w, h, c;
@@ -191,8 +202,10 @@ int WebPPictureDistortion(const WebPPicture* src, const WebPPicture* ref,
float distortion;
const size_t stride0 = 4 * (size_t)p0.argb_stride;
const size_t stride1 = 4 * (size_t)p1.argb_stride;
- if (!WebPPlaneDistortion((const uint8_t*)p0.argb + c, stride0,
- (const uint8_t*)p1.argb + c, stride1,
+ // results are reported as BGRA
+ const int offset = c ^ BLUE_OFFSET;
+ if (!WebPPlaneDistortion((const uint8_t*)p0.argb + offset, stride0,
+ (const uint8_t*)p1.argb + offset, stride1,
w, h, 4, type, &distortion, results + c)) {
goto Error;
}
@@ -210,4 +223,36 @@ int WebPPictureDistortion(const WebPPicture* src, const WebPPicture* ref,
return ok;
}
-//------------------------------------------------------------------------------
+#undef BLUE_OFFSET
+
+#else // defined(WEBP_DISABLE_STATS)
+int WebPPlaneDistortion(const uint8_t* src, size_t src_stride,
+ const uint8_t* ref, size_t ref_stride,
+ int width, int height, size_t x_step,
+ int type, float* distortion, float* result) {
+ (void)src;
+ (void)src_stride;
+ (void)ref;
+ (void)ref_stride;
+ (void)width;
+ (void)height;
+ (void)x_step;
+ (void)type;
+ if (distortion == NULL || result == NULL) return 0;
+ *distortion = 0.f;
+ *result = 0.f;
+ return 1;
+}
+
+int WebPPictureDistortion(const WebPPicture* src, const WebPPicture* ref,
+ int type, float results[5]) {
+ int i;
+ (void)src;
+ (void)ref;
+ (void)type;
+ if (results == NULL) return 0;
+ for (i = 0; i < 5; ++i) results[i] = 0.f;
+ return 1;
+}
+
+#endif // !defined(WEBP_DISABLE_STATS)