diff --git a/ChangeLog b/ChangeLog index 3be50ed7..bb58dd73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,11 @@ -xx/1/23 8.14.1 +9/1/23 8.14.1 - add vips_thread_isworker() compatibility function [remicollet] - add vips_semaphore_down_timeout() [kleisauke] - idle threads are removed after 15s [kleisauke] - fix version number in gtk-doc index [kleisauke] +- save mono fits images as NAXIS=2 [ewelot] +- fix jpeg `autorotate` for orientation 3 [zhifengzhuang] 22/12/22 8.14.0 diff --git a/libvips/create/create.c b/libvips/create/create.c index 751bb1f4..c99a4bd3 100644 --- a/libvips/create/create.c +++ b/libvips/create/create.c @@ -67,8 +67,7 @@ * VipsTextWrap: * @VIPS_TEXT_WRAP_WORD: wrap at word boundaries * @VIPS_TEXT_WRAP_CHAR: wrap at character boundaries - * @VIPS_TEXT_WRAP_WORD_CHAR: wrap at word boundaries, but fall back to - * character boundaries if there is not enough space for a full word + * @VIPS_TEXT_WRAP_WORD_CHAR: wrap at word boundaries, but fall back to character boundaries if there is not enough space for a full word * @VIPS_TEXT_WRAP_NONE: no wrapping * * Sets the word wrapping style for vips_text() when used with a maximum diff --git a/libvips/create/meson.build b/libvips/create/meson.build index ed79a13c..4e635de4 100644 --- a/libvips/create/meson.build +++ b/libvips/create/meson.build @@ -37,6 +37,8 @@ create_headers = files( 'pmask.h', ) +libvips_sources += create_sources + create_lib = static_library('create', create_sources, create_headers, diff --git a/libvips/foreign/fits.c b/libvips/foreign/fits.c index 4bce24fb..8c7770a5 100644 --- a/libvips/foreign/fits.c +++ b/libvips/foreign/fits.c @@ -36,6 +36,8 @@ * 27/10/22 * - band interleave ourselves on read * - don't duplicate metadata + * 6/1/23 ewelot + * - save mono images as NAXIS=2 */ /* @@ -658,7 +660,7 @@ vips_fits_set_header( VipsFits *fits, VipsImage *in ) status = 0; - fits->naxis = 3; + fits->naxis = in->Bands == 1 ? 2 : 3; fits->naxes[0] = in->Xsize; fits->naxes[1] = in->Ysize; fits->naxes[2] = in->Bands; diff --git a/libvips/foreign/jpeg2vips.c b/libvips/foreign/jpeg2vips.c index d494dfb3..aeed07d3 100644 --- a/libvips/foreign/jpeg2vips.c +++ b/libvips/foreign/jpeg2vips.c @@ -979,9 +979,10 @@ vips__jpeg_read( ReadJpeg *jpeg, VipsImage *out, gboolean header_only ) /* Swap width and height if we're going to rotate this image. */ - if( jpeg->autorotate && - vips_image_get_orientation_swap( out ) ) { - VIPS_SWAP( int, out->Xsize, out->Ysize ); + if( jpeg->autorotate ) { + if( vips_image_get_orientation_swap( out ) ) + VIPS_SWAP( int, out->Xsize, out->Ysize ); + vips_autorot_remove_angle( out ); } } diff --git a/libvips/iofuncs/threadpool.c b/libvips/iofuncs/threadpool.c index 8e392faf..04e57ee0 100644 --- a/libvips/iofuncs/threadpool.c +++ b/libvips/iofuncs/threadpool.c @@ -405,7 +405,7 @@ vips_thread_main_loop( void *a, void *b ) !pool->error ) { VIPS_GATE_START( "vips_worker_work_unit: u" ); vips_worker_work_unit( worker ); - VIPS_GATE_STOP( "vips_thread_work_unit: u" ); + VIPS_GATE_STOP( "vips_worker_work_unit: u" ); vips_semaphore_up( &pool->tick ); } diff --git a/libvips/iofuncs/threadset.c b/libvips/iofuncs/threadset.c index 06c91c4b..d0d11ad3 100644 --- a/libvips/iofuncs/threadset.c +++ b/libvips/iofuncs/threadset.c @@ -43,6 +43,10 @@ #endif /*HAVE_UNISTD_H*/ #include +/* +#define VIPS_DEBUG + */ + #include #include #include @@ -105,10 +109,13 @@ vips_threadset_work( void *pointer ) VipsThreadsetMember *member = (VipsThreadsetMember *) pointer; VipsThreadset *set = member->set; + VIPS_DEBUG_MSG( "vips_threadset_work: starting %p\n", member ); + for(;;) { /* Wait for at least 15 seconds to be given work. */ - if( vips_semaphore_down_timeout( &member->idle, max_idle_time ) == -1 ) + if( vips_semaphore_down_timeout( &member->idle, + max_idle_time ) == -1 ) break; /* Killed or no task available? Leave this thread. @@ -150,6 +157,8 @@ vips_threadset_work( void *pointer ) set->free = g_slist_remove( set->free, member ); set->members = g_slist_remove( set->members, member ); set->n_threads -= 1; + VIPS_DEBUG_MSG( "vips_threadset_work: stopping %p (%d remaining)\n", + member, set->n_threads ); g_mutex_unlock( set->lock ); vips_semaphore_destroy( &member->idle ); diff --git a/tools/vipsprofile b/tools/vipsprofile index f9bbb9f9..acc0f2e2 100644 --- a/tools/vipsprofile +++ b/tools/vipsprofile @@ -1,7 +1,4 @@ -#!/usr/bin/python - -from __future__ import division -from __future__ import print_function +#!/usr/bin/python3 import re import cairo @@ -154,7 +151,7 @@ for thread in threads: all_events.sort(key=lambda x: x.start) -print('loaded %d events' % n_events) +print(f'loaded {n_events} events') # move time axis to secs of computation ticks_per_sec = 1000000.0 @@ -173,7 +170,7 @@ for event in all_events: last_time = (last_time - first_time) / ticks_per_sec first_time = 0 -print('total time =', last_time) +print(f'total time = {last_time}') # calculate some simple stats for thread in threads: @@ -202,7 +199,7 @@ for thread in threads: # hide very short-lived threads thread.hide = thread.alive < 0.01 -print('name\t\talive\twait%\twork%\tunkn%\tmemory\tpeakm') +print('name alive wait% work% unkn% mem peakm') for thread in threads: if thread.hide: continue @@ -211,11 +208,10 @@ for thread in threads: work_percent = 100 * thread.work / thread.alive unkn_percent = 100 - 100 * (thread.work + thread.wait) / thread.alive - print('%13s\t%6.2g\t' % (thread.thread_name, thread.alive), end=' ') - print('%.3g\t%.3g\t%.3g\t' % - (wait_percent, work_percent, unkn_percent), end=' ') - print('%.3g\t' % (thread.mem / (1024 * 1024)), end=' ') - print('%.3g\t' % (thread.peak_mem / (1024 * 1024))) + print((f'{thread.thread_name:>13}\t{thread.alive:6.2f}\t' + f'{wait_percent:>4.1f}\t{work_percent:>4.1f}\t{unkn_percent:>4.1f}\t' + f'{thread.mem / (1024 * 1024):>4.1f}\t' + f'{thread.peak_mem / (1024 * 1024):>4.1f}')) mem = 0 peak_mem = 0 @@ -225,9 +221,9 @@ for event in all_events: if mem > peak_mem: peak_mem = mem -print('peak memory = %.3g MB' % (peak_mem / (1024 * 1024))) +print(f'peak memory = {peak_mem / (1024 * 1024):.1f} MB') if mem != 0: - print('leak! final memory = %.3g MB' % (mem / (1024 * 1024))) + print(f'leak! final memory = {mem / (1024 * 1024):.1f} MB') # does a list of events contain an overlap? # assume the list of events has been sorted by start time @@ -256,6 +252,21 @@ def gates_overlap(events, gate_name1, gate_name2): return events_overlap(merged) +# show top 10 waits +wait = {} +for thread in threads: + for event in thread.all_events: + if event.wait: + name = f'{event.gate_location}::{event.gate_name}' + if name not in wait: + wait[name] = 0 + + wait[name] += event.stop - event.start + +print('name wait') +for [name, time] in sorted(wait.items(), reverse=True, key=lambda x: x[1])[:10]: + print(f'{name:>35}\t{time:.2f}') + # allocate a y position for each gate total_y = 0 for thread in threads: