diff --git a/examples/cwebp.c b/examples/cwebp.c index 11234681..0e8235d6 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -594,6 +594,7 @@ static void HelpLong() { printf("\n"); printf(" -short ................. condense printed message\n"); printf(" -quiet ................. don't print anything.\n"); + printf(" -version ............... print version number and exit.\n"); printf(" -v ..................... verbose, e.g. print encoding/decoding " "times\n"); printf("\n"); @@ -678,6 +679,11 @@ int main(int argc, const char *argv[]) { crop_y = atoi(argv[++c]); crop_w = atoi(argv[++c]); crop_h = atoi(argv[++c]); + } else if (!strcmp(argv[c], "-version")) { + const int version = WebPGetEncoderVersion(); + printf("%d.%d.%d\n", + (version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff); + return 0; } else if (!strcmp(argv[c], "-quiet")) { quiet = 1; } else if (!strcmp(argv[c], "-preset") && c < argc - 1) { diff --git a/examples/dwebp.c b/examples/dwebp.c index be7c3520..65e6427c 100644 --- a/examples/dwebp.c +++ b/examples/dwebp.c @@ -205,12 +205,13 @@ typedef enum { static void help(const char *s) { printf("Usage: dwebp " - "[in_file] [-h] [-v] [-ppm] [-pgm] [-o out_file]\n\n" + "[in_file] [-h] [-v] [-ppm] [-pgm] [-version] [-o out_file]\n\n" "Decodes the WebP image file to PNG format [Default]\n" "Use following options to convert into alternate image formats:\n" " -ppm: save the raw RGB samples as color PPM\n" " -pgm: save the raw YUV samples as a grayscale PGM\n" " file with IMC4 layout.\n" + " -version: print version number and exit.\n" "Use -v for verbose (e.g. print encoding/decoding times)\n" ); } @@ -232,6 +233,11 @@ int main(int argc, const char *argv[]) { out_file = argv[++c]; } else if (!strcmp(argv[c], "-ppm")) { format = PPM; + } else if (!strcmp(argv[c], "-version")) { + const int version = WebPGetDecoderVersion(); + printf("%d.%d.%d\n", + (version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff); + return 0; } else if (!strcmp(argv[c], "-pgm")) { format = PGM; } else if (!strcmp(argv[c], "-v")) { diff --git a/src/dec/vp8.c b/src/dec/vp8.c index 07541f31..aa47b531 100644 --- a/src/dec/vp8.c +++ b/src/dec/vp8.c @@ -16,6 +16,12 @@ extern "C" { #endif +//----------------------------------------------------------------------------- + +int WebPGetDecoderVersion() { + return (DEC_MAJ_VERSION << 16) | (DEC_MIN_VERSION << 8) | DEC_REV_VERSION; +} + //----------------------------------------------------------------------------- // VP8Decoder diff --git a/src/dec/vp8i.h b/src/dec/vp8i.h index 9cfee043..6ed053da 100644 --- a/src/dec/vp8i.h +++ b/src/dec/vp8i.h @@ -22,6 +22,11 @@ extern "C" { //----------------------------------------------------------------------------- // Various defines and enums +// version numbers +#define DEC_MAJ_VERSION 0 +#define DEC_MIN_VERSION 1 +#define DEC_REV_VERSION 2 + #define ONLY_KEYFRAME_CODE // to remove any code related to P-Frames // intra prediction modes diff --git a/src/enc/vp8enci.h b/src/enc/vp8enci.h index cc64b31c..ae7cb78c 100644 --- a/src/enc/vp8enci.h +++ b/src/enc/vp8enci.h @@ -23,6 +23,11 @@ extern "C" { //----------------------------------------------------------------------------- // Various defines and enums +// version numbers +#define ENC_MAJ_VERSION 0 +#define ENC_MIN_VERSION 1 +#define ENC_REV_VERSION 2 + // intra prediction modes enum { B_DC_PRED = 0, // 4x4 modes B_TM_PRED = 1, diff --git a/src/enc/webpenc.c b/src/enc/webpenc.c index 5ca445ef..c1c5f071 100644 --- a/src/enc/webpenc.c +++ b/src/enc/webpenc.c @@ -27,6 +27,12 @@ extern "C" { #define MAX_DIMENSION 16384 // maximum width/height allowed by the spec +//----------------------------------------------------------------------------- + +int WebPGetEncoderVersion() { + return (ENC_MAJ_VERSION << 16) | (ENC_MIN_VERSION << 8) | ENC_REV_VERSION; +} + //----------------------------------------------------------------------------- // WebPPicture //----------------------------------------------------------------------------- diff --git a/src/webp/decode.h b/src/webp/decode.h index fefab0a4..790b5500 100644 --- a/src/webp/decode.h +++ b/src/webp/decode.h @@ -18,6 +18,10 @@ extern "C" { #endif +// Return the decoder's version number, packed in hexadecimal using 8bits for +// each of major/minor/revision. E.g: v2.5.7 is 0x020507. +int WebPGetDecoderVersion(); + // Retrieve basic header information: width, height. // This function will also validate the header and return 0 in // case of formatting error. diff --git a/src/webp/encode.h b/src/webp/encode.h index 797b4c61..50d93657 100644 --- a/src/webp/encode.h +++ b/src/webp/encode.h @@ -22,6 +22,10 @@ extern "C" { #define WEBP_ENCODER_ABI_VERSION 0x0001 +// Return the encoder's version number, packed in hexadecimal using 8bits for +// each of major/minor/revision. E.g: v2.5.7 is 0x020507. +int WebPGetEncoderVersion(); + //----------------------------------------------------------------------------- // One-stop-shop call! No questions asked: