| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#include <stdio.h> |
| 11 |
#include <stdlib.h> |
| 12 |
#include <string.h> |
| 13 |
|
| 14 |
#include "extras/extras.h" |
| 15 |
#include "imageio/imageio_util.h" |
| 16 |
#include "../examples/unicode.h" |
| 17 |
|
| 18 |
int main(int argc, const char* argv[]) { |
| 19 |
int c; |
| 20 |
int quiet = 0; |
| 21 |
int ok = 1; |
| 22 |
|
| 23 |
INIT_WARGV(argc, argv); |
| 24 |
|
| 25 |
for (c = 1; ok && c < argc; ++c) { |
| 26 |
if (!strcmp(argv[c], "-quiet")) { |
| 27 |
quiet = 1; |
| 28 |
} else if (!strcmp(argv[c], "-help") || !strcmp(argv[c], "-h")) { |
| 29 |
printf("webp_quality [-h][-quiet] webp_files...\n"); |
| 30 |
FREE_WARGV_AND_RETURN(0); |
| 31 |
} else { |
| 32 |
const char* const filename = (const char*)GET_WARGV(argv, c); |
| 33 |
const uint8_t* data = NULL; |
| 34 |
size_t data_size = 0; |
| 35 |
int q; |
| 36 |
ok = ImgIoUtilReadFile(filename, &data, &data_size); |
| 37 |
if (!ok) break; |
| 38 |
q = VP8EstimateQuality(data, data_size); |
| 39 |
if (!quiet) WPRINTF("[%s] ", (const W_CHAR*)filename); |
| 40 |
if (q < 0) { |
| 41 |
fprintf(stderr, "Not a WebP file, or not a lossy WebP file.\n"); |
| 42 |
ok = 0; |
| 43 |
} else { |
| 44 |
if (!quiet) { |
| 45 |
printf("Estimated quality factor: %d\n", q); |
| 46 |
} else { |
| 47 |
printf("%d\n", q); |
| 48 |
} |
| 49 |
} |
| 50 |
free((void*)data); |
| 51 |
} |
| 52 |
} |
| 53 |
FREE_WARGV_AND_RETURN(ok ? 0 : 1); |
| 54 |
} |