Skip to content

Commit

Permalink
Fix jpeg test const issue (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
derobins authored Feb 14, 2024
1 parent 846594a commit 0730d19
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 28 deletions.
18 changes: 8 additions & 10 deletions hdf/test/rig.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define JPEGFILE "tjpeg.hdf"
#define NONHDF_JPEGFILE "tnonhdf_jpeg.hdf"

static const uint8 jpeg_8bit_orig[JPEGY][JPEGX] = {
static uint8 jpeg_8bit_orig[JPEGY][JPEGX] = {
{200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
Expand Down Expand Up @@ -92,7 +92,7 @@ static const uint8 jpeg_8bit_orig[JPEGY][JPEGX] = {
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200}};

static const uint8 jpeg_8bit_j80[JPEGY][JPEGX] = {
static uint8 jpeg_8bit_j80[JPEGY][JPEGX] = {
{200, 200, 200, 200, 200, 200, 200, 200, 202, 202, 201, 201, 201, 200, 200, 200,
201, 201, 200, 200, 200, 201, 202, 202, 202, 202, 201, 200, 200, 200, 200, 201,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
Expand Down Expand Up @@ -161,7 +161,7 @@ static const uint8 jpeg_8bit_j80[JPEGY][JPEGX] = {
201, 201, 202, 202, 202, 202, 201, 201, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200}};

static const uint8 jpeg_8bit_j30[JPEGY][JPEGX] = {
static uint8 jpeg_8bit_j30[JPEGY][JPEGX] = {
{199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199},
Expand Down Expand Up @@ -230,7 +230,7 @@ static const uint8 jpeg_8bit_j30[JPEGY][JPEGX] = {
199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199}};

static const uint8 jpeg_8bit_j75[JPEGY][JPEGX] = {
static uint8 jpeg_8bit_j75[JPEGY][JPEGX] = {
{200, 200, 200, 200, 200, 200, 200, 200, 198, 198, 198, 199, 199, 200, 200, 200,
202, 202, 200, 199, 199, 199, 199, 200, 199, 199, 200, 201, 201, 201, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200},
Expand Down Expand Up @@ -299,9 +299,7 @@ static const uint8 jpeg_8bit_j75[JPEGY][JPEGX] = {
201, 201, 202, 202, 202, 202, 201, 201, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200}};

/* const uint8 jpeg_24bit_orig[JPEGY][JPEGX][3] =
*/
const uint8 jpeg_24bit_orig[JPEGY * JPEGX * 3] = {
static uint8 jpeg_24bit_orig[JPEGY * JPEGX * 3] = {
255, 103, 0, 255, 103, 0, 255, 103, 0, 255, 103, 0, 255, 103, 0, 255, 103, 0, 255, 103, 0,
255, 103, 0, 255, 103, 0, 255, 103, 0, 255, 103, 0, 255, 103, 0, 255, 103, 0, 255, 103, 0,
255, 103, 0, 255, 103, 0, 255, 103, 0, 255, 103, 0, 255, 103, 0, 255, 103, 0, 255, 103, 0,
Expand Down Expand Up @@ -463,9 +461,9 @@ static void check_im_pal(int32 oldx, int32 oldy, int32 newx, int32 newy, uint8 *
/* These two functions are in tusejpegfuncs.c. They use JPEG functions directly
to compress and decompress the same data as in test_r24_jpeg, to verify that
the DFR24 API work correctly regardless which JPEG library is used */
intn comp_using_jpeglib(const char *filename, long *file_offset, int im_height, int im_width, int im_ncomps,
int quality, const uint8 *written_buffer);
intn decomp_using_jpeglib(const char *filename, long file_offset, int im_height, int im_width, int im_ncomps,
int comp_using_jpeglib(const char *filename, long *file_offset, int im_height, int im_width, int im_ncomps,
int quality, uint8 *written_buffer);
int decomp_using_jpeglib(const char *filename, long file_offset, int im_height, int im_width, int im_ncomps,
uint8 *read_buffer);
void test_r24_jpeg(void);

Expand Down
33 changes: 15 additions & 18 deletions hdf/test/tusejpegfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define HAVE_BOOLEAN
#endif

#include "jpeglib.h"
#include <jpeglib.h>

#define ABS(x) ((int)(x) < 0 ? (-x) : x)

Expand All @@ -26,21 +26,19 @@
to the specified file.
Return value:
The number of errors occurred in this routine.
Apr 11, 2011 -BMR
*************************************************************************/
intn
comp_using_jpeglib(const char *filename, /* file to write compressed data in */
long *file_offset, /* end offset of previous data and indicating where
to start writing data in this round */
int im_height, /* image's height */
int im_width, /* image's width */
int im_ncomps, /* image's number of components */
int quality, /* JPEG quality value */
const uint8 *written_buffer) /* data to be compressed */
int
comp_using_jpeglib(const char *filename, /* file to write compressed data in */
long *file_offset, /* end offset of previous data and indicating where
to start writing data in this round */
int im_height, /* image's height */
int im_width, /* image's width */
int im_ncomps, /* image's number of components */
int quality, /* JPEG quality value */
uint8 *written_buffer) /* data to be compressed */
{
FILE *outfile; /* target file */
JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
int row_stride; /* physical row width in image buffer */
FILE *outfile; /* target file */
int row_stride; /* physical row width in image buffer */

/* JPEG object for JPEG compression parameters and pointers to working space
(which is allocated as needed by the JPEG library). */
Expand Down Expand Up @@ -115,8 +113,8 @@ comp_using_jpeglib(const char *filename, /* file to write compressed data
* Here the array is only one element long, but you could pass
* more than one scanline at a time if that's more convenient.
*/
row_pointer[0] = &written_buffer[cinfo.next_scanline * row_stride];
(void)jpeg_write_scanlines(&cinfo, row_pointer, 1);
JSAMPROW row_pointer = &written_buffer[cinfo.next_scanline * row_stride];
(void)jpeg_write_scanlines(&cinfo, &row_pointer, 1);
}

/* Finish compression */
Expand Down Expand Up @@ -144,9 +142,8 @@ comp_using_jpeglib(const char *filename, /* file to write compressed data
uncompressed data in the provided buffer.
Return value:
The number of errors occurred in this routine.
Apr 11, 2011 -BMR
****************************************************************************/
intn
int
decomp_using_jpeglib(const char *filename, /* file to read compressed data from */
long file_offset, /* offset in the file to start reading */
int im_height, /* image's height */
Expand Down

0 comments on commit 0730d19

Please sign in to comment.