Merge branch 'master' into working
This commit is contained in:
commit
65edb64dd8
2
stb.h
2
stb.h
@ -11205,7 +11205,7 @@ int stb_arith_decode_byte(stb_arith *a)
|
||||
// Threads
|
||||
//
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
#ifdef STB_THREADS
|
||||
#error "threads not implemented except for Windows"
|
||||
#endif
|
||||
|
72
stb_image.h
72
stb_image.h
@ -201,10 +201,11 @@
|
||||
Janez Zemva John Bartholomew Michal Cichon svdijk@github
|
||||
Jonathan Blow Ken Hamada Tero Hanninen Baldur Karlsson
|
||||
Laurent Gomila Cort Stratton Sergio Gonzalez romigrou@github
|
||||
Aruelien Pocheville Thibault Reuille Cass Everitt
|
||||
Aruelien Pocheville Thibault Reuille Cass Everitt
|
||||
Ryamond Barbiero Paul Du Bois Engin Manap
|
||||
Michaelangel007@github Oriol Ferrer Mesia
|
||||
Blazej Dariusz Roszkowski
|
||||
Michaelangel007@github
|
||||
Oriol Ferrer Mesia
|
||||
|
||||
|
||||
LICENSE
|
||||
@ -3425,10 +3426,13 @@ static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp
|
||||
|
||||
static unsigned char *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp)
|
||||
{
|
||||
stbi__jpeg j;
|
||||
j.s = s;
|
||||
stbi__setup_jpeg(&j);
|
||||
return load_jpeg_image(&j, x,y,comp,req_comp);
|
||||
unsigned char* result;
|
||||
stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg));
|
||||
j->s = s;
|
||||
stbi__setup_jpeg(j);
|
||||
result = load_jpeg_image(j, x,y,comp,req_comp);
|
||||
STBI_FREE(j);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int stbi__jpeg_test(stbi__context *s)
|
||||
@ -3456,9 +3460,12 @@ static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp)
|
||||
|
||||
static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp)
|
||||
{
|
||||
stbi__jpeg j;
|
||||
j.s = s;
|
||||
return stbi__jpeg_info_raw(&j, x, y, comp);
|
||||
int result;
|
||||
stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg)));
|
||||
j->s = s;
|
||||
result = stbi__jpeg_info_raw(j, x, y, comp);
|
||||
STBI_FREE(j);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3749,7 +3756,7 @@ static int stbi__compute_huffman_codes(stbi__zbuf *a)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int stbi__parse_uncomperssed_block(stbi__zbuf *a)
|
||||
static int stbi__parse_uncompressed_block(stbi__zbuf *a)
|
||||
{
|
||||
stbi_uc header[4];
|
||||
int len,nlen,k;
|
||||
@ -3815,7 +3822,7 @@ static int stbi__parse_zlib(stbi__zbuf *a, int parse_header)
|
||||
final = stbi__zreceive(a,1);
|
||||
type = stbi__zreceive(a,2);
|
||||
if (type == 0) {
|
||||
if (!stbi__parse_uncomperssed_block(a)) return 0;
|
||||
if (!stbi__parse_uncompressed_block(a)) return 0;
|
||||
} else if (type == 3) {
|
||||
return 0;
|
||||
} else {
|
||||
@ -5447,6 +5454,21 @@ static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int
|
||||
}
|
||||
}
|
||||
|
||||
if (channelCount >= 3) {
|
||||
for (i=0; i < w*h; ++i) {
|
||||
unsigned char *pixel = out + 4*i;
|
||||
if (pixel[3] != 0 && pixel[3] != 255) {
|
||||
// remove weird white matte from PSD
|
||||
float a = pixel[3] / 255.0f;
|
||||
float ra = 1.0f / a;
|
||||
float inv_a = 255.0f * (1 - ra);
|
||||
pixel[0] = (unsigned char) (pixel[0]*ra + inv_a);
|
||||
pixel[1] = (unsigned char) (pixel[1]*ra + inv_a);
|
||||
pixel[2] = (unsigned char) (pixel[2]*ra + inv_a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (req_comp && req_comp != 4) {
|
||||
out = stbi__convert_format(out, 4, req_comp, w, h);
|
||||
if (out == NULL) return out; // stbi__convert_format frees input on failure
|
||||
@ -5759,13 +5781,15 @@ static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_in
|
||||
|
||||
static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp)
|
||||
{
|
||||
stbi__gif g;
|
||||
if (!stbi__gif_header(s, &g, comp, 1)) {
|
||||
stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif));
|
||||
if (!stbi__gif_header(s, g, comp, 1)) {
|
||||
STBI_FREE(g);
|
||||
stbi__rewind( s );
|
||||
return 0;
|
||||
}
|
||||
if (x) *x = g.w;
|
||||
if (y) *y = g.h;
|
||||
if (x) *x = g->w;
|
||||
if (y) *y = g->h;
|
||||
STBI_FREE(g);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -6018,20 +6042,20 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i
|
||||
static stbi_uc *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp)
|
||||
{
|
||||
stbi_uc *u = 0;
|
||||
stbi__gif g;
|
||||
memset(&g, 0, sizeof(g));
|
||||
stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif));
|
||||
memset(g, 0, sizeof(*g));
|
||||
|
||||
u = stbi__gif_load_next(s, &g, comp, req_comp);
|
||||
u = stbi__gif_load_next(s, g, comp, req_comp);
|
||||
if (u == (stbi_uc *) s) u = 0; // end of animated gif marker
|
||||
if (u) {
|
||||
*x = g.w;
|
||||
*y = g.h;
|
||||
*x = g->w;
|
||||
*y = g->h;
|
||||
if (req_comp && req_comp != 4)
|
||||
u = stbi__convert_format(u, 4, req_comp, g.w, g.h);
|
||||
u = stbi__convert_format(u, 4, req_comp, g->w, g->h);
|
||||
}
|
||||
else if (g.out)
|
||||
STBI_FREE(g.out);
|
||||
|
||||
else if (g->out)
|
||||
STBI_FREE(g->out);
|
||||
STBI_FREE(g);
|
||||
return u;
|
||||
}
|
||||
|
||||
|
@ -736,7 +736,7 @@ unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_l
|
||||
unsigned int bitbuf=0;
|
||||
int i,j, bitcount=0;
|
||||
unsigned char *out = NULL;
|
||||
unsigned char **hash_table[stbiw__ZHASH]; // 64KB on the stack!
|
||||
unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(char**));
|
||||
if (quality < 5) quality = 5;
|
||||
|
||||
stbiw__sbpush(out, 0x78); // DEFLATE 32K window
|
||||
@ -808,6 +808,7 @@ unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_l
|
||||
|
||||
for (i=0; i < stbiw__ZHASH; ++i)
|
||||
(void) stbiw__sbfree(hash_table[i]);
|
||||
STBIW_FREE(hash_table);
|
||||
|
||||
{
|
||||
// compute adler32 on input
|
||||
|
@ -552,6 +552,9 @@ enum STBVorbisError
|
||||
#include <math.h>
|
||||
#if !(defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh))
|
||||
#include <malloc.h>
|
||||
#if defined(__linux__) || defined(__linux)
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
#endif
|
||||
#else // STB_VORBIS_NO_CRT
|
||||
#define NULL 0
|
||||
@ -2246,6 +2249,11 @@ static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int
|
||||
}
|
||||
done:
|
||||
CHECK(f);
|
||||
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
|
||||
temp_free(f,part_classdata);
|
||||
#else
|
||||
temp_free(f,classifications);
|
||||
#endif
|
||||
temp_alloc_restore(f,temp_alloc_point);
|
||||
}
|
||||
|
||||
@ -2891,6 +2899,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype)
|
||||
}
|
||||
}
|
||||
|
||||
temp_free(f,buf2);
|
||||
temp_alloc_restore(f,save_point);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user