remove templates

This commit is contained in:
Bechir Braham
2024-03-20 13:14:14 +01:00
parent 4da9bc0813
commit cd905e96f3
25 changed files with 223 additions and 200 deletions

View File

@ -12,17 +12,18 @@
* should be able to work with streams coming from files or network
*/
template <class DataType> class Frame {
class Frame {
ssize_t m_rows;
ssize_t m_cols;
DataType *m_data;
ssize_t m_bitdepth = sizeof(DataType) * 8;
ssize_t m_bitdepth;
std::byte* m_data;
public:
Frame(ssize_t rows, ssize_t cols);
Frame(std::byte *fp, ssize_t rows, ssize_t cols);
DataType get(int row, int col);
std::vector<std::vector<DataType>> get_array();
Frame(ssize_t rows, ssize_t cols,ssize_t m_bitdepth);
Frame(std::byte *fp, ssize_t rows, ssize_t cols,ssize_t m_bitdepth);
std::byte* get(int row, int col);
// std::vector<std::vector<DataType>> get_array();
ssize_t rows() const{
return m_rows;
}
@ -32,13 +33,17 @@ template <class DataType> class Frame {
ssize_t bitdepth() const{
return m_bitdepth;
}
DataType* _get_data(){
std::byte* _get_data(){
return m_data;
}
Frame& operator=(Frame& other){
m_rows = other.rows();
m_cols = other.cols();
m_bitdepth = other.bitdepth();
m_data = new std::byte[m_rows*m_cols*m_bitdepth/8];
std::memcpy(m_data, other.m_data, m_rows*m_cols*m_bitdepth/8);
return *this;
}
~Frame() { delete[] m_data; }
};
typedef Frame<uint16_t> Frame16;
typedef Frame<uint8_t> Frame8;
typedef Frame<uint32_t> Frame32;