#ifndef CSPACE_H
#define CSPACE_H

#include <v_lib.h>
#include "eval.h"
#include "iplmath.h"

/* the RGB and RGBA are the same */
#define IPL_MAX_COLOR_SPACES    3

#define IPL_MAX_COLOR_CHANNELS  4

/* 1st index in image_input_t->spaces */
#define CSPACE_RGB_OFFSET   0
#define CSPACE_HSV_OFFSET   1
#define CSPACE_CIE_OFFSET   2

typedef struct cspace_desc_s
{
    char_p  *key_ptr;
    u32_t   cspace_offset;
    u32_t   components;
    char_p  *channel_names[IPL_MAX_COLOR_CHANNELS];
    char_p  *desc_ptr;
    void    (*rgba_from_native)(matrix_p rgba[],matrix_p native[]); /* can be NULL */
    void    (*native_from_rgba)(matrix_p native[],matrix_p rgba[]); /* can be NULL */
}   cspace_desc_t, *cspace_desc_p;

typedef struct image_input_s
{
    char        *id;
    matrix_p    spaces[IPL_MAX_COLOR_SPACES][IPL_MAX_COLOR_CHANNELS];
}   image_input_t, *image_input_p;

matrix_p cspaceGetMatrix(char *image_name,char *channel_id);

vboolean cspaceEvalOutput(vhandle_t script);

void cspaceCollectGarbage(void);

void cspaceListSpaces(void);
void cspaceListChannels(void);

#endif  /* CSPACE_H */
