removed history.h as well

This commit is contained in:
John Cupitt 2007-11-02 17:04:31 +00:00
parent 0825569263
commit c8825917df
9 changed files with 70 additions and 151 deletions

View File

@ -1,5 +1,9 @@
31/10/07 started 7.13.2
- build cimg on windows fixes
- various include cleanups, updated man pages
- break im_wbuffer() out to a separate API
- use im_wbuffer() to make im_vips2jpeg() compress in the background
- also im_vips2png()
28/9/07 started 7.13.1
- vips2dj can print RGB images

View File

@ -8,7 +8,6 @@ pkginclude_HEADERS = \
debug.h \
dispatch.h \
fmask.h \
history.h \
mosaic.h \
proto.h \
rect.h \
@ -18,7 +17,6 @@ pkginclude_HEADERS = \
semaphore.h \
threadgroup.h \
thread.h \
time.h \
util.h \
meta.h \
version.h \

View File

@ -1,59 +0,0 @@
/* @(#) Useful macros for appending one line in the History field of the
* @(#) output image descriptor when a function is called
* @(#) The main program should use im_updatehist()
* @(#) The added line corresponds to the command relevant to the function
* @(#) for instance
* @(#) for the function: im_add(in1, in2, out) the following lines of code can
* @(#) be used to add a line of history in the Hist member
* @(#) of the out image descriptor
* @(#) ....
* @(#) IMAGE *in1, *in2, *out;
* @(#) ....
* @(#) if ( im_add(in1, in2, out) == -1 ) return(-1);
* @(#) if ( IM_ADD(in1, in2, out) == -1 ) return(-1);
* @(#) ....
* @(#)
* @(#) The first function will add the two images in1 and in2,
* @(#) whereas the second call will append
* @(#) at the history descriptor of out the line:
* @(#) add infile outfile # date
* @(#) where infile is in.filename and outfile is out.filename
* @(#) The history line has been prepared in such a way that the first
* @(#) argument is the UNIX command which corresponds to the function
* @(#) As a general rule, all functions in im_funcs directory which
* @(#) have a correponding command in src directory are listed here
* @(#)
* @(#) Since the macros presented in this file correspond to the function
* @(#) im_histlin() the returned value is 0 on success and -1 on error.
* @(#)
*/
/*
This file is part of VIPS.
VIPS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
*/
/* Made obsolete by the function database stuff ... just here in case anyone
* still includes it.
*/

View File

@ -54,6 +54,7 @@ int im__readhist( IMAGE *image );
int im__write_extension_block( IMAGE *im, void *buf, int size );
int im__writehist( IMAGE *image );
int im__handle_eval( IMAGE *im, int w, int h );
int im__time_destroy( IMAGE *im );
extern int im__read_test;
extern int im__mmap_limit;

View File

