Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef _TCM_H_
Toshihiro Shimizu 890ddd
#define _TCM_H_
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tmacro.h"
Toshihiro Shimizu 890ddd
#include "avl.h"
Toshihiro Shimizu 890ddd
/* TCM = toonz color map/mapping/mapped/manager */
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef struct
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
	/*UCHAR    tone_offs; sempre 0 */
Toshihiro Shimizu 890ddd
	UCHAR tone_bits;
Toshihiro Shimizu 890ddd
	UCHAR color_offs;
Toshihiro Shimizu 890ddd
	UCHAR color_bits;
Toshihiro Shimizu 890ddd
	UCHAR pencil_offs;
Toshihiro Shimizu 890ddd
	UCHAR pencil_bits;
Toshihiro Shimizu 890ddd
	USHORT offset_mask; /* fa allo stesso tempo sia da offset che da maschera */
Toshihiro Shimizu 890ddd
	USHORT default_val; /* da utilizzare, p.es., per pixel fuori dall'immagine */
Toshihiro Shimizu 890ddd
	short n_tones;
Toshihiro Shimizu 890ddd
	short n_colors;
Toshihiro Shimizu 890ddd
	short n_pencils;
Toshihiro Shimizu 890ddd
} TCM_INFO;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
static const TCM_INFO Tcm_old_default_info = {/*0,*/ 4, 4, 5, 9, 2,
Toshihiro Shimizu 890ddd
											  0x0800, 0x080f,
Toshihiro Shimizu 890ddd
											  16, 32, 4};
Toshihiro Shimizu 890ddd
static const TCM_INFO Tcm_new_default_info = {/*0,*/ 4, 4, 7, 11, 5,
Toshihiro Shimizu 890ddd
											  0x0000, 0x000f,
Toshihiro Shimizu 890ddd
											  16, 128, 32};
Toshihiro Shimizu 890ddd
static const TCM_INFO Tcm_24_default_info = {/*0,*/ 8, 8, 8, 16, 8,
Toshihiro Shimizu 890ddd
											 0x0000, 0x00ff,
Toshihiro Shimizu 890ddd
											 256, 256, 256};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TCM_TONE_MASK(TCM) \
Toshihiro Shimizu 890ddd
	((1U << (TCM).tone_bits) - 1U)
Toshihiro Shimizu 890ddd
#define TCM_COLOR_MASK(TCM) \
Toshihiro Shimizu 890ddd
	(((1U << (TCM).color_bits) - 1U) << (TCM).color_offs)
Toshihiro Shimizu 890ddd
#define TCM_PENCIL_MASK(TCM) \
Toshihiro Shimizu 890ddd
	(((1U << (TCM).pencil_bits) - 1U) << (TCM).pencil_offs)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TCM_COLOR_INDEX(TCM, ID) \
Toshihiro Shimizu 890ddd
	((ID) << (TCM).color_offs |  \
Toshihiro Shimizu 890ddd
	 ((TCM).n_tones - 1) | (TCM).offset_mask)
Toshihiro Shimizu 890ddd
#define TCM_PENCIL_INDEX(TCM, ID) \
Toshihiro Shimizu 890ddd
	((ID) << (TCM).pencil_offs | (TCM).offset_mask)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TCM_INDEX_IS_COLOR_ONLY(TCM, INDEX) \
Toshihiro Shimizu 890ddd
	(((INDEX)&TCM_TONE_MASK(TCM)) == TCM_TONE_MASK(TCM))
Toshihiro Shimizu 890ddd
#define TCM_INDEX_IS_PENCIL_ONLY(TCM, INDEX) \
Toshihiro Shimizu 890ddd
	(((INDEX)&TCM_TONE_MASK(TCM)) == 0)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TCM_COLOR_ID(TCM, INDEX) \
Toshihiro Shimizu 890ddd
	((int)(((INDEX) >> (TCM).color_offs) & ((1U << (TCM).color_bits) - 1U)))
Toshihiro Shimizu 890ddd
#define TCM_PENCIL_ID(TCM, INDEX) \
Toshihiro Shimizu 890ddd
	((int)(((INDEX) >> (TCM).pencil_offs) & ((1U << (TCM).pencil_bits) - 1U)))
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TCM_MIN_CMAP_BUFFER_SIZE(TCM)              \
Toshihiro Shimizu 890ddd
	((((TCM).n_pencils - 1) << (TCM).pencil_offs | \
Toshihiro Shimizu 890ddd
	  ((TCM).n_colors - 1) << (TCM).color_offs |   \
Toshihiro Shimizu 890ddd
	  (TCM).n_tones - 1) +                         \
Toshihiro Shimizu 890ddd
	 1)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TCM_MIN_CMAP_COLBUFFER_SIZE(TCM) \
Toshihiro Shimizu 890ddd
	((TCM).n_colors * (TCM).n_tones)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TCM_MIN_CMAP_PENBUFFER_SIZE(TCM) \
Toshihiro Shimizu 890ddd
	((TCM).n_pencils * (TCM).n_tones)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TCM_CMAP_BUFFER_SIZE(TCM) \
Toshihiro Shimizu 890ddd
	(1 << ((TCM).pencil_bits + (TCM).color_bits + (TCM).tone_bits))
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TCM_CMAP_COLBUFFER_SIZE(TCM) \
Toshihiro Shimizu 890ddd
	(1 << ((TCM).color_bits + (TCM).tone_bits))
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TCM_CMAP_PENBUFFER_SIZE(TCM) \
Toshihiro Shimizu 890ddd
	(1 << ((TCM).pencil_bits + (TCM).tone_bits))
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TREE *cdb_decode_all(char *names_in_plt_file, TCM_INFO tcm);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef struct
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
	int index;
Toshihiro Shimizu 890ddd
	char *group;
Toshihiro Shimizu 890ddd
	char *name;
Toshihiro Shimizu 890ddd
	char *accelerator;
Toshihiro Shimizu 890ddd
	int num_effects;
Toshihiro Shimizu 890ddd
	TREE *effects;
Toshihiro Shimizu 890ddd
} CDB_TREE_ITEM;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif