Remove subsampling dep for allocating tx_skip Resolves reopened issue #185
diff --git a/av1/common/av1_common_int.h b/av1/common/av1_common_int.h index 22c233d..bc69f7b 100644 --- a/av1/common/av1_common_int.h +++ b/av1/common/av1_common_int.h
@@ -1096,6 +1096,10 @@ */ uint8_t *wiener_class_id[MAX_MB_PLANE]; /*! + * wiener_class_id buffer allocated for each 4x4 block + */ + uint32_t wiener_class_id_buf_size[MAX_MB_PLANE]; + /*! * wiener_class_id stride */ uint32_t wiener_class_id_stride[MAX_MB_PLANE];
diff --git a/av1/common/blockd.c b/av1/common/blockd.c index ebfd5f5..34ea328 100644 --- a/av1/common/blockd.c +++ b/av1/common/blockd.c
@@ -687,13 +687,12 @@ void av1_alloc_txk_skip_array(CommonModeInfoParams *mi_params, AV1_COMMON *cm) { // Allocate based on the MIN_TX_SIZE, which is a 4x4 block. + (void)cm; for (int plane = 0; plane < MAX_MB_PLANE; plane++) { int w = mi_params->mi_cols << MI_SIZE_LOG2; int h = mi_params->mi_rows << MI_SIZE_LOG2; w = ((w + MAX_SB_SIZE - 1) >> MAX_SB_SIZE_LOG2) << MAX_SB_SIZE_LOG2; h = ((h + MAX_SB_SIZE - 1) >> MAX_SB_SIZE_LOG2) << MAX_SB_SIZE_LOG2; - w >>= ((plane == 0) ? 0 : cm->seq_params.subsampling_x); - h >>= ((plane == 0) ? 0 : cm->seq_params.subsampling_y); int stride = (w + MIN_TX_SIZE - 1) >> MIN_TX_SIZE_LOG2; int rows = (h + MIN_TX_SIZE - 1) >> MIN_TX_SIZE_LOG2; mi_params->tx_skip[plane] = aom_calloc(rows * stride, sizeof(uint8_t)); @@ -710,9 +709,16 @@ (void)cm; for (int plane = 0; plane < MAX_MB_PLANE; plane++) { int w = mi_params->mi_cols << MI_SIZE_LOG2; + int h = mi_params->mi_rows << MI_SIZE_LOG2; w = ((w + MAX_SB_SIZE - 1) >> MAX_SB_SIZE_LOG2) << MAX_SB_SIZE_LOG2; - w >>= ((plane == 0) ? 0 : cm->seq_params.subsampling_x); + h = ((h + MAX_SB_SIZE - 1) >> MAX_SB_SIZE_LOG2) << MAX_SB_SIZE_LOG2; int stride = (w + MIN_TX_SIZE - 1) >> MIN_TX_SIZE_LOG2; + int rows = (h + MIN_TX_SIZE - 1) >> MIN_TX_SIZE_LOG2; + if (rows * stride > (int)mi_params->tx_skip_buf_size[plane]) { + aom_free(mi_params->tx_skip[plane]); + mi_params->tx_skip[plane] = aom_calloc(rows * stride, sizeof(uint8_t)); + mi_params->tx_skip_buf_size[plane] = rows * stride; + } mi_params->tx_skip_stride[plane] = stride; } } @@ -840,28 +846,43 @@ } void av1_alloc_class_id_array(CommonModeInfoParams *mi_params, AV1_COMMON *cm) { + (void)cm; for (int plane = 0; plane < MAX_MB_PLANE; plane++) { - int w = cm->superres_upscaled_width; + // Allocate for the maximum possible value of cm->superres_upscaled_width, + // which is the coded frame width * 2, instead of just + // cm->superres_upscaled_width + int w = (mi_params->mi_cols << MI_SIZE_LOG2) * 2; int h = cm->superres_upscaled_height; w = ((w + MAX_SB_SIZE - 1) >> MAX_SB_SIZE_LOG2) << MAX_SB_SIZE_LOG2; h = ((h + MAX_SB_SIZE - 1) >> MAX_SB_SIZE_LOG2) << MAX_SB_SIZE_LOG2; - w >>= ((plane == 0) ? 0 : cm->seq_params.subsampling_x); - h >>= ((plane == 0) ? 0 : cm->seq_params.subsampling_y); int stride = (w + MIN_TX_SIZE - 1) >> MIN_TX_SIZE_LOG2; int rows = (h + MIN_TX_SIZE - 1) >> MIN_TX_SIZE_LOG2; mi_params->wiener_class_id[plane] = aom_calloc(rows * stride, sizeof(uint8_t)); + mi_params->wiener_class_id_buf_size[plane] = rows * stride; mi_params->wiener_class_id_stride[plane] = stride; } } void av1_set_class_id_array_stride(CommonModeInfoParams *mi_params, AV1_COMMON *cm) { + (void)cm; for (int plane = 0; plane < MAX_MB_PLANE; plane++) { - int w = cm->superres_upscaled_width; + // Allocate for the maximum possible value of cm->superres_upscaled_width, + // which is the coded frame width * 2, instead of just + // cm->superres_upscaled_width + int w = (mi_params->mi_cols << MI_SIZE_LOG2) * 2; + int h = cm->superres_upscaled_height; w = ((w + MAX_SB_SIZE - 1) >> MAX_SB_SIZE_LOG2) << MAX_SB_SIZE_LOG2; - w >>= ((plane == 0) ? 0 : cm->seq_params.subsampling_x); + h = ((h + MAX_SB_SIZE - 1) >> MAX_SB_SIZE_LOG2) << MAX_SB_SIZE_LOG2; int stride = (w + MIN_TX_SIZE - 1) >> MIN_TX_SIZE_LOG2; + int rows = (h + MIN_TX_SIZE - 1) >> MIN_TX_SIZE_LOG2; + if (rows * stride > (int)mi_params->wiener_class_id_buf_size[plane]) { + aom_free(mi_params->wiener_class_id[plane]); + mi_params->wiener_class_id[plane] = + aom_calloc(rows * stride, sizeof(uint8_t)); + mi_params->wiener_class_id_buf_size[plane] = rows * stride; + } mi_params->wiener_class_id_stride[plane] = stride; } }