Compare commits

..

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
9971e53e0d
!29 Initialize rows using heap for large images
From: @starlet-dx 
Reviewed-by: @caodongxia 
Signed-off-by: @caodongxia
2023-11-29 06:06:14 +00:00
starlet-dx
2f9d12046d Initialize rows using heap for large images 2023-11-29 09:59:51 +08:00
openeuler-ci-bot
aec88967e2
!25 [sync] PR-19: de-recurse hist_item_sort_halfvar()
From: @openeuler-sync-bot 
Reviewed-by: @lyn1001 
Signed-off-by: @lyn1001
2023-11-27 02:01:32 +00:00
liubo
ee903edc24 de-recurse hist_item_sort_halfvar()
Signed-off-by: liubo <liubo1@xfusion.com>
(cherry picked from commit 80fc3ecada9cdad5d09c699ec166fbd1b04381aa)
2023-11-27 09:21:04 +08:00
openeuler-ci-bot
0b2a813bf5
!15 【轻量级 PR】:Rebuild for next release
From: @zhouwenpei 
Reviewed-by: @ruebb 
Signed-off-by: @ruebb
2022-10-27 07:26:20 +00:00
zhouwenpei
6291a46bbd
Rebuild for next release
Signed-off-by: zhouwenpei <zhouwenpei050@chinasoftinc.com>
2022-10-26 03:33:15 +00:00
openeuler-ci-bot
193f89c9ba !13 [sync] PR-12: 需要升级到社区最新稳定版本:2.15.1
From: @openeuler-sync-bot
Reviewed-by: @orange-snn
Signed-off-by: @orange-snn
2021-12-07 07:22:22 +00:00
xingxing
e4d1443b87 updata to 2.15.1
(cherry picked from commit 26316fec2375a14a6008ba4b35cc99f1b6c19341)
2021-12-07 10:13:37 +08:00
openeuler-ci-bot
029fa3845d !9 Add a BuildRquires for gcc
From: @liuyumeng1
Reviewed-by: @shirely16,@small_leek
Signed-off-by: @small_leek
2021-06-08 10:38:16 +08:00
liuyumeng
d66b992094 Add a BuildRequires for gcc 2021-06-08 10:02:38 +08:00
6 changed files with 133 additions and 24 deletions

View File

@ -0,0 +1,86 @@
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

View File

@ -0,0 +1,25 @@
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

Binary file not shown.

BIN
libimagequant-2.15.1.tar.gz Normal file

Binary file not shown.

View File

@ -1,13 +1,17 @@
Name: libimagequant
Version: 2.14.0
Release: 1
Version: 2.15.1
Release: 4
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: libimagequant_omp.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
%description
The portable C library can convert RGBA images into
@ -46,6 +50,21 @@ 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

View File

@ -1,21 +0,0 @@
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