mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 13:48:21 +01:00
WebPEncode: clear stats at the start of encode
also relocate user_data from WebPAuxStats to the WebPPicture struct to make clearing easier while placing it closer to the progress hook with which it's used. prior to this change some spurious lossless data could be reported in the lossy (sans alpha) encoding case. additionally user_data could be lost during lossless encoding. Change-Id: I929fae3dfde4d445ff81bbaad51445ea586dd80b
This commit is contained in:
parent
a7cc729126
commit
475d87d767
@ -779,7 +779,7 @@ static int DumpPicture(const WebPPicture* const picture, const char* PGM_name) {
|
|||||||
|
|
||||||
static int ProgressReport(int percent, const WebPPicture* const picture) {
|
static int ProgressReport(int percent, const WebPPicture* const picture) {
|
||||||
printf("[%s]: %3d %% \r",
|
printf("[%s]: %3d %% \r",
|
||||||
(char*)picture->stats->user_data, percent);
|
(char*)picture->user_data, percent);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return 1; // all ok
|
return 1; // all ok
|
||||||
}
|
}
|
||||||
@ -1125,7 +1125,7 @@ int main(int argc, const char *argv[]) {
|
|||||||
}
|
}
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
picture.stats = &stats;
|
picture.stats = &stats;
|
||||||
stats.user_data = (void*)in_file;
|
picture.user_data = (void*)in_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compress
|
// Compress
|
||||||
|
@ -344,6 +344,8 @@ int WebPEncode(const WebPConfig* config, WebPPicture* pic) {
|
|||||||
if (pic->width > WEBP_MAX_DIMENSION || pic->height > WEBP_MAX_DIMENSION)
|
if (pic->width > WEBP_MAX_DIMENSION || pic->height > WEBP_MAX_DIMENSION)
|
||||||
return WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_DIMENSION);
|
return WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_DIMENSION);
|
||||||
|
|
||||||
|
if (pic->stats != NULL) memset(pic->stats, 0, sizeof(*pic->stats));
|
||||||
|
|
||||||
if (!config->lossless) {
|
if (!config->lossless) {
|
||||||
VP8Encoder* enc = NULL;
|
VP8Encoder* enc = NULL;
|
||||||
if (pic->y == NULL || pic->u == NULL || pic->v == NULL) {
|
if (pic->y == NULL || pic->u == NULL || pic->v == NULL) {
|
||||||
|
@ -170,9 +170,6 @@ typedef struct {
|
|||||||
int alpha_data_size; // size of the transparency data
|
int alpha_data_size; // size of the transparency data
|
||||||
int layer_data_size; // size of the enhancement layer 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
|
// lossless encoder statistics
|
||||||
uint32_t lossless_features; // bit0:predictor bit1:cross-color transform
|
uint32_t lossless_features; // bit0:predictor bit1:cross-color transform
|
||||||
// bit2:subtract-green bit3:color indexing
|
// bit2:subtract-green bit3:color indexing
|
||||||
@ -299,6 +296,9 @@ struct WebPPicture {
|
|||||||
// If not NULL, report progress during encoding.
|
// If not NULL, report progress during encoding.
|
||||||
WebPProgressHook progress_hook;
|
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
|
uint32_t pad3[3]; // padding for later use
|
||||||
|
|
||||||
// Unused for now: original samples (for non-YUV420 modes)
|
// Unused for now: original samples (for non-YUV420 modes)
|
||||||
|
Loading…
Reference in New Issue
Block a user