📄 kdu_sample_processing.h
字号:
// -------------------------------------------------------------------------- private: // Data -- should occupy 12 bytes on a 32-bit machine. int width; // Number of samples in buffer. bool absolute_ints; bool short_ints; bool pre_created; // True if `pre_create' called but `create' still pending bool active; union { kdu_sample32 *buf32; kdu_sample16 *buf16; kdu_sample_allocator *allocator; }; };/*****************************************************************************//* kdu_push_ifc_base *//*****************************************************************************/class kdu_push_ifc_base { protected: friend class kdu_push_ifc; virtual ~kdu_push_ifc_base() { return; } virtual void push(kdu_line_buf &line, bool allow_exchange) = 0; };/*****************************************************************************//* kdu_push_ifc *//*****************************************************************************/class kdu_push_ifc { /* All classes which support `push' calls derive from this class so that the caller may remain ignorant of the specific type of object to which samples are being delivered. The purpose of derivation is usually just to introduce the correct constructor. The objects are actually just interfaces to an object which is created by the constructor, which itself must be derived from the pure virtual base class, `kdu_push_ifc_base'. The interface directs push calls to the internal object in a manner which should incur no cost. The interface objects may be copied at will; the internal object will not be destroyed when an interface goes out of scope. Instead, to destroy the internal object, the `destroy' member function must be called explicitly. */ public: // Member functions kdu_push_ifc() { state = NULL; } void destroy() { if (state != NULL) delete state; state = NULL; } /* Automatically destroys all objects which were created by this object's constructor, including lower level DWT stages and block encoding objects. */ bool exists() { return (state==NULL)?false:true; } bool operator!() { return (state==NULL)?true:false; } kdu_push_ifc &operator=(kdu_analysis rhs); kdu_push_ifc &operator=(kdu_encoder rhs); void push(kdu_line_buf &line, bool allow_exchange=false) { /* Delivers all samples from the line buffer across the interface. If `allow_exchange' is true, the function is allowed to exchange the storage associated with the supplied `line' and an internal line. However, the two lines must have been allocated using the same `allocator' and they must have identical dimensions. This capability has the potential to fragment the memory and so both the caller and the implementor of this function should be careful to use it only when exchange is likely to be efficient. */ state->push(line,allow_exchange); } protected: // Data kdu_push_ifc_base *state; };/*****************************************************************************//* kdu_pull_ifc_base *//*****************************************************************************/class kdu_pull_ifc_base { protected: friend class kdu_pull_ifc; virtual ~kdu_pull_ifc_base() { return; } virtual void pull(kdu_line_buf &line, bool allow_exchange) = 0; };/*****************************************************************************//* kdu_pull_ifc *//*****************************************************************************/class kdu_pull_ifc { /* All classes which support `pull' calls derive from this class so that the caller may remain ignorant of the specific type of object from which samples are being retrieved. The purpose of derivation is usually just to introduce the correct constructor. The objects are actually just interfaces to an object which is created by the constructor, which itself must be derived from pure virtual base class, `kdu_pull_ifc_base'. The interface directs pull calls to this internal object in a manner which should incur no cost when compiled in release mode. These interface objects may be copied at will; the internal object will not be destroyed when an interface goes out of scope. Instead, to destroy the internal object, the `destroy' member function must be called explicitly. */ public: // Member functions kdu_pull_ifc() { state = NULL; } void destroy() { if (state != NULL) delete state; state = NULL; } /* Automatically destroys all objects which were created by this object's constructor, including lower level DWT stages and block encoding objects. */ bool exists() { return (state==NULL)?false:true; } bool operator!() { return (state==NULL)?true:false; } kdu_pull_ifc &operator=(kdu_synthesis rhs); kdu_pull_ifc &operator=(kdu_decoder rhs); void pull(kdu_line_buf &line, bool allow_exchange=false) { /* Fills out the line before returning. See comments associated with `kdu_push_ifc::push' regarding the `allow_exchange' option. */ state->pull(line,allow_exchange); } protected: // Data kdu_pull_ifc_base *state; };/*****************************************************************************//* kdu_analysis *//*****************************************************************************/class kdu_analysis : public kdu_push_ifc { /* Implements a single stage of 2D DWT analysis. */ public: // Member functions KDU_EXPORT kdu_analysis(kdu_resolution resolution, kdu_sample_allocator *allocator, bool use_shorts, float normalization=1.0F, kdu_roi_node *roi=NULL); /* Constructing an instance of this class for the highest visible resolution level of a tile-component, will cause the constructor to recursively create instances of the class for each successive DWT stage and also for the block encoding process. An `allocator' object whose `finalize()' member function has not yet been called must be supplied for pre-allocation of the various sample buffering arrays. This same allocator will be shared by the entire DWT tree and by the `kdu_encoder' objects at its leaves. `use_shorts' indicates whether 16-bit or 32-bit data representations are to be used. The same type of representation must be used throughput the DWT processing chain and line buffers pushed into the DWT engine must use this representation. The `normalization' argument will be ignored for reversibly transformed data. In the irreversible case, it indicates that the nominal range of data pushed into the `push' interface will be from -0.5*R to 0.5*R where R is the `normalization' factor. This capability is provided primarily to allow normalization steps to be skipped or approximated with simple powers of 2 during lifting implementations of the DWT; the factors can be folded into quantization step sizes. The best way to use the normalization argument will generally depend upon the implementation of the DWT. The `roi' argument, if non-NULL, provides an appropriately derived ROI node object which may be used to recover region of interest mask information for the present tile-component. In this case, the object will automatically construct an ROI processing tree to provide access to ROI information at the level of each individual subband. The `roi' object's `release' function will be called when the `analysis' object is destroyed -- possibly sooner (if it can be determined that ROI is no longer required). */ };/*****************************************************************************//* kdu_synthesis *//*****************************************************************************/class kdu_synthesis : public kdu_pull_ifc { /* Implements a single stage of 2D DWT synthesis. */ public: // Member functions KDU_EXPORT kdu_synthesis(kdu_resolution resolution, kdu_sample_allocator *allocator, bool use_shorts, float normalization=1.0F); /* Constructing an instance of this class for the highest visible resolution level of a tile-component, will cause the constructor to recursively create instances of the class for each successive DWT stage and also for the block decoding process. An `allocator' object whose `finalize()' member function has not yet been called must be supplied for pre-allocation of the various sample buffering arrays. This same allocator will be shared by the entire DWT tree and by the `kdu_encoder' objects at its leaves. `use_shorts' indicates whether 16-bit or 32-bit data representations are to be used. The same type of representation must be used throughput the DWT processing chain and line buffers pulled out of the DWT engine must use this representation. The `normalization' argument will be ignored for reversibly transformed data. In the irreversible case, it indicates that the nominal range of data pulled out of the `pull' interface should be from -0.5*R to 0.5*R, where R is the `normalization' factor. This capability is provided primarily to allow normalization steps to be skipped or approximated with simple powers of 2 during lifting implementations of the DWT; the factors can be folded into quantization step sizes. The best way to use the normalization argument will generally depend upon the implementation of the DWT. */ };/*****************************************************************************//* kdu_encoder *//*****************************************************************************/class kdu_encoder: public kdu_push_ifc { /* Implements the block encoding for a single subband, inside a single tile-component. */ public: // Member functions KDU_EXPORT kdu_encoder(kdu_subband subband, kdu_sample_allocator *allocator, bool use_shorts, float normalization=1.0F, kdu_roi_node *roi=NULL); /* Informs the encoder that data supplied via its `push' interface will have a nominal range from -0.5*R to +0.5*R where R is the value of `normalization'. The `roi' argument, if non-NULL, provides an appropriately derived `kdu_roi_node' object whose `pull' interface may be used to recover ROI mask information for this subband. Its `release' function will be called when the encoder is destroyed -- possibly sooner, if it can be determined that ROI information is no longer required. */ };/*****************************************************************************//* kdu_decoder *//*****************************************************************************/class kdu_decoder: public kdu_pull_ifc { /* Implements the block decoding for a single subband, inside a single tile-component. */ public: // Member functions KDU_EXPORT kdu_decoder(kdu_subband subband, kdu_sample_allocator *allocator, bool use_shorts, float normalization=1.0F); /* Informs the decoder that data retrieved via its `pull' interface should have a nominal range from -0.5*R to +0.5*R, where R is the value of `normalization'. */ };/*****************************************************************************//* Base Casting Assignment Operators *//*****************************************************************************/inline kdu_push_ifc &kdu_push_ifc::operator=(kdu_analysis rhs) { state = rhs.state; return *this; }inline kdu_push_ifc &kdu_push_ifc::operator=(kdu_encoder rhs) { state = rhs.state; return *this; }inline kdu_pull_ifc &kdu_pull_ifc::operator=(kdu_synthesis rhs) { state = rhs.state; return *this; }inline kdu_pull_ifc &kdu_pull_ifc::operator=(kdu_decoder rhs) { state = rhs.state; return *this; }/* ========================================================================= *//* External Function Declarations *//* ========================================================================= */extern KDU_EXPORT void kdu_convert_rgb_to_ycc(kdu_line_buf &c1, kdu_line_buf &c2, kdu_line_buf &c3); /* The line buffers must be compatible with respect to dimensions and data type. The forward ICT (RGB to YCbCr transform) is performed if the data is normalized (i.e. `frac_bits' non-zero). Otherwise, the RCT is performed. */extern KDU_EXPORT void kdu_convert_ycc_to_rgb(kdu_line_buf &c1, kdu_line_buf &c2, kdu_line_buf &c3, int width=-1); /* Inverts the effects of the forward transform above. If `width' is negative, the number of samples in each line is determined from the line buffers themselves. Otherwise, only `width' samples are actually processed. */#endif // KDU_SAMPLE_PROCESSING
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -