Add get_plane_type() helper function.
Adds the static inline function get_plane_type to convert a plane number
to the corresponding PLANE_TYPE.
There's no change to the bitstream, it only encapsulates the logic to
get the PLANE_TYPE.
Change-Id: I1199db3a32c89437d9c029ab5b2b2e62582a13a2
diff --git a/av1/common/blockd.c b/av1/common/blockd.c
index a689b81..526d237 100644
--- a/av1/common/blockd.c
+++ b/av1/common/blockd.c
@@ -244,7 +244,7 @@
int i;
for (i = 0; i < MAX_MB_PLANE; i++) {
- xd->plane[i].plane_type = i ? PLANE_TYPE_UV : PLANE_TYPE_Y;
+ xd->plane[i].plane_type = get_plane_type(i);
xd->plane[i].subsampling_x = i ? ss_x : 0;
xd->plane[i].subsampling_y = i ? ss_y : 0;
}
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index ee0f264..e7725ea 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -1123,6 +1123,10 @@
}
#endif // CONFIG_GLOBAL_MOTION
+static INLINE PLANE_TYPE get_plane_type(const int plane) {
+ return (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
+}
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 8447606..37e8e16 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -496,7 +496,7 @@
MB_MODE_INFO *const mbmi, int plane, int row, int col, TX_SIZE tx_size) {
struct macroblockd_plane *const pd = &xd->plane[plane];
PREDICTION_MODE mode = (plane == 0) ? mbmi->mode : mbmi->uv_mode;
- PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
+ PLANE_TYPE plane_type = get_plane_type(plane);
uint8_t *dst;
const int block_idx = (row << 1) + col;
#if CONFIG_PVQ
@@ -555,7 +555,7 @@
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
if (tx_size == plane_tx_size) {
- PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
+ PLANE_TYPE plane_type = get_plane_type(plane);
int block_idx = (blk_row << 1) + blk_col;
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, plane_tx_size);
const SCAN_ORDER *sc = get_scan(cm, plane_tx_size, tx_type, 1);
@@ -599,7 +599,7 @@
aom_reader *const r, int segment_id,
int plane, int row, int col,
TX_SIZE tx_size) {
- PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
+ PLANE_TYPE plane_type = get_plane_type(plane);
int block_idx = (row << 1) + col;
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
#if CONFIG_PVQ
diff --git a/av1/encoder/encodemb.c b/av1/encoder/encodemb.c
index 12a0004..2368294 100644
--- a/av1/encoder/encodemb.c
+++ b/av1/encoder/encodemb.c
@@ -503,7 +503,7 @@
struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
#endif
- PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
+ PLANE_TYPE plane_type = get_plane_type(plane);
const int block_raster_idx = av1_block_index_to_raster_order(tx_size, block);
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_raster_idx, tx_size);
const int is_inter = is_inter_block(&xd->mi[0]->mbmi);
@@ -976,7 +976,7 @@
struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
- PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
+ PLANE_TYPE plane_type = get_plane_type(plane);
const int block_raster_idx = av1_block_index_to_raster_order(tx_size, block);
const TX_TYPE tx_type =
get_tx_type(plane_type, xd, block_raster_idx, tx_size);
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 0484479..9daa6c9 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -1294,7 +1294,7 @@
DECLARE_ALIGNED(16, uint8_t, recon[MAX_TX_SQUARE]);
#endif // CONFIG_AOM_HIGHBITDEPTH
- const PLANE_TYPE plane_type = plane == 0 ? PLANE_TYPE_Y : PLANE_TYPE_UV;
+ const PLANE_TYPE plane_type = get_plane_type(plane);
INV_TXFM_PARAM inv_txfm_param;
const int block_raster_idx =
@@ -3770,7 +3770,7 @@
struct macroblockd_plane *const pd = &xd->plane[plane];
int64_t tmp;
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
- PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
+ PLANE_TYPE plane_type = get_plane_type(plane);
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const SCAN_ORDER *const scan_order =
get_scan(cm, tx_size, tx_type, is_inter_block(&xd->mi[0]->mbmi));