Skip to content

Commit

Permalink
Merge branch 'master' into msvc
Browse files Browse the repository at this point in the history
* master:
  Bump
  Alternative adjustment step
  Adjusted max error
  Tweaks
  Do not enable SSE feature for ARM64 by default
  Install library with execute permission
  • Loading branch information
kornelski committed Nov 14, 2021
2 parents f41ee30 + a6cc4ad commit e4c1334
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 22 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ file(READ version.txt VERSION)

project(imagequant C)

option(BUILD_WITH_SSE "Use SSE" ON)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL ARM64)
option(BUILD_WITH_SSE "Use SSE" OFF)
else()
option(BUILD_WITH_SSE "Use SSE" ON)
endif()

if(BUILD_WITH_SSE)
add_definitions(-DUSE_SSE=1)
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# libimagequant is a pure C library.
# Rust/Cargo is entirely optional. You can also use ./configure && make
[package]
version = "3.1.0+sys2.16.0"
version = "3.1.1+sys2.17.0"
authors = ["Kornel Lesiński <kornel@pngquant.org>"]
build = "rust-sys/build.rs"
categories = ["external-ffi-bindings"]
Expand All @@ -17,15 +17,15 @@ description = "Statically linked C part of imagequant library powering tools suc
edition = "2018"

[build-dependencies]
cc = "1.0.58"
cc = "1.0.71"

[dependencies]
rgb = "0.8.25"
bitflags = "1.2.1"
rgb = "0.8.29"
bitflags = "1.3.2"

[dependencies.openmp-sys]
optional = true
version = "1.2.0-alpha.1"
version = "1.2.0"

[features]
default = ["sse"]
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ install: all $(PKGCONFIG)
install -d $(DESTDIR)$(PKGCONFIGDIR)
install -d $(DESTDIR)$(INCLUDEDIR)
install -m 644 $(STATICLIB) $(DESTDIR)$(LIBDIR)/$(STATICLIB)
install -m 644 $(SHAREDLIBVER) $(DESTDIR)$(LIBDIR)/$(SHAREDLIBVER)
install -m 755 $(SHAREDLIBVER) $(DESTDIR)$(LIBDIR)/$(SHAREDLIBVER)
ln -sf $(SHAREDLIBVER) $(DESTDIR)$(LIBDIR)/$(SHAREDLIB)
install -m 644 $(PKGCONFIG) $(DESTDIR)$(PKGCONFIGDIR)/$(PKGCONFIG)
install -m 644 libimagequant.h $(DESTDIR)$(INCLUDEDIR)/libimagequant.h
Expand Down
6 changes: 3 additions & 3 deletions libimagequant.c
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,7 @@ LIQ_NONNULL static void contrast_maps(liq_image *image)
z *= z; // noise is amplified
z *= z;
// 85 is about 1/3rd of weight (not 0, because noisy pixels still need to be included, just not as precisely).
const unsigned int z_int = 85 + (unsigned int)(z * 171.f);
const unsigned int z_int = 80 + (unsigned int)(z * 176.f);
noise[j*cols+i] = MIN(z_int, 255);
const int e_int = 255 - (int)(edge * 256.f);
edges[j*cols+i] = e_int > 0 ? MIN(e_int, 255) : 0;
Expand Down Expand Up @@ -1877,7 +1877,7 @@ static colormap *add_fixed_colors_to_palette(colormap *palette, const int max_co

LIQ_NONNULL static void adjust_histogram_callback(hist_item *item, float diff)
{
item->adjusted_weight = (item->perceptual_weight+item->adjusted_weight) * (sqrtf(1.f+diff));
item->adjusted_weight = (item->perceptual_weight + 2.0 * item->adjusted_weight) * (0.5 + diff);
}

/**
Expand Down Expand Up @@ -2160,7 +2160,7 @@ LIQ_EXPORT LIQ_NONNULL liq_error liq_write_remapped_image_rows(liq_result *quant
// remapping above was the last chance to do K-Means iteration, hence the final palette is set after remapping
set_rounded_palette(&result->int_palette, result->palette, result->gamma, quant->min_posterization_output);

if (!remap_to_palette_floyd(input_image, row_pointers, result, MAX(remapping_error*2.4, 16.f/256.f), generate_dither_map)) {
if (!remap_to_palette_floyd(input_image, row_pointers, result, MAX(remapping_error*2.4, 8.f/256.f), generate_dither_map)) {
return LIQ_ABORTED;
}
}
Expand Down
2 changes: 1 addition & 1 deletion libimagequant.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#endif

#define LIQ_VERSION 21600
#define LIQ_VERSION_STRING "2.16.0"
#define LIQ_VERSION_STRING "2.17.0"

#ifndef LIQ_PRIVATE
#if defined(__GNUC__) || defined (__llvm__)
Expand Down
19 changes: 9 additions & 10 deletions pam.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,7 @@ LIQ_PRIVATE bool pam_computeacolorhash(struct acolorhash_table *acht, const rgba
const rgba_pixel tmp = pixels[row][col];
union rgba_as_int px = {{tmp.r, tmp.g, tmp.b, tmp.a}};
unsigned int hash;
if (!px.rgba.a) {
// "dirty alpha" has different RGBA values that end up being the same fully transparent color
px.l=0; hash=0;

boost = 2000;
if (importance_map) {
importance_map++;
}
} else {
if (px.rgba.a) {
// mask posterizes all 4 channels in one go
px.l = (px.l & posterize_mask) | ((px.l & posterize_high_mask) >> (8-ignorebits));
// fancier hashing algorithms didn't improve much
Expand All @@ -53,13 +45,20 @@ LIQ_PRIVATE bool pam_computeacolorhash(struct acolorhash_table *acht, const rgba
} else {
boost = 255;
}
} else {
// "dirty alpha" has different RGBA values that end up being the same fully transparent color
px.l=0; hash=0;

boost = 2000;
if (importance_map) {
importance_map++;
}
}

if (!pam_add_to_hash(acht, hash, boost, px, row, rows)) {
return false;
}
}

}
acht->cols = cols;
acht->rows += rows;
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.16.0
2.17.0

0 comments on commit e4c1334

Please sign in to comment.