aboutsummaryrefslogtreecommitdiff
path: root/aom_scale
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2022-04-08 15:55:52 -0700
committerJames Zern <jzern@google.com>2022-04-08 15:55:52 -0700
commitce095f16bcc905ac8ffc0a99958e89cee0af62f9 (patch)
tree38e6a1ec6e07096bebe9de07af7f49009de423ed /aom_scale
parent6bd8bce6263e73e9f8a746ca32317c6c9bb30307 (diff)
downloadlibaom-ce095f16bcc905ac8ffc0a99958e89cee0af62f9.tar.gz
Revert "Allocate TPL buffers only when required"
This reverts commit 6b150b79125ca411ed2533a735e69f373485da49. This causes some failures with monochrome test vectors. Bug: b/228634712 Change-Id: I9681cffd8b04fedcd369c5976427ae8e1b7dccde
Diffstat (limited to 'aom_scale')
-rw-r--r--aom_scale/generic/yv12config.c71
-rw-r--r--aom_scale/generic/yv12extend.c2
-rw-r--r--aom_scale/yv12config.h4
3 files changed, 33 insertions, 44 deletions
diff --git a/aom_scale/generic/yv12config.c b/aom_scale/generic/yv12config.c
index b4257814f..dedfc0277 100644
--- a/aom_scale/generic/yv12config.c
+++ b/aom_scale/generic/yv12config.c
@@ -122,14 +122,11 @@ static int realloc_frame_buffer_aligned(
ybf->y_height = aligned_height;
ybf->y_stride = y_stride;
- ybf->monochrome = (uv_width == 0 || uv_height == 0) ? 1 : 0;
- if (!ybf->monochrome) {
- ybf->uv_crop_width = (width + ss_x) >> ss_x;
- ybf->uv_crop_height = (height + ss_y) >> ss_y;
- ybf->uv_width = uv_width;
- ybf->uv_height = uv_height;
- ybf->uv_stride = uv_stride;
- }
+ ybf->uv_crop_width = (width + ss_x) >> ss_x;
+ ybf->uv_crop_height = (height + ss_y) >> ss_y;
+ ybf->uv_width = uv_width;
+ ybf->uv_height = uv_height;
+ ybf->uv_stride = uv_stride;
ybf->border = border;
ybf->frame_size = (size_t)frame_size;
@@ -147,16 +144,13 @@ static int realloc_frame_buffer_aligned(
ybf->y_buffer = (uint8_t *)aom_align_addr(
buf + (border * y_stride) + border, aom_byte_align);
- ybf->u_buffer = ybf->v_buffer = NULL;
- if (!ybf->monochrome) {
- ybf->u_buffer = (uint8_t *)aom_align_addr(
- buf + yplane_size + (uv_border_h * uv_stride) + uv_border_w,
- aom_byte_align);
- ybf->v_buffer =
- (uint8_t *)aom_align_addr(buf + yplane_size + uvplane_size +
- (uv_border_h * uv_stride) + uv_border_w,
- aom_byte_align);
- }
+ ybf->u_buffer = (uint8_t *)aom_align_addr(
+ buf + yplane_size + (uv_border_h * uv_stride) + uv_border_w,
+ aom_byte_align);
+ ybf->v_buffer =
+ (uint8_t *)aom_align_addr(buf + yplane_size + uvplane_size +
+ (uv_border_h * uv_stride) + uv_border_w,
+ aom_byte_align);
ybf->use_external_reference_buffers = 0;
@@ -178,11 +172,13 @@ static int realloc_frame_buffer_aligned(
return AOM_CODEC_MEM_ERROR;
}
-static int calc_stride_and_planesize(
- const int ss_x, const int ss_y, const int aligned_width,
- const int aligned_height, const int border, const int byte_alignment,
- int is_monochrome, int *y_stride, int *uv_stride, uint64_t *yplane_size,
- uint64_t *uvplane_size, const int uv_height) {
+static int calc_stride_and_planesize(const int ss_x, const int ss_y,
+ const int aligned_width,
+ const int aligned_height, const int border,
+ const int byte_alignment, int *y_stride,
+ int *uv_stride, uint64_t *yplane_size,
+ uint64_t *uvplane_size,
+ const int uv_height) {
/* Only support allocating buffers that have a border that's a multiple
* of 32. The border restriction is required to get 16-byte alignment of
* the start of the chroma rows without introducing an arbitrary gap
@@ -193,15 +189,9 @@ static int calc_stride_and_planesize(
*yplane_size =
(aligned_height + 2 * border) * (uint64_t)(*y_stride) + byte_alignment;
- *uv_stride = 0;
- *uvplane_size = 0;
- if (is_monochrome == 0) {
- *uv_stride = *y_stride >> ss_x;
- *uvplane_size =
- (uv_height + 2 * (border >> ss_y)) * (uint64_t)(*uv_stride) +
- byte_alignment;
- }
-
+ *uv_stride = *y_stride >> ss_x;
+ *uvplane_size = (uv_height + 2 * (border >> ss_y)) * (uint64_t)(*uv_stride) +
+ byte_alignment;
return 0;
}
@@ -210,7 +200,7 @@ int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
int border, int byte_alignment,
aom_codec_frame_buffer_t *fb,
aom_get_frame_buffer_cb_fn_t cb, void *cb_priv,
- int alloc_y_buffer_8bit, int is_monochrome) {
+ int alloc_y_buffer_8bit) {
#if CONFIG_SIZE_LIMIT
if (width > DECODE_WIDTH_LIMIT || height > DECODE_HEIGHT_LIMIT)
return AOM_CODEC_MEM_ERROR;
@@ -223,15 +213,14 @@ int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
uint64_t uvplane_size = 0;
const int aligned_width = (width + 7) & ~7;
const int aligned_height = (height + 7) & ~7;
- const int uv_width = is_monochrome == 0 ? aligned_width >> ss_x : 0;
- const int uv_height = is_monochrome == 0 ? aligned_height >> ss_y : 0;
- const int uv_border_w = is_monochrome == 0 ? border >> ss_x : 0;
- const int uv_border_h = is_monochrome == 0 ? border >> ss_y : 0;
+ const int uv_width = aligned_width >> ss_x;
+ const int uv_height = aligned_height >> ss_y;
+ const int uv_border_w = border >> ss_x;
+ const int uv_border_h = border >> ss_y;
int error = calc_stride_and_planesize(
ss_x, ss_y, aligned_width, aligned_height, border, byte_alignment,
- is_monochrome, &y_stride, &uv_stride, &yplane_size, &uvplane_size,
- uv_height);
+ &y_stride, &uv_stride, &yplane_size, &uvplane_size, uv_height);
if (error) return error;
return realloc_frame_buffer_aligned(
ybf, width, height, ss_x, ss_y, use_highbitdepth, border,
@@ -244,12 +233,12 @@ int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
int ss_x, int ss_y, int use_highbitdepth, int border,
- int byte_alignment, int is_monochrome) {
+ int byte_alignment) {
if (ybf) {
aom_free_frame_buffer(ybf);
return aom_realloc_frame_buffer(ybf, width, height, ss_x, ss_y,
use_highbitdepth, border, byte_alignment,
- NULL, NULL, NULL, 0, is_monochrome);
+ NULL, NULL, NULL, 0);
}
return AOM_CODEC_MEM_ERROR;
}
diff --git a/aom_scale/generic/yv12extend.c b/aom_scale/generic/yv12extend.c
index 5d797c8a5..a32aee564 100644
--- a/aom_scale/generic/yv12extend.c
+++ b/aom_scale/generic/yv12extend.c
@@ -460,7 +460,7 @@ int aom_yv12_realloc_with_new_border_c(YV12_BUFFER_CONFIG *ybf, int new_border,
const int error = aom_alloc_frame_buffer(
&new_buf, ybf->y_crop_width, ybf->y_crop_height, ybf->subsampling_x,
ybf->subsampling_y, ybf->flags & YV12_FLAG_HIGHBITDEPTH, new_border,
- byte_alignment, 0);
+ byte_alignment);
if (error) return error;
// Copy image buffer
aom_yv12_copy_frame(ybf, &new_buf, num_planes);
diff --git a/aom_scale/yv12config.h b/aom_scale/yv12config.h
index d8db98a41..31af69cc8 100644
--- a/aom_scale/yv12config.h
+++ b/aom_scale/yv12config.h
@@ -123,7 +123,7 @@ typedef struct yv12_buffer_config {
int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
int ss_x, int ss_y, int use_highbitdepth, int border,
- int byte_alignment, int is_monochrome);
+ int byte_alignment);
// Updates the yv12 buffer config with the frame buffer. |byte_alignment| must
// be a power of 2, from 32 to 1024. 0 sets legacy alignment. If cb is not
@@ -137,7 +137,7 @@ int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
int border, int byte_alignment,
aom_codec_frame_buffer_t *fb,
aom_get_frame_buffer_cb_fn_t cb, void *cb_priv,
- int alloc_y_buffer_8bit, int is_monochrome);
+ int alloc_y_buffer_8bit);
int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf);