mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-12 00:37:19 +00:00
Review
This commit is contained in:
@@ -7,7 +7,7 @@ using namespace butteraugli;
|
|||||||
|
|
||||||
// Turns an interleaved RGBA buffer into 4 planes for each color channel
|
// Turns an interleaved RGBA buffer into 4 planes for each color channel
|
||||||
void planarize(std::vector<ImageF>& img,
|
void planarize(std::vector<ImageF>& img,
|
||||||
const char* rgba,
|
const uint8_t* rgba,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
float gamma = 2.2) {
|
float gamma = 2.2) {
|
||||||
@@ -22,10 +22,10 @@ void planarize(std::vector<ImageF>& img,
|
|||||||
float* const row_b = img[2].Row(y);
|
float* const row_b = img[2].Row(y);
|
||||||
float* const row_a = img[3].Row(y);
|
float* const row_a = img[3].Row(y);
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
row_r[x] = 255.0 * pow((uint8_t)rgba[(y * width + x) * 4 + 0] / 255.0, gamma);
|
row_r[x] = 255.0 * pow(rgba[(y * width + x) * 4 + 0] / 255.0, gamma);
|
||||||
row_g[x] = 255.0 * pow((uint8_t)rgba[(y * width + x) * 4 + 1] / 255.0, gamma);
|
row_g[x] = 255.0 * pow(rgba[(y * width + x) * 4 + 1] / 255.0, gamma);
|
||||||
row_b[x] = 255.0 * pow((uint8_t)rgba[(y * width + x) * 4 + 2] / 255.0, gamma);
|
row_b[x] = 255.0 * pow(rgba[(y * width + x) * 4 + 2] / 255.0, gamma);
|
||||||
row_a[x] = 255.0 * pow((uint8_t)rgba[(y * width + x) * 4 + 3] / 255.0, gamma);
|
row_a[x] = 255.0 * pow(rgba[(y * width + x) * 4 + 3] / 255.0, gamma);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,14 +37,14 @@ class VisDiff {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
VisDiff(std::string ref_img, int width, int height) {
|
VisDiff(std::string ref_img, int width, int height) {
|
||||||
planarize(this->ref_img, ref_img.c_str(), width, height);
|
planarize(this->ref_img, (uint8_t*)ref_img.c_str(), width, height);
|
||||||
this->width = width;
|
this->width = width;
|
||||||
this->height = height;
|
this->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
double distance(std::string other_img) {
|
double distance(std::string other_img) {
|
||||||
std::vector<ImageF> img;
|
std::vector<ImageF> img;
|
||||||
planarize(img, other_img.c_str(), width, height);
|
planarize(img, (uint8_t*)other_img.c_str(), width, height);
|
||||||
|
|
||||||
ImageF diffmap;
|
ImageF diffmap;
|
||||||
double diffvalue;
|
double diffvalue;
|
||||||
|
|||||||
12
codecs/visdif/visdif.js
generated
12
codecs/visdif/visdif.js
generated
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
var visdif = (function() {
|
var visdif = (function() {
|
||||||
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
var _scriptDir = import.meta.url;
|
||||||
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
|
|
||||||
return (
|
return (
|
||||||
function(visdif) {
|
function(visdif) {
|
||||||
visdif = visdif || {};
|
visdif = visdif || {};
|
||||||
@@ -71,10 +71,4 @@ f.run=Wb;if(f.preInit)for("function"==typeof f.preInit&&(f.preInit=[f.preInit]);
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
})();
|
})();
|
||||||
if (typeof exports === 'object' && typeof module === 'object')
|
export default visdif;
|
||||||
module.exports = visdif;
|
|
||||||
else if (typeof define === 'function' && define['amd'])
|
|
||||||
define([], function() { return visdif; });
|
|
||||||
else if (typeof exports === 'object')
|
|
||||||
exports["visdif"] = visdif;
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user