mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-25 13:18:22 +01:00
make -short work with -print_ssim, -print_psnr, etc.
PSNR was always printed when using -short Change-Id: I826785917961d355a980e4ac27dd1cf1295cb6de
This commit is contained in:
parent
c72e08119a
commit
fff2a11b03
@ -298,6 +298,9 @@ static void PrintExtraInfoLossy(const WebPPicture* const pic, int short_output,
|
||||
PrintFullLosslessInfo(stats, "alpha");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintMapInfo(const WebPPicture* const pic) {
|
||||
if (pic->extra_info != NULL) {
|
||||
const int mb_w = (pic->width + 15) / 16;
|
||||
const int mb_h = (pic->height + 15) / 16;
|
||||
@ -716,7 +719,7 @@ int main(int argc, const char *argv[]) {
|
||||
config.show_compressed = 1;
|
||||
print_distortion = 2;
|
||||
} else if (!strcmp(argv[c], "-short")) {
|
||||
short_output++;
|
||||
++short_output;
|
||||
} else if (!strcmp(argv[c], "-s") && c < argc - 2) {
|
||||
picture.width = strtol(argv[++c], NULL, 0);
|
||||
picture.height = strtol(argv[++c], NULL, 0);
|
||||
@ -1057,38 +1060,47 @@ int main(int argc, const char *argv[]) {
|
||||
}
|
||||
|
||||
if (!quiet) {
|
||||
if (config.lossless) {
|
||||
PrintExtraInfoLossless(&picture, short_output, in_file);
|
||||
} else {
|
||||
PrintExtraInfoLossy(&picture, short_output, config.low_memory, in_file);
|
||||
if (!short_output || print_distortion < 0) {
|
||||
if (config.lossless) {
|
||||
PrintExtraInfoLossless(&picture, short_output, in_file);
|
||||
} else {
|
||||
PrintExtraInfoLossy(&picture, short_output, config.low_memory, in_file);
|
||||
}
|
||||
}
|
||||
if (!short_output && picture.extra_info_type > 0) {
|
||||
PrintMapInfo(&picture);
|
||||
}
|
||||
if (print_distortion >= 0) { // print distortion
|
||||
static const char* distortion_names[] = { "PSNR", "SSIM", "LSIM" };
|
||||
float values[5];
|
||||
// Comparison is performed in YUVA colorspace.
|
||||
if (original_picture.use_argb &&
|
||||
!WebPPictureARGBToYUVA(&original_picture, WEBP_YUV420A)) {
|
||||
fprintf(stderr, "Error while converting original picture to YUVA.\n");
|
||||
goto Error;
|
||||
}
|
||||
if (picture.use_argb &&
|
||||
!WebPPictureARGBToYUVA(&picture, WEBP_YUV420A)) {
|
||||
fprintf(stderr, "Error while converting compressed picture to YUVA.\n");
|
||||
goto Error;
|
||||
}
|
||||
if (!WebPPictureDistortion(&picture, &original_picture,
|
||||
print_distortion, values)) {
|
||||
fprintf(stderr, "Error while computing the distortion.\n");
|
||||
goto Error;
|
||||
}
|
||||
if (!short_output) {
|
||||
fprintf(stderr, "%s: Y:%.2f U:%.2f V:%.2f A:%.2f Total:%.2f\n",
|
||||
distortion_names[print_distortion],
|
||||
values[0], values[1], values[2], values[3], values[4]);
|
||||
} else {
|
||||
fprintf(stderr, "%7d %.4f\n", picture.stats->coded_size, values[4]);
|
||||
}
|
||||
}
|
||||
if (!short_output) {
|
||||
PrintMetadataInfo(&metadata, metadata_written);
|
||||
}
|
||||
}
|
||||
if (!quiet && !short_output && print_distortion >= 0) { // print distortion
|
||||
static const char* distortion_names[] = { "PSNR", "SSIM", "LSIM" };
|
||||
float values[5];
|
||||
// Comparison is performed in YUVA colorspace.
|
||||
if (original_picture.use_argb &&
|
||||
!WebPPictureARGBToYUVA(&original_picture, WEBP_YUV420A)) {
|
||||
fprintf(stderr, "Error while converting original picture to YUVA.\n");
|
||||
goto Error;
|
||||
}
|
||||
if (picture.use_argb &&
|
||||
!WebPPictureARGBToYUVA(&picture, WEBP_YUV420A)) {
|
||||
fprintf(stderr, "Error while converting compressed picture to YUVA.\n");
|
||||
goto Error;
|
||||
}
|
||||
if (!WebPPictureDistortion(&picture, &original_picture,
|
||||
print_distortion, values)) {
|
||||
fprintf(stderr, "Error while computing the distortion.\n");
|
||||
goto Error;
|
||||
}
|
||||
fprintf(stderr, "%s: Y:%.2f U:%.2f V:%.2f A:%.2f Total:%.2f\n",
|
||||
distortion_names[print_distortion],
|
||||
values[0], values[1], values[2], values[3], values[4]);
|
||||
}
|
||||
return_value = 0;
|
||||
|
||||
Error:
|
||||
|
Loading…
Reference in New Issue
Block a user