more debugging code for heifload and save

and fix an assert fail with debugging enabled on recent libheif
This commit is contained in:
John Cupitt 2020-12-24 15:50:56 +00:00
parent 9aae78f928
commit 5918af917e
3 changed files with 61 additions and 45 deletions

View File

@ -731,6 +731,9 @@ vips_foreign_load_heif_header( VipsForeignLoad *load )
}
#ifdef DEBUG
printf( "page_width = %d\n", heif->page_width );
printf( "page_height = %d\n", heif->page_height );
printf( "n_top = %d\n", heif->n_top );
for( i = 0; i < heif->n_top; i++ ) {
printf( " id[%d] = %d\n", i, heif->id[i] );
@ -763,6 +766,50 @@ vips_foreign_load_heif_header( VipsForeignLoad *load )
return( 0 );
}
#ifdef DEBUG
void
vips__heif_image_print( struct heif_image *img )
{
const static enum heif_channel channel[] = {
heif_channel_Y,
heif_channel_Cb,
heif_channel_Cr,
heif_channel_R,
heif_channel_G,
heif_channel_B,
heif_channel_Alpha,
heif_channel_interleaved
};
const static char *channel_name[] = {
"heif_channel_Y",
"heif_channel_Cb",
"heif_channel_Cr",
"heif_channel_R",
"heif_channel_G",
"heif_channel_B",
"heif_channel_Alpha",
"heif_channel_interleaved"
};
int i;
printf( "vips__heif_image_print:\n" );
for( i = 0; i < VIPS_NUMBER( channel ); i++ ) {
if( !heif_image_has_channel( img, channel[i] ) )
continue;
printf( "\t%s:\n", channel_name[i] );
printf( "\t\twidth = %d\n",
heif_image_get_width( img, channel[i] ) );
printf( "\t\theight = %d\n",
heif_image_get_height( img, channel[i] ) );
printf( "\t\tbits = %d\n",
heif_image_get_bits_per_pixel( img, channel[i] ) );
}
}
#endif /*DEBUG*/
static int
vips_foreign_load_heif_generate( VipsRegion *or,
void *seq, void *a, void *b, gboolean *stop )
@ -806,51 +853,7 @@ vips_foreign_load_heif_generate( VipsRegion *or,
}
#ifdef DEBUG
{
const static enum heif_channel channel[] = {
heif_channel_Y,
heif_channel_Cb,
heif_channel_Cr,
heif_channel_R,
heif_channel_G,
heif_channel_B,
heif_channel_Alpha,
heif_channel_interleaved
};
const static char *channel_name[] = {
"heif_channel_Y",
"heif_channel_Cb",
"heif_channel_Cr",
"heif_channel_R",
"heif_channel_G",
"heif_channel_B",
"heif_channel_Alpha",
"heif_channel_interleaved"
};
int i;
printf( "vips_foreign_load_heif_generate:\n" );
for( i = 0; i < VIPS_NUMBER( channel ); i++ ) {
if( !heif_image_has_channel( heif->img, channel[i] ) )
continue;
printf( "\t%s:\n", channel_name[i] );
printf( "\t\twidth = %d\n",
heif_image_get_width( heif->img,
channel[i] ) );
printf( "\t\theight = %d\n",
heif_image_get_height( heif->img,
channel[i] ) );
printf( "\t\tbits = %d\n",
heif_image_get_bits_per_pixel( heif->img,
channel[i] ) );
printf( "\t\thas_channel = %d\n",
heif_image_has_channel( heif->img,
channel[i] ) );
}
}
vips__heif_image_print( heif->img );
#endif /*DEBUG*/
}

View File

@ -374,6 +374,12 @@ vips_foreign_save_heif_build( VipsObject *object )
/* Make a heif image the size of a page. We send sink_disc() output
* here and write a frame each time it fills.
*/
#ifdef DEBUG
printf( "vips_foreign_save_heif_build:\n" );
printf( "\twidth = %d\n", heif->page_width );
printf( "\theight = %d\n", heif->page_height );
printf( "\talpha = %d\n", vips_image_hasalpha( heif->image ) );
#endif /*DEBUG*/
error = heif_image_create( heif->page_width, heif->page_height,
heif_colorspace_RGB,
vips_image_hasalpha( heif->image ) ?
@ -393,6 +399,10 @@ vips_foreign_save_heif_build( VipsObject *object )
return( -1 );
}
#ifdef DEBUG
vips__heif_image_print( heif->img );
#endif /*DEBUG*/
heif->data = heif_image_get_plane( heif->img,
heif_channel_interleaved, &heif->stride );

View File

@ -242,6 +242,9 @@ extern const char *vips__heif_suffs[];
struct heif_error;
void vips__heif_error( struct heif_error *error );
struct heif_image;
void vips__heif_image_print( struct heif_image *img );
#ifdef __cplusplus
}
#endif /*__cplusplus*/