Index: Makefile =================================================================== --- Makefile (revision 375268) +++ Makefile (working copy) @@ -2,15 +2,14 @@ # $FreeBSD$ PORTNAME= jpeg -PORTVERSION= 8 -PORTREVISION= 6 +PORTVERSION= 9a CATEGORIES= graphics MASTER_SITES= http://www.ijg.org/files/ \ http://sylvana.net/jpegcrop/:exif -DISTNAME= jpegsrc.v${DISTVERSION2} +DISTNAME= jpegsrc.v${PORTVERSION} DISTFILES= ${DISTNAME}${EXTRACT_SUFX} \ jpegexiforient.c:exif exifautotran.txt:exif -DIST_SUBDIR= ${PORTNAME}${DISTVERSION2} +DIST_SUBDIR= ${PORTNAME}${PORTVERSION} EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} MAINTAINER= portmgr@FreeBSD.org @@ -18,12 +17,13 @@ #CONFLICTS= libjpeg-turbo-[0-9]* -WRKSRC= ${WRKDIR}/${PORTNAME}-${DISTVERSION2} -DISTVERSION2= 8d USES= libtool GNU_CONFIGURE= yes USE_LDCONFIG= yes +INSTALL_TARGET= install-strip +WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION} + ADDITIONAL_HEADER= jinclude.h jpegint.h # define J_MAXMEM like "make J_MAXMEM=32" to limit max processing memory to 32Mb @@ -33,11 +33,9 @@ OPTIONS_DEFINE= DOCS -.include - post-extract: - @${CP} ${DISTDIR}/${DIST_SUBDIR}/jpegexiforient.c ${WRKSRC}/ - @${CP} ${DISTDIR}/${DIST_SUBDIR}/exifautotran.txt ${WRKSRC}/exifautotran + ${CP} ${DISTDIR}/${DIST_SUBDIR}/jpegexiforient.c ${WRKSRC}/ + ${CP} ${DISTDIR}/${DIST_SUBDIR}/exifautotran.txt ${WRKSRC}/exifautotran post-build: @cd ${WRKSRC} && ${CC} ${CFLAGS} -o jpegexiforient jpegexiforient.c @@ -47,17 +45,4 @@ regression-test: test -post-install: - ${LN} -s libjpeg.so.8 ${STAGEDIR}${PREFIX}/lib/libjpeg.so.11 -.if ${PORT_OPTIONS:MDOCS} - @${MKDIR} ${STAGEDIR}${PREFIX}/share/doc/jpeg - @${INSTALL_DATA} ${WRKSRC}/README ${STAGEDIR}${PREFIX}/share/doc/jpeg/ - @${INSTALL_DATA} ${WRKSRC}/*.txt ${STAGEDIR}${PREFIX}/share/doc/jpeg/ -.endif -.for header in ${ADDITIONAL_HEADER} - @${INSTALL_DATA} ${WRKSRC}/${header} ${STAGEDIR}${PREFIX}/include/ -.endfor - ${INSTALL_PROGRAM} ${WRKSRC}/jpegexiforient ${STAGEDIR}${PREFIX}/bin/ - ${INSTALL_SCRIPT} ${WRKSRC}/exifautotran ${STAGEDIR}${PREFIX}/bin/ - .include Index: distinfo =================================================================== --- distinfo (revision 375268) +++ distinfo (working copy) @@ -1,6 +1,6 @@ -SHA256 (jpeg8d/jpegsrc.v8d.tar.gz) = 00029b1473f0f0ea72fbca3230e8cb25797fbb27e58ae2e46bb8bf5a806fe0b3 -SIZE (jpeg8d/jpegsrc.v8d.tar.gz) = 991456 -SHA256 (jpeg8d/jpegexiforient.c) = bac06fcdbc6a5b6adfb5e65d5b90b88bf7d72849e21ab2d33b6900bd99200eec -SIZE (jpeg8d/jpegexiforient.c) = 8531 -SHA256 (jpeg8d/exifautotran.txt) = d1d8302e4a76f83c725d65027ff5dfd788447cc245d387a91f01737e9f245c4c -SIZE (jpeg8d/exifautotran.txt) = 684 +SHA256 (jpeg9a/jpegsrc.v9a.tar.gz) = 3a753ea48d917945dd54a2d97de388aa06ca2eb1066cbfdc6652036349fe05a7 +SIZE (jpeg9a/jpegsrc.v9a.tar.gz) = 1000034 +SHA256 (jpeg9a/jpegexiforient.c) = bac06fcdbc6a5b6adfb5e65d5b90b88bf7d72849e21ab2d33b6900bd99200eec +SIZE (jpeg9a/jpegexiforient.c) = 8531 +SHA256 (jpeg9a/exifautotran.txt) = d1d8302e4a76f83c725d65027ff5dfd788447cc245d387a91f01737e9f245c4c +SIZE (jpeg9a/exifautotran.txt) = 684 Index: files/patch-djpeg.c =================================================================== --- files/patch-djpeg.c (revision 375268) +++ files/patch-djpeg.c (working copy) @@ -1,6 +1,6 @@ ---- djpeg.c.orig Sat Oct 11 18:29:07 1997 -+++ djpeg.c Mon Apr 24 16:04:13 2000 -@@ -26,6 +26,7 @@ +--- djpeg.c.orig 2013-01-03 17:51:56 UTC ++++ djpeg.c +@@ -27,6 +27,7 @@ #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ #include "jversion.h" /* for version message */ @@ -8,7 +8,7 @@ #include /* to declare isprint() */ #ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -@@ -385,6 +386,9 @@ +@@ -386,6 +387,9 @@ print_text_marker (j_decompress_ptr cinf cinfo->unread_marker - JPEG_APP0, (long) length); } Index: files/patch-exifautotran =================================================================== --- files/patch-exifautotran (revision 375268) +++ files/patch-exifautotran (working copy) @@ -1,5 +1,5 @@ ---- exifautotran.orig Thu Mar 18 06:25:27 2004 -+++ exifautotran Thu Mar 18 06:28:29 2004 +--- exifautotran.orig 2014-12-23 21:39:40 UTC ++++ exifautotran @@ -1,3 +1,4 @@ +#!/bin/sh # exifautotran [list of files] Index: files/patch-jconfig.cfg =================================================================== --- files/patch-jconfig.cfg (revision 375268) +++ files/patch-jconfig.cfg (working copy) @@ -1,5 +1,5 @@ ---- jconfig.cfg.orig 2009-06-07 13:12:34.000000000 +0200 -+++ jconfig.cfg 2009-06-30 13:13:11.000000000 +0200 +--- jconfig.cfg.orig 2013-01-26 19:49:28 UTC ++++ jconfig.cfg @@ -7,8 +7,12 @@ #undef void #undef const Index: files/patch-jmorecfg.h =================================================================== --- files/patch-jmorecfg.h (revision 375268) +++ files/patch-jmorecfg.h (working copy) @@ -1,6 +1,6 @@ ---- jmorecfg.h.orig Sun Sep 18 14:53:48 2005 -+++ jmorecfg.h Sun Sep 18 14:54:27 2005 -@@ -187,8 +187,11 @@ +--- jmorecfg.h.orig 2013-09-17 07:20:20 UTC ++++ jmorecfg.h +@@ -245,8 +245,11 @@ typedef unsigned int JDIMENSION; /* a function referenced thru EXTERNs: */ #define GLOBAL(type) type /* a reference to a GLOBAL function: */ Index: files/patch-jpegtran.1 =================================================================== --- files/patch-jpegtran.1 (revision 375268) +++ files/patch-jpegtran.1 (working copy) @@ -1,6 +1,6 @@ ---- jpegtran.1.orig 2009-03-28 19:18:21.000000000 +0100 -+++ jpegtran.1 2009-07-01 09:19:36.000000000 +0200 -@@ -195,6 +195,14 @@ +--- jpegtran.1.orig 2013-09-13 12:58:16 UTC ++++ jpegtran.1 +@@ -216,6 +216,14 @@ but discards any other inessential (for Copy all extra markers. This setting preserves miscellaneous markers found in the source file, such as JFIF thumbnails, Exif data, and Photoshop settings. In some files these extra markers can be sizable. @@ -15,7 +15,7 @@ .IP The default behavior is .BR "\-copy comments" . -@@ -223,6 +231,26 @@ +@@ -244,6 +252,26 @@ give more output. Also, version informa .B \-debug Same as .BR \-verbose . Index: files/patch-jpegtran.c =================================================================== --- files/patch-jpegtran.c (revision 375268) +++ files/patch-jpegtran.c (working copy) @@ -1,5 +1,5 @@ ---- jpegtran.c.orig 2010-02-14 15:53:36.000000000 +0100 -+++ jpegtran.c 2010-03-09 16:00:19.000000000 +0100 +--- jpegtran.c.orig 2013-09-04 16:45:50 UTC ++++ jpegtran.c @@ -37,6 +37,7 @@ static const char * progname; /* program name for error messages */ @@ -8,150 +8,84 @@ static char * scaleoption; /* -scale switch */ static JCOPY_OPTION copyoption; /* -copy switch */ static jpeg_transform_info transformoption; /* image transformation options */ -@@ -57,6 +58,7 @@ - fprintf(stderr, " -copy none Copy no extra markers from source file\n"); - fprintf(stderr, " -copy comments Copy only comment markers (default)\n"); - fprintf(stderr, " -copy all Copy all extra markers\n"); -+ fprintf(stderr, " -copy exif Copy EXIF marker and omit JFIF if EXIF\n"); - #ifdef ENTROPY_OPT_SUPPORTED - fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); - #endif -@@ -66,6 +68,7 @@ +@@ -66,6 +67,7 @@ usage (void) 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, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n"); fprintf(stderr, " -perfect Fail if there is non-transformable edge blocks\n"); -@@ -75,7 +78,8 @@ - #if TRANSFORMS_SUPPORTED +@@ -76,6 +78,7 @@ usage (void) fprintf(stderr, " -transpose Transpose image\n"); fprintf(stderr, " -transverse Transverse transpose image\n"); -- fprintf(stderr, " -trim Drop non-transformable edge blocks\n"); -+ fprintf(stderr, " -trim Drop non-transformable edge blocks or\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"); - fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); -@@ -116,6 +120,52 @@ - } - - -+LOCAL(void) -+handle_exif (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, -+ JCOPY_OPTION *copyoption) -+/* Adjust the marker writing options to create an EXIF file, instead of JFIF, -+ * if so requested or an EXIF file is detected as input. Must be called after -+ * jpeg_copy_critical_parameters() as that sets the defaults. */ -+{ -+ jpeg_saved_marker_ptr cur_marker, prev_marker; -+ -+ /* Look for an exif marker */ -+ prev_marker = NULL; -+ cur_marker = srcinfo->marker_list; -+ while (cur_marker != NULL) { -+ if (cur_marker->marker == JPEG_APP0+1 && -+ cur_marker->data_length >= 6 && -+ GETJOCTET(cur_marker->data[0]) == 0x45 && -+ GETJOCTET(cur_marker->data[1]) == 0x78 && -+ GETJOCTET(cur_marker->data[2]) == 0x69 && -+ GETJOCTET(cur_marker->data[3]) == 0x66 && -+ GETJOCTET(cur_marker->data[4]) == 0 && -+ GETJOCTET(cur_marker->data[5]) == 0) -+ break; /* found an EXIF marker */ -+ prev_marker = cur_marker; -+ cur_marker = cur_marker->next; -+ } -+ /* If we've found an EXIF marker but not JFIF this is an EXIF file. Unless -+ * explicitely requested, make sure we keep the EXIF marker and do not -+ * emit a JFIF marker (which would come before). EXIF requires that the -+ * first marker be EXIF. */ -+ if (cur_marker != NULL && -+ ((*copyoption != JCOPYOPT_NONE && !srcinfo->saw_JFIF_marker) || -+ (*copyoption == JCOPYOPT_EXIF))) { -+ dstinfo->write_JFIF_header = FALSE; -+ if (*copyoption == JCOPYOPT_COMMENTS) -+ *copyoption = JCOPYOPT_EXIF; -+ } -+ /* If making an EXIF file, make sure that EXIF is first marker */ -+ if (cur_marker != NULL && prev_marker != NULL && -+ *copyoption == JCOPYOPT_EXIF) { -+ prev_marker->next = cur_marker->next; -+ cur_marker->next = srcinfo->marker_list; -+ srcinfo->marker_list = cur_marker; -+ } -+} -+ -+ - LOCAL(int) - parse_switches (j_compress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -@@ -136,6 +186,7 @@ - /* Set up default JPEG parameters. */ - simple_progressive = FALSE; - outfilename = NULL; -+ dropfilename = NULL; - scaleoption = NULL; - copyoption = JCOPYOPT_DEFAULT; - transformoption.transform = JXFORM_NONE; -@@ -179,6 +230,8 @@ - copyoption = JCOPYOPT_COMMENTS; - } else if (keymatch(argv[argn], "all", 1)) { - copyoption = JCOPYOPT_ALL; -+ } else if (keymatch(argv[argn], "exif", 1)) { -+ copyoption = JCOPYOPT_EXIF; - } else +@@ -188,7 +191,7 @@ parse_switches (j_compress_ptr cinfo, in + #if TRANSFORMS_SUPPORTED + if (++argn >= argc) /* advance to next argument */ usage(); - -@@ -196,6 +249,26 @@ +- 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 @@ parse_switches (j_compress_ptr cinfo, in 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 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(); ++ 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(); ++ if (++argn >= argc) /* advance to next argument */ ++ usage(); + dropfilename = argv[argn]; + select_transform(JXFORM_DROP); +#else -+ select_transform(JXFORM_NONE); /* force an error */ ++ 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 */ -@@ -204,6 +277,7 @@ - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's JPEGTRAN, version %s\n%s\n", - JVERSION, JCOPYRIGHT); -+ fprintf(stderr, "EXIF support v 0.1 added 29-Sep-2003\n"); - printed_version = TRUE; - } - cinfo->err->trace_level++; -@@ -371,6 +445,11 @@ +@@ -342,7 +365,7 @@ parse_switches (j_compress_ptr cinfo, in + #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 @@ int + main (int argc, char **argv) + { struct jpeg_decompress_struct srcinfo; - struct jpeg_compress_struct dstinfo; - struct jpeg_error_mgr jsrcerr, jdsterr; ++ 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 -@@ -452,6 +531,21 @@ +@@ -469,6 +498,21 @@ main (int argc, char **argv) fp = read_stdin(); } @@ -173,7 +107,7 @@ #ifdef PROGRESS_REPORT start_progress_monitor((j_common_ptr) &dstinfo, &progress); #endif -@@ -471,6 +565,17 @@ +@@ -488,6 +532,17 @@ main (int argc, char **argv) &srcinfo.scale_num, &srcinfo.scale_denom) < 1) usage(); @@ -191,7 +125,7 @@ /* Any space needed by a transform option must be requested before * jpeg_read_coefficients so that memory allocation will be done right. */ -@@ -486,6 +591,12 @@ +@@ -503,6 +558,12 @@ main (int argc, char **argv) /* Read source file as DCT coefficients */ src_coef_arrays = jpeg_read_coefficients(&srcinfo); @@ -204,21 +138,10 @@ /* Initialize destination compression parameters from source values */ jpeg_copy_critical_parameters(&srcinfo, &dstinfo); -@@ -524,6 +635,9 @@ - /* Adjust default compression parameters by re-parsing the options */ - file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); - -+ /* If we want EXIF, make sure we do not write incompatible markers */ -+ handle_exif(&srcinfo,&dstinfo,©option); -+ - /* Specify data destination for compression */ - jpeg_stdio_dest(&dstinfo, fp); - -@@ -545,16 +659,30 @@ +@@ -560,18 +621,33 @@ main (int argc, char **argv) + /* Finish compression and release memory */ + jpeg_finish_compress(&dstinfo); jpeg_destroy_compress(&dstinfo); - (void) jpeg_finish_decompress(&srcinfo); - jpeg_destroy_decompress(&srcinfo); -- +#if TRANSFORMS_SUPPORTED + if (dropfilename != NULL) { + (void) jpeg_finish_decompress(&dropinfo); @@ -225,6 +148,9 @@ + 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); @@ -241,7 +167,7 @@ +#if TRANSFORMS_SUPPORTED + if (dropfilename != NULL) + exit(jsrcerr.num_warnings + jdroperr.num_warnings + jdsterr.num_warnings ? -+ EXIT_WARNING : EXIT_SUCCESS); ++ EXIT_WARNING : EXIT_SUCCESS); +#endif exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS); return 0; /* suppress no-return-value warnings */ Index: files/patch-rdjpgcom.c =================================================================== --- files/patch-rdjpgcom.c (revision 375268) +++ files/patch-rdjpgcom.c (working copy) @@ -1,6 +1,6 @@ ---- rdjpgcom.c.orig 2009-04-03 01:30:13.000000000 +0200 -+++ rdjpgcom.c 2009-06-30 13:49:16.000000000 +0200 -@@ -124,6 +124,7 @@ +--- rdjpgcom.c.orig 2009-04-02 23:30:13 UTC ++++ rdjpgcom.c +@@ -124,6 +124,7 @@ read_2_bytes (void) #define M_EOI 0xD9 /* End Of Image (end of datastream) */ #define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ #define M_APP0 0xE0 /* Application-specific marker, type N */ @@ -8,7 +8,7 @@ #define M_APP12 0xEC /* (we don't bother to list all 16 APPn's) */ #define M_COM 0xFE /* COMment */ -@@ -214,6 +215,175 @@ +@@ -214,6 +215,175 @@ skip_variable (void) } } @@ -184,7 +184,7 @@ /* * Process a COM marker. -@@ -381,6 +551,15 @@ +@@ -381,6 +551,15 @@ scan_JPEG_header (int verbose, int raw) process_COM(raw); break; Index: files/patch-transupp.c =================================================================== --- files/patch-transupp.c (revision 375268) +++ files/patch-transupp.c (working copy) @@ -1,20 +1,6 @@ ---- transupp.c.orig 2011-10-26 13:20:05.000000000 +0200 -+++ transupp.c 2012-11-15 21:46:57.000000000 +0100 -@@ -51,6 +51,13 @@ - * guarantee we can touch more than one row at a time. So in that case, - * we have to use a separate destination array. - * -+ * If cropping or trimming is involved, the destination arrays may be smaller -+ * than the source arrays. Note it is not possible to do horizontal flip -+ * in-place when a nonzero Y crop offset is specified, since we'd have to move -+ * data from one block row to another but the virtual array manager doesn't -+ * guarantee we can touch more than one row at a time. So in that case, -+ * we have to use a separate destination array. -+ * - * Some notes about the operating environment of the individual transform - * routines: - * 1. Both the source and destination virtual arrays are allocated from the -@@ -75,6 +82,269 @@ +--- transupp.c.orig 2013-09-08 13:03:08 UTC ++++ transupp.c +@@ -75,6 +75,269 @@ */ @@ -273,7 +259,7 @@ + } 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)); ++ comp_width * SIZEOF(JBLOCK)); + } + } + } @@ -284,235 +270,96 @@ LOCAL(void) do_crop (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, -@@ -82,16 +352,21 @@ - jvirt_barray_ptr *dst_coef_arrays) - /* Crop. This is only used when no rotate/flip is requested with the crop. */ - { -+ JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height; - JDIMENSION dst_blk_y, x_crop_blocks, y_crop_blocks; - int ci, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; +@@ -991,10 +1254,10 @@ jtransform_request_workspace (j_decompre + jvirt_barray_ptr *coef_arrays; + boolean need_workspace, transpose_it; jpeg_component_info *compptr; - -+ MCU_cols = srcinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); -+ MCU_rows = srcinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); - /* We simply have to copy the right amount of data (the destination's - * image size) starting at the given X and Y offsets in the source. - */ - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; -+ comp_width = MCU_cols * compptr->h_samp_factor; -+ comp_height = MCU_rows * compptr->v_samp_factor; - x_crop_blocks = x_crop_offset * compptr->h_samp_factor; - y_crop_blocks = y_crop_offset * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; -@@ -99,17 +374,49 @@ - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); -+ if (dstinfo->image_height > srcinfo->image_height) { -+ if (dst_blk_y < y_crop_blocks || -+ dst_blk_y >= comp_height + y_crop_blocks) { -+ for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { -+ FMEMZERO(dst_buffer[offset_y], -+ compptr->width_in_blocks * SIZEOF(JBLOCK)); -+ } -+ continue; -+ } -+ src_buffer = (*srcinfo->mem->access_virt_barray) -+ ((j_common_ptr) srcinfo, src_coef_arrays[ci], -+ dst_blk_y - y_crop_blocks, -+ (JDIMENSION) compptr->v_samp_factor, FALSE); -+ } else { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_y + y_crop_blocks, - (JDIMENSION) compptr->v_samp_factor, FALSE); -+ } - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { -+ if (dstinfo->image_width > srcinfo->image_width) { -+ if (x_crop_blocks > 0) { -+ FMEMZERO(dst_buffer[offset_y], -+ x_crop_blocks * SIZEOF(JBLOCK)); -+ } -+ jcopy_block_row(src_buffer[offset_y], -+ dst_buffer[offset_y] + x_crop_blocks, -+ comp_width); -+ if (compptr->width_in_blocks > comp_width + x_crop_blocks) { -+ FMEMZERO(dst_buffer[offset_y] + -+ comp_width + x_crop_blocks, -+ (compptr->width_in_blocks - -+ comp_width - x_crop_blocks) * SIZEOF(JBLOCK)); -+ } -+ } else { -+ - jcopy_block_row(src_buffer[offset_y] + x_crop_blocks, - dst_buffer[offset_y], - compptr->width_in_blocks); - } - } - } -+ } - } - - -@@ -884,7 +1191,9 @@ - JDIMENSION xoffset, yoffset; +- JDIMENSION xoffset, yoffset; ++ JDIMENSION xoffset, yoffset, dtemp; JDIMENSION width_in_iMCUs, height_in_iMCUs; JDIMENSION width_in_blocks, height_in_blocks; -+ JDIMENSION dtemp; - int ci, h_samp_factor, v_samp_factor; -+ int itemp; +- 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 && -@@ -965,39 +1274,120 @@ - info->crop_xoffset = 0; /* default to +0 */ - if (info->crop_yoffset_set == JCROP_UNSET) - info->crop_yoffset = 0; /* default to +0 */ -- if (info->crop_xoffset >= info->output_width || -- info->crop_yoffset >= info->output_height) -+ if (info->crop_width_set == JCROP_UNSET) { -+ if (info->crop_xoffset >= info->output_width) - ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); -- if (info->crop_width_set == JCROP_UNSET) - info->crop_width = info->output_width - info->crop_xoffset; -- if (info->crop_height_set == JCROP_UNSET) -+ } else { -+ /* Check for crop extension */ -+ if (info->crop_width > info->output_width) { -+ /* Crop extension does not work when transforming! */ -+ if (info->transform != JXFORM_NONE || -+ info->crop_xoffset >= info->crop_width || -+ info->crop_xoffset > info->crop_width - info->output_width) -+ ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); -+ } else { -+ if (info->crop_xoffset >= info->output_width || -+ info->crop_width <= 0 || -+ info->crop_xoffset > info->output_width - info->crop_width) -+ ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); -+ } -+ } -+ if (info->crop_height_set == JCROP_UNSET) { -+ if (info->crop_yoffset >= info->output_height) -+ ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); - info->crop_height = info->output_height - info->crop_yoffset; -- /* Ensure parameters are valid */ -- if (info->crop_width <= 0 || info->crop_width > info->output_width || -- info->crop_height <= 0 || info->crop_height > info->output_height || -- info->crop_xoffset > info->output_width - info->crop_width || -+ } else { -+ /* Check for crop extension */ -+ if (info->crop_height > info->output_height) { -+ /* Crop extension does not work when transforming! */ -+ if (info->transform != JXFORM_NONE || -+ info->crop_yoffset >= info->crop_height || -+ info->crop_yoffset > info->crop_height - info->output_height) -+ ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); -+ } else { -+ if (info->crop_yoffset >= info->output_height || -+ info->crop_height <= 0 || - info->crop_yoffset > info->output_height - info->crop_height) - ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); -+ } -+ } - /* Convert negative crop offsets into regular offsets */ -- if (info->crop_xoffset_set == JCROP_NEG) -+ if (info->crop_xoffset_set == JCROP_NEG) { -+ if (info->crop_width > info->output_width) -+ xoffset = info->crop_width - info->output_width - info->crop_xoffset; -+ else - xoffset = info->output_width - info->crop_width - info->crop_xoffset; -- else -+ } else - xoffset = info->crop_xoffset; -- if (info->crop_yoffset_set == JCROP_NEG) -+ if (info->crop_yoffset_set == JCROP_NEG) { -+ if (info->crop_height > info->output_height) -+ yoffset = info->crop_height - info->output_height - info->crop_yoffset; -+ else +@@ -1128,7 +1391,54 @@ jtransform_request_workspace (j_decompre + else yoffset = info->output_height - info->crop_height - info->crop_yoffset; -- else -+ } else - yoffset = info->crop_yoffset; /* Now adjust so that upper left corner falls at an iMCU boundary */ -+ if (info->transform == JXFORM_DROP) { +- 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 = (info->crop_width - dtemp) / itemp; ++ 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 = 0; ++ 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 = (info->crop_height - dtemp) / itemp; ++ 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 = 0; ++ 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'); -+ } -+ } else { -+ /* Ensure the effective crop region will cover the requested */ -+ if (info->crop_width > info->output_width) -+ info->output_width = info->crop_width; -+ else { - if (info->crop_width_set == JCROP_FORCE) - info->output_width = info->crop_width; - else - info->output_width = - info->crop_width + (xoffset % info->iMCU_sample_width); -+ } -+ if (info->crop_height > info->output_height) -+ info->output_height = info->crop_height; -+ else { - if (info->crop_height_set == JCROP_FORCE) - info->output_height = info->crop_height; - else - info->output_height = - info->crop_height + (yoffset % info->iMCU_sample_height); -+ } -+ } ++ 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 @@ jtransform_request_workspace (j_decompre + 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 @@ jtransform_request_workspace (j_decompre + 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; - info->y_crop_offset = yoffset / info->iMCU_sample_height; -@@ -1013,7 +1403,9 @@ - transpose_it = FALSE; - switch (info->transform) { - case JXFORM_NONE: -- if (info->x_crop_offset != 0 || info->y_crop_offset != 0) -+ if (info->x_crop_offset != 0 || info->y_crop_offset != 0 || -+ info->output_width > srcinfo->image_width || -+ info->output_height > srcinfo->image_height) - need_workspace = TRUE; - /* No workspace needed if neither cropping nor transforming */ +@@ -1224,6 +1536,11 @@ jtransform_request_workspace (j_decompre break; -@@ -1067,6 +1459,11 @@ - need_workspace = TRUE; - transpose_it = TRUE; + case JXFORM_WIPE: break; + case JXFORM_DROP: +#if DROP_REQUEST_FROM_SRC @@ -522,7 +369,7 @@ } /* Allocate workspace if needed. -@@ -1373,6 +1770,11 @@ +@@ -1531,6 +1848,12 @@ jtransform_adjust_parameters (j_decompre case JXFORM_ROT_270: transpose_critical_parameters(dstinfo); break; @@ -529,31 +376,21 @@ + 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); ++ info->drop_ptr, info->drop_coef_arrays, ++ info->trim, dstinfo); ++ break; default: break; } -@@ -1427,7 +1829,9 @@ - */ - switch (info->transform) { - case JXFORM_NONE: -- if (info->x_crop_offset != 0 || info->y_crop_offset != 0) -+ if (info->x_crop_offset != 0 || info->y_crop_offset != 0 || -+ info->output_width > srcinfo->image_width || -+ info->output_height > srcinfo->image_height) - do_crop(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, dst_coef_arrays); +@@ -1629,6 +1952,12 @@ jtransform_execute_transform (j_decompre + do_wipe(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, info->drop_width, info->drop_height); break; -@@ -1463,6 +1867,12 @@ - do_rot_270(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, dst_coef_arrays); - 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); ++ src_coef_arrays, info->drop_ptr, info->drop_coef_arrays, ++ info->drop_width, info->drop_height); + break; } } Index: files/patch-transupp.h =================================================================== --- files/patch-transupp.h (revision 375268) +++ files/patch-transupp.h (working copy) @@ -1,16 +1,25 @@ ---- transupp.h.orig 2009-09-03 10:54:26.000000000 +0200 -+++ transupp.h 2010-01-13 09:34:06.000000000 +0100 -@@ -101,7 +101,8 @@ - JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */ +--- transupp.h.orig 2013-09-13 12:10:30 UTC ++++ transupp.h +@@ -106,7 +106,8 @@ typedef enum { JXFORM_ROT_90, /* 90-degree clockwise rotation */ JXFORM_ROT_180, /* 180-degree rotation */ -- JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */ -+ JXFORM_ROT_270, /* 270-degree clockwise (or 90 ccw) */ + JXFORM_ROT_270, /* 270-degree clockwise (or 90 ccw) */ +- JXFORM_WIPE /* wipe */ ++ JXFORM_WIPE, /* wipe */ + JXFORM_DROP /* drop */ } JXFORM_CODE; /* -@@ -141,6 +142,10 @@ +@@ -134,7 +135,7 @@ typedef struct { + 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 @@ typedef struct { JDIMENSION crop_yoffset; /* Y offset of selected region */ JCROP_CODE crop_yoffset_set; /* (negative measures from bottom edge) */ @@ -21,22 +30,3 @@ /* Internal workspace: caller should not touch these */ int num_components; /* # of components in workspace */ jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */ -@@ -148,6 +153,8 @@ - JDIMENSION output_height; - JDIMENSION x_crop_offset; /* destination crop offsets measured in iMCUs */ - JDIMENSION y_crop_offset; -+ JDIMENSION drop_width; /* drop dimensions measured in iMCUs */ -+ JDIMENSION drop_height; - int iMCU_sample_width; /* destination iMCU size */ - int iMCU_sample_height; - } jpeg_transform_info; -@@ -196,7 +203,8 @@ - typedef enum { - JCOPYOPT_NONE, /* copy no optional markers */ - JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */ -- JCOPYOPT_ALL /* copy all optional markers */ -+ JCOPYOPT_ALL, /* copy all optional markers */ -+ JCOPYOPT_EXIF /* copy Exif APP1 marker */ - } JCOPY_OPTION; - - #define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */ Index: pkg-plist =================================================================== --- pkg-plist (revision 375268) +++ pkg-plist (working copy) @@ -1,32 +1,18 @@ bin/cjpeg bin/djpeg -bin/exifautotran -bin/jpegexiforient bin/jpegtran bin/rdjpgcom bin/wrjpgcom include/jconfig.h include/jerror.h -include/jinclude.h include/jmorecfg.h -include/jpegint.h include/jpeglib.h lib/libjpeg.a lib/libjpeg.so -lib/libjpeg.so.11 -lib/libjpeg.so.8 -lib/libjpeg.so.8.4.0 +lib/libjpeg.so.9 +lib/libjpeg.so.9.1.0 man/man1/cjpeg.1.gz man/man1/djpeg.1.gz man/man1/jpegtran.1.gz man/man1/rdjpgcom.1.gz man/man1/wrjpgcom.1.gz -%%PORTDOCS%%%%DOCSDIR%%/README -%%PORTDOCS%%%%DOCSDIR%%/coderules.txt -%%PORTDOCS%%%%DOCSDIR%%/filelist.txt -%%PORTDOCS%%%%DOCSDIR%%/install.txt -%%PORTDOCS%%%%DOCSDIR%%/jconfig.txt -%%PORTDOCS%%%%DOCSDIR%%/libjpeg.txt -%%PORTDOCS%%%%DOCSDIR%%/structure.txt -%%PORTDOCS%%%%DOCSDIR%%/usage.txt -%%PORTDOCS%%%%DOCSDIR%%/wizard.txt