heifsave defaults to AV1 for .avif suffix

This commit is contained in:
John Cupitt 2021-03-26 09:50:17 +00:00
parent 4e60a3072f
commit 8c4486327e
1 changed files with 12 additions and 1 deletions

View File

@ -321,6 +321,7 @@ vips_foreign_save_heif_build( VipsObject *object )
VipsForeignSave *save = (VipsForeignSave *) object;
VipsForeignSaveHeif *heif = (VipsForeignSaveHeif *) object;
const char *filename;
struct heif_error error;
struct heif_writer writer;
char *chroma;
@ -335,6 +336,15 @@ vips_foreign_save_heif_build( VipsObject *object )
if( vips_copy( save->ready, &heif->image, NULL ) )
return( -1 );
/* Compression defaults to VIPS_FOREIGN_HEIF_COMPRESSION_AV1 for .avif
* suffix.
*/
filename = vips_connection_filename( VIPS_CONNECTION( heif->target ) );
if( !vips_object_argument_isset( object, "compression" ) &&
filename &&
vips_iscasepostfix( filename, ".avif" ) )
heif->compression = VIPS_FOREIGN_HEIF_COMPRESSION_AV1;
error = heif_context_get_encoder_for_format( heif->ctx,
(enum heif_compression_format) heif->compression,
&heif->encoder );
@ -722,7 +732,8 @@ vips_foreign_save_heif_target_init( VipsForeignSaveHeifTarget *target )
*
* Set @lossless %TRUE to switch to lossless compression.
*
* Use @compression to set the encoder e.g. HEVC, AVC, AV1
* Use @compression to set the encoder e.g. HEVC, AVC, AV1. It defaults to AV1
* if the target filename ends with ".avif", otherwise HEVC.
*
* Use @speed to control the CPU effort spent improving compression.
* This is currently only applicable to AV1 encoders, defaults to 5.