|
|
302caf |
|
|
|
302caf |
# HG changeset patch
|
|
|
302caf |
# User Timothy Nikkel <tnikkel@gmail.com>
|
|
|
302caf |
# Date 1678835815 0
|
|
|
302caf |
# Node ID 53b805c752ff23080e100eda2b3b4280d4370b2e
|
|
|
302caf |
# Parent 8fcdaf8d685d5903b127e041feb1716637b6008f
|
|
|
302caf |
Bug 1819244. Cherry pic webp commit fix. r=aosmond, a=dsmith
|
|
|
302caf |
|
|
|
302caf |
https://github.com/webmproject/libwebp/commit/a486d800b60d0af4cc0836bf7ed8f21e12974129
|
|
|
302caf |
|
|
|
302caf |
Differential Revision: https://phabricator.services.mozilla.com/D171814
|
|
|
302caf |
|
|
|
302caf |
diff --git a/media/libwebp/src/enc/alpha_enc.c b/media/libwebp/src/enc/alpha_enc.c
|
|
|
302caf |
--- a/src/enc/alpha_enc.c
|
|
|
302caf |
+++ b/src/enc/alpha_enc.c
|
|
|
302caf |
@@ -8,16 +8,17 @@
|
|
|
302caf |
// -----------------------------------------------------------------------------
|
|
|
302caf |
//
|
|
|
302caf |
// Alpha-plane compression.
|
|
|
302caf |
//
|
|
|
302caf |
// Author: Skal (pascal.massimino@gmail.com)
|
|
|
302caf |
|
|
|
302caf |
#include <assert.h>
|
|
|
302caf |
#include <stdlib.h>
|
|
|
302caf |
+#include <string.h>
|
|
|
302caf |
|
|
|
302caf |
#include "src/enc/vp8i_enc.h"
|
|
|
302caf |
#include "src/dsp/dsp.h"
|
|
|
302caf |
#include "src/utils/filters_utils.h"
|
|
|
302caf |
#include "src/utils/quant_levels_utils.h"
|
|
|
302caf |
#include "src/utils/utils.h"
|
|
|
302caf |
#include "src/webp/format_constants.h"
|
|
|
302caf |
|
|
|
302caf |
@@ -143,31 +144,32 @@ static int EncodeAlphaInternal(const uin
|
|
|
302caf |
output_size = VP8LBitWriterNumBytes(&tmp_bw);
|
|
|
302caf |
if (output_size > data_size) {
|
|
|
302caf |
// compressed size is larger than source! Revert to uncompressed mode.
|
|
|
302caf |
method = ALPHA_NO_COMPRESSION;
|
|
|
302caf |
VP8LBitWriterWipeOut(&tmp_bw);
|
|
|
302caf |
}
|
|
|
302caf |
} else {
|
|
|
302caf |
VP8LBitWriterWipeOut(&tmp_bw);
|
|
|
302caf |
+ memset(&result->bw, 0, sizeof(result->bw));
|
|
|
302caf |
return 0;
|
|
|
302caf |
}
|
|
|
302caf |
}
|
|
|
302caf |
|
|
|
302caf |
if (method == ALPHA_NO_COMPRESSION) {
|
|
|
302caf |
output = alpha_src;
|
|
|
302caf |
output_size = data_size;
|
|
|
302caf |
ok = 1;
|
|
|
302caf |
}
|
|
|
302caf |
|
|
|
302caf |
// Emit final result.
|
|
|
302caf |
header = method | (filter << 2);
|
|
|
302caf |
if (reduce_levels) header |= ALPHA_PREPROCESSED_LEVELS << 4;
|
|
|
302caf |
|
|
|
302caf |
- VP8BitWriterInit(&result->bw, ALPHA_HEADER_LEN + output_size);
|
|
|
302caf |
+ if (!VP8BitWriterInit(&result->bw, ALPHA_HEADER_LEN + output_size)) ok = 0;
|
|
|
302caf |
ok = ok && VP8BitWriterAppend(&result->bw, &header, ALPHA_HEADER_LEN);
|
|
|
302caf |
ok = ok && VP8BitWriterAppend(&result->bw, output, output_size);
|
|
|
302caf |
|
|
|
302caf |
if (method != ALPHA_NO_COMPRESSION) {
|
|
|
302caf |
VP8LBitWriterWipeOut(&tmp_bw);
|
|
|
302caf |
}
|
|
|
302caf |
ok = ok && !result->bw.error_;
|
|
|
302caf |
result->score = VP8BitWriterSize(&result->bw);
|
|
|
302caf |
|