Skip to content

Commit beef803

Browse files
committed
2.5.7: fix bisection
1 parent 1aa8807 commit beef803

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
JPEG Recompress
22
https://github.com/ImageProcessing-ElectronicPublications/jpeg-recompress
33

4+
2.5.7 "bisection"
5+
6+
Fix bisection
7+
48
2.5.6 "subsample"
59

610
Fix IPEP/#1: ignores subsampling option

src/jmetrics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define JMETRICS_H
2222

2323
#ifndef JMVERSION
24-
#define JMVERSION "2.5.6"
24+
#define JMVERSION "2.5.7"
2525
#endif
2626

2727
#define MIN(a, b) ((a) < (b) ? (a) : (b))

src/jpeg-recompress.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ int main (int argc, char **argv)
300300
max = jpegMax;
301301
for (attempt = attempts - 1; attempt >= 0; --attempt)
302302
{
303-
quality = min + (max - min) / 2;
303+
quality = (max + min + 1) / 2;
304304

305305
/* Terminate early once bisection interval is a singleton. */
306306
if (min == max)
@@ -365,11 +365,11 @@ int main (int argc, char **argv)
365365
return 1;
366366
}
367367
}
368-
min = MIN(quality + 1, max);
368+
min = MIN(quality, max);
369369
}
370370
else
371371
{
372-
max = MAX(quality - 1, min);
372+
max = MAX(quality, min);
373373
}
374374

375375
// If we aren't done yet, then free the image data

src/jpeg-zfpoint.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ int main (int argc, char **argv)
281281
cmpMin = qmetric * (float)min - metric;
282282
for (attempt = attempts - 1; attempt >= 0; --attempt)
283283
{
284-
quality = min + (max - min) / 2;
284+
quality = (max + min + 1) / 2;
285285
progressive = attempt ? 0 : !noProgressive;
286286
optimize = accurate ? 1 : (attempt ? 0 : 1);
287287

@@ -315,12 +315,12 @@ int main (int argc, char **argv)
315315

316316
if (cmpMin < cmpMax)
317317
{
318-
min = MIN(quality + 1, max);
318+
min = MIN(quality, max);
319319
cmpMin = cmpQ;
320320
}
321321
else
322322
{
323-
max = MAX(quality - 1, min);
323+
max = MAX(quality, min);
324324
cmpMax = cmpQ;
325325
}
326326

src/webp-compress.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ int main (int argc, char **argv)
254254
max = qMax;
255255
for (attempt = attempts - 1; attempt >= 0; --attempt)
256256
{
257-
quality = min + (max - min) / 2;
257+
quality = (max + min + 1) / 2;
258258

259259
/* Terminate early once bisection interval is a singleton. */
260260
if (min == max)
@@ -354,11 +354,11 @@ int main (int argc, char **argv)
354354
return 1;
355355
}
356356
}
357-
min = MIN(quality + 1, max);
357+
min = MIN(quality, max);
358358
}
359359
else
360360
{
361-
max = MAX(quality - 1, min);
361+
max = MAX(quality, min);
362362
}
363363

364364
// If we aren't done yet, then free the image data

0 commit comments

Comments
 (0)