aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBohan Li <bohanli@google.com>2023-11-30 16:18:25 -0800
committerJerome Jiang <jianj@google.com>2023-12-06 16:22:24 -0500
commitffd533161ab3e95333351c977325ca615f9690c9 (patch)
tree7b9beea2a0bb91f7d275b7f9b18f2f8fedac9fed
parent5d49fa1f017091ec5105b1b783c9b1e1d31ee0b0 (diff)
downloadlibvpx-ffd533161ab3e95333351c977325ca615f9690c9.tar.gz
Fix edge case when downsizing to one.
BUG: b/310329177 Change-Id: I2ebf4165adbc7351d6cc73554827812dedc4d362 (cherry picked from commit a9f1bfdb8e93a742da9a14d4a9d3b1d847edd70d)
-rw-r--r--test/encode_api_test.cc19
-rw-r--r--vp9/encoder/vp9_resize.c6
2 files changed, 25 insertions, 0 deletions
diff --git a/test/encode_api_test.cc b/test/encode_api_test.cc
index 25c8d7624..3dfcc2ebf 100644
--- a/test/encode_api_test.cc
+++ b/test/encode_api_test.cc
@@ -763,6 +763,25 @@ TEST(EncodeAPI, Buganizer312656387) {
encoder.Encode(false);
}
+// This is a test case from clusterfuzz: based on b/310329177.
+// Encode a few frames with multiple change config call
+// with different frame size.
+TEST(EncodeAPI, Buganizer310329177) {
+ VP9Encoder encoder(6);
+
+ // Set initial config.
+ encoder.Configure(10, 41, 1, VPX_VBR, VPX_DL_REALTIME);
+
+ // Encode first frame.
+ encoder.Encode(true);
+
+ // Change config.
+ encoder.Configure(16, 1, 1, VPX_VBR, VPX_DL_REALTIME);
+
+ // Encode 2nd frame with new config, set delta frame.
+ encoder.Encode(false);
+}
+
class EncodeApiGetTplStatsTest
: public ::libvpx_test::EncoderTest,
public ::testing::TestWithParam<const libvpx_test::CodecFactory *> {
diff --git a/vp9/encoder/vp9_resize.c b/vp9/encoder/vp9_resize.c
index 7486dee25..ca55ec988 100644
--- a/vp9/encoder/vp9_resize.c
+++ b/vp9/encoder/vp9_resize.c
@@ -360,6 +360,12 @@ static int get_down2_steps(int in_length, int out_length) {
while ((proj_in_length = get_down2_length(in_length, 1)) >= out_length) {
++steps;
in_length = proj_in_length;
+ if (in_length == 1) {
+ // Special case: we break because any further calls to get_down2_length()
+ // with be with length == 1, which return 1, resulting in an infinite
+ // loop.
+ break;
+ }
}
return steps;
}