aboutsummaryrefslogtreecommitdiff
path: root/jdatasrc.c
diff options
context:
space:
mode:
authorAlex Naidis <alex.naidis@linux.com>2016-10-16 23:10:08 +0200
committerAlex Naidis <alex.naidis@linux.com>2016-10-23 15:24:06 +0200
commit6eb7d3798b5a79347c62825fc4c16f7ce673bdd0 (patch)
tree1434d2258d7fe0588e35d359c21f21259d005453 /jdatasrc.c
parente7bf3c56cadcd76c624a9bd1798d64c03c2a1210 (diff)
downloadlibjpeg-turbo-6eb7d3798b5a79347c62825fc4c16f7ce673bdd0.tar.gz
libjpeg-turbo: Upgrade to 1.5.1
The changes from 1.4.2 to 1.5.1 include a big amount of fixes and huge performance improvements. As highlights there is a full ARM 64-bit (ARMv8) NEON SIMD implementation which improves compression of full-color JPEGs by about 2-2.5x on average on Cortex-A53 and Cortex-A57 cores. Also SIMD acceleration for Huffman encoding on NEON-capable ARM 32-bit and 64-bit platforms was added. Performance on x86/x86_64 was also improved by adding better optimized SSE2 routines. For the full changelog, please see the ChangeLog.md file. Partial decoding optimizations, the security fix to adress b/27494207 and the fix for the AARCH64 conformance issueare present in the release. The README.android file was edited to reflect this. The configuration files were regenerated and all Android specific changes were applied. BUG:28268702 Change-Id: I538291d894df1da01d3f733771647df1fb61ec42 Signed-off-by: Alex Naidis <alex.naidis@linux.com>
Diffstat (limited to 'jdatasrc.c')
-rw-r--r--jdatasrc.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/jdatasrc.c b/jdatasrc.c
index bf70422b..c83183fe 100644
--- a/jdatasrc.c
+++ b/jdatasrc.c
@@ -5,8 +5,9 @@
* Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2011 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2013, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README file.
+ * Copyright (C) 2013, 2016, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
*
* This file contains decompression data source routines for the case of
* reading JPEG data from memory or from a file (or any stdio stream).
@@ -28,12 +29,12 @@
typedef struct {
struct jpeg_source_mgr pub; /* public fields */
- FILE * infile; /* source stream */
- JOCTET * buffer; /* start of buffer */
+ FILE *infile; /* source stream */
+ JOCTET *buffer; /* start of buffer */
boolean start_of_file; /* have we gotten any data yet? */
} my_source_mgr;
-typedef my_source_mgr * my_src_ptr;
+typedef my_source_mgr *my_src_ptr;
#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */
@@ -161,7 +162,7 @@ fill_mem_input_buffer (j_decompress_ptr cinfo)
METHODDEF(void)
skip_input_data (j_decompress_ptr cinfo, long num_bytes)
{
- struct jpeg_source_mgr * src = cinfo->src;
+ struct jpeg_source_mgr *src = cinfo->src;
/* Just a dumb implementation for now. Could use fseek() except
* it doesn't work on pipes. Not clear that being smart is worth
@@ -213,7 +214,7 @@ term_source (j_decompress_ptr cinfo)
*/
GLOBAL(void)
-jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
+jpeg_stdio_src (j_decompress_ptr cinfo, FILE *infile)
{
my_src_ptr src;
@@ -221,8 +222,6 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
* of JPEG images can be read from the same file by calling jpeg_stdio_src
* only before the first one. (If we discarded the buffer at the end of
* one image, we'd likely lose the start of the next one.)
- * This makes it unsafe to use this manager and a different source
- * manager serially with the same JPEG object. Caveat programmer.
*/
if (cinfo->src == NULL) { /* first time for this JPEG object? */
cinfo->src = (struct jpeg_source_mgr *)
@@ -232,6 +231,14 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
src->buffer = (JOCTET *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
INPUT_BUF_SIZE * sizeof(JOCTET));
+ } else if (cinfo->src->init_source != init_source) {
+ /* It is unsafe to reuse the existing source manager unless it was created
+ * by this function. Otherwise, there is no guarantee that the opaque
+ * structure is the right size. Note that we could just create a new
+ * structure, but the old structure would not be freed until
+ * jpeg_destroy_decompress() was called.
+ */
+ ERREXIT(cinfo, JERR_BUFFER_SIZE);
}
src = (my_src_ptr) cinfo->src;
@@ -254,9 +261,9 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
GLOBAL(void)
jpeg_mem_src (j_decompress_ptr cinfo,
- unsigned char * inbuffer, unsigned long insize)
+ const unsigned char *inbuffer, unsigned long insize)
{
- struct jpeg_source_mgr * src;
+ struct jpeg_source_mgr *src;
if (inbuffer == NULL || insize == 0) /* Treat empty input as fatal error */
ERREXIT(cinfo, JERR_INPUT_EMPTY);
@@ -269,6 +276,11 @@ jpeg_mem_src (j_decompress_ptr cinfo,
cinfo->src = (struct jpeg_source_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
sizeof(struct jpeg_source_mgr));
+ } else if (cinfo->src->init_source != init_mem_source) {
+ /* It is unsafe to reuse the existing source manager unless it was created
+ * by this function.
+ */
+ ERREXIT(cinfo, JERR_BUFFER_SIZE);
}
src = cinfo->src;
@@ -278,6 +290,6 @@ jpeg_mem_src (j_decompress_ptr cinfo,
src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
src->term_source = term_source;
src->bytes_in_buffer = (size_t) insize;
- src->next_input_byte = (JOCTET *) inbuffer;
+ src->next_input_byte = (const JOCTET *) inbuffer;
}
#endif