From: DRC Date: Fri, 18 Jan 2013 23:42:31 +0000 (+0000) Subject: Implement in-memory source/destination managers even when not emulating the libjpeg... X-Git-Tag: 1.2.90~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ab70623eb29e09e67222be5b9e1ea320fe5aa0e9;p=libjpeg-turbo Implement in-memory source/destination managers even when not emulating the libjpeg v8 API/ABI git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@913 632fc199-4ca6-4c93-a231-07263d6284db --- diff --git a/CMakeLists.txt b/CMakeLists.txt index b1763d5..facf450 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,7 @@ option(WITH_ARITH_ENC "Include arithmetic encoding support" TRUE) option(WITH_ARITH_DEC "Include arithmetic decoding support" TRUE) option(WITH_JPEG7 "Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b)" FALSE) option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b)" FALSE) +option(WITH_MEM_SRCDST "Include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI" TRUE) option(WITH_JAVA "Build Java wrapper for the TurboJPEG/OSS library" FALSE) if(WITH_ARITH_ENC) @@ -67,9 +68,14 @@ else() message(STATUS "TurboJPEG/OSS Java wrapper disabled") endif() +set(SO_AGE 0) +if(WITH_MEM_SRCDST) + set(SO_AGE 1) +endif() + set(JPEG_LIB_VERSION 62) set(DLL_VERSION ${JPEG_LIB_VERSION}) -set(FULLVERSION ${DLL_VERSION}.0.0) +set(FULLVERSION ${DLL_VERSION}.${SO_AGE}.0) if(WITH_JPEG8) set(JPEG_LIB_VERSION 80) set(DLL_VERSION 8) @@ -78,10 +84,17 @@ if(WITH_JPEG8) elseif(WITH_JPEG7) set(JPEG_LIB_VERSION 70) set(DLL_VERSION 7) - set(FULLVERSION ${DLL_VERSION}.0.0) + set(FULLVERSION ${DLL_VERSION}.${SO_AGE}.0) message(STATUS "Emulating libjpeg v7 API/ABI") endif(WITH_JPEG8) +if(WITH_MEM_SRCDST) + set(MEM_SRCDST_SUPPORTED 1) + message(STATUS "In-memory source/destination managers enabled") +else() + message(STATUS "In-memory source/destination managers disabled") +endif() + if(MSVC) # Use the static C library for all build types foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE diff --git a/ChangeLog.txt b/ChangeLog.txt index 87c88cb..b073d62 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -47,6 +47,16 @@ images (feature ported from jpeg-8d.) multiple "Mismatch in operand sizes" errors when attempting to build the x86 SIMD code with NASM 0.98. +[12] The in-memory source/destination managers (jpeg_mem_src() and +jpeg_mem_dest()) are now included by default when building libjpeg-turbo with +libjpeg v6b or v7 emulation, so that programs can take advantage of these +functions without requiring the use of the backward-incompatible libjpeg v8 +ABI. The "age number" of the libjpeg-turbo library on Un*x systems has been +incremented by 1 to reflect this. You can disable this feature with a +configure/CMake switch in order to retain strict API/ABI compatibility with the +libjpeg v6b or v7 API/ABI (or with previous versions of libjpeg-turbo.) See +README-turbo.txt for more details. + 1.2.1 ===== diff --git a/Makefile.am b/Makefile.am index 407b882..b70262e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ lib_LTLIBRARIES = libjpeg.la -libjpeg_la_LDFLAGS = -version-info ${SO_MAJOR_VERSION}:${SO_MINOR_VERSION} -no-undefined +libjpeg_la_LDFLAGS = -version-info ${SO_MAJOR_VERSION}:${SO_MINOR_VERSION}:${SO_AGE} -no-undefined include_HEADERS = jerror.h jmorecfg.h jpeglib.h if WITH_TURBOJPEG diff --git a/README-turbo.txt b/README-turbo.txt index 71c3992..91666f2 100755 --- a/README-turbo.txt +++ b/README-turbo.txt @@ -286,6 +286,9 @@ Fully supported: -- libjpeg: arithmetic coding +-- libjpeg: In-memory source and destination managers + See notes below. + -- cjpeg: Separate quality settings for luminance and chrominance Note that the libpjeg v7+ API was extended to accommodate this feature only for convenience purposes. It has always been possible to implement this @@ -306,11 +309,6 @@ Fully supported: -- rdjpgcom: locale awareness -Fully supported when using libjpeg v7/v8 emulation: - --- libjpeg: In-memory source and destination managers - - Not supported: NOTE: As of this writing, extensive research has been conducted into the @@ -369,6 +367,40 @@ there is not sufficient technical justification for software to upgrade from libjpeg v8 to libjpeg v9, and therefore, not sufficient technical justification for us to emulate the libjpeg v9 ABI. +===================================== +In-Memory Source/Destination Managers +===================================== + +By default, libjpeg-turbo 1.3 and later includes the jpeg_mem_src() and +jpeg_mem_dest() functions, even when not emulating the libjpeg v8 API/ABI. +Previously, it was necessary to build libjpeg-turbo from source with libjpeg v8 +API/ABI emulation in order to use the in-memory source/destination managers, +but several projects requested that those functions be included when emulating +the libjpeg v6b API/ABI as well. This allows the use of those functions +without breaking backward ABI compatibility with libjpeg v6b, and it allows +those functions to be provided in the "official" libjpeg-turbo binaries. + +Those who are concerned about maintaining strict conformance with the libjpeg +v6b or v7 API can pass an argument of --without-mem-srcdst to configure or +an argument of -DWITH_MEM_SRCDST=0 to CMake prior to building libjpeg-turbo. +This will restore the pre-1.3 behavior, in which jpeg_mem_src() and +jpeg_mem_dest() are only included when emulating the libjpeg v8 API/ABI. + +On Un*x systems, including the in-memory source/destination managers changes +the dynamic library version from 62.0.0 to 62.1.0 if using libjpeg v6b API/ABI +emulation and from 7.0.0 to 7.1.0 if using libjpeg v7 API/ABI emulation. + +Note that, on most operating systems, the dynamic linker will not look for +a function in a library until that function is actually used. Thus, if a +program is built against libjpeg-turbo 1.3+ and uses jpeg_mem_src() or +jpeg_mem_dest(), that program will not fail if run against an older version of +libjpeg-turbo or against libjpeg v6b until the program actually tries to call +jpeg_mem_src() or jpeg_mem_dest(). + +Both cjpeg and djpeg have been extended to allow testing the in-memory +source/destination manager functions. See their respective man pages for more +details. + ******************************************************************************* ** Mathematical Compatibility diff --git a/cjpeg.1 b/cjpeg.1 index d336cc8..113efd5 100644 --- a/cjpeg.1 +++ b/cjpeg.1 @@ -1,4 +1,4 @@ -.TH CJPEG 1 "1 January 2013" +.TH CJPEG 1 "18 January 2013" .SH NAME cjpeg \- compress an image file to a JPEG file .SH SYNOPSIS @@ -195,6 +195,11 @@ selects 4000000 bytes. If more space is needed, temporary files will be used. .BI \-outfile " name" Send output image to the named file, not to standard output. .TP +.BI \-memdst +Compress to memory instead of a file. This feature was implemented mainly as a +way of testing the in-memory destination manager (jpeg_mem_dest()), but it is +also useful for benchmarking, since it reduces the I/O overhead. +.TP .B \-verbose Enable debug printout. More .BR \-v 's @@ -315,7 +320,8 @@ Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. Independent JPEG Group .PP This file was modified by The libjpeg-turbo Project to include only information -relevant to libjpeg-turbo and to wordsmith certain sections. +relevant to libjpeg-turbo, to wordsmith certain sections, and to describe +features not present in libjpeg. .SH BUGS Support for GIF input files was removed in cjpeg v6b due to concerns over the Unisys LZW patent. Although this patent expired in 2006, cjpeg still diff --git a/cjpeg.c b/cjpeg.c index 495a5bd..45b0cc7 100644 --- a/cjpeg.c +++ b/cjpeg.c @@ -5,7 +5,7 @@ * Copyright (C) 1991-1998, Thomas G. Lane. * Modified 2003-2011 by Guido Vollbeding. * Modifications: - * Copyright (C) 2010, D. R. Commander. + * Copyright (C) 2010, 2013, D. R. Commander. * For conditions of distribution and use, see the accompanying README file. * * This file contains a command-line user interface for the JPEG compressor. @@ -139,6 +139,7 @@ select_file_type (j_compress_ptr cinfo, FILE * infile) static const char * progname; /* program name for error messages */ static char * outfilename; /* for -outfile switch */ +boolean memdst; /* for -memdst switch */ LOCAL(void) @@ -187,6 +188,9 @@ usage (void) #endif fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); fprintf(stderr, " -outfile name Specify name for output file\n"); +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) + fprintf(stderr, " -memdst Compress to memory instead of file (useful for benchmarking)\n"); +#endif fprintf(stderr, " -verbose or -debug Emit debug output\n"); fprintf(stderr, "Switches for wizards:\n"); fprintf(stderr, " -baseline Force baseline quantization tables\n"); @@ -228,6 +232,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv, simple_progressive = FALSE; is_targa = FALSE; outfilename = NULL; + memdst = FALSE; cinfo->err->trace_level = 0; /* Scan command line options, adjust parameters */ @@ -312,7 +317,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv, #ifdef ENTROPY_OPT_SUPPORTED cinfo->optimize_coding = TRUE; #else - fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", + fprintf(stderr, "%s: sorry, entropy optimization was not compiled in\n", progname); exit(EXIT_FAILURE); #endif @@ -329,11 +334,21 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv, simple_progressive = TRUE; /* We must postpone execution until num_components is known. */ #else - fprintf(stderr, "%s: sorry, progressive output was not compiled\n", + fprintf(stderr, "%s: sorry, progressive output was not compiled in\n", progname); exit(EXIT_FAILURE); #endif + } else if (keymatch(arg, "memdst", 2)) { + /* Use in-memory destination manager */ +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) + memdst = TRUE; +#else + fprintf(stderr, "%s: sorry, in-memory destination manager was not compiled in\n", + progname); + exit(EXIT_FAILURE); +#endif + } else if (keymatch(arg, "quality", 1)) { /* Quality ratings (quantization table scaling factors). */ if (++argn >= argc) /* advance to next argument */ @@ -394,7 +409,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv, scansarg = argv[argn]; /* We must postpone reading the file in case -progressive appears. */ #else - fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", + fprintf(stderr, "%s: sorry, multi-scan output was not compiled in\n", progname); exit(EXIT_FAILURE); #endif @@ -473,7 +488,9 @@ main (int argc, char **argv) int file_index; cjpeg_source_ptr src_mgr; FILE * input_file; - FILE * output_file; + FILE * output_file = NULL; + unsigned char *outbuffer = NULL; + unsigned long outsize = 0; JDIMENSION num_scanlines; /* On Mac, fetch a command line. */ @@ -516,19 +533,21 @@ main (int argc, char **argv) file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); #ifdef TWO_FILE_COMMANDLINE - /* Must have either -outfile switch or explicit output file name */ - if (outfilename == NULL) { - if (file_index != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - outfilename = argv[file_index+1]; - } else { - if (file_index != argc-1) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); + if (!memdst) { + /* Must have either -outfile switch or explicit output file name */ + if (outfilename == NULL) { + if (file_index != argc-2) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } + outfilename = argv[file_index+1]; + } else { + if (file_index != argc-1) { + fprintf(stderr, "%s: must name one input and one output file\n", + progname); + usage(); + } } } #else @@ -556,7 +575,7 @@ main (int argc, char **argv) fprintf(stderr, "%s: can't open %s\n", progname, outfilename); exit(EXIT_FAILURE); } - } else { + } else if (!memdst) { /* default output file is stdout */ output_file = write_stdout(); } @@ -579,7 +598,12 @@ main (int argc, char **argv) file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); /* Specify data destination for compression */ - jpeg_stdio_dest(&cinfo, output_file); +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) + if (memdst) + jpeg_mem_dest(&cinfo, &outbuffer, &outsize); + else +#endif + jpeg_stdio_dest(&cinfo, output_file); /* Start compressor */ jpeg_start_compress(&cinfo, TRUE); @@ -598,13 +622,19 @@ main (int argc, char **argv) /* Close files, if we opened them */ if (input_file != stdin) fclose(input_file); - if (output_file != stdout) + if (output_file != stdout && output_file != NULL) fclose(output_file); #ifdef PROGRESS_REPORT end_progress_monitor((j_common_ptr) &cinfo); #endif + if (memdst) { + fprintf(stderr, "Compressed size: %lu bytes\n", outsize); + if (outbuffer != NULL) + free(outbuffer); + } + /* All done. */ exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); return 0; /* suppress no-return-value warnings */ diff --git a/configure.ac b/configure.ac index a3e748c..ae331cf 100644 --- a/configure.ac +++ b/configure.ac @@ -121,7 +121,6 @@ AC_SUBST(JPEG_LIB_VERSION_DECIMAL) AC_MSG_RESULT([$JPEG_LIB_VERSION_DECIMAL]) AC_DEFINE_UNQUOTED(JPEG_LIB_VERSION, [$JPEG_LIB_VERSION], [libjpeg API version]) -AC_MSG_CHECKING([libjpeg shared library version]) AC_ARG_VAR(SO_MAJOR_VERSION, [Major version of the libjpeg-turbo shared library (default is determined by the API version)]) AC_ARG_VAR(SO_MINOR_VERSION, [Minor version of the libjpeg-turbo shared library (default is determined by the API version)]) if test "x$SO_MAJOR_VERSION" = "x"; then @@ -136,9 +135,31 @@ if test "x$SO_MINOR_VERSION" = "x"; then *) SO_MINOR_VERSION=0 ;; esac fi -AC_MSG_RESULT([$SO_MAJOR_VERSION:$SO_MINOR_VERSION]) + +# Memory source/destination managers +SO_AGE=0 +MEM_SRCDST_FUNCTIONS= +if test "x${with_jpeg8}" != "xyes"; then + AC_MSG_CHECKING([whether to include in-memory source/destination managers]) + AC_ARG_WITH([mem-srcdst], + AC_HELP_STRING([--without-mem-srcdst], [Do not include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI])) + if test "x$with_mem_srcdst" != "xno"; then + AC_MSG_RESULT(yes) + AC_DEFINE([MEM_SRCDST_SUPPORTED], [1], [Support in-memory source/destination managers]) + SO_AGE=1 + MEM_SRCDST_FUNCTIONS="global: jpeg_mem_dest; jpeg_mem_src;"; + else + AC_MSG_RESULT(no) + fi +fi + +AC_MSG_CHECKING([libjpeg shared library version]) +AC_MSG_RESULT([$SO_MAJOR_VERSION.$SO_AGE.$SO_MINOR_VERSION]) +SO_MAJOR_VERSION=`expr $SO_MAJOR_VERSION + $SO_AGE` AC_SUBST(SO_MAJOR_VERSION) AC_SUBST(SO_MINOR_VERSION) +AC_SUBST(SO_AGE) +AC_SUBST(MEM_SRCDST_FUNCTIONS) AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION, [$VERSION], [libjpeg-turbo version]) diff --git a/djpeg.1 b/djpeg.1 index 4cc19c8..8bb7d27 100644 --- a/djpeg.1 +++ b/djpeg.1 @@ -1,4 +1,4 @@ -.TH DJPEG 1 "1 January 2013" +.TH DJPEG 1 "18 January 2013" .SH NAME djpeg \- decompress a JPEG file to an image file .SH SYNOPSIS @@ -173,6 +173,10 @@ selects 4000000 bytes. If more space is needed, temporary files will be used. .BI \-outfile " name" Send output image to the named file, not to standard output. .TP +.BI \-memsrc +Load input file into memory before decompressing. This feature was implemented +mainly as a way of testing the in-memory source manager (jpeg_mem_src().) +.TP .B \-verbose Enable debug printout. More .BR \-v 's @@ -245,7 +249,8 @@ Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44. Independent JPEG Group .PP This file was modified by The libjpeg-turbo Project to include only information -relevant to libjpeg-turbo and to wordsmith certain sections. +relevant to libjpeg-turbo, to wordsmith certain sections, and to describe +features not present in libjpeg. .SH BUGS To avoid the Unisys LZW patent, .B djpeg diff --git a/djpeg.c b/djpeg.c index b8f1187..9cfaad0 100644 --- a/djpeg.c +++ b/djpeg.c @@ -4,7 +4,7 @@ * This file was part of the Independent JPEG Group's software: * Copyright (C) 1991-1997, Thomas G. Lane. * Modifications: - * Copyright (C) 2010-2011, D. R. Commander. + * Copyright (C) 2010-2011, 2013, D. R. Commander. * For conditions of distribution and use, see the accompanying README file. * * This file contains a command-line user interface for the JPEG decompressor. @@ -87,6 +87,8 @@ static IMAGE_FORMATS requested_fmt; static const char * progname; /* program name for error messages */ static char * outfilename; /* for -outfile switch */ +boolean memsrc; /* for -memsrc switch */ +#define INPUT_BUF_SIZE 4096 LOCAL(void) @@ -157,6 +159,10 @@ usage (void) #endif fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); fprintf(stderr, " -outfile name Specify name for output file\n"); +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) + fprintf(stderr, " -memsrc Load input file into memory before decompressing\n"); +#endif + fprintf(stderr, " -verbose or -debug Emit debug output\n"); exit(EXIT_FAILURE); } @@ -180,6 +186,7 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv, /* Set up default JPEG parameters. */ requested_fmt = DEFAULT_FMT; /* set default output file format */ outfilename = NULL; + memsrc = FALSE; cinfo->err->trace_level = 0; /* Scan command line options, adjust parameters */ @@ -325,6 +332,16 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv, usage(); outfilename = argv[argn]; /* save it away for later use */ + } else if (keymatch(arg, "memsrc", 2)) { + /* Use in-memory source manager */ +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) + memsrc = TRUE; +#else + fprintf(stderr, "%s: sorry, in-memory source manager was not compiled in\n", + progname); + exit(EXIT_FAILURE); +#endif + } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) { /* PPM/PGM output format. */ requested_fmt = FMT_PPM; @@ -443,6 +460,8 @@ main (int argc, char **argv) djpeg_dest_ptr dest_mgr = NULL; FILE * input_file; FILE * output_file; + unsigned char *inbuffer = NULL; + unsigned long insize = 0; JDIMENSION num_scanlines; /* On Mac, fetch a command line. */ @@ -537,7 +556,30 @@ main (int argc, char **argv) #endif /* Specify data source for decompression */ - jpeg_stdio_src(&cinfo, input_file); +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) + if (memsrc) { + size_t nbytes; + do { + inbuffer = (unsigned char *)realloc(inbuffer, insize + INPUT_BUF_SIZE); + if (inbuffer == NULL) { + fprintf(stderr, "%s: memory allocation failure\n", progname); + exit(EXIT_FAILURE); + } + nbytes = JFREAD(input_file, &inbuffer[insize], INPUT_BUF_SIZE); + if (nbytes < 0) { + if (file_index < argc) + fprintf(stderr, "%s: can't read from %s\n", progname, + argv[file_index]); + else + fprintf(stderr, "%s: can't read from stdin\n", progname); + } + insize += nbytes; + } while (nbytes == INPUT_BUF_SIZE); + fprintf(stderr, "Compressed size: %lu bytes\n", insize); + jpeg_mem_src(&cinfo, inbuffer, insize); + } else +#endif + jpeg_stdio_src(&cinfo, input_file); /* Read file header, set default decompression parameters */ (void) jpeg_read_header(&cinfo, TRUE); @@ -621,6 +663,9 @@ main (int argc, char **argv) end_progress_monitor((j_common_ptr) &cinfo); #endif + if (memsrc && inbuffer != NULL) + free(inbuffer); + /* All done. */ exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); return 0; /* suppress no-return-value warnings */ diff --git a/jconfig.h.in b/jconfig.h.in index 27d4cc9..6b80ce2 100644 --- a/jconfig.h.in +++ b/jconfig.h.in @@ -12,6 +12,9 @@ /* Support arithmetic decoding */ #undef D_ARITH_CODING_SUPPORTED +/* Support in-memory source/destination managers */ +#undef MEM_SRCDST_SUPPORTED + /* Compiler supports function prototypes. */ #undef HAVE_PROTOTYPES diff --git a/jdatadst.c b/jdatadst.c index a363d15..ff87ecd 100644 --- a/jdatadst.c +++ b/jdatadst.c @@ -1,9 +1,11 @@ /* * jdatadst.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1994-1996, Thomas G. Lane. * Modified 2009-2012 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. + * Modifications: + * Copyright (C) 2013, D. R. Commander. * For conditions of distribution and use, see the accompanying README file. * * This file contains compression data destination routines for the case of @@ -40,7 +42,7 @@ typedef my_destination_mgr * my_dest_ptr; #define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */ -#if JPEG_LIB_VERSION >= 80 +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) /* Expanded data destination object for memory output */ typedef struct { @@ -76,7 +78,7 @@ init_destination (j_compress_ptr cinfo) dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; } -#if JPEG_LIB_VERSION >= 80 +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) METHODDEF(void) init_mem_destination (j_compress_ptr cinfo) { @@ -123,7 +125,7 @@ empty_output_buffer (j_compress_ptr cinfo) return TRUE; } -#if JPEG_LIB_VERSION >= 80 +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) METHODDEF(boolean) empty_mem_output_buffer (j_compress_ptr cinfo) { @@ -182,7 +184,7 @@ term_destination (j_compress_ptr cinfo) ERREXIT(cinfo, JERR_FILE_WRITE); } -#if JPEG_LIB_VERSION >= 80 +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) METHODDEF(void) term_mem_destination (j_compress_ptr cinfo) { @@ -225,7 +227,7 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile) } -#if JPEG_LIB_VERSION >= 80 +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) /* * Prepare for output to a memory buffer. * The caller may supply an own initial buffer with appropriate size. diff --git a/jdatasrc.c b/jdatasrc.c index 602f3e1..69e8f6d 100644 --- a/jdatasrc.c +++ b/jdatasrc.c @@ -1,9 +1,11 @@ /* * jdatasrc.c * + * This file was part of the Independent JPEG Group's software: * Copyright (C) 1994-1996, Thomas G. Lane. * Modified 2009-2011 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. + * Modifications: + * Copyright (C) 2013, D. R. Commander. * For conditions of distribution and use, see the accompanying README file. * * This file contains decompression data source routines for the case of @@ -53,7 +55,7 @@ init_source (j_decompress_ptr cinfo) src->start_of_file = TRUE; } -#if JPEG_LIB_VERSION >= 80 +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) METHODDEF(void) init_mem_source (j_decompress_ptr cinfo) { @@ -120,7 +122,7 @@ fill_input_buffer (j_decompress_ptr cinfo) return TRUE; } -#if JPEG_LIB_VERSION >= 80 +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) METHODDEF(boolean) fill_mem_input_buffer (j_decompress_ptr cinfo) { @@ -244,7 +246,7 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile) } -#if JPEG_LIB_VERSION >= 80 +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) /* * Prepare for input from a supplied memory buffer. * The buffer must contain the whole JPEG data. diff --git a/jpeglib.h b/jpeglib.h index 6bf0b78..91668ed 100644 --- a/jpeglib.h +++ b/jpeglib.h @@ -5,7 +5,7 @@ * Copyright (C) 1991-1998, Thomas G. Lane. * Modified 2002-2009 by Guido Vollbeding. * Modifications: - * Copyright (C) 2009-2011, D. R. Commander. + * Copyright (C) 2009-2011, 2013, D. R. Commander. * For conditions of distribution and use, see the accompanying README file. * * This file defines the application interface for the JPEG library. @@ -913,7 +913,7 @@ typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); #define jpeg_destroy_decompress jDestDecompress #define jpeg_stdio_dest jStdDest #define jpeg_stdio_src jStdSrc -#if JPEG_LIB_VERSION >= 80 +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) #define jpeg_mem_dest jMemDest #define jpeg_mem_src jMemSrc #endif @@ -1000,7 +1000,7 @@ EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); -#if JPEG_LIB_VERSION >= 80 +#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED) /* Data source and destination managers: memory buffers. */ EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo, unsigned char ** outbuffer, diff --git a/libjpeg.map.in b/libjpeg.map.in index 5443943..b4480d8 100644 --- a/libjpeg.map.in +++ b/libjpeg.map.in @@ -1,4 +1,5 @@ LIBJPEGTURBO_@JPEG_LIB_VERSION_DECIMAL@ { + @MEM_SRCDST_FUNCTIONS@ local: jsimd_*; jconst_*; diff --git a/sharedlib/CMakeLists.txt b/sharedlib/CMakeLists.txt index 25ddbdf..e54ee52 100755 --- a/sharedlib/CMakeLists.txt +++ b/sharedlib/CMakeLists.txt @@ -24,8 +24,13 @@ if(WITH_SIMD) set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1) endif() -add_library(jpeg SHARED ${JPEG_SRCS} ${SIMD_OBJS} - ${CMAKE_SOURCE_DIR}/win/jpeg${DLL_VERSION}.def) +if(WITH_MEM_SRCDST) + add_library(jpeg SHARED ${JPEG_SRCS} ${SIMD_OBJS} + ${CMAKE_SOURCE_DIR}/win/jpeg${DLL_VERSION}-memsrcdst.def) +else() + add_library(jpeg SHARED ${JPEG_SRCS} ${SIMD_OBJS} + ${CMAKE_SOURCE_DIR}/win/jpeg${DLL_VERSION}.def) +endif() set_target_properties(jpeg PROPERTIES SOVERSION ${DLL_VERSION} VERSION ${FULLVERSION}) if(MSVC) diff --git a/win/jconfig.h.in b/win/jconfig.h.in index be4b5c3..ddcf97e 100644 --- a/win/jconfig.h.in +++ b/win/jconfig.h.in @@ -5,6 +5,7 @@ #define LIBJPEG_TURBO_VERSION @VERSION@ #cmakedefine C_ARITH_CODING_SUPPORTED #cmakedefine D_ARITH_CODING_SUPPORTED +#cmakedefine MEM_SRCDST_SUPPORTED #define HAVE_PROTOTYPES #define HAVE_UNSIGNED_CHAR diff --git a/win/jpeg62-memsrcdst.def b/win/jpeg62-memsrcdst.def new file mode 100755 index 0000000..4511c8e --- /dev/null +++ b/win/jpeg62-memsrcdst.def @@ -0,0 +1,104 @@ +EXPORTS + jcopy_block_row @ 1 ; + jcopy_sample_rows @ 2 ; + jdiv_round_up @ 3 ; + jinit_1pass_quantizer @ 4 ; + jinit_2pass_quantizer @ 5 ; + jinit_c_coef_controller @ 6 ; + jinit_c_main_controller @ 7 ; + jinit_c_master_control @ 8 ; + jinit_c_prep_controller @ 9 ; + jinit_color_converter @ 10 ; + jinit_color_deconverter @ 11 ; + jinit_compress_master @ 12 ; + jinit_d_coef_controller @ 13 ; + jinit_d_main_controller @ 14 ; + jinit_d_post_controller @ 15 ; + jinit_downsampler @ 16 ; + jinit_forward_dct @ 17 ; + jinit_huff_decoder @ 18 ; + jinit_huff_encoder @ 19 ; + jinit_input_controller @ 20 ; + jinit_inverse_dct @ 21 ; + jinit_marker_reader @ 22 ; + jinit_marker_writer @ 23 ; + jinit_master_decompress @ 24 ; + jinit_memory_mgr @ 25 ; + jinit_merged_upsampler @ 26 ; + jinit_phuff_decoder @ 27 ; + jinit_phuff_encoder @ 28 ; + jinit_upsampler @ 29 ; + jpeg_CreateCompress @ 30 ; + jpeg_CreateDecompress @ 31 ; + jpeg_abort @ 32 ; + jpeg_abort_compress @ 33 ; + jpeg_abort_decompress @ 34 ; + jpeg_add_quant_table @ 35 ; + jpeg_alloc_huff_table @ 36 ; + jpeg_alloc_quant_table @ 37 ; + jpeg_calc_output_dimensions @ 38 ; + jpeg_consume_input @ 39 ; + jpeg_copy_critical_parameters @ 40 ; + jpeg_default_colorspace @ 41 ; + jpeg_destroy @ 42 ; + jpeg_destroy_compress @ 43 ; + jpeg_destroy_decompress @ 44 ; + jpeg_fdct_float @ 45 ; + jpeg_fdct_ifast @ 46 ; + jpeg_fdct_islow @ 47 ; + jpeg_fill_bit_buffer @ 48 ; + jpeg_finish_compress @ 49 ; + jpeg_finish_decompress @ 50 ; + jpeg_finish_output @ 51 ; + jpeg_free_large @ 52 ; + jpeg_free_small @ 53 ; + jpeg_gen_optimal_table @ 54 ; + jpeg_get_large @ 55 ; + jpeg_get_small @ 56 ; + jpeg_has_multiple_scans @ 57 ; + jpeg_huff_decode @ 58 ; + jpeg_idct_1x1 @ 59 ; + jpeg_idct_2x2 @ 60 ; + jpeg_idct_4x4 @ 61 ; + jpeg_idct_float @ 62 ; + jpeg_idct_ifast @ 63 ; + jpeg_idct_islow @ 64 ; + jpeg_input_complete @ 65 ; + jpeg_make_c_derived_tbl @ 66 ; + jpeg_make_d_derived_tbl @ 67 ; + jpeg_mem_available @ 68 ; + jpeg_mem_init @ 69 ; + jpeg_mem_term @ 70 ; + jpeg_new_colormap @ 71 ; + jpeg_open_backing_store @ 72 ; + jpeg_quality_scaling @ 73 ; + jpeg_read_coefficients @ 74 ; + jpeg_read_header @ 75 ; + jpeg_read_raw_data @ 76 ; + jpeg_read_scanlines @ 77 ; + jpeg_resync_to_restart @ 78 ; + jpeg_save_markers @ 79 ; + jpeg_set_colorspace @ 80 ; + jpeg_set_defaults @ 81 ; + jpeg_set_linear_quality @ 82 ; + jpeg_set_marker_processor @ 83 ; + jpeg_set_quality @ 84 ; + jpeg_simple_progression @ 85 ; + jpeg_start_compress @ 86 ; + jpeg_start_decompress @ 87 ; + jpeg_start_output @ 88 ; + jpeg_std_error @ 89 ; + jpeg_stdio_dest @ 90 ; + jpeg_stdio_src @ 91 ; + jpeg_suppress_tables @ 92 ; + jpeg_write_coefficients @ 93 ; + jpeg_write_m_byte @ 94 ; + jpeg_write_m_header @ 95 ; + jpeg_write_marker @ 96 ; + jpeg_write_raw_data @ 97 ; + jpeg_write_scanlines @ 98 ; + jpeg_write_tables @ 99 ; + jround_up @ 100 ; + jzero_far @ 101 ; + jpeg_mem_dest @ 102 ; + jpeg_mem_src @ 103 ; diff --git a/win/jpeg7-memsrcdst.def b/win/jpeg7-memsrcdst.def new file mode 100644 index 0000000..8c9f517 --- /dev/null +++ b/win/jpeg7-memsrcdst.def @@ -0,0 +1,106 @@ +EXPORTS + jcopy_block_row @ 1 ; + jcopy_sample_rows @ 2 ; + jdiv_round_up @ 3 ; + jinit_1pass_quantizer @ 4 ; + jinit_2pass_quantizer @ 5 ; + jinit_c_coef_controller @ 6 ; + jinit_c_main_controller @ 7 ; + jinit_c_master_control @ 8 ; + jinit_c_prep_controller @ 9 ; + jinit_color_converter @ 10 ; + jinit_color_deconverter @ 11 ; + jinit_compress_master @ 12 ; + jinit_d_coef_controller @ 13 ; + jinit_d_main_controller @ 14 ; + jinit_d_post_controller @ 15 ; + jinit_downsampler @ 16 ; + jinit_forward_dct @ 17 ; + jinit_huff_decoder @ 18 ; + jinit_huff_encoder @ 19 ; + jinit_input_controller @ 20 ; + jinit_inverse_dct @ 21 ; + jinit_marker_reader @ 22 ; + jinit_marker_writer @ 23 ; + jinit_master_decompress @ 24 ; + jinit_memory_mgr @ 25 ; + jinit_merged_upsampler @ 26 ; + jinit_phuff_decoder @ 27 ; + jinit_phuff_encoder @ 28 ; + jinit_upsampler @ 29 ; + jpeg_CreateCompress @ 30 ; + jpeg_CreateDecompress @ 31 ; + jpeg_abort @ 32 ; + jpeg_abort_compress @ 33 ; + jpeg_abort_decompress @ 34 ; + jpeg_add_quant_table @ 35 ; + jpeg_alloc_huff_table @ 36 ; + jpeg_alloc_quant_table @ 37 ; + jpeg_calc_jpeg_dimensions @ 38 ; + jpeg_calc_output_dimensions @ 39 ; + jpeg_consume_input @ 40 ; + jpeg_copy_critical_parameters @ 41 ; + jpeg_default_colorspace @ 42 ; + jpeg_default_qtables @ 43 ; + jpeg_destroy @ 44 ; + jpeg_destroy_compress @ 45 ; + jpeg_destroy_decompress @ 46 ; + jpeg_fdct_float @ 47 ; + jpeg_fdct_ifast @ 48 ; + jpeg_fdct_islow @ 49 ; + jpeg_fill_bit_buffer @ 50 ; + jpeg_finish_compress @ 51 ; + jpeg_finish_decompress @ 52 ; + jpeg_finish_output @ 53 ; + jpeg_free_large @ 54 ; + jpeg_free_small @ 55 ; + jpeg_gen_optimal_table @ 56 ; + jpeg_get_large @ 57 ; + jpeg_get_small @ 58 ; + jpeg_has_multiple_scans @ 59 ; + jpeg_huff_decode @ 60 ; + jpeg_idct_1x1 @ 61 ; + jpeg_idct_2x2 @ 62 ; + jpeg_idct_4x4 @ 63 ; + jpeg_idct_float @ 64 ; + jpeg_idct_ifast @ 65 ; + jpeg_idct_islow @ 66 ; + jpeg_input_complete @ 67 ; + jpeg_make_c_derived_tbl @ 68 ; + jpeg_make_d_derived_tbl @ 69 ; + jpeg_mem_available @ 70 ; + jpeg_mem_init @ 71 ; + jpeg_mem_term @ 72 ; + jpeg_new_colormap @ 73 ; + jpeg_open_backing_store @ 74 ; + jpeg_quality_scaling @ 75 ; + jpeg_read_coefficients @ 76 ; + jpeg_read_header @ 77 ; + jpeg_read_raw_data @ 78 ; + jpeg_read_scanlines @ 79 ; + jpeg_resync_to_restart @ 80 ; + jpeg_save_markers @ 81 ; + jpeg_set_colorspace @ 82 ; + jpeg_set_defaults @ 83 ; + jpeg_set_linear_quality @ 84 ; + jpeg_set_marker_processor @ 85 ; + jpeg_set_quality @ 86 ; + jpeg_simple_progression @ 87 ; + jpeg_start_compress @ 88 ; + jpeg_start_decompress @ 89 ; + jpeg_start_output @ 90 ; + jpeg_std_error @ 91 ; + jpeg_stdio_dest @ 92 ; + jpeg_stdio_src @ 93 ; + jpeg_suppress_tables @ 94 ; + jpeg_write_coefficients @ 95 ; + jpeg_write_m_byte @ 96 ; + jpeg_write_m_header @ 97 ; + jpeg_write_marker @ 98 ; + jpeg_write_raw_data @ 99 ; + jpeg_write_scanlines @ 100 ; + jpeg_write_tables @ 101 ; + jround_up @ 102 ; + jzero_far @ 103 ; + jpeg_mem_dest @ 104 ; + jpeg_mem_src @ 105 ;