|
|
c26c11 |
From 263682c9a29395055f3b3afe2d97be1828a6223f Mon Sep 17 00:00:00 2001
|
|
|
c26c11 |
From: Jerome Jiang <jianj@google.com>
|
|
|
c26c11 |
Date: Thu, 30 Jun 2022 13:48:56 -0400
|
|
|
c26c11 |
Subject: [PATCH] Fix bug with smaller width bigger size
|
|
|
c26c11 |
|
|
|
c26c11 |
Fixed previous patch that clusterfuzz failed on.
|
|
|
c26c11 |
|
|
|
c26c11 |
Bug: webm:1642
|
|
|
c26c11 |
Change-Id: If0e08e72abd2e042efe4dcfac21e4cc51afdfdb9
|
|
|
c26c11 |
---
|
|
|
c26c11 |
test/resize_test.cc | 11 +++--------
|
|
|
c26c11 |
vp9/common/vp9_alloccommon.c | 13 ++++++-------
|
|
|
c26c11 |
vp9/encoder/vp9_encoder.c | 27 +++++++++++++++++++++++++--
|
|
|
c26c11 |
3 files changed, 34 insertions(+), 17 deletions(-)
|
|
|
c26c11 |
|
|
|
c26c11 |
diff --git a/test/resize_test.cc b/test/resize_test.cc
|
|
|
c26c11 |
index fd1c2a92de6..20ad2229b46 100644
|
|
|
c26c11 |
--- a/test/resize_test.cc
|
|
|
c26c11 |
+++ b/test/resize_test.cc
|
|
|
c26c11 |
@@ -102,11 +102,8 @@ void ScaleForFrameNumber(unsigned int frame, unsigned int initial_w,
|
|
|
c26c11 |
if (frame < 30) {
|
|
|
c26c11 |
return;
|
|
|
c26c11 |
}
|
|
|
c26c11 |
- if (frame < 100) {
|
|
|
c26c11 |
- *w = initial_w * 7 / 10;
|
|
|
c26c11 |
- *h = initial_h * 16 / 10;
|
|
|
c26c11 |
- return;
|
|
|
c26c11 |
- }
|
|
|
c26c11 |
+ *w = initial_w * 7 / 10;
|
|
|
c26c11 |
+ *h = initial_h * 16 / 10;
|
|
|
c26c11 |
return;
|
|
|
c26c11 |
}
|
|
|
c26c11 |
if (frame < 10) {
|
|
|
c26c11 |
@@ -559,9 +556,7 @@ TEST_P(ResizeRealtimeTest, TestExternalResizeWorks) {
|
|
|
c26c11 |
}
|
|
|
c26c11 |
}
|
|
|
c26c11 |
|
|
|
c26c11 |
-// TODO(https://crbug.com/webm/1642): This causes a segfault in
|
|
|
c26c11 |
-// init_encode_frame_mb_context().
|
|
|
c26c11 |
-TEST_P(ResizeRealtimeTest, DISABLED_TestExternalResizeSmallerWidthBiggerSize) {
|
|
|
c26c11 |
+TEST_P(ResizeRealtimeTest, TestExternalResizeSmallerWidthBiggerSize) {
|
|
|
c26c11 |
ResizingVideoSource video;
|
|
|
c26c11 |
video.flag_codec_ = true;
|
|
|
c26c11 |
video.smaller_width_larger_size_ = true;
|
|
|
c26c11 |
diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c
|
|
|
c26c11 |
index e53883f621d..9e73e40ea09 100644
|
|
|
c26c11 |
--- a/vp9/common/vp9_alloccommon.c
|
|
|
c26c11 |
+++ b/vp9/common/vp9_alloccommon.c
|
|
|
c26c11 |
@@ -135,13 +135,6 @@ int vp9_alloc_context_buffers(VP9_COMMON *cm, int width, int height) {
|
|
|
c26c11 |
cm->free_mi(cm);
|
|
|
c26c11 |
if (cm->alloc_mi(cm, new_mi_size)) goto fail;
|
|
|
c26c11 |
}
|
|
|
c26c11 |
-
|
|
|
c26c11 |
- if (cm->seg_map_alloc_size < cm->mi_rows * cm->mi_cols) {
|
|
|
c26c11 |
- // Create the segmentation map structure and set to 0.
|
|
|
c26c11 |
- free_seg_map(cm);
|
|
|
c26c11 |
- if (alloc_seg_map(cm, cm->mi_rows * cm->mi_cols)) goto fail;
|
|
|
c26c11 |
- }
|
|
|
c26c11 |
-
|
|
|
c26c11 |
if (cm->above_context_alloc_cols < cm->mi_cols) {
|
|
|
c26c11 |
vpx_free(cm->above_context);
|
|
|
c26c11 |
cm->above_context = (ENTROPY_CONTEXT *)vpx_calloc(
|
|
|
c26c11 |
@@ -156,6 +149,12 @@ int vp9_alloc_context_buffers(VP9_COMMON *cm, int width, int height) {
|
|
|
c26c11 |
cm->above_context_alloc_cols = cm->mi_cols;
|
|
|
c26c11 |
}
|
|
|
c26c11 |
|
|
|
c26c11 |
+ if (cm->seg_map_alloc_size < cm->mi_rows * cm->mi_cols) {
|
|
|
c26c11 |
+ // Create the segmentation map structure and set to 0.
|
|
|
c26c11 |
+ free_seg_map(cm);
|
|
|
c26c11 |
+ if (alloc_seg_map(cm, cm->mi_rows * cm->mi_cols)) goto fail;
|
|
|
c26c11 |
+ }
|
|
|
c26c11 |
+
|
|
|
c26c11 |
if (vp9_alloc_loop_filter(cm)) goto fail;
|
|
|
c26c11 |
|
|
|
c26c11 |
return 0;
|
|
|
c26c11 |
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
|
|
|
c26c11 |
index 69a4e3c314f..e3ba294c32f 100644
|
|
|
c26c11 |
--- a/vp9/encoder/vp9_encoder.c
|
|
|
c26c11 |
+++ b/vp9/encoder/vp9_encoder.c
|
|
|
c26c11 |
@@ -2047,6 +2047,17 @@ static void alloc_copy_partition_data(VP9_COMP *cpi) {
|
|
|
c26c11 |
}
|
|
|
c26c11 |
}
|
|
|
c26c11 |
|
|
|
c26c11 |
+static void free_copy_partition_data(VP9_COMP *cpi) {
|
|
|
c26c11 |
+ vpx_free(cpi->prev_partition);
|
|
|
c26c11 |
+ cpi->prev_partition = NULL;
|
|
|
c26c11 |
+ vpx_free(cpi->prev_segment_id);
|
|
|
c26c11 |
+ cpi->prev_segment_id = NULL;
|
|
|
c26c11 |
+ vpx_free(cpi->prev_variance_low);
|
|
|
c26c11 |
+ cpi->prev_variance_low = NULL;
|
|
|
c26c11 |
+ vpx_free(cpi->copied_frame_cnt);
|
|
|
c26c11 |
+ cpi->copied_frame_cnt = NULL;
|
|
|
c26c11 |
+}
|
|
|
c26c11 |
+
|
|
|
c26c11 |
void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) {
|
|
|
c26c11 |
VP9_COMMON *const cm = &cpi->common;
|
|
|
c26c11 |
RATE_CONTROL *const rc = &cpi->rc;
|
|
|
c26c11 |
@@ -2126,6 +2137,8 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) {
|
|
|
c26c11 |
new_mi_size = cm->mi_stride * calc_mi_size(cm->mi_rows);
|
|
|
c26c11 |
if (cm->mi_alloc_size < new_mi_size) {
|
|
|
c26c11 |
vp9_free_context_buffers(cm);
|
|
|
c26c11 |
+ vp9_free_pc_tree(&cpi->td);
|
|
|
c26c11 |
+ vpx_free(cpi->mbmi_ext_base);
|
|
|
c26c11 |
alloc_compressor_data(cpi);
|
|
|
c26c11 |
realloc_segmentation_maps(cpi);
|
|
|
c26c11 |
cpi->initial_width = cpi->initial_height = 0;
|
|
|
c26c11 |
@@ -2144,8 +2157,18 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) {
|
|
|
c26c11 |
update_frame_size(cpi);
|
|
|
c26c11 |
|
|
|
c26c11 |
if (last_w != cpi->oxcf.width || last_h != cpi->oxcf.height) {
|
|
|
c26c11 |
- memset(cpi->consec_zero_mv, 0,
|
|
|
c26c11 |
- cm->mi_rows * cm->mi_cols * sizeof(*cpi->consec_zero_mv));
|
|
|
c26c11 |
+ vpx_free(cpi->consec_zero_mv);
|
|
|
c26c11 |
+ CHECK_MEM_ERROR(
|
|
|
c26c11 |
+ &cm->error, cpi->consec_zero_mv,
|
|
|
c26c11 |
+ vpx_calloc(cm->mi_rows * cm->mi_cols, sizeof(*cpi->consec_zero_mv)));
|
|
|
c26c11 |
+
|
|
|
c26c11 |
+ vpx_free(cpi->skin_map);
|
|
|
c26c11 |
+ CHECK_MEM_ERROR(
|
|
|
c26c11 |
+ &cm->error, cpi->skin_map,
|
|
|
c26c11 |
+ vpx_calloc(cm->mi_rows * cm->mi_cols, sizeof(cpi->skin_map[0])));
|
|
|
c26c11 |
+
|
|
|
c26c11 |
+ free_copy_partition_data(cpi);
|
|
|
c26c11 |
+ alloc_copy_partition_data(cpi);
|
|
|
c26c11 |
if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ)
|
|
|
c26c11 |
vp9_cyclic_refresh_reset_resize(cpi);
|
|
|
c26c11 |
rc->rc_1_frame = 0;
|