Changeset 60 for trunk/tinyjpeg
- Timestamp:
- 09/17/07 21:54:18 (4 years ago)
- Files:
-
- trunk/tinyjpeg/tinyjpeg/internal.d (modified) (1 diff)
- trunk/tinyjpeg/tinyjpeg/jidctflt.d (modified) (1 diff)
- trunk/tinyjpeg/tinyjpeg/tinyjpeg.d (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/tinyjpeg/tinyjpeg/internal.d
r59 r60 41 41 //#include <setjmp.h> 42 42 43 import std.stdint; 43 version(Tango) 44 import tango.stdc.stdint; 45 else 46 import std.stdint; 44 47 45 48 // this enables a lot of error checking, set to 0 to disable trunk/tinyjpeg/tinyjpeg/jidctflt.d
r59 r60 79 79 module tinyjpeg.jidctflt; 80 80 81 import std.stdint; 81 version(Tango) 82 import tango.stdc.stdint; 83 else 84 import std.stdint; 82 85 83 86 import tinyjpeg.internal; trunk/tinyjpeg/tinyjpeg/tinyjpeg.d
r59 r60 39 39 module tinyjpeg.tinyjpeg; 40 40 41 import std.c.stdlib; 42 import std.c.string; 43 import std.stdint; 44 import std.string; 45 debug(TinyJpegTrace) { 46 import std.stdio; 41 version(Tango) { 42 import tango.stdc.stdint; 43 import tango.stdc.stdlib; 44 import tango.stdc.string; 45 private char[] format(...) 46 { 47 return "formatted output is not yet supported with Tango"; 48 } 49 } 50 else { 51 import std.c.stdlib; 52 import std.c.string; 53 import std.stdint; 54 import std.string; 55 debug(TinyJpegTrace) { 56 import std.stdio; 57 } 47 58 } 48 59 … … 97 108 // debug trace function 98 109 debug(TinyJpegTrace) { 99 private alias writef trace; 110 version(Tango) 111 private void trace(...) {} 112 else 113 private alias writef trace; 100 114 } else { 101 115 private void trace(...) {} … … 1661 1675 return error(priv,"16 bits quantization table is not supported\n"); 1662 1676 if (qi>4) 1663 return error(priv,format("No more 4 quantization table is supported (got %d)\n", qi));1677 return error(priv,format("No more 4 quantization table is supported (got ",qi,")\n")); 1664 1678 } 1665 1679 table = priv.Q_tables[qi].ptr; … … 1692 1706 return error(priv,"We only support YUV images\n"); 1693 1707 if (height%16) 1694 return error(priv,format("Height need to be a multiple of 16 (current height is %d)\n", height));1708 return error(priv,format("Height need to be a multiple of 16 (current height is ",height," )\n")); 1695 1709 if (width%16) 1696 return error(priv,format("Width need to be a multiple of 16 (current Width is %d)\n", width));1710 return error(priv,format("Width need to be a multiple of 16 (current Width is ",width,")\n")); 1697 1711 } 1698 1712 stream += 8; … … 1705 1719 c.cid = cid; 1706 1720 if (Q_table >= COMPONENTS) { 1707 return error(priv,format("Bad Quantization table index (got %d, max allowed %d)\n", Q_table, COMPONENTS-1));1721 return error(priv,format("Bad Quantization table index (got ", Q_table, " max allowed ", COMPONENTS-1,")\n")); 1708 1722 } 1709 1723 } … … 1711 1725 c.Hfactor = sampling_factor>>>4; 1712 1726 c.Q_table = priv.Q_tables[Q_table].ptr; 1713 trace("Component:%d factor:%dx%d Quantization table:%d\n", 1714 cid, c.Hfactor, c.Hfactor, Q_table ); 1727 trace("Component:",cid," factor:",c.Hfactor,"x",c.Hfactor," Quantization table:",Q_table,"\n"); 1715 1728 } 1716 1729 priv.width = width; … … 1744 1757 return error(priv,"We do not support more than 2 DC Huffman table\n"); 1745 1758 if (cid != priv.component_infos[i].cid) 1746 return error(priv,format("SOS cid order ( %d:%d) isn't compatible with the SOF marker (%d:%d)\n", i, cid, i, priv.component_infos[i].cid));1747 trace("ComponentId: %d tableAC:%d tableDC:%d\n", cid, table&0xf, table>>>4);1759 return error(priv,format("SOS cid order (",i,":",cid,") isn't compatible with the SOF marker (",i,":",priv.component_infos[i].cid,")\n")); 1760 trace("ComponentId:",cid," tableAC:",table&0xf," tableDC:",table>>>4,"\n"); 1748 1761 } 1749 1762 priv.component_infos[i].AC_table = &priv.HTAC[table&0xf]; … … 1764 1777 stream += 2; /* Skip length */ 1765 1778 1766 trace("> DHT marker (length= %d)\n", length);1779 trace("> DHT marker (length=",length,")\n"); 1767 1780 1768 1781 while (length>0) { … … 1778 1791 static if (SANITY_CHECK) { 1779 1792 if (count >= HUFFMAN_BITS_SIZE) 1780 return error(priv,format("No more than %d bytes is allowed to describe a huffman table\n", HUFFMAN_BITS_SIZE));1793 return error(priv,format("No more than ",HUFFMAN_BITS_SIZE," bytes is allowed to describe a huffman table\n")); 1781 1794 if ( (index &0xf) >= HUFFMAN_TABLES) 1782 return error(priv,format("No more than %d Huffman tables is supported (got %d)\n", HUFFMAN_TABLES, index%0xf));1783 trace("Huffman table %s[%d] length=%d\n", (index&0xf0)?"AC":"DC", index&0xf, count);1795 return error(priv,format("No more than ",HUFFMAN_TABLES," Huffman tables is supported (got ",index%0xf,")\n")); 1796 trace("Huffman table ",(index&0xf0)?"AC":"DC","[",index&0xf,"] length=",count,"\n"); 1784 1797 } 1785 1798 … … 1814 1827 1815 1828 debug { 1816 trace("Restart interval = %d\n", priv.restart_interval);1829 trace("Restart interval = ",priv.restart_interval,"\n"); 1817 1830 } 1818 1831 … … 1866 1879 return 0; 1867 1880 } 1868 trace("RST Marker %d found at offset %d\n", priv.last_rst_marker_seen, stream - priv.stream_begin);1881 trace("RST Marker ",priv.last_rst_marker_seen," found at offset ",stream - priv.stream_begin,"\n"); 1869 1882 1870 1883 priv.stream = stream; … … 1920 1933 break; 1921 1934 default: 1922 trace("> Unknown marker %2.2x\n", marker);1935 trace("> Unknown marker ",marker,"\n"); 1923 1936 break; 1924 1937 } … … 2198 2211 } 2199 2212 2200 trace("Input file size: %d\n", priv.stream_length+2);2201 trace("Input bytes actually read: %d\n", priv.stream - priv.stream_begin + 2);2213 trace("Input file size: ",priv.stream_length+2,"\n"); 2214 trace("Input bytes actually read: ",priv.stream - priv.stream_begin + 2,"\n"); 2202 2215 return 0; 2203 2216 }
