Compare commits
No commits in common. "9971e53e0db984da4ca0fd058a5c7d69292ec55d" and "da1696686d3eb75e540478e27097181ce05f4c76" have entirely different histories.
9971e53e0d
...
da1696686d
@ -1,86 +0,0 @@
|
||||
From fd3d56154cc55ab07628f8f2d37e77f60f17874c Mon Sep 17 00:00:00 2001
|
||||
From: Pascal Massimino <skal@google.com>
|
||||
Date: Mon, 8 Mar 2021 11:07:29 +0100
|
||||
Subject: [PATCH] de-recurse hist_item_sort_halfvar()
|
||||
|
||||
This function can recurse quite deep when sorting values are
|
||||
quite flag. We remove the recursion call totally.
|
||||
The API is slightly changed to return the break_at index directly.
|
||||
---
|
||||
mediancut.c | 37 +++++++++++++++++++------------------
|
||||
1 file changed, 19 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/mediancut.c b/mediancut.c
|
||||
index 2c6d1d8..64a21f2 100644
|
||||
--- a/mediancut.c
|
||||
+++ b/mediancut.c
|
||||
@@ -134,34 +134,36 @@ static void hist_item_sort_range(hist_item base[], unsigned int len, unsigned in
|
||||
}
|
||||
|
||||
/** sorts array to make sum of weights lower than halfvar one side, returns edge between <halfvar and >halfvar parts of the set */
|
||||
-static hist_item *hist_item_sort_halfvar(hist_item base[], unsigned int len, double *const lowervar, const double halfvar)
|
||||
+static unsigned int hist_item_sort_halfvar(hist_item base[], unsigned int len, double halfvar)
|
||||
{
|
||||
+ unsigned int base_idx = 0; // track base-index
|
||||
do {
|
||||
const unsigned int l = qsort_partition(base, len), r = l+1;
|
||||
|
||||
// check if sum of left side is smaller than half,
|
||||
// if it is, then it doesn't need to be sorted
|
||||
- unsigned int t = 0; double tmpsum = *lowervar;
|
||||
- while (t <= l && tmpsum < halfvar) tmpsum += base[t++].color_weight;
|
||||
+ double tmpsum = 0.;
|
||||
+ for(unsigned int t = 0; t <= l && tmpsum < halfvar; ++t) tmpsum += base[t].color_weight;
|
||||
|
||||
- if (tmpsum < halfvar) {
|
||||
- *lowervar = tmpsum;
|
||||
- } else {
|
||||
+ // the split is on the left part
|
||||
+ if (tmpsum >= halfvar) {
|
||||
if (l > 0) {
|
||||
- hist_item *res = hist_item_sort_halfvar(base, l, lowervar, halfvar);
|
||||
- if (res) return res;
|
||||
+ len = l;
|
||||
+ continue;
|
||||
} else {
|
||||
- // End of left recursion. This will be executed in order from the first element.
|
||||
- *lowervar += base[0].color_weight;
|
||||
- if (*lowervar > halfvar) return &base[0];
|
||||
+ // End of left recursion;
|
||||
+ return base_idx;
|
||||
}
|
||||
}
|
||||
-
|
||||
+ // process the right part
|
||||
+ halfvar -= tmpsum;
|
||||
if (len > r) {
|
||||
- base += r; len -= r; // tail-recursive "call"
|
||||
+ base += r;
|
||||
+ base_idx += r;
|
||||
+ len -= r; // tail-recursive "call"
|
||||
} else {
|
||||
- *lowervar += base[r].color_weight;
|
||||
- return (*lowervar > halfvar) ? &base[r] : NULL;
|
||||
+ // End of right recursion
|
||||
+ return base_idx + len;
|
||||
}
|
||||
} while(1);
|
||||
}
|
||||
@@ -370,12 +372,11 @@ LIQ_PRIVATE colormap *mediancut(histogram *hist, unsigned int newcolors, const d
|
||||
*/
|
||||
|
||||
const double halfvar = prepare_sort(&bv[bi], achv);
|
||||
- double lowervar=0;
|
||||
|
||||
// hist_item_sort_halfvar sorts and sums lowervar at the same time
|
||||
// returns item to break at …minus one, which does smell like an off-by-one error.
|
||||
- hist_item *break_p = hist_item_sort_halfvar(&achv[indx], clrs, &lowervar, halfvar);
|
||||
- unsigned int break_at = MIN(clrs-1, break_p - &achv[indx] + 1);
|
||||
+ unsigned int break_at = hist_item_sort_halfvar(&achv[indx], clrs, halfvar);
|
||||
+ break_at = MIN(clrs-1, break_at + 1);
|
||||
|
||||
/*
|
||||
** Split the box.
|
||||
--
|
||||
2.42.0.windows.2
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
From 26af56ed7ffbec97640c52145137a5f41ec8213b Mon Sep 17 00:00:00 2001
|
||||
From: Joshua Sager <joshua.sager@shopify.com>
|
||||
Date: Mon, 13 Sep 2021 17:50:33 -0400
|
||||
Subject: [PATCH] Initialize rows using heap for large images
|
||||
|
||||
---
|
||||
libimagequant.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libimagequant.c b/libimagequant.c
|
||||
index 5507614..18b5ef6 100644
|
||||
--- a/libimagequant.c
|
||||
+++ b/libimagequant.c
|
||||
@@ -2100,7 +2100,7 @@ LIQ_EXPORT LIQ_NONNULL liq_error liq_write_remapped_image(liq_result *result, li
|
||||
return LIQ_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
- LIQ_ARRAY(unsigned char *, rows, input_image->height);
|
||||
+ unsigned char **rows = malloc(input_image->height * sizeof(unsigned char *));
|
||||
unsigned char *buffer_bytes = buffer;
|
||||
for(unsigned int i=0; i < input_image->height; i++) {
|
||||
rows[i] = &buffer_bytes[input_image->width * i];
|
||||
--
|
||||
2.42.0.windows.2
|
||||
|
||||
BIN
libimagequant-2.14.0.tar.gz
Normal file
BIN
libimagequant-2.14.0.tar.gz
Normal file
Binary file not shown.
Binary file not shown.
@ -1,17 +1,13 @@
|
||||
Name: libimagequant
|
||||
Version: 2.15.1
|
||||
Release: 4
|
||||
Version: 2.14.0
|
||||
Release: 1
|
||||
Summary: Palette quantization library
|
||||
License: GPLv3+ and MIT
|
||||
URL: https://github.com/ImageOptim/libimagequant
|
||||
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
|
||||
|
||||
Patch0000: libimagequant_solibperm.patch
|
||||
Patch0001: 0001-de-recurse-hist_item_sort_halfvar.patch
|
||||
# https://github.com/ImageOptim/libimagequant/commit/26af56ed7ffbec97640c52145137a5f41ec8213b
|
||||
Patch0002: Initialize-rows-using-heap-for-large-images.patch
|
||||
|
||||
BuildRequires: gcc
|
||||
Patch0001: libimagequant_omp.patch
|
||||
|
||||
%description
|
||||
The portable C library can convert RGBA images into
|
||||
@ -50,21 +46,6 @@ rm -f %{buildroot}%{_libdir}/%{name}.a
|
||||
%{_libdir}/pkgconfig/imagequant.pc
|
||||
|
||||
%changelog
|
||||
* Tue Nov 28 2023 yaoxin <yao_xin001@hoperun.com> - 2.15.1-4
|
||||
- Initialize rows using heap for large images
|
||||
|
||||
* Mon Oct 23 2023 liubo <liubo1@xfusion.com> - 2.15.1-3
|
||||
- de-recurse hist_item_sort_halfvar()
|
||||
|
||||
* Wed Oct 26 2022 zhouwenpei <zhouwenpei1@h-partners.com> - 2.15.1-2
|
||||
- Rebuild for next release
|
||||
|
||||
* Fri Dec 03 2021 xingxing <xingxing9@huawei.com> - 2.15.1-1
|
||||
- update to 2.15.1
|
||||
|
||||
* Tue Jun 08 2021 liuyumeng <liuyumeng5@huawei.com> - 2.14.0-2
|
||||
- Add a BuildRequires for gcc
|
||||
|
||||
* Tue Feb 02 2021 zhanzhimin <zhanzhimin@huawei.com> - 2.14.0-1
|
||||
- update to 2.14.0
|
||||
|
||||
|
||||
21
libimagequant_omp.patch
Normal file
21
libimagequant_omp.patch
Normal file
@ -0,0 +1,21 @@
|
||||
diff -rupN libimagequant-2.14.0/libimagequant.c libimagequant-2.14.0-new/libimagequant.c
|
||||
---
|
||||
libimagequant.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libimagequant.c b/libimagequant.c
|
||||
index 4f0b48f..047c042 100644
|
||||
--- a/libimagequant.c
|
||||
+++ b/libimagequant.c
|
||||
@@ -1279,7 +1279,7 @@ LIQ_NONNULL static float remap_to_palette(liq_image *const input_image, unsigned
|
||||
|
||||
#if __GNUC__ >= 9 || __clang__
|
||||
#pragma omp parallel for if (rows*cols > 3000) \
|
||||
- schedule(static) default(none) shared(acolormap,average_color,cols,input_image,map,n,output_pixels,rows,transparent_index) reduction(+:remapping_error)
|
||||
+ schedule(static) default(none) shared(acolormap,average_color,cols,input_image,map,n,output_pixels,rows,transparent_index,background) reduction(+:remapping_error)
|
||||
#else
|
||||
#pragma omp parallel for if (rows*cols > 3000) \
|
||||
schedule(static) default(none) shared(acolormap) shared(average_color) reduction(+:remapping_error)
|
||||
--
|
||||
2.23.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user