- simplified subsampling selection by setting subsample_mode=VIPS_FOREIGN_JPEG_SUBSAMPLE_OFF when no_subsample=1

This commit is contained in:
elad laufer 2020-02-18 10:54:46 +02:00
parent 494d8876eb
commit 408f3b08ce
2 changed files with 10 additions and 6 deletions

View File

@ -267,7 +267,6 @@ vips_foreign_save_jpeg_target_class_init(
VIPS_ARGUMENT_REQUIRED_INPUT, VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsForeignSaveJpegTarget, target ), G_STRUCT_OFFSET( VipsForeignSaveJpegTarget, target ),
VIPS_TYPE_TARGET ); VIPS_TYPE_TARGET );
} }
static void static void

View File

@ -479,8 +479,8 @@ write_jpeg_block( VipsRegion *region, VipsRect *area, void *a )
static int static int
write_vips( Write *write, int qfac, const char *profile, write_vips( Write *write, int qfac, const char *profile,
gboolean optimize_coding, gboolean progressive, gboolean strip, gboolean optimize_coding, gboolean progressive, gboolean strip,
gboolean no_subsample, gboolean trellis_quant, gboolean trellis_quant, gboolean overshoot_deringing,
gboolean overshoot_deringing, gboolean optimize_scans, int quant_table, gboolean optimize_scans, int quant_table,
VipsForeignJpegSubsample subsample_mode) VipsForeignJpegSubsample subsample_mode)
{ {
VipsImage *in; VipsImage *in;
@ -635,8 +635,7 @@ write_vips( Write *write, int qfac, const char *profile,
/* Turn off chroma subsampling. Follow IM and do it automatically for /* Turn off chroma subsampling. Follow IM and do it automatically for
* high Q. * high Q.
*/ */
if( !(no_subsample || if(qfac < 90) {
qfac >= 90) ) {
break; break;
} }
case VIPS_FOREIGN_JPEG_SUBSAMPLE_OFF: case VIPS_FOREIGN_JPEG_SUBSAMPLE_OFF:
@ -807,10 +806,16 @@ vips__jpeg_write_target( VipsImage *in, VipsTarget *target,
*/ */
target_dest( &write->cinfo, target ); target_dest( &write->cinfo, target );
/* Retain old behavior for now
*/
if (no_subsample) {
subsample_mode = VIPS_FOREIGN_JPEG_SUBSAMPLE_OFF;
}
/* Convert! Write errors come back here as an error return. /* Convert! Write errors come back here as an error return.
*/ */
if( write_vips( write, if( write_vips( write,
Q, profile, optimize_coding, progressive, strip, no_subsample, Q, profile, optimize_coding, progressive, strip,
trellis_quant, overshoot_deringing, optimize_scans, trellis_quant, overshoot_deringing, optimize_scans,
quant_table, subsample_mode ) ) { quant_table, subsample_mode ) ) {
write_destroy( write ); write_destroy( write );