diff --git a/examples/cwebp.c b/examples/cwebp.c index 2348d272..ef84a426 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -779,7 +779,7 @@ static int DumpPicture(const WebPPicture* const picture, const char* PGM_name) { static int ProgressReport(int percent, const WebPPicture* const picture) { printf("[%s]: %3d %% \r", - (char*)picture->stats->user_data, percent); + (char*)picture->user_data, percent); fflush(stdout); return 1; // all ok } @@ -1127,7 +1127,7 @@ int main(int argc, const char *argv[]) { } if (!quiet) { picture.stats = &stats; - stats.user_data = (void*)in_file; + picture.user_data = (void*)in_file; } // Compress diff --git a/src/enc/webpenc.c b/src/enc/webpenc.c index a00ac640..8649ce2d 100644 --- a/src/enc/webpenc.c +++ b/src/enc/webpenc.c @@ -344,6 +344,8 @@ int WebPEncode(const WebPConfig* config, WebPPicture* pic) { if (pic->width > WEBP_MAX_DIMENSION || pic->height > WEBP_MAX_DIMENSION) return WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_DIMENSION); + if (pic->stats != NULL) memset(pic->stats, 0, sizeof(*pic->stats)); + if (!config->lossless) { VP8Encoder* enc = NULL; if (pic->y == NULL || pic->u == NULL || pic->v == NULL) { diff --git a/src/webp/encode.h b/src/webp/encode.h index 8c89626c..dfaf0bbf 100644 --- a/src/webp/encode.h +++ b/src/webp/encode.h @@ -172,9 +172,6 @@ typedef struct { int alpha_data_size; // size of the transparency data int layer_data_size; // size of the enhancement layer data - void* user_data; // this field is free to be set to any value and - // used during callbacks (like progress-report e.g.). - // lossless encoder statistics uint32_t lossless_features; // bit0:predictor bit1:cross-color transform // bit2:subtract-green bit3:color indexing @@ -301,6 +298,9 @@ struct WebPPicture { // If not NULL, report progress during encoding. WebPProgressHook progress_hook; + void* user_data; // this field is free to be set to any value and + // used during callbacks (like progress-report e.g.). + uint32_t pad3[3]; // padding for later use // Unused for now: original samples (for non-YUV420 modes)