tomato/stb_image_resize_test/oldir.c
Green Sky 04b3382029 Squashed 'external/stb/stb/' changes from c39c7023eb..f4a71b1337
f4a71b1337 README.md: tweak credits
a8a25e17b5 update readme version numbers
0bc88af4de stb_image: optimizations
0ca75da4ec stb_image_resize2: remove whitespace
9d924f8a47 stb_image_resize: 2.04
4da08a1dbd stb_image: create_png_image_raw restructuring
c6d7c32e5d stb_image: Two warning fixes
07268cbf36 stb_image: New Paeth filter
ed64333410 tests: test_png_regress
45eb4ac158 global: very basic .gitignore for object files
e5f0e18d0f stb_image: Small PNG filter simplification
d373674115 stb_image: Fix zlib decoder end-of-stream handling
03f50e343d security notice
1d878bd2a3 security notice
beebb24b94 README.md: fix reference to stb_image_resize2.h
e81f294b16 stb_image_resize: switch GNU/clang from "asm" to "__asm__" for -c99 compatibility
c4bbb6e75f stb_image_resize2.h 2.00
REVERT: c39c7023eb stb_image: create_png_image_raw restructuring
REVERT: 8c3aa05487 stb_image: Two warning fixes
REVERT: 3aa1744a29 stb_image: New Paeth filter
REVERT: 2f3b7e47fa tests: test_png_regress
REVERT: d647af9ad2 global: very basic .gitignore for object files
REVERT: 5a44133dc5 stb_image: Small PNG filter simplification
REVERT: 9f1776a36d stb_image: Fix zlib decoder end-of-stream handling

git-subtree-dir: external/stb/stb
git-subtree-split: f4a71b13373436a2866c5d68f8f80ac6f0bc1ffe
2024-01-27 13:03:42 +01:00

57 lines
2.5 KiB
C

#include <stdio.h>
#include <stdlib.h>
#ifdef _MSC_VER
#define stop() __debugbreak()
#else
#define stop() __builtin_trap()
#endif
//#define HEAVYTM
#include "tm.h"
#define STBIR_SATURATE_INT
#define STB_IMAGE_RESIZE_STATIC
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#include "old_image_resize.h"
static int types[4] = { STBIR_TYPE_UINT8, STBIR_TYPE_UINT8, STBIR_TYPE_UINT16, STBIR_TYPE_FLOAT };
static int edges[4] = { STBIR_EDGE_CLAMP, STBIR_EDGE_REFLECT, STBIR_EDGE_ZERO, STBIR_EDGE_WRAP };
static int flts[5] = { STBIR_FILTER_BOX, STBIR_FILTER_TRIANGLE, STBIR_FILTER_CUBICBSPLINE, STBIR_FILTER_CATMULLROM, STBIR_FILTER_MITCHELL };
static int channels[20] = { 1, 2, 3, 4, 4,4, 2,2, 4,4, 2,2, 4,4, 2,2, 4,4, 2,2 };
static int alphapos[20] = { -1, -1, -1, -1, 3,0, 1,0, 3,0, 1,0, 3,0, 1,0, 3,0, 1,0 };
void oresize( void * o, int ox, int oy, int op, void * i, int ix, int iy, int ip, int buf, int type, int edg, int flt )
{
int t = types[type];
int ic = channels[buf];
int alpha = alphapos[buf];
int e = edges[edg];
int f = flts[flt];
int space = ( type == 1 ) ? STBIR_COLORSPACE_SRGB : 0;
int flags = ( buf >= 16 ) ? STBIR_FLAG_ALPHA_PREMULTIPLIED : ( ( buf >= 12 ) ? STBIR_FLAG_ALPHA_OUT_PREMULTIPLIED : ( ( buf >= 8 ) ? (STBIR_FLAG_ALPHA_PREMULTIPLIED|STBIR_FLAG_ALPHA_OUT_PREMULTIPLIED) : 0 ) );
stbir_uint64 start;
ENTER( "Resize (old)" );
start = tmGetAccumulationStart( tm_mask );
if(!stbir_resize( i, ix, iy, ip, o, ox, oy, op, t, ic, alpha, flags, e, e, f, f, space, 0 ) )
stop();
#ifdef STBIR_PROFILE
tmEmitAccumulationZone( 0, 0, (tm_uint64 *)&start, 0, oldprofile.named.setup, "Setup (old)" );
tmEmitAccumulationZone( 0, 0, (tm_uint64 *)&start, 0, oldprofile.named.filters, "Filters (old)" );
tmEmitAccumulationZone( 0, 0, (tm_uint64 *)&start, 0, oldprofile.named.looping, "Looping (old)" );
tmEmitAccumulationZone( 0, 0, (tm_uint64 *)&start, 0, oldprofile.named.vertical, "Vertical (old)" );
tmEmitAccumulationZone( 0, 0, (tm_uint64 *)&start, 0, oldprofile.named.horizontal, "Horizontal (old)" );
tmEmitAccumulationZone( 0, 0, (tm_uint64 *)&start, 0, oldprofile.named.decode, "Scanline input (old)" );
tmEmitAccumulationZone( 0, 0, (tm_uint64 *)&start, 0, oldprofile.named.encode, "Scanline output (old)" );
tmEmitAccumulationZone( 0, 0, (tm_uint64 *)&start, 0, oldprofile.named.alpha, "Alpha weighting (old)" );
tmEmitAccumulationZone( 0, 0, (tm_uint64 *)&start, 0, oldprofile.named.unalpha, "Alpha unweighting (old)" );
#endif
LEAVE();
}