summaryrefslogtreecommitdiff
path: root/media/libaom/src/av1/common/cfl.h
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-03-03 18:48:48 +0000
committerMoonchild <moonchild@palemoon.org>2021-03-04 00:03:46 +0000
commitd192e6808fab971ffbe8c15ff3695c7d08b280c6 (patch)
tree9d9cc4d21c93ae3e1a88ab5c160c3be5f6af0ca9 /media/libaom/src/av1/common/cfl.h
parentc81c0395a36b0a6b21a6a0ae7b31953fe4a460d9 (diff)
downloaduxp-d192e6808fab971ffbe8c15ff3695c7d08b280c6.tar.gz
Issue #1737 - Import libaom 2.0.2 source
Diffstat (limited to 'media/libaom/src/av1/common/cfl.h')
-rw-r--r--media/libaom/src/av1/common/cfl.h284
1 files changed, 135 insertions, 149 deletions
diff --git a/media/libaom/src/av1/common/cfl.h b/media/libaom/src/av1/common/cfl.h
index d627891bf5..a1d6dc2eaa 100644
--- a/media/libaom/src/av1/common/cfl.h
+++ b/media/libaom/src/av1/common/cfl.h
@@ -12,8 +12,8 @@
#ifndef AOM_AV1_COMMON_CFL_H_
#define AOM_AV1_COMMON_CFL_H_
+#include "av1/common/av1_common_int.h"
#include "av1/common/blockd.h"
-#include "av1/common/onyxc_int.h"
// Can we use CfL for the current block?
static INLINE CFL_ALLOWED_TYPE is_cfl_allowed(const MACROBLOCKD *xd) {
@@ -41,7 +41,7 @@ static INLINE CFL_ALLOWED_TYPE store_cfl_required(const AV1_COMMON *cm,
if (cm->seq_params.monochrome) return CFL_DISALLOWED;
- if (!xd->cfl.is_chroma_reference) {
+ if (!xd->is_chroma_ref) {
// For non-chroma-reference blocks, we should always store the luma pixels,
// in case the corresponding chroma-reference block uses CfL.
// Note that this can only happen for block sizes which are <8 on
@@ -80,14 +80,6 @@ void cfl_store_dc_pred(MACROBLOCKD *const xd, const uint8_t *input,
void cfl_load_dc_pred(MACROBLOCKD *const xd, uint8_t *dst, int dst_stride,
TX_SIZE tx_size, CFL_PRED_TYPE pred_plane);
-// Null function used for invalid tx_sizes
-void cfl_subsample_lbd_null(const uint8_t *input, int input_stride,
- uint16_t *output_q3);
-
-// Null function used for invalid tx_sizes
-void cfl_subsample_hbd_null(const uint16_t *input, int input_stride,
- uint16_t *output_q3);
-
// Allows the CFL_SUBSAMPLE function to switch types depending on the bitdepth.
#define CFL_lbd_TYPE uint8_t *cfl_type
#define CFL_hbd_TYPE uint16_t *cfl_type
@@ -97,7 +89,7 @@ void cfl_subsample_hbd_null(const uint16_t *input, int input_stride,
// will be constant allowing for loop unrolling and other constant propagated
// goodness.
#define CFL_SUBSAMPLE(arch, sub, bd, width, height) \
- void subsample_##bd##_##sub##_##width##x##height##_##arch( \
+ void cfl_subsample_##bd##_##sub##_##width##x##height##_##arch( \
const CFL_##bd##_TYPE, int input_stride, uint16_t *output_q3) { \
cfl_luma_subsampling_##sub##_##bd##_##arch(cfl_type, input_stride, \
output_q3, width, height); \
@@ -127,31 +119,32 @@ void cfl_subsample_hbd_null(const uint16_t *input, int input_stride,
// Declare an architecture-specific array of function pointers for size-specific
// wrappers.
-#define CFL_SUBSAMPLE_FUNCTION_ARRAY(arch, sub, bd) \
- static const cfl_subsample_##bd##_fn subfn_##sub[TX_SIZES_ALL] = { \
- subsample_##bd##_##sub##_4x4_##arch, /* 4x4 */ \
- subsample_##bd##_##sub##_8x8_##arch, /* 8x8 */ \
- subsample_##bd##_##sub##_16x16_##arch, /* 16x16 */ \
- subsample_##bd##_##sub##_32x32_##arch, /* 32x32 */ \
- cfl_subsample_##bd##_null, /* 64x64 (invalid CFL size) */ \
- subsample_##bd##_##sub##_4x8_##arch, /* 4x8 */ \
- subsample_##bd##_##sub##_8x4_##arch, /* 8x4 */ \
- subsample_##bd##_##sub##_8x16_##arch, /* 8x16 */ \
- subsample_##bd##_##sub##_16x8_##arch, /* 16x8 */ \
- subsample_##bd##_##sub##_16x32_##arch, /* 16x32 */ \
- subsample_##bd##_##sub##_32x16_##arch, /* 32x16 */ \
- cfl_subsample_##bd##_null, /* 32x64 (invalid CFL size) */ \
- cfl_subsample_##bd##_null, /* 64x32 (invalid CFL size) */ \
- subsample_##bd##_##sub##_4x16_##arch, /* 4x16 */ \
- subsample_##bd##_##sub##_16x4_##arch, /* 16x4 */ \
- subsample_##bd##_##sub##_8x32_##arch, /* 8x32 */ \
- subsample_##bd##_##sub##_32x8_##arch, /* 32x8 */ \
- cfl_subsample_##bd##_null, /* 16x64 (invalid CFL size) */ \
- cfl_subsample_##bd##_null, /* 64x16 (invalid CFL size) */ \
+#define CFL_SUBSAMPLE_FUNCTION_ARRAY(arch, sub, bd) \
+ static const cfl_subsample_##bd##_fn subfn_##sub[TX_SIZES_ALL] = { \
+ cfl_subsample_##bd##_##sub##_4x4_##arch, /* 4x4 */ \
+ cfl_subsample_##bd##_##sub##_8x8_##arch, /* 8x8 */ \
+ cfl_subsample_##bd##_##sub##_16x16_##arch, /* 16x16 */ \
+ cfl_subsample_##bd##_##sub##_32x32_##arch, /* 32x32 */ \
+ NULL, /* 64x64 (invalid CFL size) */ \
+ cfl_subsample_##bd##_##sub##_4x8_##arch, /* 4x8 */ \
+ cfl_subsample_##bd##_##sub##_8x4_##arch, /* 8x4 */ \
+ cfl_subsample_##bd##_##sub##_8x16_##arch, /* 8x16 */ \
+ cfl_subsample_##bd##_##sub##_16x8_##arch, /* 16x8 */ \
+ cfl_subsample_##bd##_##sub##_16x32_##arch, /* 16x32 */ \
+ cfl_subsample_##bd##_##sub##_32x16_##arch, /* 32x16 */ \
+ NULL, /* 32x64 (invalid CFL size) */ \
+ NULL, /* 64x32 (invalid CFL size) */ \
+ cfl_subsample_##bd##_##sub##_4x16_##arch, /* 4x16 */ \
+ cfl_subsample_##bd##_##sub##_16x4_##arch, /* 16x4 */ \
+ cfl_subsample_##bd##_##sub##_8x32_##arch, /* 8x32 */ \
+ cfl_subsample_##bd##_##sub##_32x8_##arch, /* 32x8 */ \
+ NULL, /* 16x64 (invalid CFL size) */ \
+ NULL, /* 64x16 (invalid CFL size) */ \
};
// The RTCD script does not support passing in an array, so we wrap it in this
// function.
+#if CONFIG_AV1_HIGHBITDEPTH
#define CFL_GET_SUBSAMPLE_FUNCTION(arch) \
CFL_SUBSAMPLE_FUNCTIONS(arch, 420, lbd) \
CFL_SUBSAMPLE_FUNCTIONS(arch, 422, lbd) \
@@ -159,144 +152,137 @@ void cfl_subsample_hbd_null(const uint16_t *input, int input_stride,
CFL_SUBSAMPLE_FUNCTIONS(arch, 420, hbd) \
CFL_SUBSAMPLE_FUNCTIONS(arch, 422, hbd) \
CFL_SUBSAMPLE_FUNCTIONS(arch, 444, hbd)
-
-// Null function used for invalid tx_sizes
-static INLINE void cfl_subtract_average_null(const uint16_t *src,
- int16_t *dst) {
- (void)dst;
- (void)src;
- assert(0);
-}
+#else
+#define CFL_GET_SUBSAMPLE_FUNCTION(arch) \
+ CFL_SUBSAMPLE_FUNCTIONS(arch, 420, lbd) \
+ CFL_SUBSAMPLE_FUNCTIONS(arch, 422, lbd) \
+ CFL_SUBSAMPLE_FUNCTIONS(arch, 444, lbd)
+#endif
// Declare a size-specific wrapper for the size-generic function. The compiler
// will inline the size generic function in here, the advantage is that the size
// will be constant allowing for loop unrolling and other constant propagated
// goodness.
-#define CFL_SUB_AVG_X(arch, width, height, round_offset, num_pel_log2) \
- void subtract_average_##width##x##height##_##arch(const uint16_t *src, \
- int16_t *dst) { \
- subtract_average_##arch(src, dst, width, height, round_offset, \
- num_pel_log2); \
+#define CFL_SUB_AVG_X(arch, width, height, round_offset, num_pel_log2) \
+ void cfl_subtract_average_##width##x##height##_##arch(const uint16_t *src, \
+ int16_t *dst) { \
+ subtract_average_##arch(src, dst, width, height, round_offset, \
+ num_pel_log2); \
}
// Declare size-specific wrappers for all valid CfL sizes.
-#define CFL_SUB_AVG_FN(arch) \
- CFL_SUB_AVG_X(arch, 4, 4, 8, 4) \
- CFL_SUB_AVG_X(arch, 4, 8, 16, 5) \
- CFL_SUB_AVG_X(arch, 4, 16, 32, 6) \
- CFL_SUB_AVG_X(arch, 8, 4, 16, 5) \
- CFL_SUB_AVG_X(arch, 8, 8, 32, 6) \
- CFL_SUB_AVG_X(arch, 8, 16, 64, 7) \
- CFL_SUB_AVG_X(arch, 8, 32, 128, 8) \
- CFL_SUB_AVG_X(arch, 16, 4, 32, 6) \
- CFL_SUB_AVG_X(arch, 16, 8, 64, 7) \
- CFL_SUB_AVG_X(arch, 16, 16, 128, 8) \
- CFL_SUB_AVG_X(arch, 16, 32, 256, 9) \
- CFL_SUB_AVG_X(arch, 32, 8, 128, 8) \
- CFL_SUB_AVG_X(arch, 32, 16, 256, 9) \
- CFL_SUB_AVG_X(arch, 32, 32, 512, 10) \
- cfl_subtract_average_fn get_subtract_average_fn_##arch(TX_SIZE tx_size) { \
- static const cfl_subtract_average_fn sub_avg[TX_SIZES_ALL] = { \
- subtract_average_4x4_##arch, /* 4x4 */ \
- subtract_average_8x8_##arch, /* 8x8 */ \
- subtract_average_16x16_##arch, /* 16x16 */ \
- subtract_average_32x32_##arch, /* 32x32 */ \
- cfl_subtract_average_null, /* 64x64 (invalid CFL size) */ \
- subtract_average_4x8_##arch, /* 4x8 */ \
- subtract_average_8x4_##arch, /* 8x4 */ \
- subtract_average_8x16_##arch, /* 8x16 */ \
- subtract_average_16x8_##arch, /* 16x8 */ \
- subtract_average_16x32_##arch, /* 16x32 */ \
- subtract_average_32x16_##arch, /* 32x16 */ \
- cfl_subtract_average_null, /* 32x64 (invalid CFL size) */ \
- cfl_subtract_average_null, /* 64x32 (invalid CFL size) */ \
- subtract_average_4x16_##arch, /* 4x16 (invalid CFL size) */ \
- subtract_average_16x4_##arch, /* 16x4 (invalid CFL size) */ \
- subtract_average_8x32_##arch, /* 8x32 (invalid CFL size) */ \
- subtract_average_32x8_##arch, /* 32x8 (invalid CFL size) */ \
- cfl_subtract_average_null, /* 16x64 (invalid CFL size) */ \
- cfl_subtract_average_null, /* 64x16 (invalid CFL size) */ \
- }; \
- /* Modulo TX_SIZES_ALL to ensure that an attacker won't be able to */ \
- /* index the function pointer array out of bounds. */ \
- return sub_avg[tx_size % TX_SIZES_ALL]; \
+#define CFL_SUB_AVG_FN(arch) \
+ CFL_SUB_AVG_X(arch, 4, 4, 8, 4) \
+ CFL_SUB_AVG_X(arch, 4, 8, 16, 5) \
+ CFL_SUB_AVG_X(arch, 4, 16, 32, 6) \
+ CFL_SUB_AVG_X(arch, 8, 4, 16, 5) \
+ CFL_SUB_AVG_X(arch, 8, 8, 32, 6) \
+ CFL_SUB_AVG_X(arch, 8, 16, 64, 7) \
+ CFL_SUB_AVG_X(arch, 8, 32, 128, 8) \
+ CFL_SUB_AVG_X(arch, 16, 4, 32, 6) \
+ CFL_SUB_AVG_X(arch, 16, 8, 64, 7) \
+ CFL_SUB_AVG_X(arch, 16, 16, 128, 8) \
+ CFL_SUB_AVG_X(arch, 16, 32, 256, 9) \
+ CFL_SUB_AVG_X(arch, 32, 8, 128, 8) \
+ CFL_SUB_AVG_X(arch, 32, 16, 256, 9) \
+ CFL_SUB_AVG_X(arch, 32, 32, 512, 10) \
+ cfl_subtract_average_fn cfl_get_subtract_average_fn_##arch( \
+ TX_SIZE tx_size) { \
+ static const cfl_subtract_average_fn sub_avg[TX_SIZES_ALL] = { \
+ cfl_subtract_average_4x4_##arch, /* 4x4 */ \
+ cfl_subtract_average_8x8_##arch, /* 8x8 */ \
+ cfl_subtract_average_16x16_##arch, /* 16x16 */ \
+ cfl_subtract_average_32x32_##arch, /* 32x32 */ \
+ NULL, /* 64x64 (invalid CFL size) */ \
+ cfl_subtract_average_4x8_##arch, /* 4x8 */ \
+ cfl_subtract_average_8x4_##arch, /* 8x4 */ \
+ cfl_subtract_average_8x16_##arch, /* 8x16 */ \
+ cfl_subtract_average_16x8_##arch, /* 16x8 */ \
+ cfl_subtract_average_16x32_##arch, /* 16x32 */ \
+ cfl_subtract_average_32x16_##arch, /* 32x16 */ \
+ NULL, /* 32x64 (invalid CFL size) */ \
+ NULL, /* 64x32 (invalid CFL size) */ \
+ cfl_subtract_average_4x16_##arch, /* 4x16 (invalid CFL size) */ \
+ cfl_subtract_average_16x4_##arch, /* 16x4 (invalid CFL size) */ \
+ cfl_subtract_average_8x32_##arch, /* 8x32 (invalid CFL size) */ \
+ cfl_subtract_average_32x8_##arch, /* 32x8 (invalid CFL size) */ \
+ NULL, /* 16x64 (invalid CFL size) */ \
+ NULL, /* 64x16 (invalid CFL size) */ \
+ }; \
+ /* Modulo TX_SIZES_ALL to ensure that an attacker won't be able to */ \
+ /* index the function pointer array out of bounds. */ \
+ return sub_avg[tx_size % TX_SIZES_ALL]; \
}
// For VSX SIMD optimization, the C versions of width == 4 subtract are
// faster than the VSX. As such, the VSX code calls the C versions.
-void subtract_average_4x4_c(const uint16_t *src, int16_t *dst);
-void subtract_average_4x8_c(const uint16_t *src, int16_t *dst);
-void subtract_average_4x16_c(const uint16_t *src, int16_t *dst);
-
-#define CFL_PREDICT_lbd(arch, width, height) \
- void predict_lbd_##width##x##height##_##arch(const int16_t *pred_buf_q3, \
- uint8_t *dst, int dst_stride, \
- int alpha_q3) { \
- cfl_predict_lbd_##arch(pred_buf_q3, dst, dst_stride, alpha_q3, width, \
- height); \
+void cfl_subtract_average_4x4_c(const uint16_t *src, int16_t *dst);
+void cfl_subtract_average_4x8_c(const uint16_t *src, int16_t *dst);
+void cfl_subtract_average_4x16_c(const uint16_t *src, int16_t *dst);
+
+#define CFL_PREDICT_lbd(arch, width, height) \
+ void cfl_predict_lbd_##width##x##height##_##arch( \
+ const int16_t *pred_buf_q3, uint8_t *dst, int dst_stride, \
+ int alpha_q3) { \
+ cfl_predict_lbd_##arch(pred_buf_q3, dst, dst_stride, alpha_q3, width, \
+ height); \
}
-#define CFL_PREDICT_hbd(arch, width, height) \
- void predict_hbd_##width##x##height##_##arch(const int16_t *pred_buf_q3, \
- uint16_t *dst, int dst_stride, \
- int alpha_q3, int bd) { \
- cfl_predict_hbd_##arch(pred_buf_q3, dst, dst_stride, alpha_q3, bd, width, \
- height); \
+#if CONFIG_AV1_HIGHBITDEPTH
+#define CFL_PREDICT_hbd(arch, width, height) \
+ void cfl_predict_hbd_##width##x##height##_##arch( \
+ const int16_t *pred_buf_q3, uint16_t *dst, int dst_stride, int alpha_q3, \
+ int bd) { \
+ cfl_predict_hbd_##arch(pred_buf_q3, dst, dst_stride, alpha_q3, bd, width, \
+ height); \
}
+#endif
// This wrapper exists because clang format does not like calling macros with
// lowercase letters.
#define CFL_PREDICT_X(arch, width, height, bd) \
CFL_PREDICT_##bd(arch, width, height)
-// Null function used for invalid tx_sizes
-void cfl_predict_lbd_null(const int16_t *pred_buf_q3, uint8_t *dst,
- int dst_stride, int alpha_q3);
-
-// Null function used for invalid tx_sizes
-void cfl_predict_hbd_null(const int16_t *pred_buf_q3, uint16_t *dst,
- int dst_stride, int alpha_q3, int bd);
-
-#define CFL_PREDICT_FN(arch, bd) \
- CFL_PREDICT_X(arch, 4, 4, bd) \
- CFL_PREDICT_X(arch, 4, 8, bd) \
- CFL_PREDICT_X(arch, 4, 16, bd) \
- CFL_PREDICT_X(arch, 8, 4, bd) \
- CFL_PREDICT_X(arch, 8, 8, bd) \
- CFL_PREDICT_X(arch, 8, 16, bd) \
- CFL_PREDICT_X(arch, 8, 32, bd) \
- CFL_PREDICT_X(arch, 16, 4, bd) \
- CFL_PREDICT_X(arch, 16, 8, bd) \
- CFL_PREDICT_X(arch, 16, 16, bd) \
- CFL_PREDICT_X(arch, 16, 32, bd) \
- CFL_PREDICT_X(arch, 32, 8, bd) \
- CFL_PREDICT_X(arch, 32, 16, bd) \
- CFL_PREDICT_X(arch, 32, 32, bd) \
- cfl_predict_##bd##_fn get_predict_##bd##_fn_##arch(TX_SIZE tx_size) { \
- static const cfl_predict_##bd##_fn pred[TX_SIZES_ALL] = { \
- predict_##bd##_4x4_##arch, /* 4x4 */ \
- predict_##bd##_8x8_##arch, /* 8x8 */ \
- predict_##bd##_16x16_##arch, /* 16x16 */ \
- predict_##bd##_32x32_##arch, /* 32x32 */ \
- cfl_predict_##bd##_null, /* 64x64 (invalid CFL size) */ \
- predict_##bd##_4x8_##arch, /* 4x8 */ \
- predict_##bd##_8x4_##arch, /* 8x4 */ \
- predict_##bd##_8x16_##arch, /* 8x16 */ \
- predict_##bd##_16x8_##arch, /* 16x8 */ \
- predict_##bd##_16x32_##arch, /* 16x32 */ \
- predict_##bd##_32x16_##arch, /* 32x16 */ \
- cfl_predict_##bd##_null, /* 32x64 (invalid CFL size) */ \
- cfl_predict_##bd##_null, /* 64x32 (invalid CFL size) */ \
- predict_##bd##_4x16_##arch, /* 4x16 */ \
- predict_##bd##_16x4_##arch, /* 16x4 */ \
- predict_##bd##_8x32_##arch, /* 8x32 */ \
- predict_##bd##_32x8_##arch, /* 32x8 */ \
- cfl_predict_##bd##_null, /* 16x64 (invalid CFL size) */ \
- cfl_predict_##bd##_null, /* 64x16 (invalid CFL size) */ \
- }; \
- /* Modulo TX_SIZES_ALL to ensure that an attacker won't be able to */ \
- /* index the function pointer array out of bounds. */ \
- return pred[tx_size % TX_SIZES_ALL]; \
+#define CFL_PREDICT_FN(arch, bd) \
+ CFL_PREDICT_X(arch, 4, 4, bd) \
+ CFL_PREDICT_X(arch, 4, 8, bd) \
+ CFL_PREDICT_X(arch, 4, 16, bd) \
+ CFL_PREDICT_X(arch, 8, 4, bd) \
+ CFL_PREDICT_X(arch, 8, 8, bd) \
+ CFL_PREDICT_X(arch, 8, 16, bd) \
+ CFL_PREDICT_X(arch, 8, 32, bd) \
+ CFL_PREDICT_X(arch, 16, 4, bd) \
+ CFL_PREDICT_X(arch, 16, 8, bd) \
+ CFL_PREDICT_X(arch, 16, 16, bd) \
+ CFL_PREDICT_X(arch, 16, 32, bd) \
+ CFL_PREDICT_X(arch, 32, 8, bd) \
+ CFL_PREDICT_X(arch, 32, 16, bd) \
+ CFL_PREDICT_X(arch, 32, 32, bd) \
+ cfl_predict_##bd##_fn cfl_get_predict_##bd##_fn_##arch(TX_SIZE tx_size) { \
+ static const cfl_predict_##bd##_fn pred[TX_SIZES_ALL] = { \
+ cfl_predict_##bd##_4x4_##arch, /* 4x4 */ \
+ cfl_predict_##bd##_8x8_##arch, /* 8x8 */ \
+ cfl_predict_##bd##_16x16_##arch, /* 16x16 */ \
+ cfl_predict_##bd##_32x32_##arch, /* 32x32 */ \
+ NULL, /* 64x64 (invalid CFL size) */ \
+ cfl_predict_##bd##_4x8_##arch, /* 4x8 */ \
+ cfl_predict_##bd##_8x4_##arch, /* 8x4 */ \
+ cfl_predict_##bd##_8x16_##arch, /* 8x16 */ \
+ cfl_predict_##bd##_16x8_##arch, /* 16x8 */ \
+ cfl_predict_##bd##_16x32_##arch, /* 16x32 */ \
+ cfl_predict_##bd##_32x16_##arch, /* 32x16 */ \
+ NULL, /* 32x64 (invalid CFL size) */ \
+ NULL, /* 64x32 (invalid CFL size) */ \
+ cfl_predict_##bd##_4x16_##arch, /* 4x16 */ \
+ cfl_predict_##bd##_16x4_##arch, /* 16x4 */ \
+ cfl_predict_##bd##_8x32_##arch, /* 8x32 */ \
+ cfl_predict_##bd##_32x8_##arch, /* 32x8 */ \
+ NULL, /* 16x64 (invalid CFL size) */ \
+ NULL, /* 64x16 (invalid CFL size) */ \
+ }; \
+ /* Modulo TX_SIZES_ALL to ensure that an attacker won't be able to */ \
+ /* index the function pointer array out of bounds. */ \
+ return pred[tx_size % TX_SIZES_ALL]; \
}
#endif // AOM_AV1_COMMON_CFL_H_