@ -36,12 +36,12 @@
extern "C" {
#endif /*__cplusplus*/
/* Profiling madness only, who cares about portability.
*/
#ifdef TIME_THREAD
#include <sys/time.h>
#endif /*TIME_THREAD*/
#include "rect.h"
/* Per-thread buffer cache. Held in a GPrivate.
*/
typedef struct im__buffer_cache_t {

View File

@ -1,44 +0,0 @@
/* Definitions for time struct.
*
* J.Cupitt, 8/4/93
*/
/*
This file is part of VIPS.
VIPS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
*/
#ifndef IM_TIME_H
#define IM_TIME_H
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*IM_TIME_H*/

View File

@ -10,6 +10,8 @@
* - auto convert to sRGB/mono (with optional alpha) for save
* 1/5/06
* - from vips_png.c
* 2/11/07
* - use im_wbuffer() API for BG writes
*/
/*
@ -166,6 +168,26 @@ write_new( IMAGE *in )
return( write );
}
static int
write_png_block( REGION *region, Rect *area, void *a, void *b )
{
Write *write = (Write *) a;
int i;
/* Catch PNG errors. Yuk.
*/
if( setjmp( write->pPng->jmpbuf ) )
return( -1 );
for( i = 0; i < area->height; i++ )
write->row_pointer[i] = (png_bytep)
IM_REGION_ADDR( region, 0, area->top + i );
png_write_rows( write->pPng, write->row_pointer, area->height );
return( 0 );
}
/* Write a VIPS image to PNG.
*/
static int
@ -229,22 +251,13 @@ write_vips( Write *write, int compress, int interlace )
/* Write data.
*/
for( i = 0; i < nb_passes; i++ )
for( y = 0; y < in->Ysize; y += write->tg->nlines ) {
area.left = 0;
area.top = y;
area.width = in->Xsize;
area.height = IM_MIN( write->tg->nlines,
in->Ysize - y );
if( im_wbuffer( write->tg, write_png_block, write, NULL ) )
return( -1 );
if( im_prepare_thread( write->tg, write->reg, &area ) )
return( -1 );
for( j = 0; j < area.height; j++ )
write->row_pointer[j] = (png_bytep)
IM_REGION_ADDR( write->reg, 0, y + j );
png_write_rows( write->pPng,
write->row_pointer, area.height );
}
/* The setjmp() was held by our background writer: reset it.
*/
if( setjmp( write->pPng->jmpbuf ) )
return( -1 );
png_write_end( write->pPng, write->pInfo );

View File

@ -104,7 +104,6 @@
#include <vips/vips.h>
#include <vips/internal.h>
#include <vips/debug.h>
#include <vips/thread.h>
#ifdef WITH_DMALLOC
#include <dmalloc.h>
@ -297,6 +296,7 @@ im_close( IMAGE *im )
IM_FREEF( im__gslist_gvalue_free, im->history_list );
im__meta_destroy( im );
im__open_images = g_slist_remove( im__open_images, im );
im__time_destroy( im );
IM_FREE( im );
return( result );

View File

@ -38,39 +38,45 @@
#include <errno.h>
#include <stdlib.h>
#include <stdarg.h>
#include <time.h>
#include <vips/vips.h>
#include <vips/internal.h>
#include <vips/time.h>
#ifdef WITH_DMALLOC
#include <dmalloc.h>
#endif /*WITH_DMALLOC*/
/* Allocate a new time struct and fill in start values.
*/
static int
new_time( IMAGE *im )
int
im__time_destroy( IMAGE *im )
{
struct time_info *tim = IM_NEW( im, struct time_info );
if( !tim )
return( -1 );
if( im->time ) {
im_errormsg( "new_time: sanity failure" );
return( -1 );
g_timer_destroy( im->time->start );
im_free( im->time );
im->time = NULL;
}
tim->im = im;
tim->start = time( NULL );
tim->run = 0;
tim->eta = 0;
tim->tpels = (gint64) im->Xsize * im->Ysize;
tim->npels = 0;
tim->percent = 0;
im->time = tim;
return( 0 );
}
/* Attach a new time struct and fill in start values.
*/
int
time_add( IMAGE *im )
{
im_time_t *time;
if( im__time_destroy( im ) ||
!(time = IM_NEW( NULL, im_time_t )) )
return( -1 );
time->im = im;
time->start = g_timer_new();
time->run = 0;
time->eta = 0;
time->tpels = (gint64) im->Xsize * im->Ysize;
time->npels = 0;
time->percent = 0;
im->time = time;
return( 0 );
}
@ -78,16 +84,16 @@ new_time( IMAGE *im )
/* A new tile has been computed. Update time_info.
*/
static int
update_time( struct time_info *tim, int w, int h )
update_time( im_time_t *time, int w, int h )
{
float prop;
tim->run = time( NULL ) - tim->start;
tim->npels += w * h;
prop = (float) tim->npels / (float) tim->tpels;
tim->percent = 100 * prop;
time->run = g_timer_elapsed( time->start, NULL );
time->npels += w * h;
prop = (float) time->npels / (float) time->tpels;
time->percent = 100 * prop;
if( prop > 0 )
tim->eta = (1.0 / prop) * tim->run - tim->run;
time->eta = (1.0 / prop) * time->run - time->run;
return( 0 );
}
@ -99,7 +105,7 @@ im__handle_eval( IMAGE *im, int w, int h )
{
if( im->evalfns ) {
if( !im->time )
if( new_time( im ) )
if( time_add( im ) )
return( -1 );
if( update_time( im->time, w, h ) )
return( -1 );