small rad cleanups
This commit is contained in:
parent
20410b79ef
commit
9a06b2cea7
9
TODO
9
TODO
@ -1,11 +1,4 @@
|
|||||||
- check rad write again
|
- drag display control slider, broken
|
||||||
|
|
||||||
vips copy x.jpg x.hdr
|
|
||||||
vips copy x.hdr x2.jpg
|
|
||||||
|
|
||||||
should this be an identity op?
|
|
||||||
|
|
||||||
drag display control slider, broken
|
|
||||||
|
|
||||||
- do conv and morph quickly as simple wrappers over the vips7 operations
|
- do conv and morph quickly as simple wrappers over the vips7 operations
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* 4/11/13
|
* 4/11/13
|
||||||
* - support sequential read
|
* - support sequential read
|
||||||
* 5/11/13
|
* 5/11/13
|
||||||
* - rewritten read and write, now much faster
|
* - rewritten scanline encode and decode, now much faster
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -803,62 +803,52 @@ scanline_write( COLR *scanline, int width, FILE *fp )
|
|||||||
PUTC( width >> 8 );
|
PUTC( width >> 8 );
|
||||||
PUTC( width & 255 );
|
PUTC( width & 255 );
|
||||||
|
|
||||||
cnt = 1;
|
|
||||||
for( i = 0; i < 4; i++ ) {
|
for( i = 0; i < 4; i++ ) {
|
||||||
for( j = 0; j < width; j += cnt ) {
|
for( j = 0; j < width; ) {
|
||||||
/* Search for next run.
|
/* Set beg / cnt to the start and length of the next
|
||||||
|
* run longer than MINRUN.
|
||||||
*/
|
*/
|
||||||
for( beg = j; beg < width; beg += cnt ) {
|
for( beg = j; beg < width; beg += cnt ) {
|
||||||
for( cnt = 1; cnt < 127 &&
|
for( cnt = 1;
|
||||||
|
cnt < 127 &&
|
||||||
beg + cnt < width &&
|
beg + cnt < width &&
|
||||||
scanline[beg + cnt][i] ==
|
scanline[beg + cnt][i] ==
|
||||||
scanline[beg][i]; cnt++ )
|
scanline[beg][i];
|
||||||
|
cnt++ )
|
||||||
;
|
;
|
||||||
|
|
||||||
if( cnt >= MINRUN )
|
if( cnt >= MINRUN )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( beg - j > 1 &&
|
/* Code pixels leading up to the run as a set of
|
||||||
beg - j < MINRUN ) {
|
* non-runs.
|
||||||
c2 = j + 1;
|
*/
|
||||||
while( scanline[c2++][i] == scanline[j][i] )
|
while( j < beg ) {
|
||||||
if( c2 == beg ) {
|
int len = VIPS_MIN( 128, beg - j );
|
||||||
/* Short run.
|
COLR *p = scanline + j;
|
||||||
*/
|
|
||||||
PUTC( 128 + beg - j );
|
int k;
|
||||||
PUTC( scanline[j][i] );
|
|
||||||
j = beg;
|
PUTC( len );
|
||||||
break;
|
for( k = 0; k < len; k++ )
|
||||||
}
|
PUTC( p[k][i] );
|
||||||
}
|
j += len;
|
||||||
|
|
||||||
while( j < beg ) {
|
|
||||||
/* Non-run.
|
|
||||||
*/
|
|
||||||
c2 = VIPS_MIN( beg - j, 128 );
|
|
||||||
PUTC( c2 );
|
|
||||||
while( c2-- )
|
|
||||||
PUTC( scanline[j++][i] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Code the run we found, if any
|
||||||
|
*/
|
||||||
if( cnt >= MINRUN ) {
|
if( cnt >= MINRUN ) {
|
||||||
/* Run.
|
|
||||||
*/
|
|
||||||
PUTC( 128 + cnt );
|
PUTC( 128 + cnt );
|
||||||
PUTC( scanline[beg][i] );
|
PUTC( scanline[j][i] );
|
||||||
|
j += cnt;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
cnt = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return( fwrite( buffer, 1, buffer_pos, fp ) - buffer_pos );
|
return( fwrite( buffer, 1, buffer_pos, fp ) - buffer_pos );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* What we track during radiance file read.
|
/* What we track during radiance file read.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -899,6 +889,7 @@ read_destroy( VipsObject *object, Read *read )
|
|||||||
{
|
{
|
||||||
VIPS_FREE( read->filename );
|
VIPS_FREE( read->filename );
|
||||||
VIPS_FREEF( fclose, read->fin );
|
VIPS_FREEF( fclose, read->fin );
|
||||||
|
buffer_init( NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Read *
|
static Read *
|
||||||
@ -1047,7 +1038,6 @@ rad2vips_generate( VipsRegion *or,
|
|||||||
void *seq, void *a, void *b, gboolean *stop )
|
void *seq, void *a, void *b, gboolean *stop )
|
||||||
{
|
{
|
||||||
VipsRect *r = &or->valid;
|
VipsRect *r = &or->valid;
|
||||||
Read *read = (Read *) a;
|
|
||||||
|
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
@ -1216,8 +1206,8 @@ vips2rad_put_data_block( VipsRegion *region, Rect *area, void *a )
|
|||||||
for( i = 0; i < area->height; i++ ) {
|
for( i = 0; i < area->height; i++ ) {
|
||||||
VipsPel *p = VIPS_REGION_ADDR( region, 0, area->top + i );
|
VipsPel *p = VIPS_REGION_ADDR( region, 0, area->top + i );
|
||||||
|
|
||||||
//if( fwritecolrs( p, area->width, write->fout ) )
|
|
||||||
if( scanline_write( (COLR *) p, area->width, write->fout ) )
|
if( scanline_write( (COLR *) p, area->width, write->fout ) )
|
||||||
|
//if( scanline_write_old( (COLR *) p, area->width, write->fout ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user