// // file name: coeff.h // written by Ee-Chien Chang //---------------------------------------------------- // T A B L E //---------------------------------------------------- // // a nos_row by nos_col table of pointers. // Each pointer points to an BLOCK_SIZE by BLOCK_SIZE array. // Each entry of the array is a 3-byte coeff. // // The content of the array is stored in file: an array // correspoind to a single file. // // when an entry of the table is zero, this mean that // the file is not yet loaded into memory. // To load it into memory, use // loadimage (i,j) //---------------------------------------------------- #ifndef COEFF_H #define COEFF_H class table { public: ~table (); table ( int row, int col ); void loadimage ( char * name, int i,int j); unsigned char ** tb; private: int nos_row; int nos_col; }; //----------------------------------------------------- // F O U R T A B L E //----------------------------------------------------- // this are just 3 copies of table correspponding to // d (diagonal), v (vertical ), h( horizontal ), and m (mixed) // // For simplicity we try not to use the C++ // inhereditance or subclass or.... //----------------------------------------------------- // // request ( stream, row, start_from, end_at ): // copy value from (row, start_from) to (row, end_at) // to stream. // // The format of output to stream is... // // a pixel of mixed, followed by a pixel of h, v, d. // each pixel is 3 bytes consisting red, green, blue. // That is... // // m_r m_g m_b v_r v_g v_b h_r h_g h_b d_r d_g d_b //----------------------------------------------------- // // As it is not yet clear whether the above format is better // or a seperate stream for each d,v,h,n,m or // even seperate stream for red, green, blue is better. // We will not implement other options. // //----------------------------------------------------- class four_table { public: four_table ( int level, int nos_row, int nos_col, char *basename ); ~four_table(); int request ( unsigned char *stream, int gap, int row, int st, int en ); table *v; table *d; table *h; table *m; private: void loadimage ( int i, int j ); char * mybasename; int nos_row; int nos_col; int mylevel; }; //-------------------------------------------------------- // C O E F //-------------------------------------------------------- // // keeping the coefficient (in memory and fiiles) // Basically using the class four_table. // // However, contain overall image information like total // number of level, width, height, etc... //-------------------------------------------------------- // // NOTE // request ( , ,reqlist) will destruct the linked list reqlist // after the call. // //-------------------------------------------------------- class coeff { public: coeff ( char *base_name ); coeff () { nos_level =0;} ~coeff(); // int request (unsigned char * mystream, int level, int st_row, int en_row, // int st_col, int en_col ); int request (unsigned char * mystream, int gap, int level, int row, item* reqlist); void getaverage ( unsigned char **); int Nos_Level () {return nos_level;} int Block_Size() {return BLOCK_SIZE;} private: four_table **table_list ; // //------------ h e a d e r f i l e i n f o -------------- int nos_level ; int image_width ; // equivalent to number of column int image_height ; // number of row void read_file_header (); // char *basename; }; #endif