Merge branch 'master' into dev
This commit is contained in:
47
example.txt
47
example.txt
@@ -288,12 +288,14 @@ my_error_exit(j_common_ptr cinfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
METHODDEF(int) do_read_JPEG_file(struct jpeg_decompress_struct *cinfo,
|
||||||
|
char *filename);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sample routine for JPEG decompression. We assume that the source file name
|
* Sample routine for JPEG decompression. We assume that the source file name
|
||||||
* is passed in. We want to return 1 on success, 0 on error.
|
* is passed in. We want to return 1 on success, 0 on error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
GLOBAL(int)
|
GLOBAL(int)
|
||||||
read_JPEG_file(char *filename)
|
read_JPEG_file(char *filename)
|
||||||
{
|
{
|
||||||
@@ -301,6 +303,21 @@ read_JPEG_file(char *filename)
|
|||||||
* working space (which is allocated as needed by the JPEG library).
|
* working space (which is allocated as needed by the JPEG library).
|
||||||
*/
|
*/
|
||||||
struct jpeg_decompress_struct cinfo;
|
struct jpeg_decompress_struct cinfo;
|
||||||
|
|
||||||
|
return do_read_JPEG_file(&cinfo, filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We call the libjpeg API from within a separate function, because modifying
|
||||||
|
* the local non-volatile jpeg_decompress_struct instance below the setjmp()
|
||||||
|
* return point and then accessing the instance after setjmp() returns would
|
||||||
|
* return in undefined behavior that may potentially overwrite all or part of
|
||||||
|
* the structure.
|
||||||
|
*/
|
||||||
|
|
||||||
|
METHODDEF(int)
|
||||||
|
do_read_JPEG_file(struct jpeg_decompress_struct *cinfo, char *filename)
|
||||||
|
{
|
||||||
/* We use our private extension JPEG error handler.
|
/* We use our private extension JPEG error handler.
|
||||||
* Note that this struct must live as long as the main JPEG parameter
|
* Note that this struct must live as long as the main JPEG parameter
|
||||||
* struct, to avoid dangling-pointer problems.
|
* struct, to avoid dangling-pointer problems.
|
||||||
@@ -325,27 +342,27 @@ read_JPEG_file(char *filename)
|
|||||||
/* Step 1: allocate and initialize JPEG decompression object */
|
/* Step 1: allocate and initialize JPEG decompression object */
|
||||||
|
|
||||||
/* We set up the normal JPEG error routines, then override error_exit. */
|
/* We set up the normal JPEG error routines, then override error_exit. */
|
||||||
cinfo.err = jpeg_std_error(&jerr.pub);
|
cinfo->err = jpeg_std_error(&jerr.pub);
|
||||||
jerr.pub.error_exit = my_error_exit;
|
jerr.pub.error_exit = my_error_exit;
|
||||||
/* Establish the setjmp return context for my_error_exit to use. */
|
/* Establish the setjmp return context for my_error_exit to use. */
|
||||||
if (setjmp(jerr.setjmp_buffer)) {
|
if (setjmp(jerr.setjmp_buffer)) {
|
||||||
/* If we get here, the JPEG code has signaled an error.
|
/* If we get here, the JPEG code has signaled an error.
|
||||||
* We need to clean up the JPEG object, close the input file, and return.
|
* We need to clean up the JPEG object, close the input file, and return.
|
||||||
*/
|
*/
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(cinfo);
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Now we can initialize the JPEG decompression object. */
|
/* Now we can initialize the JPEG decompression object. */
|
||||||
jpeg_create_decompress(&cinfo);
|
jpeg_create_decompress(cinfo);
|
||||||
|
|
||||||
/* Step 2: specify data source (eg, a file) */
|
/* Step 2: specify data source (eg, a file) */
|
||||||
|
|
||||||
jpeg_stdio_src(&cinfo, infile);
|
jpeg_stdio_src(cinfo, infile);
|
||||||
|
|
||||||
/* Step 3: read file parameters with jpeg_read_header() */
|
/* Step 3: read file parameters with jpeg_read_header() */
|
||||||
|
|
||||||
(void)jpeg_read_header(&cinfo, TRUE);
|
(void)jpeg_read_header(cinfo, TRUE);
|
||||||
/* We can ignore the return value from jpeg_read_header since
|
/* We can ignore the return value from jpeg_read_header since
|
||||||
* (a) suspension is not possible with the stdio data source, and
|
* (a) suspension is not possible with the stdio data source, and
|
||||||
* (b) we passed TRUE to reject a tables-only JPEG file as an error.
|
* (b) we passed TRUE to reject a tables-only JPEG file as an error.
|
||||||
@@ -360,7 +377,7 @@ read_JPEG_file(char *filename)
|
|||||||
|
|
||||||
/* Step 5: Start decompressor */
|
/* Step 5: Start decompressor */
|
||||||
|
|
||||||
(void)jpeg_start_decompress(&cinfo);
|
(void)jpeg_start_decompress(cinfo);
|
||||||
/* We can ignore the return value since suspension is not possible
|
/* We can ignore the return value since suspension is not possible
|
||||||
* with the stdio data source.
|
* with the stdio data source.
|
||||||
*/
|
*/
|
||||||
@@ -372,30 +389,30 @@ read_JPEG_file(char *filename)
|
|||||||
* In this example, we need to make an output work buffer of the right size.
|
* In this example, we need to make an output work buffer of the right size.
|
||||||
*/
|
*/
|
||||||
/* JSAMPLEs per row in output buffer */
|
/* JSAMPLEs per row in output buffer */
|
||||||
row_stride = cinfo.output_width * cinfo.output_components;
|
row_stride = cinfo->output_width * cinfo->output_components;
|
||||||
/* Make a one-row-high sample array that will go away when done with image */
|
/* Make a one-row-high sample array that will go away when done with image */
|
||||||
buffer = (*cinfo.mem->alloc_sarray)
|
buffer = (*cinfo->mem->alloc_sarray)
|
||||||
((j_common_ptr)&cinfo, JPOOL_IMAGE, row_stride, 1);
|
((j_common_ptr)cinfo, JPOOL_IMAGE, row_stride, 1);
|
||||||
|
|
||||||
/* Step 6: while (scan lines remain to be read) */
|
/* Step 6: while (scan lines remain to be read) */
|
||||||
/* jpeg_read_scanlines(...); */
|
/* jpeg_read_scanlines(...); */
|
||||||
|
|
||||||
/* Here we use the library's state variable cinfo.output_scanline as the
|
/* Here we use the library's state variable cinfo->output_scanline as the
|
||||||
* loop counter, so that we don't have to keep track ourselves.
|
* loop counter, so that we don't have to keep track ourselves.
|
||||||
*/
|
*/
|
||||||
while (cinfo.output_scanline < cinfo.output_height) {
|
while (cinfo->output_scanline < cinfo->output_height) {
|
||||||
/* jpeg_read_scanlines expects an array of pointers to scanlines.
|
/* jpeg_read_scanlines expects an array of pointers to scanlines.
|
||||||
* Here the array is only one element long, but you could ask for
|
* Here the array is only one element long, but you could ask for
|
||||||
* more than one scanline at a time if that's more convenient.
|
* more than one scanline at a time if that's more convenient.
|
||||||
*/
|
*/
|
||||||
(void)jpeg_read_scanlines(&cinfo, buffer, 1);
|
(void)jpeg_read_scanlines(cinfo, buffer, 1);
|
||||||
/* Assume put_scanline_someplace wants a pointer and sample count. */
|
/* Assume put_scanline_someplace wants a pointer and sample count. */
|
||||||
put_scanline_someplace(buffer[0], row_stride);
|
put_scanline_someplace(buffer[0], row_stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Step 7: Finish decompression */
|
/* Step 7: Finish decompression */
|
||||||
|
|
||||||
(void)jpeg_finish_decompress(&cinfo);
|
(void)jpeg_finish_decompress(cinfo);
|
||||||
/* We can ignore the return value since suspension is not possible
|
/* We can ignore the return value since suspension is not possible
|
||||||
* with the stdio data source.
|
* with the stdio data source.
|
||||||
*/
|
*/
|
||||||
@@ -403,7 +420,7 @@ read_JPEG_file(char *filename)
|
|||||||
/* Step 8: Release JPEG decompression object */
|
/* Step 8: Release JPEG decompression object */
|
||||||
|
|
||||||
/* This is an important step since it will release a good deal of memory. */
|
/* This is an important step since it will release a good deal of memory. */
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(cinfo);
|
||||||
|
|
||||||
/* After finish_decompress, we can close the input file.
|
/* After finish_decompress, we can close the input file.
|
||||||
* Here we postpone it until after no more JPEG errors are possible,
|
* Here we postpone it until after no more JPEG errors are possible,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* jfdctint.c
|
* jfdctint.c
|
||||||
*
|
*
|
||||||
* This file was part of the Independent JPEG Group's software.
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2015, D. R. Commander.
|
* Copyright (C) 2015, D. R. Commander.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* jidctint.c
|
* jidctint.c
|
||||||
*
|
*
|
||||||
* This file was part of the Independent JPEG Group's software.
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||||
* Modification developed 2002-2009 by Guido Vollbeding.
|
* Modification developed 2002-2009 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* jidctred.c
|
* jidctred.c
|
||||||
*
|
*
|
||||||
* This file was part of the Independent JPEG Group's software.
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1994-1998, Thomas G. Lane.
|
* Copyright (C) 1994-1998, Thomas G. Lane.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2015, D. R. Commander.
|
* Copyright (C) 2015, D. R. Commander.
|
||||||
|
|||||||
Reference in New Issue
Block a user