Skip to content

Commit 19e0557

Browse files
committed
Merge branch 'master' into 8.16
2 parents 5d20bf7 + 6c397fb commit 19e0557

File tree

7 files changed

+50
-19
lines changed

7 files changed

+50
-19
lines changed

libvips/foreign/jpeg.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ extern "C" {
6262
#include <jpeglib.h>
6363
#include <jerror.h>
6464

65+
/* Our custom error message codes.
66+
*/
67+
#define JERR_VIPS_IMAGE_EOF (1000)
68+
#define JWRN_VIPS_IMAGE_EOF JERR_VIPS_IMAGE_EOF
69+
#define JERR_VIPS_TARGET_WRITE (1001)
70+
6571
/* Define a new error handler for when we bomb out.
6672
*/
6773
typedef struct {
@@ -75,6 +81,8 @@ typedef struct {
7581
FILE *fp; /* fclose() if non-NULL */
7682
} ErrorManager;
7783

84+
extern const char *vips__jpeg_message_table[];
85+
7886
void vips__new_output_message(j_common_ptr cinfo);
7987
void vips__new_error_exit(j_common_ptr cinfo);
8088

libvips/foreign/jpeg2vips.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,10 @@ source_fill_input_buffer(j_decompress_ptr cinfo)
245245
/* Knock the output out of cache.
246246
*/
247247
vips_foreign_load_invalidate(src->jpeg->out);
248-
ERREXIT(cinfo, JERR_INPUT_EOF);
248+
ERREXIT(cinfo, JERR_VIPS_IMAGE_EOF);
249249
}
250250
else
251-
WARNMS(cinfo, JWRN_JPEG_EOF);
251+
WARNMS(cinfo, JWRN_VIPS_IMAGE_EOF);
252252

253253
/* Insert a fake EOI marker.
254254
*/
@@ -272,10 +272,10 @@ source_fill_input_buffer_mappable(j_decompress_ptr cinfo)
272272
/* Knock the output out of cache.
273273
*/
274274
vips_foreign_load_invalidate(src->jpeg->out);
275-
ERREXIT(cinfo, JERR_INPUT_EOF);
275+
ERREXIT(cinfo, JERR_VIPS_IMAGE_EOF);
276276
}
277277
else
278-
WARNMS(cinfo, JWRN_JPEG_EOF);
278+
WARNMS(cinfo, JWRN_VIPS_IMAGE_EOF);
279279

