mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 05:38:22 +01:00
Merge changes Id9890a60,I376d81e6,I1c958838 into main
* changes: GetBackwardReferences: fail on alloc error BackwardReferencesHashChainDistanceOnly: fix segfault on OOM VP8LEncodeStream: fix segfault on OOM
This commit is contained in:
commit
2de4b05a56
@ -577,7 +577,7 @@ static int BackwardReferencesHashChainDistanceOnly(
|
||||
(CostModel*)WebPSafeCalloc(1ULL, cost_model_size);
|
||||
VP8LColorCache hashers;
|
||||
CostManager* cost_manager =
|
||||
(CostManager*)WebPSafeMalloc(1ULL, sizeof(*cost_manager));
|
||||
(CostManager*)WebPSafeCalloc(1ULL, sizeof(*cost_manager));
|
||||
int offset_prev = -1, len_prev = -1;
|
||||
double offset_cost = -1;
|
||||
int first_offset_is_constant = -1; // initialized with 'impossible' value
|
||||
|
@ -1007,15 +1007,16 @@ static int GetBackwardReferences(int width, int height,
|
||||
const VP8LHashChain* const hash_chain_tmp =
|
||||
(lz77_types_best[i] == kLZ77Standard) ? hash_chain : &hash_chain_box;
|
||||
const int cache_bits = (i == 1) ? 0 : *cache_bits_best;
|
||||
if (VP8LBackwardReferencesTraceBackwards(width, height, argb, cache_bits,
|
||||
hash_chain_tmp, &refs[i],
|
||||
refs_tmp)) {
|
||||
double bit_cost_trace;
|
||||
VP8LHistogramCreate(histo, refs_tmp, cache_bits);
|
||||
bit_cost_trace = VP8LHistogramEstimateBits(histo);
|
||||
if (bit_cost_trace < bit_costs_best[i]) {
|
||||
BackwardRefsSwap(refs_tmp, &refs[i]);
|
||||
}
|
||||
double bit_cost_trace;
|
||||
if (!VP8LBackwardReferencesTraceBackwards(width, height, argb, cache_bits,
|
||||
hash_chain_tmp, &refs[i],
|
||||
refs_tmp)) {
|
||||
goto Error;
|
||||
}
|
||||
VP8LHistogramCreate(histo, refs_tmp, cache_bits);
|
||||
bit_cost_trace = VP8LHistogramEstimateBits(histo);
|
||||
if (bit_cost_trace < bit_costs_best[i]) {
|
||||
BackwardRefsSwap(refs_tmp, &refs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1966,14 +1966,19 @@ int VP8LEncodeStream(const WebPConfig* const config,
|
||||
const WebPWorkerInterface* const worker_interface = WebPGetWorkerInterface();
|
||||
int ok_main;
|
||||
|
||||
if (enc_main == NULL || !VP8LBitWriterInit(&bw_side, 0)) {
|
||||
WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY);
|
||||
VP8LEncoderDelete(enc_main);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Avoid "garbage value" error from Clang's static analysis tool.
|
||||
WebPPictureInit(&picture_side);
|
||||
|
||||
// Analyze image (entropy, num_palettes etc)
|
||||
if (enc_main == NULL ||
|
||||
!EncoderAnalyze(enc_main, crunch_configs, &num_crunch_configs_main,
|
||||
if (!EncoderAnalyze(enc_main, crunch_configs, &num_crunch_configs_main,
|
||||
&red_and_blue_always_zero) ||
|
||||
!EncoderInit(enc_main) || !VP8LBitWriterInit(&bw_side, 0)) {
|
||||
!EncoderInit(enc_main)) {
|
||||
WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY);
|
||||
goto Error;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user