shrink2 now done
big mem saving, still a bit slower though
This commit is contained in:
parent
da8f236f95
commit
582a7f1810
14
TODO
14
TODO
@ -14,17 +14,15 @@
|
|||||||
we would then only need to demand the source a line at a time, and the
|
we would then only need to demand the source a line at a time, and the
|
||||||
intermediate image would be much smaller ... possible cache savings as well
|
intermediate image would be much smaller ... possible cache savings as well
|
||||||
|
|
||||||
added shrink2 for the new code
|
currently a bit slower than old shrink, much less mem though
|
||||||
|
|
||||||
current state on work machine, debug build
|
try:
|
||||||
|
|
||||||
$ time vips shrink wtc.jpg x.v 10 10
|
* special path for RGB and mono
|
||||||
memory: high-water mark 238.09 MB
|
|
||||||
real 0m1.178s
|
|
||||||
user 0m1.384s
|
|
||||||
sys 0m0.064s
|
|
||||||
|
|
||||||
done h/v, get shrink2 done and bench against plain shrink
|
* for shrinkh, prepare input in batches?
|
||||||
|
|
||||||
|
* change loop indexing? don't use *p++ etc., it'll break vectorization
|
||||||
|
|
||||||
|
|
||||||
- add bandjoinconst ... append a band (or bands?) from a constant
|
- add bandjoinconst ... append a band (or bands?) from a constant
|
||||||
|
@ -25,6 +25,7 @@ TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)
|
|||||||
|
|
||||||
SETUP_FILES = \
|
SETUP_FILES = \
|
||||||
$(content_files) \
|
$(content_files) \
|
||||||
|
$(expand_content_files) \
|
||||||
$(DOC_MAIN_SGML_FILE) \
|
$(DOC_MAIN_SGML_FILE) \
|
||||||
$(DOC_MODULE)-sections.txt \
|
$(DOC_MODULE)-sections.txt \
|
||||||
$(DOC_MODULE)-overrides.txt
|
$(DOC_MODULE)-overrides.txt
|
||||||
@ -86,7 +87,7 @@ GTK_DOC_V_SETUP_0=@echo " DOC Preparing build";
|
|||||||
|
|
||||||
setup-build.stamp:
|
setup-build.stamp:
|
||||||
-$(GTK_DOC_V_SETUP)if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
|
-$(GTK_DOC_V_SETUP)if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
|
||||||
files=`echo $(SETUP_FILES) $(expand_content_files) $(DOC_MODULE).types`; \
|
files=`echo $(SETUP_FILES) $(DOC_MODULE).types`; \
|
||||||
if test "x$$files" != "x" ; then \
|
if test "x$$files" != "x" ; then \
|
||||||
for file in $$files ; do \
|
for file in $$files ; do \
|
||||||
destdir=`dirname $(abs_builddir)/$$file`; \
|
destdir=`dirname $(abs_builddir)/$$file`; \
|
||||||
@ -118,7 +119,7 @@ scan-build.stamp: setup-build.stamp $(HFILE_GLOB) $(CFILE_GLOB)
|
|||||||
$(GTK_DOC_V_INTROSPECT)if grep -l '^..*$$' $(DOC_MODULE).types > /dev/null 2>&1 ; then \
|
$(GTK_DOC_V_INTROSPECT)if grep -l '^..*$$' $(DOC_MODULE).types > /dev/null 2>&1 ; then \
|
||||||
scanobj_options=""; \
|
scanobj_options=""; \
|
||||||
gtkdoc-scangobj 2>&1 --help | grep >/dev/null "\-\-verbose"; \
|
gtkdoc-scangobj 2>&1 --help | grep >/dev/null "\-\-verbose"; \
|
||||||
if test "$(?)" = "0"; then \
|
if test "$$?" = "0"; then \
|
||||||
if test "x$(V)" = "x1"; then \
|
if test "x$(V)" = "x1"; then \
|
||||||
scanobj_options="--verbose"; \
|
scanobj_options="--verbose"; \
|
||||||
fi; \
|
fi; \
|
||||||
@ -162,17 +163,17 @@ GTK_DOC_V_XREF=$(GTK_DOC_V_XREF_$(V))
|
|||||||
GTK_DOC_V_XREF_=$(GTK_DOC_V_XREF_$(AM_DEFAULT_VERBOSITY))
|
GTK_DOC_V_XREF_=$(GTK_DOC_V_XREF_$(AM_DEFAULT_VERBOSITY))
|
||||||
GTK_DOC_V_XREF_0=@echo " DOC Fixing cross-references";
|
GTK_DOC_V_XREF_0=@echo " DOC Fixing cross-references";
|
||||||
|
|
||||||
html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
|
html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files)
|
||||||
$(GTK_DOC_V_HTML)rm -rf html && mkdir html && \
|
$(GTK_DOC_V_HTML)rm -rf html && mkdir html && \
|
||||||
mkhtml_options=""; \
|
mkhtml_options=""; \
|
||||||
gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-verbose"; \
|
gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-verbose"; \
|
||||||
if test "$(?)" = "0"; then \
|
if test "$$?" = "0"; then \
|
||||||
if test "x$(V)" = "x1"; then \
|
if test "x$(V)" = "x1"; then \
|
||||||
mkhtml_options="$$mkhtml_options --verbose"; \
|
mkhtml_options="$$mkhtml_options --verbose"; \
|
||||||
fi; \
|
fi; \
|
||||||
fi; \
|
fi; \
|
||||||
gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-path"; \
|
gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-path"; \
|
||||||
if test "$(?)" = "0"; then \
|
if test "$$?" = "0"; then \
|
||||||
mkhtml_options="$$mkhtml_options --path=\"$(abs_srcdir)\""; \
|
mkhtml_options="$$mkhtml_options --path=\"$(abs_srcdir)\""; \
|
||||||
fi; \
|
fi; \
|
||||||
cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
|
cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
|
||||||
@ -194,11 +195,11 @@ GTK_DOC_V_PDF=$(GTK_DOC_V_PDF_$(V))
|
|||||||
GTK_DOC_V_PDF_=$(GTK_DOC_V_PDF_$(AM_DEFAULT_VERBOSITY))
|
GTK_DOC_V_PDF_=$(GTK_DOC_V_PDF_$(AM_DEFAULT_VERBOSITY))
|
||||||
GTK_DOC_V_PDF_0=@echo " DOC Building PDF";
|
GTK_DOC_V_PDF_0=@echo " DOC Building PDF";
|
||||||
|
|
||||||
pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
|
pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files)
|
||||||
$(GTK_DOC_V_PDF)rm -f $(DOC_MODULE).pdf && \
|
$(GTK_DOC_V_PDF)rm -f $(DOC_MODULE).pdf && \
|
||||||
mkpdf_options=""; \
|
mkpdf_options=""; \
|
||||||
gtkdoc-mkpdf 2>&1 --help | grep >/dev/null "\-\-verbose"; \
|
gtkdoc-mkpdf 2>&1 --help | grep >/dev/null "\-\-verbose"; \
|
||||||
if test "$(?)" = "0"; then \
|
if test "$$?" = "0"; then \
|
||||||
if test "x$(V)" = "x1"; then \
|
if test "x$(V)" = "x1"; then \
|
||||||
mkpdf_options="$$mkpdf_options --verbose"; \
|
mkpdf_options="$$mkpdf_options --verbose"; \
|
||||||
fi; \
|
fi; \
|
||||||
@ -223,12 +224,15 @@ clean-local:
|
|||||||
@if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-types" ; then \
|
@if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-types" ; then \
|
||||||
rm -f $(DOC_MODULE).types; \
|
rm -f $(DOC_MODULE).types; \
|
||||||
fi
|
fi
|
||||||
|
@if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-sections" ; then \
|
||||||
|
rm -f $(DOC_MODULE)-sections.txt; \
|
||||||
|
fi
|
||||||
|
|
||||||
distclean-local:
|
distclean-local:
|
||||||
@rm -rf xml html $(REPORT_FILES) $(DOC_MODULE).pdf \
|
@rm -rf xml html $(REPORT_FILES) $(DOC_MODULE).pdf \
|
||||||
$(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
|
$(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
|
||||||
@if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
|
@if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
|
||||||
rm -f $(SETUP_FILES) $(expand_content_files) $(DOC_MODULE).types; \
|
rm -f $(SETUP_FILES) $(DOC_MODULE).types; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
maintainer-clean-local:
|
maintainer-clean-local:
|
||||||
|
@ -43,6 +43,8 @@ int vips_shrink( VipsImage *in, VipsImage **out,
|
|||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
int vips_shrinkh( VipsImage *in, VipsImage **out, int xshrink, ... );
|
int vips_shrinkh( VipsImage *in, VipsImage **out, int xshrink, ... );
|
||||||
int vips_shrinkv( VipsImage *in, VipsImage **out, int yshrink, ... );
|
int vips_shrinkv( VipsImage *in, VipsImage **out, int yshrink, ... );
|
||||||
|
int vips_shrink2( VipsImage *in, VipsImage **out,
|
||||||
|
int xshrink, int yshrink, ... );
|
||||||
int vips_similarity( VipsImage *in, VipsImage **out, ... )
|
int vips_similarity( VipsImage *in, VipsImage **out, ... )
|
||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
int vips_resize( VipsImage *in, VipsImage **out, double scale, ... )
|
int vips_resize( VipsImage *in, VipsImage **out, double scale, ... )
|
||||||
|
@ -8,6 +8,7 @@ libresample_la_SOURCES = \
|
|||||||
shrink.c \
|
shrink.c \
|
||||||
shrinkh.c \
|
shrinkh.c \
|
||||||
shrinkv.c \
|
shrinkv.c \
|
||||||
|
shrink2.c \
|
||||||
interpolate.c \
|
interpolate.c \
|
||||||
transform.c \
|
transform.c \
|
||||||
bicubic.cpp \
|
bicubic.cpp \
|
||||||
|
@ -114,6 +114,7 @@ vips_resample_operation_init( void )
|
|||||||
extern GType vips_shrink_get_type( void );
|
extern GType vips_shrink_get_type( void );
|
||||||
extern GType vips_shrinkh_get_type( void );
|
extern GType vips_shrinkh_get_type( void );
|
||||||
extern GType vips_shrinkv_get_type( void );
|
extern GType vips_shrinkv_get_type( void );
|
||||||
|
extern GType vips_shrink2_get_type( void );
|
||||||
extern GType vips_quadratic_get_type( void );
|
extern GType vips_quadratic_get_type( void );
|
||||||
extern GType vips_affine_get_type( void );
|
extern GType vips_affine_get_type( void );
|
||||||
extern GType vips_similarity_get_type( void );
|
extern GType vips_similarity_get_type( void );
|
||||||
@ -122,6 +123,7 @@ vips_resample_operation_init( void )
|
|||||||
vips_shrink_get_type();
|
vips_shrink_get_type();
|
||||||
vips_shrinkh_get_type();
|
vips_shrinkh_get_type();
|
||||||
vips_shrinkv_get_type();
|
vips_shrinkv_get_type();
|
||||||
|
vips_shrink2_get_type();
|
||||||
vips_quadratic_get_type();
|
vips_quadratic_get_type();
|
||||||
vips_affine_get_type();
|
vips_affine_get_type();
|
||||||
vips_similarity_get_type();
|
vips_similarity_get_type();
|
||||||
|
@ -69,19 +69,15 @@ vips_shrink2_build( VipsObject *object )
|
|||||||
VipsResample *resample = VIPS_RESAMPLE( object );
|
VipsResample *resample = VIPS_RESAMPLE( object );
|
||||||
VipsShrink2 *shrink = (VipsShrink2 *) object;
|
VipsShrink2 *shrink = (VipsShrink2 *) object;
|
||||||
VipsImage **t = (VipsImage **)
|
VipsImage **t = (VipsImage **)
|
||||||
vips_object_local_array( object, 1 );
|
vips_object_local_array( object, 2 );
|
||||||
|
|
||||||
VipsImage *in;
|
|
||||||
|
|
||||||
if( VIPS_OBJECT_CLASS( vips_shrink2_parent_class )->build( object ) )
|
if( VIPS_OBJECT_CLASS( vips_shrink2_parent_class )->build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
in = resample->in;
|
if( vips_shrinkh( resample->in, &t[0], shrink->xshrink, NULL ) ||
|
||||||
|
vips_shrinkv( t[0], &t[1], shrink->yshrink, NULL ) ||
|
||||||
if( vips_shrinkh( in, &t[0], shrink->xshrink, NULL ) ||
|
vips_image_write( t[1], resample->out ) )
|
||||||
vips_shrinkv( t[0], &t[1], shrink->yshrink, NULL ) )
|
|
||||||
return( -1 );
|
return( -1 );
|
||||||
in = t[1];
|
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
@ -102,7 +98,7 @@ vips_shrink2_class_init( VipsShrink2Class *class )
|
|||||||
vobject_class->description = _( "shrink an image" );
|
vobject_class->description = _( "shrink an image" );
|
||||||
vobject_class->build = vips_shrink2_build;
|
vobject_class->build = vips_shrink2_build;
|
||||||
|
|
||||||
operation_class->flags = VIPS_OPERATION_SEQUENTIAL;
|
operation_class->flags = VIPS_OPERATION_SEQUENTIAL_UNBUFFERED;
|
||||||
|
|
||||||
VIPS_ARG_INT( class, "xshrink", 8,
|
VIPS_ARG_INT( class, "xshrink", 8,
|
||||||
_( "Xshrink" ),
|
_( "Xshrink" ),
|
||||||
|
@ -106,9 +106,9 @@ vips_shrinkh_start( VipsImage *out, void *a, void *b )
|
|||||||
/* Integer shrink.
|
/* Integer shrink.
|
||||||
*/
|
*/
|
||||||
#define ISHRINK( TYPE ) { \
|
#define ISHRINK( TYPE ) { \
|
||||||
int *sum = (int *) seq->sum; \
|
int * restrict sum = (int *) seq->sum; \
|
||||||
TYPE *p = (TYPE *) in; \
|
TYPE * restrict p = (TYPE *) in; \
|
||||||
TYPE *q = (TYPE *) out; \
|
TYPE * restrict q = (TYPE *) out; \
|
||||||
\
|
\
|
||||||
for( x = 0; x < width; x++ ) { \
|
for( x = 0; x < width; x++ ) { \
|
||||||
for( b = 0; b < bands; b++ ) \
|
for( b = 0; b < bands; b++ ) \
|
||||||
@ -127,9 +127,9 @@ vips_shrinkh_start( VipsImage *out, void *a, void *b )
|
|||||||
/* Float shrink.
|
/* Float shrink.
|
||||||
*/
|
*/
|
||||||
#define FSHRINK( TYPE ) { \
|
#define FSHRINK( TYPE ) { \
|
||||||
double *sum = (double *) seq->sum; \
|
double * restrict sum = (double *) seq->sum; \
|
||||||
TYPE *p = (TYPE *) in; \
|
TYPE * restrict p = (TYPE *) in; \
|
||||||
TYPE *q = (TYPE *) out; \
|
TYPE * restrict q = (TYPE *) out; \
|
||||||
\
|
\
|
||||||
for( x = 0; x < width; x++ ) { \
|
for( x = 0; x < width; x++ ) { \
|
||||||
for( b = 0; b < bands; b++ ) \
|
for( b = 0; b < bands; b++ ) \
|
||||||
@ -324,7 +324,7 @@ vips_shrinkh_class_init( VipsShrinkhClass *class )
|
|||||||
vobject_class->description = _( "shrink an image horizontally" );
|
vobject_class->description = _( "shrink an image horizontally" );
|
||||||
vobject_class->build = vips_shrinkh_build;
|
vobject_class->build = vips_shrinkh_build;
|
||||||
|
|
||||||
operation_class->flags = VIPS_OPERATION_SEQUENTIAL;
|
operation_class->flags = VIPS_OPERATION_SEQUENTIAL_UNBUFFERED;
|
||||||
|
|
||||||
VIPS_ARG_INT( class, "xshrink", 8,
|
VIPS_ARG_INT( class, "xshrink", 8,
|
||||||
_( "Xshrink" ),
|
_( "Xshrink" ),
|
||||||
|
@ -144,8 +144,8 @@ vips_shrinkv_start( VipsImage *out, void *a, void *b )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define ADD( ACC_TYPE, TYPE ) { \
|
#define ADD( ACC_TYPE, TYPE ) { \
|
||||||
ACC_TYPE *sum = (ACC_TYPE *) seq->sum; \
|
ACC_TYPE * restrict sum = (ACC_TYPE *) seq->sum; \
|
||||||
TYPE *p = (TYPE *) in; \
|
TYPE * restrict p = (TYPE *) in; \
|
||||||
\
|
\
|
||||||
for( x = 0; x < sz; x++ ) \
|
for( x = 0; x < sz; x++ ) \
|
||||||
sum[x] += p[x]; \
|
sum[x] += p[x]; \
|
||||||
@ -196,8 +196,8 @@ vips_shrinkv_add_line( VipsShrinkv *shrink, VipsShrinkvSequence *seq,
|
|||||||
/* Integer average.
|
/* Integer average.
|
||||||
*/
|
*/
|
||||||
#define IAVG( TYPE ) { \
|
#define IAVG( TYPE ) { \
|
||||||
int *sum = (int *) seq->sum; \
|
int * restrict sum = (int *) seq->sum; \
|
||||||
TYPE *q = (TYPE *) out; \
|
TYPE * restrict q = (TYPE *) out; \
|
||||||
\
|
\
|
||||||
for( x = 0; x < sz; x++ ) \
|
for( x = 0; x < sz; x++ ) \
|
||||||
q[x] = (sum[x] + shrink->yshrink / 2) / shrink->yshrink; \
|
q[x] = (sum[x] + shrink->yshrink / 2) / shrink->yshrink; \
|
||||||
@ -206,8 +206,8 @@ vips_shrinkv_add_line( VipsShrinkv *shrink, VipsShrinkvSequence *seq,
|
|||||||
/* Float average.
|
/* Float average.
|
||||||
*/
|
*/
|
||||||
#define FAVG( TYPE ) { \
|
#define FAVG( TYPE ) { \
|
||||||
double *sum = (double *) seq->sum; \
|
double * restrict sum = (double *) seq->sum; \
|
||||||
TYPE *q = (TYPE *) out; \
|
TYPE * restrict q = (TYPE *) out; \
|
||||||
\
|
\
|
||||||
for( x = 0; x < sz; x++ ) \
|
for( x = 0; x < sz; x++ ) \
|
||||||
q[x] = sum[x] / shrink->yshrink; \
|
q[x] = sum[x] / shrink->yshrink; \
|
||||||
@ -407,7 +407,7 @@ vips_shrinkv_class_init( VipsShrinkvClass *class )
|
|||||||
vobject_class->description = _( "shrink an image vertically" );
|
vobject_class->description = _( "shrink an image vertically" );
|
||||||
vobject_class->build = vips_shrinkv_build;
|
vobject_class->build = vips_shrinkv_build;
|
||||||
|
|
||||||
operation_class->flags = VIPS_OPERATION_SEQUENTIAL;
|
operation_class->flags = VIPS_OPERATION_SEQUENTIAL_UNBUFFERED;
|
||||||
|
|
||||||
VIPS_ARG_INT( class, "yshrink", 9,
|
VIPS_ARG_INT( class, "yshrink", 9,
|
||||||
_( "Yshrink" ),
|
_( "Yshrink" ),
|
||||||
|
Loading…
Reference in New Issue
Block a user