280280
/* Insert a fake EOI marker.
281281
*/
@@ -463,6 +463,9 @@ readjpeg_new(VipsSource *source, VipsImage *out,
463463
jpeg->shrink = shrink;
464464
jpeg->fail_on = fail_on;
465465
jpeg->cinfo.err = jpeg_std_error(&jpeg->eman.pub);
466+
jpeg->cinfo.err->addon_message_table = vips__jpeg_message_table;
467+
jpeg->cinfo.err->first_addon_message = 1000;
468+
jpeg->cinfo.err->last_addon_message = 1001;
466469
jpeg->eman.pub.error_exit = vips__new_error_exit;
467470
jpeg->eman.pub.emit_message = readjpeg_emit_message;
468471
jpeg->eman.pub.output_message = vips__new_output_message;

libvips/foreign/tiff2vips.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1973,7 +1973,7 @@ rtiff_decompress_jpeg_fill_input_buffer(j_decompress_ptr cinfo)
19731973
* buffer, so any request for more data beyond the given buffer size
19741974
* is treated as an error.
19751975
*/
1976-
WARNMS(cinfo, JWRN_JPEG_EOF);
1976+
WARNMS(cinfo, JWRN_VIPS_IMAGE_EOF);
19771977

19781978
/* Insert a fake EOI marker
19791979
*/
@@ -2163,6 +2163,9 @@ rtiff_decompress_jpeg(Rtiff *rtiff, void *data, size_t data_len, void *out)
21632163

21642164
if (setjmp(eman.jmp) == 0) {
21652165
cinfo.err = jpeg_std_error(&eman.pub);
2166+
cinfo.err->addon_message_table = vips__jpeg_message_table;
2167+
cinfo.err->first_addon_message = 1000;
2168+
cinfo.err->last_addon_message = 1001;
21662169
eman.pub.error_exit = vips__new_error_exit;
21672170
eman.pub.emit_message = rtiff_decompress_jpeg_emit_message;
21682171
eman.pub.output_message = vips__new_output_message;

libvips/foreign/vips2jpeg.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@
159159
#define MAX_BYTES_IN_MARKER 65533 /* maximum data len of a JPEG marker */
160160
#define MAX_DATA_BYTES_IN_MARKER (MAX_BYTES_IN_MARKER - ICC_OVERHEAD_LEN)
161161

162+
const char *vips__jpeg_message_table[] = {
163+
"premature end of JPEG image",
164+
"unable to write to target",
165+
NULL
166+
};
167+
162168
/* New output message method - send to VIPS.
163169
*/
164170
void
@@ -229,6 +235,9 @@ write_new(void)
229235

230236
write->row_pointer = NULL;
231237
write->cinfo.err = jpeg_std_error(&write->eman.pub);
238+
write->cinfo.err->addon_message_table = vips__jpeg_message_table;
239+
write->cinfo.err->first_addon_message = 1000;
240+
write->cinfo.err->last_addon_message = 1001;
232241
write->cinfo.dest = NULL;
233242
write->eman.pub.error_exit = vips__new_error_exit;
234243
write->eman.pub.output_message = vips__new_output_message;
@@ -811,7 +820,7 @@ empty_output_buffer(j_compress_ptr cinfo)
811820

812821
if (vips_target_write(dest->target,
813822
dest->buf, TARGET_BUFFER_SIZE))
814-
ERREXIT(cinfo, JERR_FILE_WRITE);
823+
ERREXIT(cinfo, JERR_VIPS_TARGET_WRITE);
815824

816825
dest->pub.next_output_byte = dest->buf;
817826
dest->pub.free_in_buffer = TARGET_BUFFER_SIZE;
@@ -839,7 +848,7 @@ term_destination(j_compress_ptr cinfo)
839848

840849
if (vips_target_write(dest->target,
841850
dest->buf, TARGET_BUFFER_SIZE - dest->pub.free_in_buffer))
842-
ERREXIT(cinfo, JERR_FILE_WRITE);
851+
ERREXIT(cinfo, JERR_VIPS_TARGET_WRITE);
843852
}
844853

845854
/* Set dest to one of our objects.

libvips/foreign/vips2tiff.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,9 @@ wtiff_compress_jpeg(Wtiff *wtiff,
732732

733733
// we could have one of these per thread and reuse it for a small speedup
734734
cinfo.err = jpeg_std_error(&eman.pub);
735+
cinfo.err->addon_message_table = vips__jpeg_message_table;
736+
cinfo.err->first_addon_message = 1000;
737+
cinfo.err->last_addon_message = 1001;
735738
cinfo.dest = NULL;
736739
eman.pub.error_exit = vips__new_error_exit;
737740
eman.pub.output_message = vips__new_output_message;
@@ -740,7 +743,7 @@ wtiff_compress_jpeg(Wtiff *wtiff,
740743
// we need a line buffer to pad edge tiles
741744
line = VIPS_MALLOC(NULL, wtiff->tilew * sizeof_pel);
742745

743-
/* Error handling. The error message will have ben set by our handlers.
746+
/* Error handling. The error message will have been set by our handlers.
744747
*/
745748
if (setjmp(eman.jmp)) {
746749
jpeg_destroy_compress(&cinfo);
@@ -805,6 +808,9 @@ wtiff_compress_jpeg_tables(Wtiff *wtiff,
805808
struct jpeg_error_mgr jerr;
806809

807810
cinfo.err = jpeg_std_error(&jerr);
811+
cinfo.err->addon_message_table = vips__jpeg_message_table;
812+
cinfo.err->first_addon_message = 1000;
813+
cinfo.err->last_addon_message = 1001;
808814
jpeg_create_compress(&cinfo);
809815

810816
/* Attach output.

libvips/include/vips/vips.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,14 @@ extern "C" {
135135
#include <vips/colour.h>
136136
#include <vips/draw.h>
137137
#include <vips/create.h>
138-
#if VIPS_ENABLE_DEPRECATED
138+
139+
/* VIPS_DISABLE_COMPAT:
140+
*
141+
* Disable automatically inclusion of `vips7compat.h`.
142+
*
143+
* This has no effect when building with `-Ddeprecated=false`.
144+
*/
145+
#if VIPS_ENABLE_DEPRECATED && !defined(VIPS_DISABLE_COMPAT)
139146
#include <vips/vips7compat.h>
140147
#endif
141148

libvips/include/vips/vips7compat.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,9 @@
3636

3737
#include <vips/mask.h>
3838

39-
/* The old deprecated VipsVector/VipsExecutor API required orc.
40-
* Avoid a possible ABI/API break with the adoption of highway.
41-
*/
4239
#ifdef HAVE_ORC
4340
#include <orc/orc.h>
44-
#else
45-
typedef struct _OrcProgram OrcProgram;
46-
47-
typedef struct _OrcExecutor {
48-
char data[808];
49-
} OrcExecutor;
50-
#endif
41+
#endif /* HAVE_ORC */
5142

5243
#ifdef __cplusplus
5344
extern "C" {
@@ -1692,13 +1683,17 @@ typedef struct {
16921683

16931684
int d1;
16941685

1686+
#ifdef HAVE_ORC
16951687
OrcProgram *program;
1688+
#endif /*HAVE_ORC*/
16961689

16971690
gboolean compiled;
16981691
} VipsVector;
16991692

17001693
typedef struct {
1694+
#ifdef HAVE_ORC
17011695
OrcExecutor executor;
1696+
#endif /*HAVE_ORC*/
17021697

17031698
VipsVector *vector;
17041699
} VipsExecutor;

0 commit comments

Comments
 (0)