Skip to content

Instantly share code, notes, and snippets.

@ap
Created December 27, 2015 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ap/7b3219ff1bb285d36548 to your computer and use it in GitHub Desktop.
Save ap/7b3219ff1bb285d36548 to your computer and use it in GitHub Desktop.
diff -urd --unidirectional-new-file orig/jpegtran.c droppatch/jpegtran.c
--- orig/jpegtran.c 2015-12-27 12:11:58.000000000 +0000
+++ droppatch/jpegtran.c 2014-03-26 11:52:18.000000000 +0000
@@ -37,6 +37,7 @@
static const char * progname; /* program name for error messages */
static char * outfilename; /* for -outfile switch */
+static char * dropfilename; /* for -drop switch */
static char * scaleoption; /* -scale switch */
static JCOPY_OPTION copyoption; /* -copy switch */
static jpeg_transform_info transformoption; /* image transformation options */
@@ -66,6 +67,7 @@
fprintf(stderr, "Switches for modifying the image:\n");
#if TRANSFORMS_SUPPORTED
fprintf(stderr, " -crop WxH+X+Y Crop to a rectangular subarea\n");
+ fprintf(stderr, " -drop +X+Y filename Drop another image\n");
fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n");
fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n");
fprintf(stderr, " -perfect Fail if there is non-transformable edge blocks\n");
@@ -76,6 +78,7 @@
fprintf(stderr, " -transpose Transpose image\n");
fprintf(stderr, " -transverse Transverse transpose image\n");
fprintf(stderr, " -trim Drop non-transformable edge blocks\n");
+ fprintf(stderr, " with -drop: Requantize drop file to source file\n");
fprintf(stderr, " -wipe WxH+X+Y Wipe (gray out) a rectangular subarea\n");
#endif
fprintf(stderr, "Switches for advanced users:\n");
@@ -188,7 +191,7 @@
#if TRANSFORMS_SUPPORTED
if (++argn >= argc) /* advance to next argument */
usage();
- if (transformoption.crop /* reject multiple crop/wipe requests */ ||
+ if (transformoption.crop /* reject multiple crop/drop/wipe requests */ ||
! jtransform_parse_crop_spec(&transformoption, argv[argn])) {
fprintf(stderr, "%s: bogus -crop argument '%s'\n",
progname, argv[argn]);
@@ -198,6 +201,26 @@
select_transform(JXFORM_NONE); /* force an error */
#endif
+ } else if (keymatch(arg, "drop", 2)) {
+#if TRANSFORMS_SUPPORTED
+ if (++argn >= argc) /* advance to next argument */
+ usage();
+ if (transformoption.crop /* reject multiple crop/drop/wipe requests */ ||
+ ! jtransform_parse_crop_spec(&transformoption, argv[argn]) ||
+ transformoption.crop_width_set != JCROP_UNSET ||
+ transformoption.crop_height_set != JCROP_UNSET) {
+ fprintf(stderr, "%s: bogus -drop argument '%s'\n",
+ progname, argv[argn]);
+ exit(EXIT_FAILURE);
+ }
+ if (++argn >= argc) /* advance to next argument */
+ usage();
+ dropfilename = argv[argn];
+ select_transform(JXFORM_DROP);
+#else
+ select_transform(JXFORM_NONE); /* force an error */
+#endif
+
} else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
/* Enable debug printouts. */
/* On first -d, print version identification */
@@ -342,7 +365,7 @@
#if TRANSFORMS_SUPPORTED
if (++argn >= argc) /* advance to next argument */
usage();
- if (transformoption.crop /* reject multiple crop/wipe requests */ ||
+ if (transformoption.crop /* reject multiple crop/drop/wipe requests */ ||
! jtransform_parse_crop_spec(&transformoption, argv[argn])) {
fprintf(stderr, "%s: bogus -wipe argument '%s'\n",
progname, argv[argn]);
@@ -386,8 +409,14 @@
main (int argc, char **argv)
{
struct jpeg_decompress_struct srcinfo;
+ struct jpeg_error_mgr jsrcerr;
+#if TRANSFORMS_SUPPORTED
+ struct jpeg_decompress_struct dropinfo;
+ struct jpeg_error_mgr jdroperr;
+ FILE * drop_file;
+#endif
struct jpeg_compress_struct dstinfo;
- struct jpeg_error_mgr jsrcerr, jdsterr;
+ struct jpeg_error_mgr jdsterr;
#ifdef PROGRESS_REPORT
struct cdjpeg_progress_mgr progress;
#endif
@@ -469,6 +498,21 @@
fp = read_stdin();
}
+#if TRANSFORMS_SUPPORTED
+ /* Open the drop file. */
+ if (dropfilename != NULL) {
+ if ((drop_file = fopen(dropfilename, READ_BINARY)) == NULL) {
+ fprintf(stderr, "%s: can't open %s for reading\n", progname, dropfilename);
+ exit(EXIT_FAILURE);
+ }
+ dropinfo.err = jpeg_std_error(&jdroperr);
+ jpeg_create_decompress(&dropinfo);
+ jpeg_stdio_src(&dropinfo, drop_file);
+ } else {
+ drop_file = NULL;
+ }
+#endif
+
#ifdef PROGRESS_REPORT
start_progress_monitor((j_common_ptr) &dstinfo, &progress);
#endif
@@ -488,6 +532,17 @@
&srcinfo.scale_num, &srcinfo.scale_denom) < 1)
usage();
+#if TRANSFORMS_SUPPORTED
+ if (dropfilename != NULL) {
+ (void) jpeg_read_header(&dropinfo, TRUE);
+ transformoption.crop_width = dropinfo.image_width;
+ transformoption.crop_width_set = JCROP_POS;
+ transformoption.crop_height = dropinfo.image_height;
+ transformoption.crop_height_set = JCROP_POS;
+ transformoption.drop_ptr = &dropinfo;
+ }
+#endif
+
/* Any space needed by a transform option must be requested before
* jpeg_read_coefficients so that memory allocation will be done right.
*/
@@ -503,6 +558,12 @@
/* Read source file as DCT coefficients */
src_coef_arrays = jpeg_read_coefficients(&srcinfo);
+#if TRANSFORMS_SUPPORTED
+ if (dropfilename != NULL) {
+ transformoption.drop_coef_arrays = jpeg_read_coefficients(&dropinfo);
+ }
+#endif
+
/* Initialize destination compression parameters from source values */
jpeg_copy_critical_parameters(&srcinfo, &dstinfo);
@@ -560,18 +621,33 @@
/* Finish compression and release memory */
jpeg_finish_compress(&dstinfo);
jpeg_destroy_compress(&dstinfo);
+#if TRANSFORMS_SUPPORTED
+ if (dropfilename != NULL) {
+ (void) jpeg_finish_decompress(&dropinfo);
+ jpeg_destroy_decompress(&dropinfo);
+ }
+#endif
(void) jpeg_finish_decompress(&srcinfo);
jpeg_destroy_decompress(&srcinfo);
/* Close output file, if we opened it */
if (fp != stdout)
fclose(fp);
+#if TRANSFORMS_SUPPORTED
+ if (drop_file != NULL)
+ fclose(drop_file);
+#endif
#ifdef PROGRESS_REPORT
end_progress_monitor((j_common_ptr) &dstinfo);
#endif
/* All done. */
+#if TRANSFORMS_SUPPORTED
+ if (dropfilename != NULL)
+ exit(jsrcerr.num_warnings + jdroperr.num_warnings + jdsterr.num_warnings ?
+ EXIT_WARNING : EXIT_SUCCESS);
+#endif
exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS);
return 0; /* suppress no-return-value warnings */
}
diff -urd --unidirectional-new-file orig/transupp.c droppatch/transupp.c
--- orig/transupp.c 2015-12-27 12:11:58.000000000 +0000
+++ droppatch/transupp.c 2013-09-08 14:03:02.000000000 +0000
@@ -75,6 +75,269 @@
*/
+/* Drop code may be used with or without virtual memory adaptation code.
+ * This code has some dependencies on internal library behavior, so you
+ * may choose to disable it. For example, it doesn't make a difference
+ * if you only use jmemnobs anyway.
+ */
+#ifndef DROP_REQUEST_FROM_SRC
+#define DROP_REQUEST_FROM_SRC 1 /* 0 disables adaptation */
+#endif
+
+
+#if DROP_REQUEST_FROM_SRC
+/* Force jpeg_read_coefficients to request
+ * the virtual coefficient arrays from
+ * the source decompression object.
+ */
+METHODDEF(jvirt_barray_ptr)
+drop_request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
+ JDIMENSION blocksperrow, JDIMENSION numrows,
+ JDIMENSION maxaccess)
+{
+ j_decompress_ptr srcinfo = (j_decompress_ptr) cinfo->client_data;
+
+ return (*srcinfo->mem->request_virt_barray)
+ ((j_common_ptr) srcinfo, pool_id, pre_zero,
+ blocksperrow, numrows, maxaccess);
+}
+
+
+/* Force jpeg_read_coefficients to return
+ * after requesting and before accessing
+ * the virtual coefficient arrays.
+ */
+METHODDEF(int)
+drop_consume_input (j_decompress_ptr cinfo)
+{
+ return JPEG_SUSPENDED;
+}
+
+
+METHODDEF(void)
+drop_start_input_pass (j_decompress_ptr cinfo)
+{
+ cinfo->inputctl->consume_input = drop_consume_input;
+}
+
+
+LOCAL(void)
+drop_request_from_src (j_decompress_ptr dropinfo, j_decompress_ptr srcinfo)
+{
+ void *save_client_data;
+ JMETHOD(jvirt_barray_ptr, save_request_virt_barray,
+ (j_common_ptr cinfo, int pool_id, boolean pre_zero,
+ JDIMENSION blocksperrow, JDIMENSION numrows, JDIMENSION maxaccess));
+ JMETHOD(void, save_start_input_pass, (j_decompress_ptr cinfo));
+
+ /* Set custom method pointers, save original pointers */
+ save_client_data = dropinfo->client_data;
+ dropinfo->client_data = (void *) srcinfo;
+ save_request_virt_barray = dropinfo->mem->request_virt_barray;
+ dropinfo->mem->request_virt_barray = drop_request_virt_barray;
+ save_start_input_pass = dropinfo->inputctl->start_input_pass;
+ dropinfo->inputctl->start_input_pass = drop_start_input_pass;
+
+ /* Execute only initialization part.
+ * Requested coefficient arrays will be realized later by the srcinfo object.
+ * Next call to the same function will then do the actual data reading.
+ * NB: since we request the coefficient arrays from another object,
+ * the inherent realization call is effectively a no-op.
+ */
+ (void) jpeg_read_coefficients(dropinfo);
+
+ /* Reset method pointers */
+ dropinfo->client_data = save_client_data;
+ dropinfo->mem->request_virt_barray = save_request_virt_barray;
+ dropinfo->inputctl->start_input_pass = save_start_input_pass;
+ /* Do input initialization for first scan now,
+ * which also resets the consume_input method.
+ */
+ (*save_start_input_pass)(dropinfo);
+}
+#endif /* DROP_REQUEST_FROM_SRC */
+
+
+LOCAL(void)
+dequant_comp (j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ jvirt_barray_ptr coef_array, JQUANT_TBL *qtblptr1)
+{
+ JDIMENSION blk_x, blk_y;
+ int offset_y, k;
+ JQUANT_TBL *qtblptr;
+ JBLOCKARRAY buffer;
+ JBLOCKROW block;
+ JCOEFPTR ptr;
+
+ qtblptr = compptr->quant_table;
+ for (blk_y = 0; blk_y < compptr->height_in_blocks;
+ blk_y += compptr->v_samp_factor) {
+ buffer = (*cinfo->mem->access_virt_barray)
+ ((j_common_ptr) cinfo, coef_array, blk_y,
+ (JDIMENSION) compptr->v_samp_factor, TRUE);
+ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
+ block = buffer[offset_y];
+ for (blk_x = 0; blk_x < compptr->width_in_blocks; blk_x++) {
+ ptr = block[blk_x];
+ for (k = 0; k < DCTSIZE2; k++)
+ if (qtblptr->quantval[k] != qtblptr1->quantval[k])
+ ptr[k] *= qtblptr->quantval[k] / qtblptr1->quantval[k];
+ }
+ }
+ }
+}
+
+
+LOCAL(void)
+requant_comp (j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ jvirt_barray_ptr coef_array, JQUANT_TBL *qtblptr1)
+{
+ JDIMENSION blk_x, blk_y;
+ int offset_y, k;
+ JQUANT_TBL *qtblptr;
+ JBLOCKARRAY buffer;
+ JBLOCKROW block;
+ JCOEFPTR ptr;
+ JCOEF temp, qval;
+
+ qtblptr = compptr->quant_table;
+ for (blk_y = 0; blk_y < compptr->height_in_blocks;
+ blk_y += compptr->v_samp_factor) {
+ buffer = (*cinfo->mem->access_virt_barray)
+ ((j_common_ptr) cinfo, coef_array, blk_y,
+ (JDIMENSION) compptr->v_samp_factor, TRUE);
+ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
+ block = buffer[offset_y];
+ for (blk_x = 0; blk_x < compptr->width_in_blocks; blk_x++) {
+ ptr = block[blk_x];
+ for (k = 0; k < DCTSIZE2; k++) {
+ temp = qtblptr->quantval[k];
+ qval = qtblptr1->quantval[k];
+ if (temp != qval) {
+ temp *= ptr[k];
+ /* The following quantization code is a copy from jcdctmgr.c */
+#ifdef FAST_DIVIDE
+#define DIVIDE_BY(a,b) a /= b
+#else
+#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0
+#endif
+ if (temp < 0) {
+ temp = -temp;
+ temp += qval>>1; /* for rounding */
+ DIVIDE_BY(temp, qval);
+ temp = -temp;
+ } else {
+ temp += qval>>1; /* for rounding */
+ DIVIDE_BY(temp, qval);
+ }
+ ptr[k] = temp;
+ }
+ }
+ }
+ }
+ }
+}
+
+
+/* Calculate largest common denominator with Euklid's algorithm.
+ */
+LOCAL(JCOEF)
+largest_common_denominator(JCOEF a, JCOEF b)
+{
+ JCOEF c;
+
+ do {
+ c = a % b;
+ a = b;
+ b = c;
+ } while (c);
+
+ return a;
+}
+
+
+LOCAL(void)
+adjust_quant(j_decompress_ptr srcinfo, jvirt_barray_ptr *src_coef_arrays,
+ j_decompress_ptr dropinfo, jvirt_barray_ptr *drop_coef_arrays,
+ boolean trim, j_compress_ptr dstinfo)
+{
+ jpeg_component_info *compptr1, *compptr2;
+ JQUANT_TBL *qtblptr1, *qtblptr2, *qtblptr3;
+ int ci, k;
+
+ for (ci = 0; ci < dstinfo->num_components &&
+ ci < dropinfo->num_components; ci++) {
+ compptr1 = srcinfo->comp_info + ci;
+ compptr2 = dropinfo->comp_info + ci;
+ qtblptr1 = compptr1->quant_table;
+ qtblptr2 = compptr2->quant_table;
+ for (k = 0; k < DCTSIZE2; k++) {
+ if (qtblptr1->quantval[k] != qtblptr2->quantval[k]) {
+ if (trim)
+ requant_comp(dropinfo, compptr2, drop_coef_arrays[ci], qtblptr1);
+ else {
+ qtblptr3 = dstinfo->quant_tbl_ptrs[compptr1->quant_tbl_no];
+ for (k = 0; k < DCTSIZE2; k++)
+ if (qtblptr1->quantval[k] != qtblptr2->quantval[k])
+ qtblptr3->quantval[k] = largest_common_denominator
+ (qtblptr1->quantval[k], qtblptr2->quantval[k]);
+ dequant_comp(srcinfo, compptr1, src_coef_arrays[ci], qtblptr3);
+ dequant_comp(dropinfo, compptr2, drop_coef_arrays[ci], qtblptr3);
+ }
+ break;
+ }
+ }
+ }
+}
+
+
+LOCAL(void)
+do_drop (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
+ JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
+ jvirt_barray_ptr *src_coef_arrays,
+ j_decompress_ptr dropinfo, jvirt_barray_ptr *drop_coef_arrays,
+ JDIMENSION drop_width, JDIMENSION drop_height)
+/* Drop. If the dropinfo component number is smaller than the destination's,
+ * we fill in the remaining components with zero. This provides the feature
+ * of dropping grayscale into (arbitrarily sampled) color images.
+ */
+{
+ JDIMENSION comp_width, comp_height;
+ JDIMENSION blk_y, x_drop_blocks, y_drop_blocks;
+ int ci, offset_y;
+ JBLOCKARRAY src_buffer, dst_buffer;
+ jpeg_component_info *compptr;
+
+ for (ci = 0; ci < dstinfo->num_components; ci++) {
+ compptr = dstinfo->comp_info + ci;
+ comp_width = drop_width * compptr->h_samp_factor;
+ comp_height = drop_height * compptr->v_samp_factor;
+ x_drop_blocks = x_crop_offset * compptr->h_samp_factor;
+ y_drop_blocks = y_crop_offset * compptr->v_samp_factor;
+ for (blk_y = 0; blk_y < comp_height; blk_y += compptr->v_samp_factor) {
+ dst_buffer = (*srcinfo->mem->access_virt_barray)
+ ((j_common_ptr) srcinfo, src_coef_arrays[ci], blk_y + y_drop_blocks,
+ (JDIMENSION) compptr->v_samp_factor, TRUE);
+ if (ci < dropinfo->num_components) {
+ src_buffer = (*srcinfo->mem->access_virt_barray)
+ ((j_common_ptr) srcinfo, drop_coef_arrays[ci], blk_y,
+ (JDIMENSION) compptr->v_samp_factor, FALSE);
+ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
+ jcopy_block_row(src_buffer[offset_y],
+ dst_buffer[offset_y] + x_drop_blocks,
+ comp_width);
+ }
+ } else {
+ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
+ FMEMZERO(dst_buffer[offset_y] + x_drop_blocks,
+ comp_width * SIZEOF(JBLOCK));
+ }
+ }
+ }
+ }
+}
+
+
LOCAL(void)
do_crop (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
JDIMENSION x_crop_offset, JDIMENSION y_crop_offset,
@@ -991,10 +1254,10 @@
jvirt_barray_ptr *coef_arrays;
boolean need_workspace, transpose_it;
jpeg_component_info *compptr;
- JDIMENSION xoffset, yoffset;
+ JDIMENSION xoffset, yoffset, dtemp;
JDIMENSION width_in_iMCUs, height_in_iMCUs;
JDIMENSION width_in_blocks, height_in_blocks;
- int ci, h_samp_factor, v_samp_factor;
+ int itemp, ci, h_samp_factor, v_samp_factor;
/* Determine number of components in output image */
if (info->force_grayscale &&
@@ -1128,7 +1391,54 @@
else
yoffset = info->output_height - info->crop_height - info->crop_yoffset;
/* Now adjust so that upper left corner falls at an iMCU boundary */
- if (info->transform == JXFORM_WIPE) {
+ switch (info->transform) {
+ case JXFORM_DROP:
+ /* Ensure the effective drop region will not exceed the requested */
+ itemp = info->iMCU_sample_width;
+ dtemp = itemp - 1 - ((xoffset + itemp - 1) % itemp);
+ xoffset += dtemp;
+ if (info->crop_width <= dtemp)
+ info->drop_width = 0;
+ else if (xoffset + info->crop_width - dtemp == info->output_width)
+ /* Matching right edge: include partial iMCU */
+ info->drop_width = (info->crop_width - dtemp + itemp - 1) / itemp;
+ else
+ info->drop_width = (info->crop_width - dtemp) / itemp;
+ itemp = info->iMCU_sample_height;
+ dtemp = itemp - 1 - ((yoffset + itemp - 1) % itemp);
+ yoffset += dtemp;
+ if (info->crop_height <= dtemp)
+ info->drop_height = 0;
+ else if (yoffset + info->crop_height - dtemp == info->output_height)
+ /* Matching bottom edge: include partial iMCU */
+ info->drop_height = (info->crop_height - dtemp + itemp - 1) / itemp;
+ else
+ info->drop_height = (info->crop_height - dtemp) / itemp;
+ /* Check if sampling factors match for dropping */
+ if (info->drop_width != 0 && info->drop_height != 0)
+ for (ci = 0; ci < info->num_components &&
+ ci < info->drop_ptr->num_components; ci++) {
+ if (info->drop_ptr->comp_info[ci].h_samp_factor *
+ srcinfo->max_h_samp_factor !=
+ srcinfo->comp_info[ci].h_samp_factor *
+ info->drop_ptr->max_h_samp_factor)
+ ERREXIT6(srcinfo, JERR_BAD_DROP_SAMPLING, ci,
+ info->drop_ptr->comp_info[ci].h_samp_factor,
+ info->drop_ptr->max_h_samp_factor,
+ srcinfo->comp_info[ci].h_samp_factor,
+ srcinfo->max_h_samp_factor, 'h');
+ if (info->drop_ptr->comp_info[ci].v_samp_factor *
+ srcinfo->max_v_samp_factor !=
+ srcinfo->comp_info[ci].v_samp_factor *
+ info->drop_ptr->max_v_samp_factor)
+ ERREXIT6(srcinfo, JERR_BAD_DROP_SAMPLING, ci,
+ info->drop_ptr->comp_info[ci].v_samp_factor,
+ info->drop_ptr->max_v_samp_factor,
+ srcinfo->comp_info[ci].v_samp_factor,
+ srcinfo->max_v_samp_factor, 'v');
+ }
+ break;
+ case JXFORM_WIPE:
/* Ensure the effective wipe region will cover the requested */
info->drop_width = (JDIMENSION) jdiv_round_up
((long) (info->crop_width + (xoffset % info->iMCU_sample_width)),
@@ -1136,7 +1446,8 @@
info->drop_height = (JDIMENSION) jdiv_round_up
((long) (info->crop_height + (yoffset % info->iMCU_sample_height)),
(long) info->iMCU_sample_height);
- } else {
+ break;
+ default:
/* Ensure the effective crop region will cover the requested */
if (info->crop_width_set == JCROP_FORCE ||
info->crop_width > info->output_width)
@@ -1150,6 +1461,7 @@
else
info->output_height =
info->crop_height + (yoffset % info->iMCU_sample_height);
+ break;
}
/* Save x/y offsets measured in iMCUs */
info->x_crop_offset = xoffset / info->iMCU_sample_width;
@@ -1224,6 +1536,11 @@
break;
case JXFORM_WIPE:
break;
+ case JXFORM_DROP:
+#if DROP_REQUEST_FROM_SRC
+ drop_request_from_src(info->drop_ptr, srcinfo);
+#endif
+ break;
}
/* Allocate workspace if needed.
@@ -1531,6 +1848,12 @@
case JXFORM_ROT_270:
transpose_critical_parameters(dstinfo);
break;
+ case JXFORM_DROP:
+ if (info->drop_width != 0 && info->drop_height != 0)
+ adjust_quant(srcinfo, src_coef_arrays,
+ info->drop_ptr, info->drop_coef_arrays,
+ info->trim, dstinfo);
+ break;
default:
break;
}
@@ -1629,6 +1952,12 @@
do_wipe(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
src_coef_arrays, info->drop_width, info->drop_height);
break;
+ case JXFORM_DROP:
+ if (info->drop_width != 0 && info->drop_height != 0)
+ do_drop(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
+ src_coef_arrays, info->drop_ptr, info->drop_coef_arrays,
+ info->drop_width, info->drop_height);
+ break;
}
}
diff -urd --unidirectional-new-file orig/transupp.h droppatch/transupp.h
--- orig/transupp.h 2015-12-27 12:11:58.000000000 +0000
+++ droppatch/transupp.h 2013-09-13 15:02:48.000000000 +0000
@@ -106,7 +106,8 @@
JXFORM_ROT_90, /* 90-degree clockwise rotation */
JXFORM_ROT_180, /* 180-degree rotation */
JXFORM_ROT_270, /* 270-degree clockwise (or 90 ccw) */
- JXFORM_WIPE /* wipe */
+ JXFORM_WIPE, /* wipe */
+ JXFORM_DROP /* drop */
} JXFORM_CODE;
/*
@@ -134,7 +135,7 @@
boolean perfect; /* if TRUE, fail if partial MCUs are requested */
boolean trim; /* if TRUE, trim partial MCUs as needed */
boolean force_grayscale; /* if TRUE, convert color image to grayscale */
- boolean crop; /* if TRUE, crop or wipe source image */
+ boolean crop; /* if TRUE, crop or wipe source image, or drop */
/* Crop parameters: application need not set these unless crop is TRUE.
* These can be filled in by jtransform_parse_crop_spec().
@@ -148,6 +149,10 @@
JDIMENSION crop_yoffset; /* Y offset of selected region */
JCROP_CODE crop_yoffset_set; /* (negative measures from bottom edge) */
+ /* Drop parameters: set by caller for drop request */
+ j_decompress_ptr drop_ptr;
+ jvirt_barray_ptr * drop_coef_arrays;
+
/* Internal workspace: caller should not touch these */
int num_components; /* # of components in workspace */
jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */
@ap
Copy link
Author

ap commented Dec 27, 2015

This does not appear to be published anywhere else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment