2016-07-20 21:55:05 +02:00
|
|
|
// Simple tool to roughly evaluate the quality encoding of a webp bitstream
|
|
|
|
//
|
|
|
|
// Result is a *rough* estimation of the quality. You should just consider
|
|
|
|
// the bucket it's in (q > 80? > 50? > 20?) and not take it for face value.
|
|
|
|
/*
|
|
|
|
gcc -o webp_quality webp_quality.c -O3 -I../ -L. -L../imageio \
|
2017-01-19 01:10:44 +01:00
|
|
|
-limageio_util -lwebpextras -lwebp -lm -lpthread
|
2016-07-20 21:55:05 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2017-10-07 23:15:11 +02:00
|
|
|
#include "extras/extras.h"
|
|
|
|
#include "imageio/imageio_util.h"
|
libwebp: Unicode command tools on Windows
Define macros in examples/unicode.h to use Unicode argv
on Windows. Keep char everywhere on Unix since it handles
UTF-8 without any change.
Impact:
- All fopen () and SHCreateStreamOnFile(),
- All fprintf() printing file paths,
- All strcmp() used with "-",
- File path parsing,
- Gif reading.
Concerned executables from examples/ and extras/:
anim_diff, anim_dump, vwebp, vwebp_sdl,
cwebp, dwebp, gif2webp, img2webp,
webpmux, webpinfo, webp_quality, get_disto
When compiled on Windows with Unicode enabled, webpmux and
img2webp will not work when used with an argument file and
will print "Reading arguments from a file is a feature
unavailable with Unicode binaries."
BUG=webp:398
Change-Id: Ic55d222a3ce1a715f9c4cce57ecbe2705d5ce317
2018-10-16 11:03:18 +02:00
|
|
|
#include "../examples/unicode.h"
|
2016-07-20 21:55:05 +02:00
|
|
|
|
2019-07-26 09:46:40 +02:00
|
|
|
int main(int argc, const char* argv[]) {
|
2016-07-20 21:55:05 +02:00
|
|
|
int c;
|
|
|
|
int quiet = 0;
|
2016-08-20 21:07:31 +02:00
|
|
|
int ok = 1;
|
libwebp: Unicode command tools on Windows
Define macros in examples/unicode.h to use Unicode argv
on Windows. Keep char everywhere on Unix since it handles
UTF-8 without any change.
Impact:
- All fopen () and SHCreateStreamOnFile(),
- All fprintf() printing file paths,
- All strcmp() used with "-",
- File path parsing,
- Gif reading.
Concerned executables from examples/ and extras/:
anim_diff, anim_dump, vwebp, vwebp_sdl,
cwebp, dwebp, gif2webp, img2webp,
webpmux, webpinfo, webp_quality, get_disto
When compiled on Windows with Unicode enabled, webpmux and
img2webp will not work when used with an argument file and
will print "Reading arguments from a file is a feature
unavailable with Unicode binaries."
BUG=webp:398
Change-Id: Ic55d222a3ce1a715f9c4cce57ecbe2705d5ce317
2018-10-16 11:03:18 +02:00
|
|
|
|
|
|
|
INIT_WARGV(argc, argv);
|
|
|
|
|
2016-08-20 21:07:31 +02:00
|
|
|
for (c = 1; ok && c < argc; ++c) {
|
2016-07-20 21:55:05 +02:00
|
|
|
if (!strcmp(argv[c], "-quiet")) {
|
|
|
|
quiet = 1;
|
|
|
|
} else if (!strcmp(argv[c], "-help") || !strcmp(argv[c], "-h")) {
|
|
|
|
printf("webp_quality [-h][-quiet] webp_files...\n");
|
libwebp: Unicode command tools on Windows
Define macros in examples/unicode.h to use Unicode argv
on Windows. Keep char everywhere on Unix since it handles
UTF-8 without any change.
Impact:
- All fopen () and SHCreateStreamOnFile(),
- All fprintf() printing file paths,
- All strcmp() used with "-",
- File path parsing,
- Gif reading.
Concerned executables from examples/ and extras/:
anim_diff, anim_dump, vwebp, vwebp_sdl,
cwebp, dwebp, gif2webp, img2webp,
webpmux, webpinfo, webp_quality, get_disto
When compiled on Windows with Unicode enabled, webpmux and
img2webp will not work when used with an argument file and
will print "Reading arguments from a file is a feature
unavailable with Unicode binaries."
BUG=webp:398
Change-Id: Ic55d222a3ce1a715f9c4cce57ecbe2705d5ce317
2018-10-16 11:03:18 +02:00
|
|
|
FREE_WARGV_AND_RETURN(0);
|
2016-07-20 21:55:05 +02:00
|
|
|
} else {
|
libwebp: Unicode command tools on Windows
Define macros in examples/unicode.h to use Unicode argv
on Windows. Keep char everywhere on Unix since it handles
UTF-8 without any change.
Impact:
- All fopen () and SHCreateStreamOnFile(),
- All fprintf() printing file paths,
- All strcmp() used with "-",
- File path parsing,
- Gif reading.
Concerned executables from examples/ and extras/:
anim_diff, anim_dump, vwebp, vwebp_sdl,
cwebp, dwebp, gif2webp, img2webp,
webpmux, webpinfo, webp_quality, get_disto
When compiled on Windows with Unicode enabled, webpmux and
img2webp will not work when used with an argument file and
will print "Reading arguments from a file is a feature
unavailable with Unicode binaries."
BUG=webp:398
Change-Id: Ic55d222a3ce1a715f9c4cce57ecbe2705d5ce317
2018-10-16 11:03:18 +02:00
|
|
|
const char* const filename = (const char*)GET_WARGV(argv, c);
|
2016-07-20 21:55:05 +02:00
|
|
|
const uint8_t* data = NULL;
|
|
|
|
size_t data_size = 0;
|
|
|
|
int q;
|
2016-08-20 21:07:31 +02:00
|
|
|
ok = ImgIoUtilReadFile(filename, &data, &data_size);
|
|
|
|
if (!ok) break;
|
2016-07-20 21:55:05 +02:00
|
|
|
q = VP8EstimateQuality(data, data_size);
|
libwebp: Unicode command tools on Windows
Define macros in examples/unicode.h to use Unicode argv
on Windows. Keep char everywhere on Unix since it handles
UTF-8 without any change.
Impact:
- All fopen () and SHCreateStreamOnFile(),
- All fprintf() printing file paths,
- All strcmp() used with "-",
- File path parsing,
- Gif reading.
Concerned executables from examples/ and extras/:
anim_diff, anim_dump, vwebp, vwebp_sdl,
cwebp, dwebp, gif2webp, img2webp,
webpmux, webpinfo, webp_quality, get_disto
When compiled on Windows with Unicode enabled, webpmux and
img2webp will not work when used with an argument file and
will print "Reading arguments from a file is a feature
unavailable with Unicode binaries."
BUG=webp:398
Change-Id: Ic55d222a3ce1a715f9c4cce57ecbe2705d5ce317
2018-10-16 11:03:18 +02:00
|
|
|
if (!quiet) WPRINTF("[%s] ", (const W_CHAR*)filename);
|
2016-07-20 21:55:05 +02:00
|
|
|
if (q < 0) {
|
|
|
|
fprintf(stderr, "Not a WebP file, or not a lossy WebP file.\n");
|
2016-08-20 21:07:31 +02:00
|
|
|
ok = 0;
|
2016-07-20 21:55:05 +02:00
|
|
|
} else {
|
|
|
|
if (!quiet) {
|
|
|
|
printf("Estimated quality factor: %d\n", q);
|
|
|
|
} else {
|
|
|
|
printf("%d\n", q); // just print the number
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free((void*)data);
|
|
|
|
}
|
|
|
|
}
|
libwebp: Unicode command tools on Windows
Define macros in examples/unicode.h to use Unicode argv
on Windows. Keep char everywhere on Unix since it handles
UTF-8 without any change.
Impact:
- All fopen () and SHCreateStreamOnFile(),
- All fprintf() printing file paths,
- All strcmp() used with "-",
- File path parsing,
- Gif reading.
Concerned executables from examples/ and extras/:
anim_diff, anim_dump, vwebp, vwebp_sdl,
cwebp, dwebp, gif2webp, img2webp,
webpmux, webpinfo, webp_quality, get_disto
When compiled on Windows with Unicode enabled, webpmux and
img2webp will not work when used with an argument file and
will print "Reading arguments from a file is a feature
unavailable with Unicode binaries."
BUG=webp:398
Change-Id: Ic55d222a3ce1a715f9c4cce57ecbe2705d5ce317
2018-10-16 11:03:18 +02:00
|
|
|
FREE_WARGV_AND_RETURN(ok ? 0 : 1);
|
2016-07-20 21:55:05 +02:00
|
|
|
}
|