webp_quality should return '0' in case of success.

-> clarify the return value in case of error

Change-Id: I6f1e675c80d237b302fada28e7612a684b931c7a
This commit is contained in:
Pascal Massimino 2016-08-20 21:07:31 +02:00
parent 7f1b897bee
commit 57a5e3b6a5

View File

@ -18,23 +18,25 @@
int main(int argc, const char *argv[]) {
int c;
int quiet = 0;
for (c = 1; c < argc; ++c) {
int ok = 1;
for (c = 1; ok && c < argc; ++c) {
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");
return 1;
return 0;
} else {
const char* const filename = argv[c];
const uint8_t* data = NULL;
size_t data_size = 0;
int q;
const int ok = ImgIoUtilReadFile(filename, &data, &data_size);
if (!ok) continue;
ok = ImgIoUtilReadFile(filename, &data, &data_size);
if (!ok) break;
q = VP8EstimateQuality(data, data_size);
if (!quiet) printf("[%s] ", filename);
if (q < 0) {
fprintf(stderr, "Not a WebP file, or not a lossy WebP file.\n");
ok = 0;
} else {
if (!quiet) {
printf("Estimated quality factor: %d\n", q);
@ -45,5 +47,5 @@ int main(int argc, const char *argv[]) {
free((void*)data);
}
}
return 1;
return ok ? 0 : 1;
}