diff --git a/examples/cwebp.c b/examples/cwebp.c index 9f933cff..c1a5b13c 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 } @@ -1125,7 +1125,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 1ee42819..18e433d4 100644 --- a/src/webp/encode.h +++ b/src/webp/encode.h @@ -170,9 +170,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 @@ -299,6 +296,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)