#define Drc Data[r][c]
#define DrcOutlet Data[r_outlet][c_outlet]
#define MV(r,c) IS_MV_REAL4(&Mask->Data[r][c])
#define FOR_ROW_COL_MV for (int r = 0; r < nrRows; r++)\
for (int c = 0; c < nrCols; c++)\
if(!IS_MV_REAL4(&Mask->Data[r][c]))
#define FOR_ROW_COL_MV_CH for (int r = 0; r < nrRows; r++)\
for (int c = 0; c < nrCols; c++)\
if(!IS_MV_REAL4(& ChannelMask->Data[r][c]))
#define Drc Data[r][c]
#define DrcOutlet Data[r_outlet][c_outlet]
#define MV(r,c) IS_MV_REAL4(&Mask->Data[r][c])
#define FOR_ROW_COL_MV for (int r = 0; r < nrRows; r++)\
for (int c = 0; c < nrCols; c++)\
if(!IS_MV_REAL4(&Mask->Data[r][c]))
#define FOR_ROW_COL_MV_CH for (int r = 0; r < nrRows; r++)\
for (int c = 0; c < nrCols; c++)\
if(!IS_MV_REAL4(& ChannelMask->Data[r][c]))
To copy to clipboard, switch view to plain text mode
Normally, not a big fan of macros, but in this circumstance they work well.
// return the row and col index, computed from input idx and nCols
void RowColFromIndex(int & row, int & col, int idx, int nCols)
{
row = idx / nCols;
col = idx % nCols;
}
// return the flat index computed from inputs row, col, nCols
int IndexFromRowCol(int row, int col, int nCols)
{
return row * nCols + col;
}
#define DrcIdx Data[rIdx][cIdx]
#define FOR_ROW_COL_MV for (int idx = 0; idx < nrRows * nrCols; ++idx)\
int rIdx, cIdx; \
RowColFromIndex(rIdx, cIdx, idx, nrCols); \
if(!IS_MV_REAL4(&Mask->Data[rIdx][cIdx]))
#define FOR_ROW_COL_MV_CH for (int idx = 0; idx < nrRows * nrCols; ++idx)\
int rIdx, cIdx; \
RowColFromIndex(rIdx, cIdx, idx, nrCols); \
if(!IS_MV_REAL4(& ChannelMask->Data[rIdx][cIdx]))
// return the row and col index, computed from input idx and nCols
void RowColFromIndex(int & row, int & col, int idx, int nCols)
{
row = idx / nCols;
col = idx % nCols;
}
// return the flat index computed from inputs row, col, nCols
int IndexFromRowCol(int row, int col, int nCols)
{
return row * nCols + col;
}
#define DrcIdx Data[rIdx][cIdx]
#define FOR_ROW_COL_MV for (int idx = 0; idx < nrRows * nrCols; ++idx)\
int rIdx, cIdx; \
RowColFromIndex(rIdx, cIdx, idx, nrCols); \
if(!IS_MV_REAL4(&Mask->Data[rIdx][cIdx]))
#define FOR_ROW_COL_MV_CH for (int idx = 0; idx < nrRows * nrCols; ++idx)\
int rIdx, cIdx; \
RowColFromIndex(rIdx, cIdx, idx, nrCols); \
if(!IS_MV_REAL4(& ChannelMask->Data[rIdx][cIdx]))
To copy to clipboard, switch view to plain text mode
So, basically anywhere variable r and c are used need to be changed to rIdx and cIdx (using rIdx and cIdx helps find errors while porting).
Bookmarks