Merge branch 'msvc-friendly-profiles' into 8.8
This commit is contained in:
commit
31f7421b11
@ -58,58 +58,19 @@ typedef VipsOperationClass VipsProfileLoadClass;
|
||||
|
||||
G_DEFINE_TYPE( VipsProfileLoad, vips_profile_load, VIPS_TYPE_OPERATION );
|
||||
|
||||
/* Created on first use from a base64 string in profiles.c.
|
||||
*/
|
||||
typedef struct _VipsFallbackProfile {
|
||||
const char *name;
|
||||
void *data;
|
||||
size_t data_length;
|
||||
} VipsFallbackProfile;
|
||||
|
||||
static GSList *vips_fallback_profile_list = NULL;
|
||||
|
||||
static void *
|
||||
vips_fallback_profile_get_init( void )
|
||||
static const void *
|
||||
vips_profile_fallback_get( const char *name, size_t *length )
|
||||
{
|
||||
int i;
|
||||
VipsProfileFallback *fallback;
|
||||
|
||||
for( i = 0; vips__coded_profiles[i].name; i++ ) {
|
||||
size_t data_length;
|
||||
unsigned char *data;
|
||||
VipsFallbackProfile *fallback;
|
||||
|
||||
if( !(data = vips__b64_decode(
|
||||
vips__coded_profiles[i].data, &data_length )) )
|
||||
return( NULL );
|
||||
fallback = g_new( VipsFallbackProfile,1 );
|
||||
fallback->name = vips__coded_profiles[i].name;
|
||||
fallback->data = data;
|
||||
fallback->data_length = data_length;
|
||||
vips_fallback_profile_list = g_slist_prepend(
|
||||
vips_fallback_profile_list, fallback );
|
||||
}
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
static void *
|
||||
vips_fallback_profile_get( const char *name, size_t *length )
|
||||
{
|
||||
static GOnce once = G_ONCE_INIT;
|
||||
|
||||
GSList *p;
|
||||
|
||||
VIPS_ONCE( &once, (GThreadFunc) vips_fallback_profile_get_init, NULL );
|
||||
|
||||
for( p = vips_fallback_profile_list; p; p = p->next ) {
|
||||
VipsFallbackProfile *fallback = (VipsFallbackProfile *) p->data;
|
||||
|
||||
for( i = 0; (fallback = vips__profile_fallback_table[i]); i++ )
|
||||
if( g_ascii_strcasecmp( fallback->name, name ) == 0 ) {
|
||||
*length = fallback->data_length;
|
||||
if( length )
|
||||
*length = fallback->length;
|
||||
|
||||
return( fallback->data );
|
||||
}
|
||||
}
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
@ -131,7 +92,7 @@ vips_profile_load_build( VipsObject *object )
|
||||
if( g_ascii_strcasecmp( load->name, "none" ) == 0 ) {
|
||||
profile = NULL;
|
||||
}
|
||||
else if( (data = vips_fallback_profile_get( load->name, &length )) ) {
|
||||
else if( (data = vips_profile_fallback_get( load->name, &length )) ) {
|
||||
profile = vips_blob_new( NULL, data, length );
|
||||
}
|
||||
else if( (data = vips__file_read_name( load->name,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,13 @@
|
||||
/* The fallback profiles, coded as a set of base64 strings, see
|
||||
* wrap-profiles.sh
|
||||
/* The fallback profiles, coded as a set of uchar arrays, see wrap-profiles.sh
|
||||
*/
|
||||
typedef struct _VipsCodedProfile {
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct _VipsProfileFallback {
|
||||
const char *name;
|
||||
const char *data;
|
||||
} VipsCodedProfile;
|
||||
size_t length;
|
||||
const unsigned char data[];
|
||||
} VipsProfileFallback;
|
||||
|
||||
extern VipsCodedProfile vips__coded_profiles[];
|
||||
extern VipsProfileFallback *vips__profile_fallback_table[];
|
||||
|
||||
|
@ -1,22 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
# code up the binary files in $1 as a set of name / base64-encoded strings
|
||||
# code up the binary files in $1 as a set of name / string pairs
|
||||
# in $2
|
||||
|
||||
# we have to use arrays for the strings, since MSVC won't allow string
|
||||
# literals larger than 64kb
|
||||
|
||||
in=$1
|
||||
out=$2
|
||||
|
||||
echo "/* coded files, generated automatically */" > $out
|
||||
echo "/* this file generated automatically, do not edit */" > $out
|
||||
echo "" >> $out
|
||||
echo "#include \"profiles.h\"" >> $out
|
||||
echo "" >> $out
|
||||
echo "VipsCodedProfile vips__coded_profiles[] = {" >> $out
|
||||
|
||||
profile_names=
|
||||
for file in $in/*; do
|
||||
root=${file%.icm}
|
||||
base=${root##*/}
|
||||
echo " { \"$base\"," >> $out
|
||||
base64 $file | sed 's/\(.*\)/"\1"/g' >> $out
|
||||
echo " }," >> $out
|
||||
profile_name=vips__profile_fallback_$base
|
||||
profile_names="$profile_names $profile_name"
|
||||
echo "static VipsProfileFallback $profile_name = {" >> $out
|
||||
echo " \"$base\"," >> $out
|
||||
echo " $(stat --format=%s $file)," >> $out
|
||||
echo " {" >> $out
|
||||
hexdump -v -e '" 0x" 1/1 "%02X,"' $file | fmt >> $out
|
||||
echo " }" >> $out
|
||||
echo "};" >> $out
|
||||
echo >> $out
|
||||
done
|
||||
echo " { 0, 0 }" >> $out
|
||||
|
||||
echo "VipsProfileFallback *vips__profile_fallback_table[] = {" >> $out
|
||||
for profile_name in $profile_names; do
|
||||
echo " &$profile_name," >> $out
|
||||
done
|
||||
echo " NULL" >> $out
|
||||
echo "};" >> $out
|
||||
|
@ -461,7 +461,9 @@ class TestForeign:
|
||||
def test_webp(self):
|
||||
def webp_valid(im):
|
||||
a = im(10, 10)
|
||||
assert_almost_equal_objects(a, [71, 166, 236])
|
||||
# different webp versions use different rounding systems leading
|
||||
# to small variations
|
||||
assert_almost_equal_objects(a, [71, 166, 236], threshold=2)
|
||||
assert im.width == 550
|
||||
assert im.height == 368
|
||||
assert im.bands == 3
|
||||
@ -476,7 +478,7 @@ class TestForeign:
|
||||
im = pyvips.Image.new_from_file(WEBP_FILE)
|
||||
buf = im.webpsave_buffer(lossless=True)
|
||||
im2 = pyvips.Image.new_from_buffer(buf, "")
|
||||
assert im.avg() == im2.avg()
|
||||
assert abs(im.avg() - im2.avg()) < 1
|
||||
|
||||
# higher Q should mean a bigger buffer
|
||||
b1 = im.webpsave_buffer(Q=10)
|
||||
|
Loading…
Reference in New Issue
Block a user