mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-03 19:22:27 +00:00
Update stb (#885)
This commit and, by extension, PR attempts to update `stb` in the most straightforward way possible as well as include fixes from main repo's unmerged PRs for cases rearing their ugly heads during everyday usage: - stb#1299: stb_rect_pack: Make rect_height_compare a stable sort - stb#1402: stb_image: Fix "unused invalid_chunk" with STBI_FAILURE_USERMSG - stb#1404: stb_image: Fix gif two_back memory address - stb#1420: stb_image: Improve error reporting if file operations fail within *_from_file functions - stb#1445: stb_vorbis: Few static analyzers fixes - stb#1487: stb_vorbis: Fix residue classdata bounding for f->temp_memory_required - stb#1490: stb_vorbis: Fix broken clamp in codebook_decode_deinterleave_repeat - stb#1496: stb_image: Fix pnm only build - stb#1497: stb_image: Fix memory leaks if stbi__convert failed - stb#1498: stb_vorbis: Fix memory leaks in stb_vorbis - stb#1499: stb_vorbis: Minor change to prevent the undefined behavior - left shift of a negative value - stb#1500: stb_vorbis: Fix signed integer overflow Includes additional small fixes that I felt didn't warrant a separate PR.
This commit is contained in:
parent
7faffde303
commit
1bc48bc8e4
20 changed files with 1560 additions and 1282 deletions
30
third_party/stb/stb_image_resize.c
vendored
30
third_party/stb/stb_image_resize.c
vendored
|
@ -1,7 +1,7 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
|
@ -655,9 +655,14 @@ static void stbir__calculate_coefficients_upsample(
|
|||
total_filter += coefficient_group[i];
|
||||
}
|
||||
|
||||
STBIR_ASSERT(stbir__filter_info_table[filter].kernel(
|
||||
(float)(in_last_pixel + 1) + 0.5f - in_center_of_out,
|
||||
1 / scale) == 0);
|
||||
// NOTE(fg): Not actually true in general, nor is there any reason to expect
|
||||
// it should be. It would be true in exact math but is at best approximately
|
||||
// true in floating-point math, and it would not make sense to try and put
|
||||
// actual bounds on this here because it depends on the image aspect ratio
|
||||
// which can get pretty extreme.
|
||||
// STBIR_ASSERT(stbir__filter_info_table[filter].kernel(
|
||||
// (float)(in_last_pixel + 1) + 0.5f - in_center_of_out,
|
||||
// 1 / scale) == 0);
|
||||
|
||||
STBIR_ASSERT(total_filter > 0.9);
|
||||
STBIR_ASSERT(total_filter < 1.1f); // Make sure it's not way off.
|
||||
|
@ -701,9 +706,14 @@ static void stbir__calculate_coefficients_downsample(
|
|||
stbir__filter_info_table[filter].kernel(x, scale_ratio) * scale_ratio;
|
||||
}
|
||||
|
||||
STBIR_ASSERT(stbir__filter_info_table[filter].kernel(
|
||||
(float)(out_last_pixel + 1) + 0.5f - out_center_of_in,
|
||||
scale_ratio) == 0);
|
||||
// NOTE(fg): Not actually true in general, nor is there any reason to expect
|
||||
// it should be. It would be true in exact math but is at best approximately
|
||||
// true in floating-point math, and it would not make sense to try and put
|
||||
// actual bounds on this here because it depends on the image aspect ratio
|
||||
// which can get pretty extreme.
|
||||
// STBIR_ASSERT(stbir__filter_info_table[filter].kernel(
|
||||
// (float)(out_last_pixel + 1) + 0.5f - out_center_of_in,
|
||||
// scale_ratio) == 0);
|
||||
|
||||
for (i = out_last_pixel - out_first_pixel; i >= 0; i--) {
|
||||
if (coefficient_group[i]) break;
|
||||
|
@ -851,7 +861,7 @@ static float* stbir__get_decode_buffer(stbir__info* stbir_info) {
|
|||
}
|
||||
|
||||
#define STBIR__DECODE(type, colorspace) \
|
||||
((type) * (STBIR_MAX_COLORSPACES) + (colorspace))
|
||||
((int)(type) * (STBIR_MAX_COLORSPACES) + (int)(colorspace))
|
||||
|
||||
static void stbir__decode_scanline(stbir__info* stbir_info, int n) {
|
||||
int c;
|
||||
|
@ -1199,7 +1209,6 @@ static void stbir__resample_horizontal_downsample(stbir__info* stbir_info,
|
|||
int out_pixel_index = k * 1;
|
||||
float coefficient =
|
||||
horizontal_coefficients[coefficient_group + k - n0];
|
||||
STBIR_ASSERT(coefficient != 0);
|
||||
output_buffer[out_pixel_index + 0] +=
|
||||
decode_buffer[in_pixel_index + 0] * coefficient;
|
||||
}
|
||||
|
@ -1220,7 +1229,6 @@ static void stbir__resample_horizontal_downsample(stbir__info* stbir_info,
|
|||
int out_pixel_index = k * 2;
|
||||
float coefficient =
|
||||
horizontal_coefficients[coefficient_group + k - n0];
|
||||
STBIR_ASSERT(coefficient != 0);
|
||||
output_buffer[out_pixel_index + 0] +=
|
||||
decode_buffer[in_pixel_index + 0] * coefficient;
|
||||
output_buffer[out_pixel_index + 1] +=
|
||||
|
@ -1243,7 +1251,6 @@ static void stbir__resample_horizontal_downsample(stbir__info* stbir_info,
|
|||
int out_pixel_index = k * 3;
|
||||
float coefficient =
|
||||
horizontal_coefficients[coefficient_group + k - n0];
|
||||
STBIR_ASSERT(coefficient != 0);
|
||||
output_buffer[out_pixel_index + 0] +=
|
||||
decode_buffer[in_pixel_index + 0] * coefficient;
|
||||
output_buffer[out_pixel_index + 1] +=
|
||||
|
@ -1268,7 +1275,6 @@ static void stbir__resample_horizontal_downsample(stbir__info* stbir_info,
|
|||
int out_pixel_index = k * 4;
|
||||
float coefficient =
|
||||
horizontal_coefficients[coefficient_group + k - n0];
|
||||
STBIR_ASSERT(coefficient != 0);
|
||||
output_buffer[out_pixel_index + 0] +=
|
||||
decode_buffer[in_pixel_index + 0] * coefficient;
|
||||
output_buffer[out_pixel_index + 1] +=
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue