Go to the documentation of this file.
9 #ifndef HAS_LIVES_COLOURSPACE_H
10 #define HAS_LIVES_COLOURSPACE_H
12 #ifdef USE_16BIT_PCONV
18 #define WEED_LEAF_CLIP "clip"
19 #define WEED_LEAF_FRAME "frame"
20 #define WEED_LEAF_HOST_PIXEL_DATA_CONTIGUOUS "host_contiguous"
21 #define WEED_LEAF_HOST_PIXBUF_SRC "host_pixbuf_src"
22 #define WEED_LEAF_HOST_SURFACE_SRC "host_surface_src"
23 #define WEED_LEAF_PIXEL_BITS "pixel_bits"
24 #define WEED_LEAF_HOST_FLAGS "host_flags"
25 #define WEED_LEAF_RESIZE_THREAD "res_thread"
26 #define WEED_LEAF_PROGSCAN "progscan"
28 #define DEF_SCREEN_GAMMA 1.4 // extra gammm boost
38 #define SCALE_FACTOR 65793.
40 #define SCALE_FACTOR (1 << FP_BITS)
43 #define KR_YCBCR 0.2989
44 #define KB_YCBCR 0.114
49 #define KR_BT709 0.2126
50 #define KB_BT709 0.0722
52 #define KR_BT2020 0.2627
53 #define KB_BT2020 0.0593
55 #define YUV_CLAMP_MIN 16.
56 #define YUV_CLAMP_MINI 16
58 #define Y_CLAMP_MAX 235.
59 #define Y_CLAMP_MAXI 235
61 #define UV_CLAMP_MAX 240.
62 #define UV_CLAMP_MAXI 240
64 #define CLAMP_FACTOR_Y ((Y_CLAMP_MAX-YUV_CLAMP_MIN)/255.) // unclamped -> clamped
65 #define CLAMP_FACTOR_UV ((UV_CLAMP_MAX-YUV_CLAMP_MIN)/255.) // unclamped -> clamped
69 #define MAX_THREADS 65536
129 #include <libswscale/swscale.h>
137 struct SwsContext *swscale;
138 const uint8_t *ipd[4];
139 const uint8_t *opd[4];
147 void rgb2hsv(uint8_t r, uint8_t g, uint8_t b,
double *h,
double *s,
double *v);
148 void hsv2rgb(
double h,
double s,
double v, uint8_t *r, uint8_t *g, uint8_t *b);
149 boolean pick_nice_colour(uint8_t r0, uint8_t g0, uint8_t b0, uint8_t *r1, uint8_t *g1, uint8_t *b1,
150 double max,
double lmin,
double lmax);
152 double cdist94(uint8_t r0, uint8_t g0, uint8_t b0, uint8_t r1, uint8_t g1, uint8_t b1);
154 #ifdef WEED_ADVANCED_PALETTES
155 #define LIVES_VCHAN_grey 2048
156 #define LIVES_VCHAN_mono_b 2049
157 #define LIVES_VCHAN_mono_w 2050
159 #define LIVES_VCHAN_cc 3000
160 #define LIVES_VCHAN_mm 3001
161 #define LIVES_VCHAN_yy 3002
162 #define LIVES_VCHAN_kk 3003
164 #define LIVES_VCHAN_xxx 4000
165 #define LIVES_VCHAN_yyy 4001
166 #define LIVES_VCHAN_zzz 4002
168 #define LIVES_VCHAN_hh 4000
169 #define LIVES_VCHAN_ss 4001
170 #define LIVES_VCHAN_vv 4002
173 #define LIVES_PALETTE_ABGR32 6
174 #define LIVES_PALETTE_YUV121010 8211
175 #define LIVES_PALETTE_RGB48 9001
176 #define LIVES_PALETTE_RGBA64 9003
177 #define LIVES_PALETTE_YUVA420P 9512
178 #define LIVES_PALETTE_YVU422P 9522
179 #define LIVES_PALETTE_AYUV8888 9545
180 #define LIVES_PALETTE_YUVFLOAT 9564
181 #define LIVES_PALETTE_YUVAFLOAT 9565
212 double get_luma8(uint8_t r, uint8_t g, uint8_t b);
213 double get_luma16(uint16_t r, uint16_t g, uint16_t b);
217 #define WEED_PLANT_LAYER 128
219 #define WEED_LEAF_LAYER_TYPE "layer_type"
220 #define WEED_LAYER_TYPE_NONE 0
221 #define WEED_LAYER_TYPE_VIDEO 1
222 #define WEED_LAYER_TYPE_AUDIO 2
224 #define WEED_IS_LAYER(plant) (weed_plant_get_type(plant) == WEED_PLANT_LAYER)
231 int YUV_clamping,
int YUV_sampling,
int YUV_subspace,
int gamma_type);
253 #define WEED_GAMMA_MONITOR 1024
254 #define WEED_GAMMA_FILE 1025
255 #define WEED_GAMMA_VARIANT 2048
256 #define WEED_LAYER_ALPHA_PREMULT 1
259 #define LIVES_LAYER_LOAD_IF_NEEDS_RESIZE 1
260 #define LIVES_LAYER_GET_SIZE_ONLY 2
263 #define LIVES_LAYER_HAS_SIZE_NOW (1 << 16)
271 int width,
int height,
boolean may_thread);
279 boolean resize_layer(
weed_layer_t *,
int width,
int height, LiVESInterpType interp,
int opal_hint,
int oclamp_hint);
296 #define weed_palette_is_pixbuf_palette(pal) ((pal == WEED_PALETTE_RGB24 || pal == WEED_PALETTE_RGBA32) ? TRUE : FALSE)
void init_conversions(int intent)
boolean pick_nice_colour(uint8_t r0, uint8_t g0, uint8_t b0, uint8_t *r1, uint8_t *g1, uint8_t *b1, double max, double lmin, double lmax)
int weed_layer_get_gamma(weed_layer_t *)
int weed_layer_is_audio(weed_layer_t *)
weed_layer_t * weed_layer_set_palette(weed_layer_t *, int palette)
functions all return the input layer for convenience; no checking for valid values is done if layer i...
boolean gamma_convert_layer(int gamma_type, weed_layer_t *)
int weed_layer_get_audio_rate(weed_layer_t *layer)
boolean gamma_convert_layer_variant(double file_gamma, int tgamma, weed_layer_t *)
weed_layer_t * weed_layer_set_pixel_data(weed_layer_t *, void **pixel_data, int nplanes)
lives_painter_t * layer_to_lives_painter(weed_layer_t *)
convert a weed layer to lives_painter (a.k.a cairo)
boolean lives_pixbuf_is_all_black(LiVESPixbuf *pixbuf)
LIVES_GLOBAL_INLINE int get_simple_palette(weed_macropixel_t *mpx)
weed_layer_t * weed_layer_set_rowstride(weed_layer_t *, int rowstride)
int weed_layer_get_flags(weed_layer_t *)
frames_t lives_layer_get_frame(weed_layer_t *)
weed_layer_t * lives_layer_new_for_frame(int clip, frames_t frame)
double cdist94(uint8_t r0, uint8_t g0, uint8_t b0, uint8_t r1, uint8_t g1, uint8_t b1)
int * weed_layer_get_rowstrides(weed_layer_t *, int *nplanes)
weed_layer_t * create_blank_layer(weed_layer_t *, const char *image_ext, int width, int height, int target_palette)
fills layer with default values.
LIVES_GLOBAL_INLINE int weed_palette_get_nplanes(int pal)
LIVES_GLOBAL_INLINE int weed_palette_get_alpha_offset(int pal)
int weed_layer_get_palette_yuv(weed_layer_t *, int *clamping, int *sampling, int *subspace)
void ** weed_layer_get_pixel_data(weed_layer_t *, int *nplanes)
LIVES_GLOBAL_INLINE size_t pixel_size(int pal)
weed_layer_t * weed_layer_set_pixel_data_packed(weed_layer_t *, void *pixel_data)
weed_layer_t * weed_layer_set_size(weed_layer_t *, int width, int height)
int weed_layer_is_video(weed_layer_t *)
LIVES_GLOBAL_INLINE boolean weed_palette_is_alpha(int pal)
weed_layer_t * weed_layer_create(int width, int height, int *rowstrides, int current_palette)
create a layer, setting the most important properties
weed_layer_t * weed_layer_set_audio_data(weed_layer_t *, float **data, int arate, int naudchans, weed_size_t nsamps)
weed_layer_t * weed_layer_set_yuv_sampling(weed_layer_t *, int sampling)
boolean lives_painter_to_layer(lives_painter_t *cairo, weed_layer_t *)
convert a lives_painter_t (a.k.a) cairo_t to a weed layer
LiVESPixbuf * layer_to_pixbuf(weed_layer_t *, boolean realpalette, boolean fordisp)
void lives_layer_set_frame(weed_layer_t *, frames_t frame)
LIVES_GLOBAL_INLINE int weed_palette_get_alpha_plane(int pal)
LIVES_GLOBAL_INLINE boolean weed_palette_red_first(int pal)
boolean gamma_convert_sub_layer(int gamma_type, double fileg, weed_layer_t *, int x, int y, int width, int height, boolean may_thread)
alter the transfer function of a Weed layer, from current value to gamma_type
weed_layer_t * weed_layer_free(weed_layer_t *)
frees pixel_data for a layer, then the layer itself
boolean convert_layer_palette_with_sampling(weed_layer_t *, int outpl, int out_sampling)
weed_layer_t * weed_layer_set_yuv_subspace(weed_layer_t *, int subspace)
void lives_pixbuf_set_opaque(LiVESPixbuf *pixbuf)
LIVES_GLOBAL_INLINE boolean weed_palette_is_yuv(int pal)
weed_layer_t * weed_layer_set_width(weed_layer_t *, int width)
width in macropixels of the layer palette
boolean weed_palette_is_lower_quality(int p1, int p2)
void init_colour_engine(void)
LIVES_GLOBAL_INLINE boolean weed_palette_is_valid(int pal)
LIVES_GLOBAL_INLINE boolean weed_palette_is_rgb(int pal)
LIVES_GLOBAL_INLINE const weed_macropixel_t * get_advanced_palette(int weed_palette)
LIVES_GLOBAL_INLINE boolean weed_palette_is_float(int pal)
int weed_layer_get_width_pixels(weed_layer_t *)
int resize_all(int fileno, int width, int height, lives_img_type_t imgtype, boolean do_back, int *nbad, int *nmiss)
utility funcs for GUI
weed_layer_t * weed_layer_copy(weed_layer_t *dlayer, weed_layer_t *slayer)
copy source layer slayer to dest layer dlayer
weed_layer_t * weed_layer_set_rowstrides(weed_layer_t *, int *rowstrides, int nplanes)
double get_luma8(uint8_t r, uint8_t g, uint8_t b)
int weed_layer_get_naudchans(weed_layer_t *layer)
weed_layer_t * weed_layer_set_height(weed_layer_t *, int height)
LIVES_GLOBAL_INLINE boolean weed_palettes_rbswapped(int pal0, int pal1)
int weed_layer_get_yuv_sampling(weed_layer_t *)
weed_layer_t * weed_layer_new(int layer_type)
boolean resize_layer(weed_layer_t *, int width, int height, LiVESInterpType interp, int opal_hint, int oclamp_hint)
widths in PIXELS
LIVES_GLOBAL_INLINE boolean weed_palette_has_alpha(int pal)
boolean create_empty_pixel_data(weed_layer_t *, boolean black_fill, boolean may_contig)
layer should be pre-set with palette, width in MACROPIXELS, and height gamma_type will be set WEED_GA...
_palette * palette
interface colour settings
int weed_layer_ref(weed_layer_t *)
int weed_layer_get_yuv_subspace(weed_layer_t *)
boolean convert_layer_palette_full(weed_layer_t *, int outpl, int oclamping, int osampling, int osubspace, int tgamma)
convert the palette of a layer
void weed_layer_pixel_data_free(weed_layer_t *)
free pixel_data from layer
weed_layer_t * weed_layer_set_palette_yuv(weed_layer_t *, int palette, int clamping, int sampling, int subspace)
void hsv2rgb(double h, double s, double v, uint8_t *r, uint8_t *g, uint8_t *b)
LIVES_GLOBAL_INLINE double weed_palette_get_plane_ratio_vertical(int pal, int plane)
LIVES_GLOBAL_INLINE boolean weed_palette_has_alpha_last(int pal)
weed_plant_t weed_layer_t
void lives_layer_set_opaque(weed_layer_t *)
boolean pixbuf_to_layer(weed_layer_t *, LiVESPixbuf *) WARN_UNUSED
turn a (Gdk)Pixbuf into a Weed layer
boolean copy_pixel_data(weed_layer_t *dst, weed_layer_t *src_or_null, size_t alignment)
void alpha_unpremult(weed_layer_t *, boolean un)
(un)premultply alpha using a lookup table
float ** weed_layer_get_audio_data(weed_layer_t *, int *naudchans)
LIVES_GLOBAL_INLINE boolean weed_palette_has_alpha_first(int pal)
boolean letterbox_layer(weed_layer_t *, int nwidth, int nheight, int width, int height, LiVESInterpType interp, int tpal, int tclamp)
boolean convert_layer_palette(weed_layer_t *, int outpl, int op_clamping)
boolean rowstrides_differ(int n1, int *n1_array, int n2, int *n2_array)
boolean compact_rowstrides(weed_layer_t *)
void lives_layer_set_clip(weed_layer_t *, int clip)
void gamma_conv_params(int gamma_type, weed_layer_t *inst, boolean is_in)
boolean weed_palette_is_painter_palette(int pal)
int weed_layer_get_yuv_clamping(weed_layer_t *)
int weed_layer_get_height(weed_layer_t *)
int weed_layer_unref(weed_layer_t *)
weed_layer_t * weed_layer_nullify_pixel_data(weed_layer_t *)
LIVES_GLOBAL_INLINE double weed_palette_get_plane_ratio_horizontal(int pal, int plane)
double get_luma16(uint16_t r, uint16_t g, uint16_t b)
boolean consider_swapping(int *inpal, int *outpal)
look for shortcuts in palette conversions instead of converting e.g RGB -> BGRA, we may be able to pr...
weed_layer_t * weed_layer_set_yuv_clamping(weed_layer_t *, int clamping)
int weed_layer_get_palette(weed_layer_t *)
int weed_layer_get_audio_length(weed_layer_t *layer)
void pixel_data_planar_from_membuf(void **pixel_data, void *data, size_t size, int palette, boolean dest_contig)
int32_t round_special(int32_t val)
int weed_layer_get_width(weed_layer_t *)
int weed_layer_get_rowstride(weed_layer_t *)
for packed palettes
uint8_t * weed_layer_get_pixel_data_packed(weed_layer_t *)
LIVES_GLOBAL_INLINE int weed_palette_get_pixels_per_macropixel(int pal)
LIVES_GLOBAL_INLINE int weed_palette_get_bits_per_macropixel(int pal)
void rgb2hsv(uint8_t r, uint8_t g, uint8_t b, double *h, double *s, double *v)
int lives_layer_get_clip(weed_layer_t *)
weed_layer_t * weed_layer_create_full(int width, int height, int *rowstrides, int current_palette, int YUV_clamping, int YUV_sampling, int YUV_subspace, int gamma_type)
weed_layer_t * weed_layer_set_gamma(weed_layer_t *, int gamma_type)
weed_layer_t * weed_layer_set_flags(weed_layer_t *, int flags)