From 7a8d8762c1ab0baec3c07e3c3512c746494f84a8 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Mon, 12 Sep 2011 19:27:21 +0000 Subject: [PATCH] use a user-visible MACRO for max width/height. This has been pointed as a useful information to have in the header (for the non VP8-specs savvy ones) Change-Id: I494b1da41dfafce882a94e3677d1cd6206bc504b --- src/enc/webpenc.c | 4 +--- src/webp/encode.h | 9 ++++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/enc/webpenc.c b/src/enc/webpenc.c index 3444e596..00c7d61c 100644 --- a/src/enc/webpenc.c +++ b/src/enc/webpenc.c @@ -26,8 +26,6 @@ extern "C" { #include #endif -#define MAX_DIMENSION 16384 // maximum width/height allowed by the spec - //------------------------------------------------------------------------------ int WebPGetEncoderVersion(void) { @@ -329,7 +327,7 @@ int WebPEncode(const WebPConfig* const config, WebPPicture* const pic) { return WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_DIMENSION); if (pic->y == NULL || pic->u == NULL || pic->v == NULL) return WebPEncodingSetError(pic, VP8_ENC_ERROR_NULL_PARAMETER); - if (pic->width >= MAX_DIMENSION || pic->height >= MAX_DIMENSION) + if (pic->width > WEBP_MAX_DIMENSION || pic->height > WEBP_MAX_DIMENSION) return WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_DIMENSION); enc = InitEncoder(config, pic); diff --git a/src/webp/encode.h b/src/webp/encode.h index bb341dba..31f05397 100644 --- a/src/webp/encode.h +++ b/src/webp/encode.h @@ -167,10 +167,13 @@ typedef enum { VP8_ENC_ERROR_FILE_TOO_BIG, // file is bigger than 4G } WebPEncodingError; +// maximum width/height allowed (inclusive), in pixels +#define WEBP_MAX_DIMENSION 16383 + struct WebPPicture { // input WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr). - int width, height; // dimensions. + int width, height; // dimensions (less or equal to WEBP_MAX_DIMENSION) uint8_t *y, *u, *v; // pointers to luma/chroma planes. int y_stride, uv_stride; // luma/chroma strides. uint8_t *a; // pointer to the alpha plane @@ -260,8 +263,8 @@ WEBP_EXTERN(int) WebPPictureImportBGRA( // Main call // Main encoding call, after config and picture have been initialized. -// 'picture' must be less than 16384x16384 in dimension, and the 'config' object -// must be a valid one. +// 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION), +// and the 'config' object must be a valid one. // Returns false in case of error, true otherwise. // In case of error, picture->error_code is updated accordingly. WEBP_EXTERN(int) WebPEncode(