Commit Graph

548 Commits

Author SHA1 Message Date
Jorge Rodriguez 13acfca829 I had the whole premultiply thing backwards. 2014-07-31 18:46:00 -07:00
Jorge Rodriguez 21c7c8f5d9 Another stab at the api, offering classes of functions for different common tasks. 2014-07-31 18:04:57 -07:00
Jorge Rodriguez 8063ea0952 Specify a channel as having premultiplied alpha and use it to un-premultiply all other channels before resampling. 2014-07-31 17:20:00 -07:00
Jorge Rodriguez a32fa8b4df This to-do item done. 2014-07-31 16:36:09 -07:00
Jorge Rodriguez daf325dc03 Sub pixel source area test cases. No problems. 2014-07-31 16:31:45 -07:00
Jorge Rodriguez aae1c7ca41 ZOOM AND ENHANCE! 2014-07-31 15:16:36 -07:00
Jorge Rodriguez 1b2d104e00 Some error conditions. 2014-07-31 00:52:03 -07:00
Jorge Rodriguez 35cb95b803 Allow for specifying a sub-region of the source image to use. Downsampling only, currently. 2014-07-31 00:39:33 -07:00
Jorge Rodriguez 52ac93225a C<99 ports 2014-07-30 17:33:47 -07:00
Jorge Rodriguez fdc979e48b Some minor ports for Linux. No idea how it worked at all in Windows with STB_RESIZE_IMPLEMENTATION instead of STB_RESAMPLE_IMPLEMENTATION. 2014-07-30 17:30:25 -07:00
Jorge Rodriguez c5de2f3298 Test channels. 2014-07-30 09:42:12 -07:00
Jorge Rodriguez 985ac75251 When doing a perfect po2 nearest neighbor downsample don't allow -0.5 and 0.5 to both contribute to a texel or you'll get a double tap. 2014-07-30 09:27:42 -07:00
Jorge Rodriguez c2449acc3e Tests for edge behavior 2014-07-30 09:14:38 -07:00
Jorge Rodriguez 59cb71ea18 Fix float conversion. 2014-07-30 08:47:55 -07:00
Jorge Rodriguez 6625259959 Try to keep integer precision by briefly casting to double while decoding and encoding. 2014-07-30 01:18:23 -07:00
Jorge Rodriguez 11897fbf96 More fixing shorts. 2014-07-30 00:34:25 -07:00
Jorge Rodriguez 1fcbe0daaf Fix shorts. Add test cases for shorts. 2014-07-30 00:16:13 -07:00
Jorge Rodriguez 7ead9a748d Fix. Ring buffers are a height value. 2014-07-29 23:09:41 -07:00
Jorge Rodriguez 043fa28c11 Same deal with height. 2014-07-29 23:02:56 -07:00
Jorge Rodriguez ebe0473d8b Add a test suite to do a bunch of different resizes to find problems. One problem found was an incorrect calculation of texel support how many margin texels needed when downsampling. When downsampling we need to spread out the support of each contributing texel, so to compensate you need more margin texels. 2014-07-29 22:50:06 -07:00
Jorge Rodriguez 68f93b72d5 Update documentation and add helper functions. 2014-07-29 20:18:28 -07:00
Jorge Rodriguez 5b40906271 My perf testing code. 2014-07-29 17:44:45 -07:00
Jorge Rodriguez d96c97298c This is still faster than the function pointer solution, and neater. 2014-07-29 16:22:22 -07:00
Jorge Rodriguez 3a3e06029e This is definitely faster than the function pointer solution. 2014-07-29 12:11:03 -07:00
Jorge Rodriguez 9bd5abb52d Both versions run within the margin of error on my machine so we'll go with the simpler one. 2014-07-29 11:44:32 -07:00
Jorge Rodriguez 5dff80ed31 Trying some different strategies for optimizing the decoder. The code in #ifdef 1 is slightly faster by my measurements, but a whole lot uglier. 2014-07-29 11:39:42 -07:00
Jorge Rodriguez 05f775e977 Merge branch 'master' of https://github.com/BSVino/stb 2014-07-29 00:33:54 -07:00
Jorge Rodriguez 1fcf30ada0 Fix a math error. 2014-07-29 00:33:29 -07:00
Jorge Rodriguez e2ac4f6505 More resample ideas 2014-07-27 12:05:17 -07:00
Jorge Rodriguez ef3a460ec4 Some better looking horners save another multiplication. 2014-07-27 00:55:47 -07:00
Jorge Rodriguez 7d47582578 Support for 16 and 32 bit integer images, and float images. 2014-07-27 00:09:22 -07:00
Jorge Rodriguez 6c8cac0a66 Support for sRGB color space. 2014-07-26 23:44:45 -07:00
Jorge Rodriguez 41dc4c476c In some situations with certain filter kernels with negative values it's possible to generate valid results > 1.0, so saturate it before we write it to make sure it doesn't overflow. Also fix incorrect filter radius while downsampling. 2014-07-26 22:49:56 -07:00
Jorge Rodriguez af1ed58f51 Add wrap, fix reflect so it doesn't wrap. 2014-07-26 19:30:13 -07:00
Jorge Rodriguez 8723567439 Add edge reflect mode. 2014-07-26 19:11:02 -07:00
Jorge Rodriguez 6cd81d4dd5 Put the polynomials in horner form to save a multiplication. 2014-07-26 15:36:15 -07:00
Jorge Rodriguez fb2f8df5cc Add mitchell filter. 2014-07-26 15:06:31 -07:00
Jorge Rodriguez 69af963c42 Add catmull rom filter. Also, move the debug asserts for values <= 1 to the very end of the process. This will make these bugs a lot harder to find, but because some filter kernels have negative values it's possible for the buffers to have values > 1 up until the point where it's converted back to an int. 2014-07-26 14:52:28 -07:00
Jorge Rodriguez 12acf87eec When downsampling start the buffer loop at -filter_texel_margin to make sure that all contributors get their taps in at the ring buffer. 2014-07-26 13:56:23 -07:00
Jorge Rodriguez 155c71fb90 Reorder these loops because I think we get a cache win if we write the entire ring buffer entry at once. 2014-07-26 13:12:48 -07:00
Jorge Rodriguez 01fb58d6b4 Add a bicubic filter. 2014-07-26 13:07:04 -07:00
Jorge Rodriguez a95da9ee1d Unroll the multiply-add loops. At the cost of a function pointer dereference we get a whole lot of conditionals eliminated. Should be a solid win once the debug asserts are gone. 2014-07-26 12:04:39 -07:00
Jorge Rodriguez 7abd4ccf34 Support for filters with larger support. Initial support for edge behavior. 2014-07-26 11:51:02 -07:00
Jorge Rodriguez 62ff271c7a I put it in the to do list and now I can close my browser tab. 2014-07-25 00:08:23 -07:00
Jorge Rodriguez 81c1ddf110 Keeping a list of suggestions so I don't forget them. 2014-07-25 00:00:40 -07:00
Jorge Rodriguez 27926e78b8 Make consistent tests for whether we're doing upsampling or downsampling of width and height. Don't request memory for horizontal buffer or encode buffer if we don't need it. 2014-07-24 23:50:14 -07:00
Jorge Rodriguez 666c025710 Fix non uniform scaling where out_w < in_w && out_h > in_h. 2014-07-24 23:32:25 -07:00
Jorge Rodriguez 736596ba09 Fix non uniform scaling where out_w > in_w && out_h < in_h. 2014-07-24 23:27:29 -07:00
Jorge Rodriguez 178e301ea4 Fix upsampling, avoid dereferencing in an inner loop. 2014-07-24 22:54:35 -07:00
Jorge Rodriguez dbb7480f12 Fix nonuniform downsampling. 2014-07-24 22:30:35 -07:00