Skip to content

Commit

Permalink
Add colour format: gray8 and cccn888 to colour-reversing
Browse files Browse the repository at this point in the history
  • Loading branch information
GorgonMeducer committed Nov 29, 2024
1 parent 79fbb3c commit e20c95f
Show file tree
Hide file tree
Showing 4 changed files with 292 additions and 34 deletions.
57 changes: 52 additions & 5 deletions Library/Include/__arm_2d_filter_reverse_colour.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Description: APIs for colour-reversing
*
* $Date: 29. Nov 2024
* $Revision: V.0.3.0
* $Revision: V.1.0.0
*
* Target Processor: Cortex-M cores
*
Expand Down Expand Up @@ -56,27 +56,74 @@ extern "C" {

/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/

#define arm_2d_gray8_filter_reverse_colour(__TARGET_ADDR, /* target tile */ \
__REGION_ADDR) /* target region */ \
arm_2dp_gray8_filter_reverse_colour(NULL, \
(__TARGET_ADDR), \
(__REGION_ADDR))

#define arm_2d_rgb565_filter_reverse_colour(__TARGET_ADDR, /* target tile */ \
__REGION_ADDR) /* target region */ \
arm_2dp_rgb565_filter_reverse_colour(NULL, \
(__TARGET_ADDR), \
(__REGION_ADDR))

#define arm_2d_cccn888_filter_reverse_colour(__TARGET_ADDR, /* target tile */ \
__REGION_ADDR) /* target region */ \
arm_2dp_cccn888_filter_reverse_colour(NULL, \
(__TARGET_ADDR), \
(__REGION_ADDR))
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ IMPLEMENTATION ================================*/

