**libturbojpeg.a**<br>
Static link library for the TurboJPEG API
-**libturbojpeg.so.0.1.0** (Linux, Unix)<br>
-**libturbojpeg.0.1.0.dylib** (Mac)<br>
+**libturbojpeg.so.0.2.0** (Linux, Unix)<br>
+**libturbojpeg.0.2.0.dylib** (Mac)<br>
**cygturbojpeg-0.dll** (Cygwin)<br>
Shared library for the TurboJPEG API
# minor SO versions don't change. However, we increase the middle number (the
# SO "age") whenever functions are added to the API.
set(TURBOJPEG_SO_MAJOR_VERSION 0)
-set(TURBOJPEG_SO_VERSION 0.1.0)
+set(TURBOJPEG_SO_VERSION 0.2.0)
###############################################################################
eliminates the need for downstream projects, such as color management libraries
and browsers, to include their own glueware for accomplishing this.
+4. Improved error handling in the TurboJPEG API library:
+
+ - Introduced a new function (`tjGetErrorStr2()`) in the TurboJPEG C API
+that allows compression/decompression/transform error messages to be retrieved
+in a thread-safe manner. Retrieving error messages from global functions, such
+as `tjInitCompress()` or `tjBufSize()`, is still thread-unsafe, but since those
+functions will only throw errors if passed an invalid argument or if a memory
+allocation failure occurs, thread safety is not as much of a concern.
+
1.5.2
=====
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">TurboJPEG
-  <span id="projectnumber">1.5</span>
+  <span id="projectnumber">1.6</span>
</div>
</td>
</tr>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">TurboJPEG
-  <span id="projectnumber">1.5</span>
+  <span id="projectnumber">1.6</span>
</div>
</td>
</tr>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">TurboJPEG
-  <span id="projectnumber">1.5</span>
+  <span id="projectnumber">1.6</span>
</div>
</td>
</tr>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">TurboJPEG
-  <span id="projectnumber">1.5</span>
+  <span id="projectnumber">1.6</span>
</div>
</td>
</tr>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">TurboJPEG
-  <span id="projectnumber">1.5</span>
+  <span id="projectnumber">1.6</span>
</div>
</td>
</tr>
<tr class="memitem:ga8c4a1231dc06a450514c835f6471f137"><td class="memItemLeft" align="right" valign="top">DLLEXPORT void DLLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga8c4a1231dc06a450514c835f6471f137">tjFree</a> (unsigned char *buffer)</td></tr>
<tr class="memdesc:ga8c4a1231dc06a450514c835f6471f137"><td class="mdescLeft"> </td><td class="mdescRight">Free an image buffer previously allocated by TurboJPEG. <a href="#ga8c4a1231dc06a450514c835f6471f137">More...</a><br/></td></tr>
<tr class="separator:ga8c4a1231dc06a450514c835f6471f137"><td class="memSeparator" colspan="2"> </td></tr>
-<tr class="memitem:ga9af79c908ec131b1ae8d52fe40375abf"><td class="memItemLeft" align="right" valign="top">DLLEXPORT char *DLLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf">tjGetErrorStr</a> (void)</td></tr>
-<tr class="memdesc:ga9af79c908ec131b1ae8d52fe40375abf"><td class="mdescLeft"> </td><td class="mdescRight">Returns a descriptive error message explaining why the last command failed. <a href="#ga9af79c908ec131b1ae8d52fe40375abf">More...</a><br/></td></tr>
-<tr class="separator:ga9af79c908ec131b1ae8d52fe40375abf"><td class="memSeparator" colspan="2"> </td></tr>
+<tr class="memitem:ga94a235bd4f1088f61ad87b4eadb64c9c"><td class="memItemLeft" align="right" valign="top">DLLEXPORT char *DLLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c">tjGetErrorStr2</a> (<a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> handle)</td></tr>
+<tr class="memdesc:ga94a235bd4f1088f61ad87b4eadb64c9c"><td class="mdescLeft"> </td><td class="mdescRight">Returns a descriptive error message explaining why the last command failed. <a href="#ga94a235bd4f1088f61ad87b4eadb64c9c">More...</a><br/></td></tr>
+<tr class="separator:ga94a235bd4f1088f61ad87b4eadb64c9c"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
Variables</h2></td></tr>
</table>
</dd>
</dl>
-<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</table>
</dd>
</dl>
-<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</table>
</dd>
</dl>
-<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</table>
</dd>
</dl>
-<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</table>
</dd>
</dl>
-<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</table>
</dd>
</dl>
-<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</table>
</dd>
</dl>
-<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</table>
</dd>
</dl>
-<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</table>
</dd>
</dl>
-<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</table>
</dd>
</dl>
-<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</table>
</dd>
</dl>
-<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</table>
</dd>
</dl>
-<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</div>
</div>
-<a class="anchor" id="ga9af79c908ec131b1ae8d52fe40375abf"></a>
+<a class="anchor" id="ga94a235bd4f1088f61ad87b4eadb64c9c"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
- <td class="memname">DLLEXPORT char* DLLCALL tjGetErrorStr </td>
+ <td class="memname">DLLEXPORT char* DLLCALL tjGetErrorStr2 </td>
<td>(</td>
- <td class="paramtype">void </td>
- <td class="paramname"></td><td>)</td>
+ <td class="paramtype"><a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> </td>
+ <td class="paramname"><em>handle</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns a descriptive error message explaining why the last command failed. </p>
+<dl class="params"><dt>Parameters</dt><dd>
+ <table class="params">
+ <tr><td class="paramname">handle</td><td>a handle to a TurboJPEG compressor, decompressor, or transformer instance, or NULL if the error was generated by a global function (but note that retrieving the error message for a global function is not thread-safe.)</td></tr>
+ </table>
+ </dd>
+</dl>
<dl class="section return"><dt>Returns</dt><dd>a descriptive error message explaining why the last command failed. </dd></dl>
</div>
</table>
</dd>
</dl>
-<dl class="section return"><dt>Returns</dt><dd>a pointer to a list of fractional scaling factors, or NULL if an error is encountered (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>a pointer to a list of fractional scaling factors, or NULL if an error is encountered (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</div><div class="memdoc">
<p>Create a TurboJPEG compressor instance. </p>
-<dl class="section return"><dt>Returns</dt><dd>a handle to the newly-created instance, or NULL if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>a handle to the newly-created instance, or NULL if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</div><div class="memdoc">
<p>Create a TurboJPEG decompressor instance. </p>
-<dl class="section return"><dt>Returns</dt><dd>a handle to the newly-created instance, or NULL if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>a handle to the newly-created instance, or NULL if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</div><div class="memdoc">
<p>Create a new TurboJPEG transformer instance. </p>
-<dl class="section return"><dt>Returns</dt><dd>a handle to the newly-created instance, or NULL if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>a handle to the newly-created instance, or NULL if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
</table>
</dd>
</dl>
-<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr2()</a>.) </dd></dl>
</div>
</div>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">TurboJPEG
-  <span id="projectnumber">1.5</span>
+  <span id="projectnumber">1.6</span>
</div>
</td>
</tr>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">TurboJPEG
-  <span id="projectnumber">1.5</span>
+  <span id="projectnumber">1.6</span>
</div>
</td>
</tr>
['tjflag_5ffastupsample',['TJFLAG_FASTUPSAMPLE',['../group___turbo_j_p_e_g.html#ga4ee4506c81177a06f77e2504a22efd2d',1,'turbojpeg.h']]],
['tjflag_5fnorealloc',['TJFLAG_NOREALLOC',['../group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963',1,'turbojpeg.h']]],
['tjfree',['tjFree',['../group___turbo_j_p_e_g.html#ga8c4a1231dc06a450514c835f6471f137',1,'turbojpeg.h']]],
- ['tjgeterrorstr',['tjGetErrorStr',['../group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf',1,'turbojpeg.h']]],
+ ['tjgeterrorstr2',['tjGetErrorStr2',['../group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c',1,'turbojpeg.h']]],
['tjgetscalingfactors',['tjGetScalingFactors',['../group___turbo_j_p_e_g.html#ga6449044b9af402999ccf52f401333be8',1,'turbojpeg.h']]],
['tjgreenoffset',['tjGreenOffset',['../group___turbo_j_p_e_g.html#ga82d6e35da441112a411da41923c0ba2f',1,'turbojpeg.h']]],
['tjhandle',['tjhandle',['../group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763',1,'turbojpeg.h']]],
['tjencodeyuv3',['tjEncodeYUV3',['../group___turbo_j_p_e_g.html#gaabe05acd734990053ad1294b5ef239aa',1,'turbojpeg.h']]],
['tjencodeyuvplanes',['tjEncodeYUVPlanes',['../group___turbo_j_p_e_g.html#ga8a65ed3bd12df57c219d46afbc9008f1',1,'turbojpeg.h']]],
['tjfree',['tjFree',['../group___turbo_j_p_e_g.html#ga8c4a1231dc06a450514c835f6471f137',1,'turbojpeg.h']]],
- ['tjgeterrorstr',['tjGetErrorStr',['../group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf',1,'turbojpeg.h']]],
+ ['tjgeterrorstr2',['tjGetErrorStr2',['../group___turbo_j_p_e_g.html#ga94a235bd4f1088f61ad87b4eadb64c9c',1,'turbojpeg.h']]],
['tjgetscalingfactors',['tjGetScalingFactors',['../group___turbo_j_p_e_g.html#ga6449044b9af402999ccf52f401333be8',1,'turbojpeg.h']]],
['tjinitcompress',['tjInitCompress',['../group___turbo_j_p_e_g.html#ga3d10c47fbe4a2489a2b30c931551d01a',1,'turbojpeg.h']]],
['tjinitdecompress',['tjInitDecompress',['../group___turbo_j_p_e_g.html#gae5408179d041e2a2f7199c8283cf649e',1,'turbojpeg.h']]],
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">TurboJPEG
-  <span id="projectnumber">1.5</span>
+  <span id="projectnumber">1.6</span>
</div>
</td>
</tr>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">TurboJPEG
-  <span id="projectnumber">1.5</span>
+  <span id="projectnumber">1.6</span>
</div>
</td>
</tr>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">TurboJPEG
-  <span id="projectnumber">1.5</span>
+  <span id="projectnumber">1.6</span>
</div>
</td>
</tr>
PROJECT_NAME = TurboJPEG
-PROJECT_NUMBER = 1.5
+PROJECT_NUMBER = 1.6
OUTPUT_DIRECTORY = doc/
USE_WINDOWS_ENCODING = NO
OPTIMIZE_OUTPUT_FOR_C = YES
/*
- * Copyright (C)2011-2016 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2011-2017 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
goto bailout; \
}
-#define _throwtj() _throw(tjGetErrorStr(), "org/libjpegturbo/turbojpeg/TJException")
+#define _throwtj() _throw(tjGetErrorStr2(handle), "org/libjpegturbo/turbojpeg/TJException")
#define _throwarg(msg) _throw(msg, "java/lang/IllegalArgumentException")
tjPlaneSizeYUV;
tjPlaneWidth;
} TURBOJPEG_1.2;
+
+TURBOJPEG_1.6
+{
+ global:
+ tjGetErrorStr2;
+} TURBOJPEG_1.4;
Java_org_libjpegturbo_turbojpeg_TJ_planeSizeYUV__IIIII;
Java_org_libjpegturbo_turbojpeg_TJ_planeWidth__III;
} TURBOJPEG_1.3;
+
+TURBOJPEG_1.6
+{
+ global:
+ tjGetErrorStr2;
+} TURBOJPEG_1.4;
struct jpeg_decompress_struct dinfo;
struct my_error_mgr jerr;
int init, headerRead;
+ char errStr[JMSG_LENGTH_MAX];
+ boolean isInstanceError;
} tjinstance;
static const int pixelsize[TJ_NUMSAMP]={3, 3, 3, 1, 3, 3};
{1, 8}
};
-#define _throw(m) {snprintf(errStr, JMSG_LENGTH_MAX, "%s", m); \
+#define _throwg(m) {snprintf(errStr, JMSG_LENGTH_MAX, "%s", m); \
retval=-1; goto bailout;}
+#define _throw(m) {snprintf(this->errStr, JMSG_LENGTH_MAX, "%s", m); \
+ this->isInstanceError=TRUE; _throwg(m);}
#define getinstance(handle) tjinstance *this=(tjinstance *)handle; \
j_compress_ptr cinfo=NULL; j_decompress_ptr dinfo=NULL; \
if(!this) {snprintf(errStr, JMSG_LENGTH_MAX, "Invalid handle"); \
return -1;} \
cinfo=&this->cinfo; dinfo=&this->dinfo; \
- this->jerr.warning=FALSE;
+ this->jerr.warning=FALSE; \
+ this->isInstanceError=FALSE;
#define getcinstance(handle) tjinstance *this=(tjinstance *)handle; \
j_compress_ptr cinfo=NULL; \
if(!this) {snprintf(errStr, JMSG_LENGTH_MAX, "Invalid handle"); \
return -1;} \
cinfo=&this->cinfo; \
- this->jerr.warning=FALSE;
+ this->jerr.warning=FALSE; \
+ this->isInstanceError=FALSE;
#define getdinstance(handle) tjinstance *this=(tjinstance *)handle; \
j_decompress_ptr dinfo=NULL; \
if(!this) {snprintf(errStr, JMSG_LENGTH_MAX, "Invalid handle"); \
return -1;} \
dinfo=&this->dinfo; \
- this->jerr.warning=FALSE;
+ this->jerr.warning=FALSE; \
+ this->isInstanceError=FALSE;
static int getPixelFormat(int pixelSize, int flags)
{
return retval;
}
-static int setDecompDefaults(struct jpeg_decompress_struct *dinfo,
- int pixelFormat, int flags)
+static int setDecompDefaults(tjinstance *this, int pixelFormat, int flags)
{
int retval=0;
switch(pixelFormat)
{
case TJPF_GRAY:
- dinfo->out_color_space=JCS_GRAYSCALE; break;
+ this->dinfo.out_color_space=JCS_GRAYSCALE; break;
#if JCS_EXTENSIONS==1
case TJPF_RGB:
- dinfo->out_color_space=JCS_EXT_RGB; break;
+ this->dinfo.out_color_space=JCS_EXT_RGB; break;
case TJPF_BGR:
- dinfo->out_color_space=JCS_EXT_BGR; break;
+ this->dinfo.out_color_space=JCS_EXT_BGR; break;
case TJPF_RGBX:
- dinfo->out_color_space=JCS_EXT_RGBX; break;
+ this->dinfo.out_color_space=JCS_EXT_RGBX; break;
case TJPF_BGRX:
- dinfo->out_color_space=JCS_EXT_BGRX; break;
+ this->dinfo.out_color_space=JCS_EXT_BGRX; break;
case TJPF_XRGB:
- dinfo->out_color_space=JCS_EXT_XRGB; break;
+ this->dinfo.out_color_space=JCS_EXT_XRGB; break;
case TJPF_XBGR:
- dinfo->out_color_space=JCS_EXT_XBGR; break;
+ this->dinfo.out_color_space=JCS_EXT_XBGR; break;
#if JCS_ALPHA_EXTENSIONS==1
case TJPF_RGBA:
- dinfo->out_color_space=JCS_EXT_RGBA; break;
+ this->dinfo.out_color_space=JCS_EXT_RGBA; break;
case TJPF_BGRA:
- dinfo->out_color_space=JCS_EXT_BGRA; break;
+ this->dinfo.out_color_space=JCS_EXT_BGRA; break;
case TJPF_ARGB:
- dinfo->out_color_space=JCS_EXT_ARGB; break;
+ this->dinfo.out_color_space=JCS_EXT_ARGB; break;
case TJPF_ABGR:
- dinfo->out_color_space=JCS_EXT_ABGR; break;
+ this->dinfo.out_color_space=JCS_EXT_ABGR; break;
#endif
#else
case TJPF_RGB:
case TJPF_BGRA:
case TJPF_ARGB:
case TJPF_ABGR:
- dinfo->out_color_space=JCS_RGB; break;
+ this->dinfo.out_color_space=JCS_RGB; break;
#endif
case TJPF_CMYK:
- dinfo->out_color_space=JCS_CMYK; break;
+ this->dinfo.out_color_space=JCS_CMYK; break;
default:
_throw("Unsupported pixel format");
}
- if(flags&TJFLAG_FASTDCT) dinfo->dct_method=JDCT_FASTEST;
+ if(flags&TJFLAG_FASTDCT) this->dinfo.dct_method=JDCT_FASTEST;
bailout:
return retval;
/* General API functions */
+DLLEXPORT char* DLLCALL tjGetErrorStr2(tjhandle handle)
+{
+ tjinstance *this=(tjinstance *)handle;
+ if(this && this->isInstanceError)
+ {
+ this->isInstanceError=FALSE;
+ return this->errStr;
+ }
+ else return errStr;
+}
+
+
DLLEXPORT char* DLLCALL tjGetErrorStr(void)
{
return errStr;
return NULL;
}
MEMZERO(this, sizeof(tjinstance));
+ snprintf(this->errStr, JMSG_LENGTH_MAX, "No error");
return _tjInitCompress(this);
}
{
unsigned long retval=0; int mcuw, mcuh, chromasf;
if(width<1 || height<1 || jpegSubsamp<0 || jpegSubsamp>=NUMSUBOPT)
- _throw("tjBufSize(): Invalid argument");
+ _throwg("tjBufSize(): Invalid argument");
/* This allows for rare corner cases in which a JPEG image can actually be
larger than the uncompressed input (we wouldn't mention it if it hadn't
{
unsigned long retval=0;
if(width<1 || height<1)
- _throw("TJBUFSIZE(): Invalid argument");
+ _throwg("TJBUFSIZE(): Invalid argument");
/* This allows for rare corner cases in which a JPEG image can actually be
larger than the uncompressed input (we wouldn't mention it if it hadn't
int retval=0, nc, i;
if(subsamp<0 || subsamp>=NUMSUBOPT)
- _throw("tjBufSizeYUV2(): Invalid argument");
+ _throwg("tjBufSizeYUV2(): Invalid argument");
nc=(subsamp==TJSAMP_GRAY? 1:3);
for(i=0; i<nc; i++)
int pw, nc, retval=0;
if(width<1 || subsamp<0 || subsamp>=TJ_NUMSAMP)
- _throw("tjPlaneWidth(): Invalid argument");
+ _throwg("tjPlaneWidth(): Invalid argument");
nc=(subsamp==TJSAMP_GRAY? 1:3);
if(componentID<0 || componentID>=nc)
- _throw("tjPlaneWidth(): Invalid argument");
+ _throwg("tjPlaneWidth(): Invalid argument");
pw=PAD(width, tjMCUWidth[subsamp]/8);
if(componentID==0)
int ph, nc, retval=0;
if(height<1 || subsamp<0 || subsamp>=TJ_NUMSAMP)
- _throw("tjPlaneHeight(): Invalid argument");
+ _throwg("tjPlaneHeight(): Invalid argument");
nc=(subsamp==TJSAMP_GRAY? 1:3);
if(componentID<0 || componentID>=nc)
- _throw("tjPlaneHeight(): Invalid argument");
+ _throwg("tjPlaneHeight(): Invalid argument");
ph=PAD(height, tjMCUHeight[subsamp]/8);
if(componentID==0)
int pw, ph;
if(width<1 || height<1 || subsamp<0 || subsamp>=NUMSUBOPT)
- _throw("tjPlaneSizeYUV(): Invalid argument");
+ _throwg("tjPlaneSizeYUV(): Invalid argument");
pw=tjPlaneWidth(componentID, width, subsamp);
ph=tjPlaneHeight(componentID, height, subsamp);
unsigned char *dstPlanes[3];
int pw0, ph0, strides[3], retval=-1;
+ getcinstance(handle);
+
if(width<=0 || height<=0 || dstBuf==NULL || pad<0 || !isPow2(pad)
|| subsamp<0 || subsamp>=NUMSUBOPT)
_throw("tjEncodeYUV3(): Invalid argument");
const unsigned char *srcPlanes[3];
int pw0, ph0, strides[3], retval=-1;
+ getcinstance(handle);
+
if(srcBuf==NULL || width<=0 || pad<1 || height<=0 || subsamp<0
|| subsamp>=NUMSUBOPT)
_throw("tjCompressFromYUV(): Invalid argument");
return NULL;
}
MEMZERO(this, sizeof(tjinstance));
+ snprintf(this->errStr, JMSG_LENGTH_MAX, "No error");
return _tjInitDecompress(this);
}
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
jpeg_read_header(dinfo, TRUE);
- if(setDecompDefaults(dinfo, pixelFormat, flags)==-1)
+ if(setDecompDefaults(this, pixelFormat, flags)==-1)
{
retval=-1; goto bailout;
}
dinfo->marker->read_markers=old_read_markers;
dinfo->marker->reset_marker_reader=old_reset_marker_reader;
- if(setDecompDefaults(dinfo, pixelFormat, flags)==-1)
+ if(setDecompDefaults(this, pixelFormat, flags)==-1)
{
retval=-1; goto bailout;
}
const unsigned char *srcPlanes[3];
int pw0, ph0, strides[3], retval=-1;
+ getdinstance(handle);
+
if(srcBuf==NULL || pad<0 || !isPow2(pad) || subsamp<0 || subsamp>=NUMSUBOPT
|| width<=0 || height<=0)
_throw("tjDecodeYUV(): Invalid argument");
return NULL;
}
MEMZERO(this, sizeof(tjinstance));
+ snprintf(this->errStr, JMSG_LENGTH_MAX, "No error");
handle=_tjInitCompress(this);
if(!handle) return NULL;
handle=_tjInitDecompress(this);
/*
- * Copyright (C)2009-2015 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2009-2015, 2017 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Create a TurboJPEG compressor instance.
*
* @return a handle to the newly-created instance, or NULL if an error
- * occurred (see #tjGetErrorStr().)
+ * occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT tjhandle DLLCALL tjInitCompress(void);
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* "flags"
*
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf,
int width, int pitch, int height, int pixelFormat, unsigned char **jpegBuf,
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* "flags"
*
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle,
const unsigned char *srcBuf, int width, int pad, int height, int subsamp,
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* "flags"
*
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT int DLLCALL tjCompressFromYUVPlanes(tjhandle handle,
const unsigned char **srcPlanes, int width, const int *strides, int height,
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* "flags"
*
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT int DLLCALL tjEncodeYUV3(tjhandle handle,
const unsigned char *srcBuf, int width, int pitch, int height,
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* "flags"
*
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle,
const unsigned char *srcBuf, int width, int pitch, int height,
* Create a TurboJPEG decompressor instance.
*
* @return a handle to the newly-created instance, or NULL if an error
- * occurred (see #tjGetErrorStr().)
+ * occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT tjhandle DLLCALL tjInitDecompress(void);
* of the JPEG colorspace constants, indicating the colorspace of the JPEG
* image (see @ref TJCS "JPEG colorspaces".)
*
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT int DLLCALL tjDecompressHeader3(tjhandle handle,
const unsigned char *jpegBuf, unsigned long jpegSize, int *width,
* the number of elements in the list
*
* @return a pointer to a list of fractional scaling factors, or NULL if an
- * error is encountered (see #tjGetErrorStr().)
+ * error is encountered (see #tjGetErrorStr2().)
*/
DLLEXPORT tjscalingfactor* DLLCALL tjGetScalingFactors(int *numscalingfactors);
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* "flags"
*
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle,
const unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf,
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* "flags"
*
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT int DLLCALL tjDecompressToYUV2(tjhandle handle,
const unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf,
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* "flags"
*
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
const unsigned char *jpegBuf, unsigned long jpegSize,
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* "flags"
*
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, const unsigned char *srcBuf,
int pad, int subsamp, unsigned char *dstBuf, int width, int pitch,
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* "flags"
*
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT int DLLCALL tjDecodeYUVPlanes(tjhandle handle,
const unsigned char **srcPlanes, const int *strides, int subsamp,
* Create a new TurboJPEG transformer instance.
*
* @return a handle to the newly-created instance, or NULL if an error
- * occurred (see #tjGetErrorStr().)
+ * occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT tjhandle DLLCALL tjInitTransform(void);
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* "flags"
*
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT int DLLCALL tjTransform(tjhandle handle,
const unsigned char *jpegBuf, unsigned long jpegSize, int n,
* @param handle a handle to a TurboJPEG compressor, decompressor or
* transformer instance
*
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
*/
DLLEXPORT int DLLCALL tjDestroy(tjhandle handle);
/**
* Returns a descriptive error message explaining why the last command failed.
*
+ * @param handle a handle to a TurboJPEG compressor, decompressor, or
+ * transformer instance, or NULL if the error was generated by a global
+ * function (but note that retrieving the error message for a global function
+ * is not thread-safe.)
+ *
* @return a descriptive error message explaining why the last command failed.
*/
-DLLEXPORT char* DLLCALL tjGetErrorStr(void);
+DLLEXPORT char* DLLCALL tjGetErrorStr2(tjhandle handle);
/* Deprecated functions and macros */
unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf,
int flags);
+DLLEXPORT char* DLLCALL tjGetErrorStr(void);
+
/**
* @}