diff --git a/TODO b/TODO index 5dbb524f..81db3d5c 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,4 @@ -- test vips_foreign_load_vips_get_flags(), sense inverted? - - test load/save jpeg buffer +- test load/save jpeg buffer leaktest diff --git a/libvips/conversion/copy.c b/libvips/conversion/copy.c index 7df5b9f4..bf728a33 100644 --- a/libvips/conversion/copy.c +++ b/libvips/conversion/copy.c @@ -145,7 +145,7 @@ vips_copy_swap2( PEL *in, PEL *out, int width, VipsImage *im ) int x; for( x = 0; x < sz; x++ ) - out[x] = GUINT16_SWAP_LE_BE( in[x] ); + q[x] = GUINT16_SWAP_LE_BE( p[x] ); } /* Swap 4- of bytes. @@ -160,7 +160,7 @@ vips_copy_swap4( PEL *in, PEL *out, int width, VipsImage *im ) int x; for( x = 0; x < sz; x++ ) - out[x] = GUINT32_SWAP_LE_BE( in[x] ); + q[x] = GUINT32_SWAP_LE_BE( p[x] ); } /* Swap 8- of bytes. @@ -175,7 +175,7 @@ vips_copy_swap8( PEL *in, PEL *out, int width, VipsImage *im ) int x; for( x = 0; x < sz; x++ ) - out[x] = GUINT64_SWAP_LE_BE( in[x] ); + q[x] = GUINT64_SWAP_LE_BE( p[x] ); } typedef void (*SwapFn)( PEL *in, PEL *out, int width, VipsImage *im ); diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index 68627f83..713ff579 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -528,9 +528,12 @@ vips_foreign_load_build( VipsObject *object ) VipsForeignLoad *load = VIPS_FOREIGN_LOAD( object ); VipsForeignLoadClass *class = VIPS_FOREIGN_LOAD_GET_CLASS( object ); - if( class->get_flags && - class->get_flags( load ) ) - return( -1 ); + VipsForeignFlags flags; + + flags = 0; + if( class->get_flags ) + flags |= class->get_flags( load ); + g_object_set( load, "flags", flags, NULL ); if( VIPS_OBJECT_CLASS( vips_foreign_load_parent_class )-> build( object ) ) @@ -605,7 +608,6 @@ vips_foreign_load_class_init( VipsForeignLoadClass *class ) VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsForeignLoad, disc ), TRUE ); - } static void diff --git a/libvips/foreign/vipsload.c b/libvips/foreign/vipsload.c index b4777d00..2716f98d 100644 --- a/libvips/foreign/vipsload.c +++ b/libvips/foreign/vipsload.c @@ -62,21 +62,18 @@ vips_foreign_load_vips_is_a( const char *filename ) return( vips__file_magic( filename ) ); } -static int +static VipsForeignFlags vips_foreign_load_vips_get_flags( VipsForeignLoad *load ) { VipsForeignLoadVips *vips = (VipsForeignLoadVips *) load; + VipsForeignFlags flags; - load->flags = VIPS_FOREIGN_PARTIAL; + flags = VIPS_FOREIGN_PARTIAL; - if( vips__file_magic( vips->filename ) == VIPS_MAGIC_INTEL ) { - printf( "vips_foreign_load_vips_get_flags: " - "%s is intel, setting bigendian\n", - vips->filename ); - load->flags |= VIPS_FOREIGN_BIGENDIAN; - } + if( vips__file_magic( vips->filename ) == VIPS_MAGIC_SPARC ) + flags |= VIPS_FOREIGN_BIGENDIAN; - return( 0 ); + return( flags ); } static int diff --git a/libvips/include/vips/foreign.h b/libvips/include/vips/foreign.h index 04024f1d..037cd6a3 100644 --- a/libvips/include/vips/foreign.h +++ b/libvips/include/vips/foreign.h @@ -88,7 +88,8 @@ void *vips_foreign_map( const char *base, typedef enum { VIPS_FOREIGN_NONE = 0, /* No flags set */ VIPS_FOREIGN_PARTIAL = 1, /* Lazy read OK (eg. tiled tiff) */ - VIPS_FOREIGN_BIGENDIAN = 2 /* Most-significant byte first */ + VIPS_FOREIGN_BIGENDIAN = 2, /* Most-significant byte first */ + VIPS_FOREIGN_ALL = 3 /* All flags set */ } VipsForeignFlags; #define VIPS_TYPE_FOREIGN_LOAD (vips_foreign_load_get_type()) @@ -134,15 +135,15 @@ typedef struct _VipsForeignLoadClass { /*< public >*/ - /* Is a foreign in this format. + /* Is a file in this format. */ gboolean (*is_a)( const char * ); - /* Get the flags for this foreign. + /* Get the flags for this file. */ - int (*get_flags)( VipsForeignLoad * ); + VipsForeignFlags (*get_flags)( VipsForeignLoad * ); - /* Set the header fields in @out from @foreignname. If you can read the + /* Set the header fields in @out from @filename. If you can read the * whole image as well with no performance cost (as with vipsload), * leave ->load() NULL and only @header will be used. */ diff --git a/libvips/iofuncs/enumtypes.c b/libvips/iofuncs/enumtypes.c index 93d73650..c9fddd72 100644 --- a/libvips/iofuncs/enumtypes.c +++ b/libvips/iofuncs/enumtypes.c @@ -15,6 +15,7 @@ vips_foreign_flags_get_type( void ) {VIPS_FOREIGN_NONE, "VIPS_FOREIGN_NONE", "none"}, {VIPS_FOREIGN_PARTIAL, "VIPS_FOREIGN_PARTIAL", "partial"}, {VIPS_FOREIGN_BIGENDIAN, "VIPS_FOREIGN_BIGENDIAN", "bigendian"}, + {VIPS_FOREIGN_ALL, "VIPS_FOREIGN_ALL", "all"}, {0, NULL, NULL} };