aboutsummaryrefslogtreecommitdiffstats
path: root/tjexample.c
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-09-20 02:58:38 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-09-20 02:58:38 +0000
commit0f346c08878097e6170c080b1b11d3596a774ac8 (patch)
tree74ff998f72c18bdf7efba586b9b4a7a2f4075df9 /tjexample.c
parent7478c4c675f3bfdbf0f06730f432230a59abeb39 (diff)
parentd3db2a2634c422286f75c4b38af98837f3d2f0ff (diff)
downloadplatform_external_libjpeg-turbo-android10-release.tar.gz
platform_external_libjpeg-turbo-android10-release.tar.bz2
platform_external_libjpeg-turbo-android10-release.zip
Merge cherrypicks of [9427496, 9427497, 9427498, 9427499, 9427540, 9427541, 9427522, 9427523, 9427525, 9427526, 9427527, 9427504, 9427542, 9427505, 9427468, 9427469, 9427506, 9427236, 9427238, 9427239, 9427454, 9427455, 9427561, 9427390, 9427470, 9427456, 9427472, 9427393, 9427531, 9427213, 9427459, 9427581, 9427583, 9427545, 9427362, 9427563, 9427564, 9427533, 9427534, 9427546, 9427395, 9427397, 9427475, 9427565, 9427535] into qt-releaseandroid-10.0.0_r11android-10.0.0_r10android10-release
Change-Id: I05603396ecade241b9c211b3004f023107989cbc
Diffstat (limited to 'tjexample.c')
-rw-r--r--tjexample.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/tjexample.c b/tjexample.c
index 61200e60..0db2269d 100644
--- a/tjexample.c
+++ b/tjexample.c
@@ -44,14 +44,14 @@
#define strncasecmp strnicmp
#endif
-#define _throw(action, message) { \
+#define THROW(action, message) { \
printf("ERROR in line %d while %s:\n%s\n", __LINE__, action, message); \
retval = -1; goto bailout; \
}
-#define _throwtj(action) _throw(action, tjGetErrorStr2(tjInstance))
+#define THROW_TJ(action) THROW(action, tjGetErrorStr2(tjInstance))
-#define _throwunix(action) _throw(action, strerror(errno))
+#define THROW_UNIX(action) THROW(action, strerror(errno))
#define DEFAULT_SUBSAMP TJSAMP_444
#define DEFAULT_QUALITY 95
@@ -172,7 +172,7 @@ int main(int argc, char **argv)
tjhandle tjInstance = NULL;
if ((scalingFactors = tjGetScalingFactors(&numScalingFactors)) == NULL)
- _throwtj("getting scaling factors");
+ THROW_TJ("getting scaling factors");
memset(&xform, 0, sizeof(tjtransform));
if (argc < 3)
@@ -266,17 +266,17 @@ int main(int argc, char **argv)
/* Read the JPEG file into memory. */
if ((jpegFile = fopen(argv[1], "rb")) == NULL)
- _throwunix("opening input file");
+ THROW_UNIX("opening input file");
if (fseek(jpegFile, 0, SEEK_END) < 0 || ((size = ftell(jpegFile)) < 0) ||
fseek(jpegFile, 0, SEEK_SET) < 0)
- _throwunix("determining input file size");
+ THROW_UNIX("determining input file size");
if (size == 0)
- _throw("determining input file size", "Input file contains no data");
+ THROW("determining input file size", "Input file contains no data");
jpegSize = (unsigned long)size;
if ((jpegBuf = (unsigned char *)tjAlloc(jpegSize)) == NULL)
- _throwunix("allocating JPEG buffer");
+ THROW_UNIX("allocating JPEG buffer");
if (fread(jpegBuf, jpegSize, 1, jpegFile) < 1)
- _throwunix("reading input file");
+ THROW_UNIX("reading input file");
fclose(jpegFile); jpegFile = NULL;
if (doTransform) {
@@ -285,22 +285,22 @@ int main(int argc, char **argv)
unsigned long dstSize = 0;
if ((tjInstance = tjInitTransform()) == NULL)
- _throwtj("initializing transformer");
+ THROW_TJ("initializing transformer");
xform.options |= TJXOPT_TRIM;
if (tjTransform(tjInstance, jpegBuf, jpegSize, 1, &dstBuf, &dstSize,
&xform, flags) < 0)
- _throwtj("transforming input image");
+ THROW_TJ("transforming input image");
tjFree(jpegBuf);
jpegBuf = dstBuf;
jpegSize = dstSize;
} else {
if ((tjInstance = tjInitDecompress()) == NULL)
- _throwtj("initializing decompressor");
+ THROW_TJ("initializing decompressor");
}
if (tjDecompressHeader3(tjInstance, jpegBuf, jpegSize, &width, &height,
&inSubsamp, &inColorspace) < 0)
- _throwtj("reading JPEG header");
+ THROW_TJ("reading JPEG header");
printf("%s Image: %d x %d pixels, %s subsampling, %s colorspace\n",
(doTransform ? "Transformed" : "Input"), width, height,
@@ -312,9 +312,9 @@ int main(int argc, char **argv)
/* Input image has been transformed, and no re-compression options
have been selected. Write the transformed image to disk and exit. */
if ((jpegFile = fopen(argv[2], "wb")) == NULL)
- _throwunix("opening output file");
+ THROW_UNIX("opening output file");
if (fwrite(jpegBuf, jpegSize, 1, jpegFile) < 1)
- _throwunix("writing output file");
+ THROW_UNIX("writing output file");
fclose(jpegFile); jpegFile = NULL;
goto bailout;
}
@@ -330,18 +330,18 @@ int main(int argc, char **argv)
pixelFormat = TJPF_BGRX;
if ((imgBuf = (unsigned char *)tjAlloc(width * height *
tjPixelSize[pixelFormat])) == NULL)
- _throwunix("allocating uncompressed image buffer");
+ THROW_UNIX("allocating uncompressed image buffer");
if (tjDecompress2(tjInstance, jpegBuf, jpegSize, imgBuf, width, 0, height,
pixelFormat, flags) < 0)
- _throwtj("decompressing JPEG image");
+ THROW_TJ("decompressing JPEG image");
tjFree(jpegBuf); jpegBuf = NULL;
tjDestroy(tjInstance); tjInstance = NULL;
} else {
/* Input image is not a JPEG image. Load it into memory. */
if ((imgBuf = tjLoadImage(argv[1], &width, 1, &height, &pixelFormat,
0)) == NULL)
- _throwtj("loading input image");
+ THROW_TJ("loading input image");
if (outSubsamp < 0) {
if (pixelFormat == TJPF_GRAY)
outSubsamp = TJSAMP_GRAY;
@@ -364,17 +364,17 @@ int main(int argc, char **argv)
outQual);
if ((tjInstance = tjInitCompress()) == NULL)
- _throwtj("initializing compressor");
+ THROW_TJ("initializing compressor");
if (tjCompress2(tjInstance, imgBuf, width, 0, height, pixelFormat,
&jpegBuf, &jpegSize, outSubsamp, outQual, flags) < 0)
- _throwtj("compressing image");
+ THROW_TJ("compressing image");
tjDestroy(tjInstance); tjInstance = NULL;
/* Write the JPEG image to disk. */
if ((jpegFile = fopen(argv[2], "wb")) == NULL)
- _throwunix("opening output file");
+ THROW_UNIX("opening output file");
if (fwrite(jpegBuf, jpegSize, 1, jpegFile) < 1)
- _throwunix("writing output file");
+ THROW_UNIX("writing output file");
tjDestroy(tjInstance); tjInstance = NULL;
fclose(jpegFile); jpegFile = NULL;
tjFree(jpegBuf); jpegBuf = NULL;
@@ -383,7 +383,7 @@ int main(int argc, char **argv)
directly to disk. */
printf("\n");
if (tjSaveImage(argv[2], imgBuf, width, 0, height, pixelFormat, 0) < 0)
- _throwtj("saving output image");
+ THROW_TJ("saving output image");
}
bailout: