<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>AlbumShaper: jpegInternal.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.2 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>jpegInternal.h</h1><a href="jpegInternal_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//==============================================</span> <a name="l00002"></a>00002 <span class="comment">// copyright : (C) 2003-2005 by Will Stokes</span> <a name="l00003"></a>00003 <span class="comment">//==============================================</span> <a name="l00004"></a>00004 <span class="comment">// This program is free software; you can redistribute it</span> <a name="l00005"></a>00005 <span class="comment">// and/or modify it under the terms of the GNU General</span> <a name="l00006"></a>00006 <span class="comment">// Public License as published by the Free Software</span> <a name="l00007"></a>00007 <span class="comment">// Foundation; either version 2 of the License, or</span> <a name="l00008"></a>00008 <span class="comment">// (at your option) any later version.</span> <a name="l00009"></a>00009 <span class="comment">//==============================================</span> <a name="l00010"></a>00010 <a name="l00011"></a>00011 <span class="preprocessor">#ifndef BACKEND_TOOLS_JPEG_JPEGINTERNAL</span> <a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor">#define BACKEND_TOOLS_JPEG_JPEGINTERNAL</span> <a name="l00013"></a>00013 <span class="preprocessor"></span> <a name="l00014"></a>00014 <span class="comment">//Support for copying optional markers from source to destination file.</span> <a name="l00015"></a><a class="code" href="jpegInternal_8h.html#a65c3abad1d72d7ac3f89ef621613c553">00015</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> { <a name="l00016"></a><a class="code" href="jpegInternal_8h.html#a65c3abad1d72d7ac3f89ef621613c553ab7f793a912d8fa20dbb45d6340547570">00016</a> <a class="code" href="jpegInternal_8h.html#a65c3abad1d72d7ac3f89ef621613c553ab7f793a912d8fa20dbb45d6340547570">JCOPYOPT_NONE</a>, <span class="comment">//copy no optional markers</span> <a name="l00017"></a><a class="code" href="jpegInternal_8h.html#a65c3abad1d72d7ac3f89ef621613c553ac9a81502d8ebd4eae5acc77d9523ae42">00017</a> <a class="code" href="jpegInternal_8h.html#a65c3abad1d72d7ac3f89ef621613c553ac9a81502d8ebd4eae5acc77d9523ae42">JCOPYOPT_COMMENTS</a>,<span class="comment">//copy only comment (COM) markers</span> <a name="l00018"></a><a class="code" href="jpegInternal_8h.html#a65c3abad1d72d7ac3f89ef621613c553afedac1a02c9e88bd8728433b9301bf2b">00018</a> <a class="code" href="jpegInternal_8h.html#a65c3abad1d72d7ac3f89ef621613c553afedac1a02c9e88bd8728433b9301bf2b">JCOPYOPT_ALL</a> <span class="comment">//copy all optional markers</span> <a name="l00019"></a>00019 } <a class="code" href="jpegInternal_8h.html#a65c3abad1d72d7ac3f89ef621613c553">JCOPY_OPTION</a>; <a name="l00020"></a>00020 <a name="l00021"></a>00021 <span class="comment">//Codes for supported types of image transformations.</span> <a name="l00022"></a><a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315">00022</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> { <a name="l00023"></a><a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315abfca53d9f6c4fd7ae9a90dbc7cdf0a03">00023</a> <a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315abfca53d9f6c4fd7ae9a90dbc7cdf0a03">JXFORM_NONE</a>, <span class="comment">// no transformation</span> <a name="l00024"></a><a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315a1f49341c48b481f2e8ed911840a3fbe3">00024</a> <a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315a1f49341c48b481f2e8ed911840a3fbe3">JXFORM_FLIP_H</a>, <span class="comment">// horizontal flip</span> <a name="l00025"></a><a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315ae522c3e42f2258a43ec693632f30cda4">00025</a> <a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315ae522c3e42f2258a43ec693632f30cda4">JXFORM_FLIP_V</a>, <span class="comment">// vertical flip</span> <a name="l00026"></a><a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315a6f2b9779602ffd890b0ef0b0fc997af7">00026</a> <a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315a6f2b9779602ffd890b0ef0b0fc997af7">JXFORM_TRANSPOSE</a>, <span class="comment">// transpose across UL-to-LR axis</span> <a name="l00027"></a><a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315a87c797c76d9acff5f7134c671d99345e">00027</a> <a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315a87c797c76d9acff5f7134c671d99345e">JXFORM_TRANSVERSE</a>, <span class="comment">// transpose across UR-to-LL axis</span> <a name="l00028"></a><a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315af40c41fbed3c0713a2506c5a09b148eb">00028</a> <a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315af40c41fbed3c0713a2506c5a09b148eb">JXFORM_ROT_90</a>, <span class="comment">// 90-degree clockwise rotation</span> <a name="l00029"></a><a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315adf60d76040ace4a0a7f0b5248af6f556">00029</a> <a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315adf60d76040ace4a0a7f0b5248af6f556">JXFORM_ROT_180</a>, <span class="comment">// 180-degree rotation</span> <a name="l00030"></a><a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315a2f7ec56736e086e309eef1a593bd3e67">00030</a> <a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315a2f7ec56736e086e309eef1a593bd3e67">JXFORM_ROT_270</a> <span class="comment">// 270-degree clockwise (or 90 ccw)</span> <a name="l00031"></a>00031 } <a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315">JXFORM_CODE</a>; <a name="l00032"></a>00032 <a name="l00033"></a>00033 <span class="comment">// Although rotating and flipping data expressed as DCT coefficients is not</span> <a name="l00034"></a>00034 <span class="comment">// hard, there is an asymmetry in the JPEG format specification for images</span> <a name="l00035"></a>00035 <span class="comment">// whose dimensions aren't multiples of the iMCU size. The right and bottom</span> <a name="l00036"></a>00036 <span class="comment">// image edges are padded out to the next iMCU boundary with junk data; but</span> <a name="l00037"></a>00037 <span class="comment">// no padding is possible at the top and left edges. If we were to flip</span> <a name="l00038"></a>00038 <span class="comment">// the whole image including the pad data, then pad garbage would become</span> <a name="l00039"></a>00039 <span class="comment">// visible at the top and/or left, and real pixels would disappear into the</span> <a name="l00040"></a>00040 <span class="comment">// pad margins --- perhaps permanently, since encoders & decoders may not</span> <a name="l00041"></a>00041 <span class="comment">// bother to preserve DCT blocks that appear to be completely outside the</span> <a name="l00042"></a>00042 <span class="comment">// nominal image area. So, we have to exclude any partial iMCUs from the</span> <a name="l00043"></a>00043 <span class="comment">// basic transformation.</span> <a name="l00044"></a>00044 <span class="comment">// </span> <a name="l00045"></a>00045 <span class="comment">// Transpose is the only transformation that can handle partial iMCUs at the</span> <a name="l00046"></a>00046 <span class="comment">// right and bottom edges completely cleanly. flip_h can flip partial iMCUs</span> <a name="l00047"></a>00047 <span class="comment">// at the bottom, but leaves any partial iMCUs at the right edge untouched.</span> <a name="l00048"></a>00048 <span class="comment">// Similarly flip_v leaves any partial iMCUs at the bottom edge untouched.</span> <a name="l00049"></a>00049 <span class="comment">// The other transforms are defined as combinations of these basic transforms</span> <a name="l00050"></a>00050 <span class="comment">// and process edge blocks in a way that preserves the equivalence.</span> <a name="l00051"></a>00051 <span class="comment">// </span> <a name="l00052"></a>00052 <span class="comment">// The "trim" option causes untransformable partial iMCUs to be dropped;</span> <a name="l00053"></a>00053 <span class="comment">// this is not strictly lossless, but it usually gives the best-looking</span> <a name="l00054"></a>00054 <span class="comment">// result for odd-size images. Note that when this option is active,</span> <a name="l00055"></a>00055 <span class="comment">// the expected mathematical equivalences between the transforms may not hold.</span> <a name="l00056"></a>00056 <span class="comment">// (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim</span> <a name="l00057"></a>00057 <span class="comment">// followed by -rot 180 -trim trims both edges.)</span> <a name="l00058"></a>00058 <span class="comment">// </span> <a name="l00059"></a>00059 <span class="comment">// We also offer a "force to grayscale" option, which simply discards the</span> <a name="l00060"></a>00060 <span class="comment">// chrominance channels of a YCbCr image. This is lossless in the sense that</span> <a name="l00061"></a>00061 <span class="comment">// the luminance channel is preserved exactly. It's not the same kind of</span> <a name="l00062"></a>00062 <span class="comment">// thing as the rotate/flip transformations, but it's convenient to handle it</span> <a name="l00063"></a>00063 <span class="comment">// as part of this package, mainly because the transformation routines have to</span> <a name="l00064"></a>00064 <span class="comment">// be aware of the option to know how many components to work on.</span> <a name="l00065"></a><a class="code" href="structjpeg__transform__info.html">00065</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{ <a name="l00066"></a>00066 <span class="comment">//Options: set by caller</span> <a name="l00067"></a><a class="code" href="structjpeg__transform__info.html#aa3227394d9b01bae8543faf79e9c5fe8">00067</a> <a class="code" href="jpegInternal_8h.html#a1133cd2487f1134aed16868dc1f04315">JXFORM_CODE</a> transform; <span class="comment">// image transform operator </span> <a name="l00068"></a><a class="code" href="structjpeg__transform__info.html#a4f1f979322463d2c02a307047f0cf6b7">00068</a> <span class="keywordtype">boolean</span> trim; <span class="comment">// if TRUE, trim partial MCUs as needed </span> <a name="l00069"></a><a class="code" href="structjpeg__transform__info.html#a26d925edb18e0095056b38312fb86e53">00069</a> <span class="keywordtype">boolean</span> force_grayscale; <span class="comment">// if TRUE, convert color image to grayscale</span> <a name="l00070"></a>00070 <a name="l00072"></a><a class="code" href="structjpeg__transform__info.html#a87e3cb664c289649af4ef16b528d995e">00072</a> <span class="keywordtype">int</span> num_components; <span class="comment">// # of components in workspace </span> <a name="l00073"></a><a class="code" href="structjpeg__transform__info.html#a76eb9df454f32d48eafb01b3f433da5c">00073</a> jvirt_barray_ptr * workspace_coef_arrays; <span class="comment">// workspace for transformations </span> <a name="l00074"></a>00074 } <a class="code" href="structjpeg__transform__info.html">jpeg_transform_info</a>; <a name="l00075"></a>00075 <a name="l00076"></a>00076 <span class="comment">// Setup decompression object to save desired markers in memory</span> <a name="l00077"></a>00077 <span class="keywordtype">void</span> <a class="code" href="jpegInternal_8h.html#ac39445ce130600a507ce41e7f76c54da">jcopy_markers_setup</a>(j_decompress_ptr srcinfo, <a class="code" href="jpegInternal_8h.html#a65c3abad1d72d7ac3f89ef621613c553">JCOPY_OPTION</a> option); <a name="l00078"></a>00078 <a name="l00079"></a>00079 <span class="comment">// Request any required workspace</span> <a name="l00080"></a>00080 <span class="keywordtype">void</span> <a class="code" href="jpegInternal_8h.html#a758e220b145193fe08dd975f60421438">jtransform_request_workspace</a>(j_decompress_ptr srcinfo, <a class="code" href="structjpeg__transform__info.html">jpeg_transform_info</a> *info); <a name="l00081"></a>00081 <a name="l00082"></a>00082 <span class="comment">// Adjust output image parameters</span> <a name="l00083"></a>00083 jvirt_barray_ptr * <a class="code" href="jpegInternal_8h.html#a57beb980c0cf186d46e1dca71df4f156">jtransform_adjust_parameters</a>(j_compress_ptr dstinfo, <a name="l00084"></a>00084 jvirt_barray_ptr *src_coef_arrays, <a name="l00085"></a>00085 <a class="code" href="structjpeg__transform__info.html">jpeg_transform_info</a> *info); <a name="l00086"></a>00086 <span class="comment">// Execute the actual transformation, if any</span> <a name="l00087"></a>00087 <span class="keywordtype">void</span> <a class="code" href="jpegInternal_8h.html#ac2a41f9bd0eba30af6992bdf94570d24">jtransform_execute_transformation</a>(j_decompress_ptr srcinfo, j_compress_ptr dstinfo, <a name="l00088"></a>00088 jvirt_barray_ptr *src_coef_arrays, <a name="l00089"></a>00089 <a class="code" href="structjpeg__transform__info.html">jpeg_transform_info</a> *info); <a name="l00090"></a>00090 <a name="l00091"></a>00091 <span class="comment">// Copy markers saved in the given source object to the destination object</span> <a name="l00092"></a>00092 <span class="keywordtype">void</span> <a class="code" href="jpegInternal_8h.html#a8b7f34edce3037c64a42d7de0af24aaf">jcopy_markers_execute</a>(j_decompress_ptr srcinfo, j_compress_ptr dstinfo); <a name="l00093"></a>00093 <a name="l00094"></a>00094 <a name="l00095"></a>00095 <span class="keywordtype">void</span> <a class="code" href="jpegInternal_8h.html#aeecc0f9524d975b17b1ebce119b15db1">do_rot_90</a> (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, <a name="l00096"></a>00096 jvirt_barray_ptr *src_coef_arrays, <a name="l00097"></a>00097 jvirt_barray_ptr *dst_coef_arrays); <a name="l00098"></a>00098 <a name="l00099"></a>00099 <span class="keywordtype">void</span> <a class="code" href="jpegInternal_8h.html#a30296a7d78cf540cb788af95ca0b0513">do_rot_270</a> (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, <a name="l00100"></a>00100 jvirt_barray_ptr *src_coef_arrays, <a name="l00101"></a>00101 jvirt_barray_ptr *dst_coef_arrays); <a name="l00102"></a>00102 <a name="l00103"></a>00103 <span class="keywordtype">void</span> <a class="code" href="jpegInternal_8h.html#a99bc088a91443f3cf4af261730808dcd">do_rot_180</a> (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, <a name="l00104"></a>00104 jvirt_barray_ptr *src_coef_arrays, <a name="l00105"></a>00105 jvirt_barray_ptr *dst_coef_arrays); <a name="l00106"></a>00106 <a name="l00107"></a>00107 <span class="keywordtype">void</span> <a class="code" href="jpegInternal_8h.html#a3ba176a36d8672773082efadb58f7c55">do_transverse</a> (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, <a name="l00108"></a>00108 jvirt_barray_ptr *src_coef_arrays, <a name="l00109"></a>00109 jvirt_barray_ptr *dst_coef_arrays); <a name="l00110"></a>00110 <a name="l00111"></a>00111 <span class="keywordtype">void</span> <a class="code" href="jpegInternal_8h.html#a3413538c59a486d06ab7fd430fb18422">do_flip_v</a> (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, <a name="l00112"></a>00112 jvirt_barray_ptr *src_coef_arrays, <a name="l00113"></a>00113 jvirt_barray_ptr *dst_coef_arrays); <a name="l00114"></a>00114 <a name="l00115"></a>00115 <span class="keywordtype">void</span> <a class="code" href="jpegInternal_8h.html#af5203eec07cb621a2b02a9f58f661763">do_flip_h</a> (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, <a name="l00116"></a>00116 jvirt_barray_ptr *src_coef_arrays); <a name="l00117"></a>00117 <a name="l00118"></a>00118 <span class="keywordtype">void</span> <a class="code" href="jpegInternal_8h.html#a527dab54518b2d4c47e5b911aef99778">trim_bottom_edge</a> (j_compress_ptr dstinfo); <a name="l00119"></a>00119 <span class="keywordtype">void</span> <a class="code" href="jpegInternal_8h.html#a6adde1d88ef2f005c6aefd726e5c3c83">trim_right_edge</a> (j_compress_ptr dstinfo); <a name="l00120"></a>00120 <a name="l00121"></a>00121 <span class="keywordtype">void</span> <a class="code" href="jpegInternal_8h.html#a5ec39e01ddee98da1ffa133eaaf1d27e">do_transpose</a> (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, <a name="l00122"></a>00122 jvirt_barray_ptr *src_coef_arrays, <a name="l00123"></a>00123 jvirt_barray_ptr *dst_coef_arrays); <a name="l00124"></a>00124 <a name="l00125"></a><a class="code" href="jpegInternal_8h.html#af320905358fa78701e4cc60b6135601f">00125</a> <a class="code" href="jpegInternal_8h.html#a8f2dfbb2e1491503d54d155e6873e807">EXTERN</a>(<span class="keywordtype">long</span>) jround_up JPP((<span class="keywordtype">long</span> a, <span class="keywordtype">long</span> <a class="code" href="jpegInternal_8h.html#af320905358fa78701e4cc60b6135601f">b</a>)); <a name="l00126"></a>00126 <a name="l00127"></a>00127 <a class="code" href="jpegInternal_8h.html#a8f2dfbb2e1491503d54d155e6873e807">EXTERN</a>(<span class="keywordtype">void</span>) jcopy_block_row JPP((JBLOCKROW input_row, <a name="l00128"></a><a class="code" href="jpegInternal_8h.html#a58518ef80cb2e9d15ba1837bef666ec6">00128</a> JBLOCKROW <a class="code" href="jpegInternal_8h.html#a58518ef80cb2e9d15ba1837bef666ec6">output_row</a>, <a name="l00129"></a>00129 JDIMENSION <a class="code" href="jpegInternal_8h.html#ac794c67860ca56fc95e4f0f34632bdeb">num_blocks</a>)); <a name="l00130"></a>00130 <a name="l00131"></a>00131 <span class="preprocessor">#endif //BACKEND_TOOLS_JPEG_JPEGINTERNAL</span> <a name="l00132"></a>00132 <span class="preprocessor"></span> </pre></div></div> <hr size="1"/><address style="text-align: right;"><small>Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2 </small></address> </body> </html>