Changeset 60 for trunk/tinyjpeg

Show
Ignore:
Timestamp:
09/17/07 21:54:18 (4 years ago)
Author:
lindquist
Message:

updated tinyjpeg to compile with tango. console tracing and error messages are borked with tango right now.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tinyjpeg/tinyjpeg/internal.d

    r59 r60  
    4141//#include <setjmp.h> 
    4242 
    43 import std.stdint; 
     43version(Tango) 
     44    import tango.stdc.stdint; 
     45else 
     46    import std.stdint; 
    4447 
    4548// this enables a lot of error checking, set to 0 to disable 
  • trunk/tinyjpeg/tinyjpeg/jidctflt.d

    r59 r60  
    7979module tinyjpeg.jidctflt; 
    8080 
    81 import std.stdint; 
     81version(Tango) 
     82    import tango.stdc.stdint; 
     83else 
     84    import std.stdint; 
    8285 
    8386import tinyjpeg.internal; 
  • trunk/tinyjpeg/tinyjpeg/tinyjpeg.d

    r59 r60  
    3939module tinyjpeg.tinyjpeg; 
    4040 
    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; 
     41version(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
     50else { 
     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    } 
    4758} 
    4859 
     
    97108// debug trace function 
    98109debug(TinyJpegTrace) { 
    99     private alias writef trace; 
     110    version(Tango) 
     111        private void trace(...) {} 
     112    else 
     113        private alias writef trace; 
    100114} else { 
    101115    private void trace(...) {} 
     
    16611675       return error(priv,"16 bits quantization table is not supported\n"); 
    16621676     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")); 
    16641678} 
    16651679     table = priv.Q_tables[qi].ptr; 
     
    16921706    return error(priv,"We only support YUV images\n"); 
    16931707  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")); 
    16951709  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")); 
    16971711} 
    16981712  stream += 8; 
     
    17051719     c.cid = cid; 
    17061720     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")); 
    17081722     } 
    17091723} 
     
    17111725     c.Hfactor = sampling_factor>>>4; 
    17121726     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"); 
    17151728  } 
    17161729  priv.width = width; 
     
    17441757       return error(priv,"We do not support more than 2 DC Huffman table\n"); 
    17451758     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"); 
    17481761} 
    17491762     priv.component_infos[i].AC_table = &priv.HTAC[table&0xf]; 
     
    17641777  stream += 2;  /* Skip length */ 
    17651778 
    1766   trace("> DHT marker (length=%d)\n", length); 
     1779  trace("> DHT marker (length=",length,")\n"); 
    17671780 
    17681781  while (length>0) { 
     
    17781791static if (SANITY_CHECK) { 
    17791792     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")); 
    17811794     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"); 
    17841797} 
    17851798 
     
    18141827 
    18151828debug { 
    1816   trace("Restart interval = %d\n", priv.restart_interval); 
     1829  trace("Restart interval = ",priv.restart_interval,"\n"); 
    18171830} 
    18181831 
     
    18661879       return 0; 
    18671880   } 
    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"); 
    18691882 
    18701883  priv.stream = stream; 
     
    19201933     break; 
    19211934       default: 
    1922      trace("> Unknown marker %2.2x\n", marker); 
     1935     trace("> Unknown marker ",marker,"\n"); 
    19231936     break; 
    19241937      } 
     
    21982211  } 
    21992212 
    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"); 
    22022215  return 0; 
    22032216}