extern
ARM_NONNULL(2)
/*!
* \brief reverse the colour of the target region
* \brief reverse the colour of the target region for gray8
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] ptLineMsk the target line mask
* \param[in] tColour the target colour
* \return arm_fsm_rt_t the operations result
*/
arm_fsm_rt_t arm_2dp_rgb565_reverse_colour( arm_2d_op_fill_cl_msk_t *ptOP,
arm_fsm_rt_t arm_2dp_gray8_filter_reverse_colour(
arm_2d_op_fill_cl_msk_t *ptOP,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion);
extern
ARM_NONNULL(2)
/*!
* \brief reverse the colour of the target region for rgb565
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] ptLineMsk the target line mask
* \param[in] tColour the target colour
* \return arm_fsm_rt_t the operations result
*/
arm_fsm_rt_t arm_2dp_rgb565_filter_reverse_colour(
arm_2d_op_fill_cl_msk_t *ptOP,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion);
extern
ARM_NONNULL(2)
/*!
* \brief reverse the colour of the target region for cccn888
* \param[in] ptOP the control block, NULL means using the default control block
* \param[in] ptTarget the target tile
* \param[in] ptRegion the target region
* \param[in] ptLineMsk the target line mask
* \param[in] tColour the target colour
* \return arm_fsm_rt_t the operations result
*/
arm_fsm_rt_t arm_2dp_cccn888_filter_reverse_colour(
arm_2d_op_fill_cl_msk_t *ptOP,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion);

/*! @} */

#if defined(__clang__)
Expand Down
190 changes: 183 additions & 7 deletions Library/Source/__arm_2d_filter_reverse_colour.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Description: the source code of the colour-reversing
*
* $Date: 29. Nov 2024
* $Revision: V.0.3.0
* $Revision: V.1.0.0
*
* Target Processor: Cortex-M cores
*
Expand Down Expand Up @@ -77,21 +77,108 @@ extern "C" {
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
extern
const __arm_2d_op_info_t ARM_2D_OP_FILTER_REVERSE_COLOUR_RGB565;
/*============================ PROTOTYPES ====================================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ IMPLEMENTATION ================================*/

/*
* the Frontend API
*/

ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_gray8_filter_reverse_colour(
arm_2d_op_fill_cl_msk_t *ptOP,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion)
{
assert(NULL != ptTarget);

ARM_2D_IMPL(arm_2d_op_t, ptOP);

if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) {
return arm_fsm_rt_on_going;
}

OP_CORE.ptOp = &ARM_2D_OP_FILTER_REVERSE_COLOUR_GRAY8;

this.Target.ptTile = ptTarget;
this.Target.ptRegion = ptRegion;

return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
}


/* default low level implementation */

__WEAK
void __arm_2d_impl_gray8_reverse_colour( uint8_t *__RESTRICT pchTarget,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize)
{
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {

uint8_t *__RESTRICT pchTargetLine = pchTarget;
for (int_fast16_t x = 0; x < ptCopySize->iWidth; x++){
*pchTargetLine++ ^= __UINT8_MAX__;
}
pchTarget += iTargetStride;
}
}

/*
* The backend entry
*/
arm_fsm_rt_t __arm_2d_gray8_sw_filter_reverse_colour( __arm_2d_sub_task_t *ptTask)
{
ARM_2D_IMPL(arm_2d_op_t, ptTask->ptOP);
assert(ARM_2D_COLOUR_SZ_8BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ);

__arm_2d_impl_gray8_reverse_colour(
ptTask->Param.tTileProcess.pBuffer,
ptTask->Param.tTileProcess.iStride,
&(ptTask->Param.tTileProcess.tValidRegion.tSize));

return arm_fsm_rt_cpl;
}

/*
* OPCODE Low Level Implementation Entries
*/
__WEAK
def_low_lv_io( __ARM_2D_IO_FILTER_REVERSE_COLOUR_GRAY8,
__arm_2d_gray8_sw_filter_reverse_colour); /* Default SW Implementation */


/*
* OPCODE
*/

const __arm_2d_op_info_t ARM_2D_OP_FILTER_REVERSE_COLOUR_GRAY8 = {
.Info = {
.Colour = {
.chScheme = ARM_2D_COLOUR_GRAY8,
},
.Param = {
.bHasSource = false,
.bHasTarget = true,
},
.chOpIndex = __ARM_2D_OP_IDX_FILTER_REVERSE_COLOUR,

.LowLevelIO = {
.ptTileProcessLike = ref_low_lv_io(__ARM_2D_IO_FILTER_REVERSE_COLOUR_GRAY8),
},
},
};

/*
* the Frontend API
*/

ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_rgb565_reverse_colour( arm_2d_op_fill_cl_msk_t *ptOP,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion)
arm_fsm_rt_t arm_2dp_rgb565_filter_reverse_colour(
arm_2d_op_fill_cl_msk_t *ptOP,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion)
{
assert(NULL != ptTarget);

Expand All @@ -118,8 +205,10 @@ void __arm_2d_impl_rgb565_reverse_colour( uint16_t *__RESTRICT phwTarget,
arm_2d_size_t *__RESTRICT ptCopySize)
{
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {

uint16_t *__RESTRICT phwTargetLine = phwTarget;
for (int_fast16_t x = 0; x < ptCopySize->iWidth; x++){
phwTarget[x] ^= __UINT16_MAX__;
*phwTargetLine++ ^= __UINT16_MAX__;
}
phwTarget += iTargetStride;
}
Expand Down Expand Up @@ -170,7 +259,94 @@ const __arm_2d_op_info_t ARM_2D_OP_FILTER_REVERSE_COLOUR_RGB565 = {
},
};

/*
* the Frontend API
*/

ARM_NONNULL(2)
arm_fsm_rt_t arm_2dp_cccn888_filter_reverse_colour(
arm_2d_op_fill_cl_msk_t *ptOP,
const arm_2d_tile_t *ptTarget,
const arm_2d_region_t *ptRegion)
{
assert(NULL != ptTarget);

ARM_2D_IMPL(arm_2d_op_t, ptOP);

if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) {
return arm_fsm_rt_on_going;
}

OP_CORE.ptOp = &ARM_2D_OP_FILTER_REVERSE_COLOUR_CCCN888;

this.Target.ptTile = ptTarget;
this.Target.ptRegion = ptRegion;

return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
}


/* default low level implementation */

__WEAK
void __arm_2d_impl_cccn888_reverse_colour( uint32_t *__RESTRICT pwTarget,
int16_t iTargetStride,
arm_2d_size_t *__RESTRICT ptCopySize)
{
for (int_fast16_t y = 0; y < ptCopySize->iHeight; y++) {

uint32_t *__RESTRICT pwTargetLine = pwTarget;
for (int_fast16_t x = 0; x < ptCopySize->iWidth; x++){
*pwTargetLine++ ^= 0x00FFFFFF;
}
pwTarget += iTargetStride;
}
}

/*
* The backend entry
*/
arm_fsm_rt_t __arm_2d_cccn888_sw_filter_reverse_colour( __arm_2d_sub_task_t *ptTask)
{
ARM_2D_IMPL(arm_2d_op_t, ptTask->ptOP);
assert(ARM_2D_COLOUR_SZ_32BIT == OP_CORE.ptOp->Info.Colour.u3ColourSZ);

__arm_2d_impl_cccn888_reverse_colour(
ptTask->Param.tTileProcess.pBuffer,
ptTask->Param.tTileProcess.iStride,
&(ptTask->Param.tTileProcess.tValidRegion.tSize));

return arm_fsm_rt_cpl;
}

/*
* OPCODE Low Level Implementation Entries
*/
__WEAK
def_low_lv_io( __ARM_2D_IO_FILTER_REVERSE_COLOUR_CCCN888,
__arm_2d_cccn888_sw_filter_reverse_colour); /* Default SW Implementation */


/*
* OPCODE
*/

const __arm_2d_op_info_t ARM_2D_OP_FILTER_REVERSE_COLOUR_CCCN888 = {
.Info = {
.Colour = {
.chScheme = ARM_2D_COLOUR_CCCN888,
},
.Param = {
.bHasSource = false,
.bHasTarget = true,
},
.chOpIndex = __ARM_2D_OP_IDX_FILTER_REVERSE_COLOUR,

.LowLevelIO = {
.ptTileProcessLike = ref_low_lv_io(__ARM_2D_IO_FILTER_REVERSE_COLOUR_CCCN888),
},
},
};

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit e20c95f

Please sign in to comment.