mirror of
https://github.com/webmproject/libwebp.git
synced 2026-04-09 14:22:31 +02:00
Merge changes I45ce1744,I350d9144 into main
* changes: anim_encode,KeyFramePenalty: add missing cast ALPHInit: move assignment closer to first use
This commit is contained in:
@@ -58,7 +58,6 @@ WEBP_NODISCARD static int ALPHInit(ALPHDecoder* const dec, const uint8_t* data,
|
|||||||
uint8_t* output) {
|
uint8_t* output) {
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
const uint8_t* const alpha_data = data + ALPHA_HEADER_LEN;
|
const uint8_t* const alpha_data = data + ALPHA_HEADER_LEN;
|
||||||
const size_t alpha_data_size = data_size - ALPHA_HEADER_LEN;
|
|
||||||
int rsrv;
|
int rsrv;
|
||||||
VP8Io* const io = &dec->io;
|
VP8Io* const io = &dec->io;
|
||||||
|
|
||||||
@@ -101,16 +100,19 @@ WEBP_NODISCARD static int ALPHInit(ALPHDecoder* const dec, const uint8_t* data,
|
|||||||
io->crop_bottom = src_io->crop_bottom;
|
io->crop_bottom = src_io->crop_bottom;
|
||||||
// No need to copy the scaling parameters.
|
// No need to copy the scaling parameters.
|
||||||
|
|
||||||
if (dec->method == ALPHA_NO_COMPRESSION) {
|
{
|
||||||
const size_t alpha_decoded_size = dec->width * dec->height;
|
const size_t alpha_data_size = data_size - ALPHA_HEADER_LEN;
|
||||||
ok = (alpha_data_size >= alpha_decoded_size);
|
if (dec->method == ALPHA_NO_COMPRESSION) {
|
||||||
} else {
|
const size_t alpha_decoded_size = dec->width * dec->height;
|
||||||
assert(dec->method == ALPHA_LOSSLESS_COMPRESSION);
|
ok = (alpha_data_size >= alpha_decoded_size);
|
||||||
{
|
} else {
|
||||||
const uint8_t* WEBP_BIDI_INDEXABLE const bounded_alpha_data =
|
assert(dec->method == ALPHA_LOSSLESS_COMPRESSION);
|
||||||
WEBP_UNSAFE_FORGE_BIDI_INDEXABLE(const uint8_t*, alpha_data,
|
{
|
||||||
alpha_data_size);
|
const uint8_t* WEBP_BIDI_INDEXABLE const bounded_alpha_data =
|
||||||
ok = VP8LDecodeAlphaHeader(dec, bounded_alpha_data, alpha_data_size);
|
WEBP_UNSAFE_FORGE_BIDI_INDEXABLE(const uint8_t*, alpha_data,
|
||||||
|
alpha_data_size);
|
||||||
|
ok = VP8LDecodeAlphaHeader(dec, bounded_alpha_data, alpha_data_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1339,7 +1339,7 @@ End:
|
|||||||
// instead of a subframe.
|
// instead of a subframe.
|
||||||
static int64_t KeyFramePenalty(const EncodedFrame* const encoded_frame) {
|
static int64_t KeyFramePenalty(const EncodedFrame* const encoded_frame) {
|
||||||
return ((int64_t)encoded_frame->key_frame.bitstream.size -
|
return ((int64_t)encoded_frame->key_frame.bitstream.size -
|
||||||
encoded_frame->sub_frame.bitstream.size);
|
(int64_t)encoded_frame->sub_frame.bitstream.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CacheFrame(WebPAnimEncoder* const enc,
|
static int CacheFrame(WebPAnimEncoder* const enc,
|
||||||
|
|||||||
@@ -18,9 +18,11 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#include "./fuzz_utils.h"
|
#include "./fuzz_utils.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
#include "src/dec/webpi_dec.h"
|
#include "src/dec/webpi_dec.h"
|
||||||
#include "src/utils/rescaler_utils.h"
|
#include "src/utils/rescaler_utils.h"
|
||||||
#include "webp/decode.h"
|
#include "webp/decode.h"
|
||||||
@@ -162,3 +164,25 @@ FUZZ_TEST(AdvancedApi, AdvancedApiTest)
|
|||||||
#endif
|
#endif
|
||||||
/*incremental=*/fuzztest::Arbitrary<bool>(),
|
/*incremental=*/fuzztest::Arbitrary<bool>(),
|
||||||
fuzz_utils::ArbitraryValidWebPDecoderOptions());
|
fuzz_utils::ArbitraryValidWebPDecoderOptions());
|
||||||
|
|
||||||
|
TEST(AdvancedApi, Buganizer498966235) {
|
||||||
|
AdvancedApiTest(
|
||||||
|
std::string(
|
||||||
|
"RIFF\014|"
|
||||||
|
"\000\000WEBPVP8X\n\000\000\000\020\000\000D\002\000\000\017\000\000A"
|
||||||
|
"LPH5\000\000\000\004\327\000\000\000\000\000\000c8\345S\000\243\000"
|
||||||
|
"\253c\311\000\027\000\000\000\200\000\000\000\000\240\"AE\001\000"
|
||||||
|
"\000\0008<"
|
||||||
|
"ALP\010\000s\002\000\000\000\000\000\000\000\000\000ALPH\000\000\000"
|
||||||
|
"\000VP8 "
|
||||||
|
"(\000\000\000\224\001\000\235\001*\003\000\020\000\003,\000~"
|
||||||
|
"\342\000\000se\002ionR\265Vq\302M}\"webp\"r\010\003\000\020#"
|
||||||
|
"\366\356\002\323\220\000 "
|
||||||
|
"\212N@\000\026\327A\367\266\201\201\"IFF@\"RIFF\"&\226!"
|
||||||
|
"VP\n8Rg\000\0001\"\335\"I\"XEBP\"\002\002\"\367\\x0\203\203\203\341"
|
||||||
|
"\341l,\203\\sectiqncJUN=\"sectistre\\x9D\\x01\\x2A\"JUKQ\"",
|
||||||
|
257),
|
||||||
|
68, 3, true,
|
||||||
|
fuzz_utils::WebPDecoderOptionsCpp{
|
||||||
|
0, 0, 1, 5, 10, 5, 9, 0, 1, 3, 0, 72, 0, 83, {0, 0, 0, 0, 0}});
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,9 +16,11 @@
|
|||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#include "./fuzz_utils.h"
|
#include "./fuzz_utils.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
#include "webp/decode.h"
|
#include "webp/decode.h"
|
||||||
#include "webp/demux.h"
|
#include "webp/demux.h"
|
||||||
#include "webp/mux_types.h"
|
#include "webp/mux_types.h"
|
||||||
@@ -88,3 +90,15 @@ FUZZ_TEST(AnimationApi, AnimationApiTest)
|
|||||||
// Animations only support 4 (out of 12) modes.
|
// Animations only support 4 (out of 12) modes.
|
||||||
fuzztest::ElementOf<WEBP_CSP_MODE>({MODE_RGBA, MODE_BGRA,
|
fuzztest::ElementOf<WEBP_CSP_MODE>({MODE_RGBA, MODE_BGRA,
|
||||||
MODE_rgbA, MODE_bgrA}));
|
MODE_rgbA, MODE_bgrA}));
|
||||||
|
|
||||||
|
TEST(AnimationApi, Buganizer498965803) {
|
||||||
|
AnimationApiTest(
|
||||||
|
std::string("ALPH\000\000\000\000\000\000\000\000\021\000\000\000\t\305"
|
||||||
|
"\006d\301\013\177\000\000webp\034\205\000#@VP8 "
|
||||||
|
"!\000\000\000v\003\000\235\001*\007\200\"\000\0020("
|
||||||
|
"\000\377\377\377\003\000\000\000\311\311\311\311\311\311\311"
|
||||||
|
"\311\311\311\311\311\311\311\311\311\311\311\311\311\311\211"
|
||||||
|
"\311\311\311\311\311\030\030\030\030\030\030\311\311",
|
||||||
|
98),
|
||||||
|
false, static_cast<WEBP_CSP_MODE>(1));
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,10 +16,12 @@
|
|||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#include "./fuzz_utils.h"
|
#include "./fuzz_utils.h"
|
||||||
#include "./nalloc.h"
|
#include "./nalloc.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
#include "imageio/imageio_util.h"
|
#include "imageio/imageio_util.h"
|
||||||
#include "webp/decode.h"
|
#include "webp/decode.h"
|
||||||
#include "webp/demux.h"
|
#include "webp/demux.h"
|
||||||
@@ -79,3 +81,12 @@ End:
|
|||||||
FUZZ_TEST(AnimDecoder, AnimDecoderTest)
|
FUZZ_TEST(AnimDecoder, AnimDecoderTest)
|
||||||
.WithDomains(fuzztest::String().WithMaxSize(fuzz_utils::kMaxWebPFileSize +
|
.WithDomains(fuzztest::String().WithMaxSize(fuzz_utils::kMaxWebPFileSize +
|
||||||
1));
|
1));
|
||||||
|
|
||||||
|
TEST(AnimDecoder, Buganizer498967090) {
|
||||||
|
AnimDecoderTest(std::string(
|
||||||
|
"ALPH\000\000\000\000\000\000\000\000\003\000\000\000\014EBPVP8 "
|
||||||
|
"\030\000\000\0000\001\000\235\001*\002\000\001\000\003\0004%"
|
||||||
|
"\244\000\003~\000*\316\373\224\"AFM\"<0\334\"\231J\002`"
|
||||||
|
"\256\233\233\233\233\272\000\000",
|
||||||
|
72));
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "./fuzz_utils.h"
|
#include "./fuzz_utils.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
#include "src/dsp/cpu.h"
|
#include "src/dsp/cpu.h"
|
||||||
#include "webp/encode.h"
|
#include "webp/encode.h"
|
||||||
#include "webp/mux.h"
|
#include "webp/mux.h"
|
||||||
@@ -208,3 +209,38 @@ FUZZ_TEST(AnimArbitraryEncoder, AnimEncoderTest)
|
|||||||
.WithMaxSize(15),
|
.WithMaxSize(15),
|
||||||
/*optimization_index=*/
|
/*optimization_index=*/
|
||||||
fuzztest::InRange<uint32_t>(0, fuzz_utils::kMaxOptimizationIndex));
|
fuzztest::InRange<uint32_t>(0, fuzz_utils::kMaxOptimizationIndex));
|
||||||
|
|
||||||
|
TEST(AnimIndexEncoder, Buganizer498967191) {
|
||||||
|
auto GetWebPPicture = [](int index,
|
||||||
|
bool use_argb) -> fuzz_utils::WebPPictureCpp {
|
||||||
|
WebPPicture pic = fuzz_utils::GetSourcePicture(index, use_argb);
|
||||||
|
return fuzz_utils::WebPPictureCpp(
|
||||||
|
use_argb, pic.colorspace, pic.width, pic.height, pic.y, pic.u, pic.v,
|
||||||
|
pic.y_stride, pic.uv_stride, pic.a, pic.a_stride, pic.argb,
|
||||||
|
pic.argb_stride, pic.memory_, pic.memory_argb_);
|
||||||
|
};
|
||||||
|
AnimEncoderTest(
|
||||||
|
false, {0, 1}, true,
|
||||||
|
{FrameConfig{1, 0, WebPConfig{0, 0.f, 6, static_cast<WebPImageHint>(3),
|
||||||
|
0, 0.f, 4, 0,
|
||||||
|
38, 7, 1, 0,
|
||||||
|
0, 0, 1, 10,
|
||||||
|
1, 1, 1, 10,
|
||||||
|
0, 0, 0, 20,
|
||||||
|
1, 0, 0, 0,
|
||||||
|
100},
|
||||||
|
fuzz_utils::CropOrScaleParams{true, true, 6, 1, 2, 1},
|
||||||
|
GetWebPPicture(0, true)},
|
||||||
|
FrameConfig{0, 7248,
|
||||||
|
WebPConfig{1, 0.f, 1, static_cast<WebPImageHint>(3),
|
||||||
|
0, 0.f, 1, 0,
|
||||||
|
100, 0, 1, 0,
|
||||||
|
1, 0, 0, 10,
|
||||||
|
1, 1, 0, 10,
|
||||||
|
0, 1, 0, 0,
|
||||||
|
1, 0, 0, 0,
|
||||||
|
100},
|
||||||
|
fuzz_utils::CropOrScaleParams{true, true, 6, 8, 2, 1},
|
||||||
|
GetWebPPicture(0, true)}},
|
||||||
|
1);
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,9 +17,11 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#include "./fuzz_utils.h"
|
#include "./fuzz_utils.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
#include "webp/decode.h"
|
#include "webp/decode.h"
|
||||||
#include "webp/types.h"
|
#include "webp/types.h"
|
||||||
|
|
||||||
@@ -101,3 +103,15 @@ void SimpleApiTest(std::string_view data_in) {
|
|||||||
FUZZ_TEST(SimpleApi, SimpleApiTest)
|
FUZZ_TEST(SimpleApi, SimpleApiTest)
|
||||||
.WithDomains(fuzztest::String().WithMaxSize(fuzz_utils::kMaxWebPFileSize +
|
.WithDomains(fuzztest::String().WithMaxSize(fuzz_utils::kMaxWebPFileSize +
|
||||||
1));
|
1));
|
||||||
|
|
||||||
|
TEST(SimpleApi, Buganizer498966511) {
|
||||||
|
SimpleApiTest(
|
||||||
|
std::string("ALPH\004\000\000\000A\377\377\377\377LP\010\000\000\000\000"
|
||||||
|
"\000\000\311H\006\000\000\000\"E\356PW\"ALPH\000\000\000\000"
|
||||||
|
"ALpH\004\000\000\000\004\010\000\200VP8 "
|
||||||
|
"T\000\000\000\266\003\000\235\001*"
|
||||||
|
"\001\000\002\000y\336n\366\001O\363\374\243\000\003LPS\"\002"
|
||||||
|
"iF\000FjRsa\232vP\"EO\"K\217OM;rOect\275n\"Wsection_JUNQ="
|
||||||
|
"\"JUNQ\"\250YO,_I\362\021\"ANIM\"",
|
||||||
|
150));
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user