LiVES  3.2.0
Data Structures | Macros | Typedefs | Functions
colourspace.h File Reference

Go to the source code of this file.

Data Structures

struct  gamma_const_t
 
struct  uyvy_macropixel
 
struct  yuyv_macropixel
 
struct  yuv411_macropixel
 
struct  lives_cc_params
 

Macros

#define WEED_LEAF_CLIP   "clip"
 
#define WEED_LEAF_FRAME   "frame"
 
#define WEED_LEAF_HOST_PIXEL_DATA_CONTIGUOUS   "host_contiguous"
 
#define WEED_LEAF_HOST_PIXBUF_SRC   "host_pixbuf_src"
 
#define WEED_LEAF_HOST_SURFACE_SRC   "host_surface_src"
 
#define WEED_LEAF_PIXEL_BITS   "pixel_bits"
 
#define WEED_LEAF_HOST_FLAGS   "host_flags"
 
#define WEED_LEAF_RESIZE_THREAD   "res_thread"
 
#define WEED_LEAF_PROGSCAN   "progscan"
 
#define DEF_SCREEN_GAMMA   1.4
 
#define ALIGN_MIN   4
 rowstride alignment values More...
 
#define ALIGN_DEF   16
 
#define FP_BITS   16
 
#define SCALE_FACTOR   (1 << FP_BITS)
 
#define KR_YCBCR   0.2989
 
#define KB_YCBCR   0.114
 
#define KR_I240   0.212
 
#define KB_I240   0.087
 
#define KR_BT709   0.2126
 
#define KB_BT709   0.0722
 
#define KR_BT2020   0.2627
 
#define KB_BT2020   0.0593
 
#define YUV_CLAMP_MIN   16.
 
#define YUV_CLAMP_MINI   16
 
#define Y_CLAMP_MAX   235.
 
#define Y_CLAMP_MAXI   235
 
#define UV_CLAMP_MAX   240.
 
#define UV_CLAMP_MAXI   240
 
#define CLAMP_FACTOR_Y   ((Y_CLAMP_MAX-YUV_CLAMP_MIN)/255.)
 
#define CLAMP_FACTOR_UV   ((UV_CLAMP_MAX-YUV_CLAMP_MIN)/255.)
 
#define UV_BIAS   128.
 
#define MAX_THREADS   65536
 
#define WEED_PLANT_LAYER   128
 
#define WEED_LEAF_LAYER_TYPE   "layer_type"
 
#define WEED_LAYER_TYPE_NONE   0
 
#define WEED_LAYER_TYPE_VIDEO   1
 
#define WEED_LAYER_TYPE_AUDIO   2
 
#define WEED_IS_LAYER(plant)   (weed_plant_get_type(plant) == WEED_PLANT_LAYER)
 
#define WEED_GAMMA_MONITOR   1024
 
#define WEED_GAMMA_FILE   1025
 
#define WEED_GAMMA_VARIANT   2048
 
#define WEED_LAYER_ALPHA_PREMULT   1
 
#define LIVES_LAYER_LOAD_IF_NEEDS_RESIZE   1
 private flags More...
 
#define LIVES_LAYER_GET_SIZE_ONLY   2
 
#define LIVES_LAYER_HAS_SIZE_NOW   (1 << 16)
 
#define weed_palette_is_pixbuf_palette(pal)   ((pal == WEED_PALETTE_RGB24 || pal == WEED_PALETTE_RGBA32) ? TRUE : FALSE)
 

Typedefs

typedef weed_plant_t weed_layer_t
 

Functions

void rgb2hsv (uint8_t r, uint8_t g, uint8_t b, double *h, double *s, double *v)
 
void hsv2rgb (double h, double s, double v, uint8_t *r, uint8_t *g, uint8_t *b)
 
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)
 
double cdist94 (uint8_t r0, uint8_t g0, uint8_t b0, uint8_t r1, uint8_t g1, uint8_t b1)
 
int32_t round_special (int32_t val)
 
void init_conversions (int intent)
 
void init_colour_engine (void)
 
double get_luma8 (uint8_t r, uint8_t g, uint8_t b)
 
double get_luma16 (uint16_t r, uint16_t g, uint16_t b)
 
weed_layer_tweed_layer_new (int layer_type)
 
weed_layer_tcreate_blank_layer (weed_layer_t *, const char *image_ext, int width, int height, int target_palette)
 fills layer with default values. More...
 
weed_layer_tweed_layer_create (int width, int height, int *rowstrides, int current_palette)
 create a layer, setting the most important properties More...
 
weed_layer_tweed_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_tweed_layer_copy (weed_layer_t *dlayer, weed_layer_t *slayer)
 copy source layer slayer to dest layer dlayer More...
 
weed_layer_tweed_layer_free (weed_layer_t *)
 frees pixel_data for a layer, then the layer itself More...
 
int weed_layer_unref (weed_layer_t *)
 
int weed_layer_ref (weed_layer_t *)
 
weed_layer_tlives_layer_new_for_frame (int clip, frames_t frame)
 
void lives_layer_set_clip (weed_layer_t *, int clip)
 
void lives_layer_set_frame (weed_layer_t *, frames_t frame)
 
int lives_layer_get_clip (weed_layer_t *)
 
frames_t lives_layer_get_frame (weed_layer_t *)
 
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_GAMMA_SRGB, old pixel_data will not be freed. More...
 
void pixel_data_planar_from_membuf (void **pixel_data, void *data, size_t size, int palette, boolean dest_contig)
 
void weed_layer_pixel_data_free (weed_layer_t *)
 free pixel_data from layer More...
 
void alpha_unpremult (weed_layer_t *, boolean un)
 (un)premultply alpha using a lookup table More...
 
boolean copy_pixel_data (weed_layer_t *dst, weed_layer_t *src_or_null, size_t alignment)
 
boolean gamma_convert_layer (int gamma_type, weed_layer_t *)
 
boolean gamma_convert_layer_variant (double file_gamma, int tgamma, weed_layer_t *)
 
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 More...
 
boolean convert_layer_palette (weed_layer_t *, int outpl, int op_clamping)
 
boolean convert_layer_palette_with_sampling (weed_layer_t *, int outpl, int out_sampling)
 
boolean convert_layer_palette_full (weed_layer_t *, int outpl, int oclamping, int osampling, int osubspace, int tgamma)
 convert the palette of a layer More...
 
void lives_layer_set_opaque (weed_layer_t *)
 
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 pretend that the input palette is BGR and thus the conversion to BGRA is slightly cheaper we can do this provided the caller can take into account that the red / blue components are now swapped. More...
 
boolean resize_layer (weed_layer_t *, int width, int height, LiVESInterpType interp, int opal_hint, int oclamp_hint)
 widths in PIXELS More...
 
boolean letterbox_layer (weed_layer_t *, int nwidth, int nheight, int width, int height, LiVESInterpType interp, int tpal, int tclamp)
 
boolean compact_rowstrides (weed_layer_t *)
 
void gamma_conv_params (int gamma_type, weed_layer_t *inst, boolean is_in)
 
boolean weed_palette_is_lower_quality (int p1, int p2)
 
boolean rowstrides_differ (int n1, int *n1_array, int n2, int *n2_array)
 
boolean weed_palette_is_painter_palette (int pal)
 
lives_painter_t * layer_to_lives_painter (weed_layer_t *)
 convert a weed layer to lives_painter (a.k.a cairo) More...
 
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 More...
 
boolean lives_pixbuf_is_all_black (LiVESPixbuf *pixbuf)
 
void lives_pixbuf_set_opaque (LiVESPixbuf *pixbuf)
 
LiVESPixbuf * layer_to_pixbuf (weed_layer_t *, boolean realpalette, boolean fordisp)
 
boolean pixbuf_to_layer (weed_layer_t *, LiVESPixbuf *) WARN_UNUSED
 turn a (Gdk)Pixbuf into a Weed layer More...
 
int weed_layer_is_video (weed_layer_t *)
 
int weed_layer_is_audio (weed_layer_t *)
 
int weed_layer_get_palette (weed_layer_t *)
 
int weed_layer_get_palette_yuv (weed_layer_t *, int *clamping, int *sampling, int *subspace)
 
int weed_layer_get_yuv_clamping (weed_layer_t *)
 
int weed_layer_get_yuv_sampling (weed_layer_t *)
 
int weed_layer_get_yuv_subspace (weed_layer_t *)
 
uint8_t * weed_layer_get_pixel_data_packed (weed_layer_t *)
 
void ** weed_layer_get_pixel_data (weed_layer_t *, int *nplanes)
 
float ** weed_layer_get_audio_data (weed_layer_t *, int *naudchans)
 
int weed_layer_get_audio_rate (weed_layer_t *layer)
 
int weed_layer_get_naudchans (weed_layer_t *layer)
 
int weed_layer_get_audio_length (weed_layer_t *layer)
 
int * weed_layer_get_rowstrides (weed_layer_t *, int *nplanes)
 
int weed_layer_get_rowstride (weed_layer_t *)
 for packed palettes More...
 
int weed_layer_get_width (weed_layer_t *)
 
int weed_layer_get_width_pixels (weed_layer_t *)
 
int weed_layer_get_height (weed_layer_t *)
 
int weed_layer_get_gamma (weed_layer_t *)
 
int weed_layer_get_flags (weed_layer_t *)
 
weed_layer_tweed_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 is NULL or not weed_layer then NULL is returned More...
 
weed_layer_tweed_layer_set_palette_yuv (weed_layer_t *, int palette, int clamping, int sampling, int subspace)
 
weed_layer_tweed_layer_set_yuv_clamping (weed_layer_t *, int clamping)
 
weed_layer_tweed_layer_set_yuv_sampling (weed_layer_t *, int sampling)
 
weed_layer_tweed_layer_set_yuv_subspace (weed_layer_t *, int subspace)
 
weed_layer_tweed_layer_set_gamma (weed_layer_t *, int gamma_type)
 
weed_layer_tweed_layer_set_width (weed_layer_t *, int width)
 width in macropixels of the layer palette More...
 
weed_layer_tweed_layer_set_height (weed_layer_t *, int height)
 
weed_layer_tweed_layer_set_size (weed_layer_t *, int width, int height)
 
weed_layer_tweed_layer_set_rowstrides (weed_layer_t *, int *rowstrides, int nplanes)
 
weed_layer_tweed_layer_set_rowstride (weed_layer_t *, int rowstride)
 
weed_layer_tweed_layer_set_flags (weed_layer_t *, int flags)
 
weed_layer_tweed_layer_set_pixel_data (weed_layer_t *, void **pixel_data, int nplanes)
 
weed_layer_tweed_layer_set_pixel_data_packed (weed_layer_t *, void *pixel_data)
 
weed_layer_tweed_layer_nullify_pixel_data (weed_layer_t *)
 
weed_layer_tweed_layer_set_audio_data (weed_layer_t *, float **data, int arate, int naudchans, weed_size_t nsamps)
 
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 More...
 

Macro Definition Documentation

◆ ALIGN_DEF

#define ALIGN_DEF   16

Definition at line 32 of file colourspace.h.

◆ ALIGN_MIN

#define ALIGN_MIN   4

rowstride alignment values

Definition at line 31 of file colourspace.h.

◆ CLAMP_FACTOR_UV

#define CLAMP_FACTOR_UV   ((UV_CLAMP_MAX-YUV_CLAMP_MIN)/255.)

Definition at line 65 of file colourspace.h.

◆ CLAMP_FACTOR_Y

#define CLAMP_FACTOR_Y   ((Y_CLAMP_MAX-YUV_CLAMP_MIN)/255.)

Definition at line 64 of file colourspace.h.

◆ DEF_SCREEN_GAMMA

#define DEF_SCREEN_GAMMA   1.4

Definition at line 28 of file colourspace.h.

◆ FP_BITS

#define FP_BITS   16

Definition at line 35 of file colourspace.h.

◆ KB_BT2020

#define KB_BT2020   0.0593

Definition at line 53 of file colourspace.h.

◆ KB_BT709

#define KB_BT709   0.0722

Definition at line 50 of file colourspace.h.

◆ KB_I240

#define KB_I240   0.087

Definition at line 47 of file colourspace.h.

◆ KB_YCBCR

#define KB_YCBCR   0.114

Definition at line 44 of file colourspace.h.

◆ KR_BT2020

#define KR_BT2020   0.2627

Definition at line 52 of file colourspace.h.

◆ KR_BT709

#define KR_BT709   0.2126

Definition at line 49 of file colourspace.h.

◆ KR_I240

#define KR_I240   0.212

Definition at line 46 of file colourspace.h.

◆ KR_YCBCR

#define KR_YCBCR   0.2989

Definition at line 43 of file colourspace.h.

◆ LIVES_LAYER_GET_SIZE_ONLY

#define LIVES_LAYER_GET_SIZE_ONLY   2

Definition at line 260 of file colourspace.h.

◆ LIVES_LAYER_HAS_SIZE_NOW

#define LIVES_LAYER_HAS_SIZE_NOW   (1 << 16)

Definition at line 263 of file colourspace.h.

◆ LIVES_LAYER_LOAD_IF_NEEDS_RESIZE

#define LIVES_LAYER_LOAD_IF_NEEDS_RESIZE   1

private flags

Definition at line 259 of file colourspace.h.

◆ MAX_THREADS

#define MAX_THREADS   65536

Definition at line 69 of file colourspace.h.

◆ SCALE_FACTOR

#define SCALE_FACTOR   (1 << FP_BITS)

Definition at line 40 of file colourspace.h.

◆ UV_BIAS

#define UV_BIAS   128.

Definition at line 67 of file colourspace.h.

◆ UV_CLAMP_MAX

#define UV_CLAMP_MAX   240.

Definition at line 61 of file colourspace.h.

◆ UV_CLAMP_MAXI

#define UV_CLAMP_MAXI   240

Definition at line 62 of file colourspace.h.

◆ WEED_GAMMA_FILE

#define WEED_GAMMA_FILE   1025

Definition at line 254 of file colourspace.h.

◆ WEED_GAMMA_MONITOR

#define WEED_GAMMA_MONITOR   1024

Definition at line 253 of file colourspace.h.

◆ WEED_GAMMA_VARIANT

#define WEED_GAMMA_VARIANT   2048

Definition at line 255 of file colourspace.h.

◆ WEED_IS_LAYER

#define WEED_IS_LAYER (   plant)    (weed_plant_get_type(plant) == WEED_PLANT_LAYER)

Definition at line 224 of file colourspace.h.

◆ WEED_LAYER_ALPHA_PREMULT

#define WEED_LAYER_ALPHA_PREMULT   1

Definition at line 256 of file colourspace.h.

◆ WEED_LAYER_TYPE_AUDIO

#define WEED_LAYER_TYPE_AUDIO   2

Definition at line 222 of file colourspace.h.

◆ WEED_LAYER_TYPE_NONE

#define WEED_LAYER_TYPE_NONE   0

Definition at line 220 of file colourspace.h.

◆ WEED_LAYER_TYPE_VIDEO

#define WEED_LAYER_TYPE_VIDEO   1

Definition at line 221 of file colourspace.h.

◆ WEED_LEAF_CLIP

#define WEED_LEAF_CLIP   "clip"

Definition at line 18 of file colourspace.h.

◆ WEED_LEAF_FRAME

#define WEED_LEAF_FRAME   "frame"

Definition at line 19 of file colourspace.h.

◆ WEED_LEAF_HOST_FLAGS

#define WEED_LEAF_HOST_FLAGS   "host_flags"

Definition at line 24 of file colourspace.h.

◆ WEED_LEAF_HOST_PIXBUF_SRC

#define WEED_LEAF_HOST_PIXBUF_SRC   "host_pixbuf_src"

Definition at line 21 of file colourspace.h.

◆ WEED_LEAF_HOST_PIXEL_DATA_CONTIGUOUS

#define WEED_LEAF_HOST_PIXEL_DATA_CONTIGUOUS   "host_contiguous"

Definition at line 20 of file colourspace.h.

◆ WEED_LEAF_HOST_SURFACE_SRC

#define WEED_LEAF_HOST_SURFACE_SRC   "host_surface_src"

Definition at line 22 of file colourspace.h.

◆ WEED_LEAF_LAYER_TYPE

#define WEED_LEAF_LAYER_TYPE   "layer_type"

Definition at line 219 of file colourspace.h.

◆ WEED_LEAF_PIXEL_BITS

#define WEED_LEAF_PIXEL_BITS   "pixel_bits"

Definition at line 23 of file colourspace.h.

◆ WEED_LEAF_PROGSCAN

#define WEED_LEAF_PROGSCAN   "progscan"

Definition at line 26 of file colourspace.h.

◆ WEED_LEAF_RESIZE_THREAD

#define WEED_LEAF_RESIZE_THREAD   "res_thread"

Definition at line 25 of file colourspace.h.

◆ weed_palette_is_pixbuf_palette

#define weed_palette_is_pixbuf_palette (   pal)    ((pal == WEED_PALETTE_RGB24 || pal == WEED_PALETTE_RGBA32) ? TRUE : FALSE)

Definition at line 296 of file colourspace.h.

◆ WEED_PLANT_LAYER

#define WEED_PLANT_LAYER   128

Definition at line 217 of file colourspace.h.

◆ Y_CLAMP_MAX

#define Y_CLAMP_MAX   235.

Definition at line 58 of file colourspace.h.

◆ Y_CLAMP_MAXI

#define Y_CLAMP_MAXI   235

Definition at line 59 of file colourspace.h.

◆ YUV_CLAMP_MIN

#define YUV_CLAMP_MIN   16.

Definition at line 55 of file colourspace.h.

◆ YUV_CLAMP_MINI

#define YUV_CLAMP_MINI   16

Definition at line 56 of file colourspace.h.

Typedef Documentation

◆ weed_layer_t

typedef weed_plant_t weed_layer_t

Definition at line 71 of file colourspace.h.

Function Documentation

◆ alpha_unpremult()

void alpha_unpremult ( weed_layer_t layer,
boolean  un 
)

(un)premultply alpha using a lookup table

if un is FALSE we go the other way, and do a pre-multiplication

this is only used when going from palette with alpha to one without

special case - planar with alpha

unclamped YUVA8888 (packed)

Definition at line 9923 of file colourspace.c.

◆ cdist94()

double cdist94 ( uint8_t  r0,
uint8_t  g0,
uint8_t  b0,
uint8_t  r1,
uint8_t  g1,
uint8_t  b1 
)

Definition at line 1075 of file colourspace.c.

Referenced by pick_nice_colour().

◆ compact_rowstrides()

boolean compact_rowstrides ( weed_layer_t )

Definition at line 12422 of file colourspace.c.

◆ consider_swapping()

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 pretend that the input palette is BGR and thus the conversion to BGRA is slightly cheaper we can do this provided the caller can take into account that the red / blue components are now swapped.

If this is possible, then either inpal or outpal mau ne altered, and TRUE is returned

since we dont have ABGR, we can switch the out palette instead

Definition at line 13427 of file colourspace.c.

◆ convert_layer_palette()

boolean convert_layer_palette ( weed_layer_t ,
int  outpl,
int  op_clamping 
)

Definition at line 11945 of file colourspace.c.

Referenced by cconx_convert_pixel_data().

◆ convert_layer_palette_full()

boolean convert_layer_palette_full ( weed_layer_t layer,
int  outpl,
int  oclamping,
int  osampling,
int  osubspace,
int  tgamma 
)

convert the palette of a layer

convert to/from the 5 non-float RGB palettes and 10 YUV palettes giving a total of 15*14=210 conversions

in addition YUV can be converted from clamped to unclamped and vice-versa

chroma sub and supersampling is implemented, and threading is used wherever possible

all conversions are performed via lookup tables

NOTE - if converting to YUV411, we cut pixels so (RGB) width is divisible by 4 if converting to YUV420 or YVU420, we cut pixels so (RGB) width is divisible by 2 if converting to YUV420 or YVU420, we cut pixels so height is divisible by 2

returns FALSE if the palette conversion fails or if layer is NULL

  • original palette pixel_data is free()d (unless converting between YUV420 and YVU420, there the u and v pointers are simply swapped).

current limitations:

  • chroma is assumed centred between luma for input and output
  • bt709 yuv is only implemented for conversions to / from rgb palettes and yuv420 / yvu420
  • rowstride values may be ignored for UYVY, YUYV and YUV411 planar palettes.
  • RGB float palettes not yet implemented

if V plane is before U, swap the pointers

add pre

inpl has post

outpl has post

outpl has pre

outpl has post

outpl has pre

if we came in as YVU, we got swapped to YUV

swap (again) and both become YVU

swap again and both become YUV (YVU out will get swapped on more time)

if V plane is before U, swap the pointers

Definition at line 10160 of file colourspace.c.

Referenced by convert_layer_palette().

◆ convert_layer_palette_with_sampling()

boolean convert_layer_palette_with_sampling ( weed_layer_t ,
int  outpl,
int  out_sampling 
)

◆ copy_pixel_data()

boolean copy_pixel_data ( weed_layer_t dst,
weed_layer_t src_or_null,
size_t  alignment 
)

Definition at line 9843 of file colourspace.c.

◆ create_blank_layer()

weed_layer_t* create_blank_layer ( weed_layer_t layer,
const char *  image_ext,
int  width,
int  height,
int  target_palette 
)

fills layer with default values.

If either width or height are zero, then dimensions will be taken from the layer or defaults used if layer has a palette set, that will be maintained, else it will be set to target_palette if targette palette is WEED_PALETTE_END then default will be set depending on image_ext if this is "jpg" then it will be RGB24, otherwise RGBA32 finally we create the pixel data for layer

Definition at line 9611 of file colourspace.c.

◆ create_empty_pixel_data()

boolean create_empty_pixel_data ( weed_layer_t layer,
boolean  black_fill,
boolean  may_contig 
)

layer should be pre-set with palette, width in MACROPIXELS, and height gamma_type will be set WEED_GAMMA_SRGB, old pixel_data will not be freed.

layer should be pre-set with palette, width in MACROPIXELS, and height gamma_type will be set WEED_GAMMA_SRGB, old pixel_data will not be freed.

Returns
FALSE on memory error

width, height, and current_palette must be pre-set in layer; width is in (macro) pixels of the palette width and height may be adjusted (rounded) in the function rowstrides will be set, and each plane will be aligned depending on THREADVAR(rowstride_alignment) if THREADVAR(rowstride_alignment_hint) is non 0 it will set THREADVAR(rowstride_alignment), which must be a power of 2 the special value -1 for the hint will create compact frames (rowstride = width * pixel_size)

if black_fill is set, fill with opaque black in the specified palette: for yuv palettes, YUV_clamping may be pre-set otherwise it will be set to WEED_YUV_CLAMPING_CLAMPED.

may_contig should normally be set to TRUE, except for special uses during palette conversion if set, then for planar palettes, only plane 0 will be allocated, so only this value should be freed in this case, the leaf WEED_LEAF_HOST_PIXEL_DATA_CONTIGUOUS will be set to WEED_TRUE

the allocated frames will be aligned to the pixel size for whatever palette and may be padded with extra bytes to guard against accidental overwrites

force use of fixed rowstrides, eg. decoder plugin

Definition at line 9058 of file colourspace.c.

Referenced by cconx_convert_pixel_data().

◆ gamma_conv_params()

void gamma_conv_params ( int  gamma_type,
weed_layer_t inst,
boolean  is_in 
)

Definition at line 12019 of file colourspace.c.

◆ gamma_convert_layer()

boolean gamma_convert_layer ( int  gamma_type,
weed_layer_t  
)

Definition at line 12195 of file colourspace.c.

◆ gamma_convert_layer_variant()

boolean gamma_convert_layer_variant ( double  file_gamma,
int  tgamma,
weed_layer_t  
)

Definition at line 12202 of file colourspace.c.

◆ gamma_convert_sub_layer()

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

Definition at line 12124 of file colourspace.c.

◆ get_luma16()

double get_luma16 ( uint16_t  r,
uint16_t  g,
uint16_t  b 
)

return luma value between 0. (black) and 1. (white)

Definition at line 557 of file colourspace.c.

◆ get_luma8()

double get_luma8 ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

return luma value between 0. (black) and 1. (white)

Definition at line 549 of file colourspace.c.

Referenced by get_luma16(), and pick_nice_colour().

◆ hsv2rgb()

void hsv2rgb ( double  h,
double  s,
double  v,
uint8_t *  r,
uint8_t *  g,
uint8_t *  b 
)

Definition at line 1113 of file colourspace.c.

◆ init_colour_engine()

void init_colour_engine ( void  )

Definition at line 1661 of file colourspace.c.

◆ init_conversions()

void init_conversions ( int  intent)

set the 'effort' to as low as possible; if using adaptive quality

Definition at line 1804 of file colourspace.c.

Referenced by play_file(), and render_events().

◆ layer_to_lives_painter()

lives_painter_t* layer_to_lives_painter ( weed_layer_t layer)

convert a weed layer to lives_painter (a.k.a cairo)

width, height and rowstrides of source layer may all change

Definition at line 13473 of file colourspace.c.

◆ layer_to_pixbuf()

LiVESPixbuf* layer_to_pixbuf ( weed_layer_t ,
boolean  realpalette,
boolean  fordisp 
)

Definition at line 12210 of file colourspace.c.

◆ letterbox_layer()

boolean letterbox_layer ( weed_layer_t ,
int  nwidth,
int  nheight,
int  width,
int  height,
LiVESInterpType  interp,
int  tpal,
int  tclamp 
)

no letterboxing needed - resize and return

resize the inner rectangle

create the outer rectangle in layer

get the actual size after any adjustments

this shouldnt happen, but if the outer rectangle is smaller than the inner we have to abort

retain pixel_data if it belongs to mainw->frame_layer

otherwise do not nullify, as we want to free old pixel_data

Definition at line 13015 of file colourspace.c.

◆ lives_layer_get_clip()

int lives_layer_get_clip ( weed_layer_t )

Definition at line 9705 of file colourspace.c.

◆ lives_layer_get_frame()

frames_t lives_layer_get_frame ( weed_layer_t )

Definition at line 9711 of file colourspace.c.

◆ lives_layer_new_for_frame()

weed_layer_t* lives_layer_new_for_frame ( int  clip,
frames_t  frame 
)

Definition at line 9833 of file colourspace.c.

Referenced by load_frame_image(), load_rfx_preview(), and render_events().

◆ lives_layer_set_clip()

void lives_layer_set_clip ( weed_layer_t ,
int  clip 
)

Definition at line 9828 of file colourspace.c.

Referenced by lives_layer_new_for_frame().

◆ lives_layer_set_frame()

void lives_layer_set_frame ( weed_layer_t ,
frames_t  frame 
)

Definition at line 9822 of file colourspace.c.

Referenced by lives_layer_new_for_frame().

◆ lives_layer_set_opaque()

void lives_layer_set_opaque ( weed_layer_t )

Definition at line 12385 of file colourspace.c.

◆ lives_painter_to_layer()

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

flush to ensure all writing to the image surface was done

un-premultiply the alpha

Definition at line 13549 of file colourspace.c.

◆ lives_pixbuf_is_all_black()

boolean lives_pixbuf_is_all_black ( LiVESPixbuf *  pixbuf)

return FALSE if r >= 32, b >= 32 and g >= 24 here we use a, b, and c for the first 3 bytes of the pixel. Since a and c are symmetric and we ignore byte 4, this will work for RGB, BGR, RGBA and BGRA (we could also check ARGB by setting offs to 1).

Algorithm: (a & 0x1F) ^ a - nonzero iff a >= 32 (c & 0x1F) ^ c - nonzero iff c >= 32

((a & c) & 0x1F) ^ (a & c) - nonzero only if both are true

(b & 0x1F) ^ b - nonzero iff b >= 32 ((b << 1) & 0x1F) ^ (b << 1) - nonzero iff b >= 16 ((b << 2) & 0x1F) ^ (b << 2) - nonzero iff b >= 8 b & 0x0F - masks any values >= 32

Definition at line 2193 of file colourspace.c.

◆ lives_pixbuf_set_opaque()

void lives_pixbuf_set_opaque ( LiVESPixbuf *  pixbuf)

Definition at line 12362 of file colourspace.c.

◆ pick_nice_colour()

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 
)

pick a random col

Definition at line 1142 of file colourspace.c.

◆ pixbuf_to_layer()

boolean pixbuf_to_layer ( weed_layer_t layer,
LiVESPixbuf *  pixbuf 
)

turn a (Gdk)Pixbuf into a Weed layer

return TRUE if we can use the original pixbuf pixels; in this case the pixbuf pixels should only be freed via lives_layer_pixel_data_free() or lives_layer_free() see code example.

code example:

if (pixbuf) { if (!pixbuf_to_layer(layer, pixbuf)) lives_widget_object_unref(pixbuf); else do NOT unref the pixbuf !!!! }

do something with layer...

weed_layer_pixel_data_free(layer); unrefs the pixbuf or weed_layer_free(layer); also unrefs the pixbuf

Definition at line 13347 of file colourspace.c.

◆ pixel_data_planar_from_membuf()

void pixel_data_planar_from_membuf ( void **  pixel_data,
void *  data,
size_t  size,
int  palette,
boolean  dest_contig 
)

Definition at line 2236 of file colourspace.c.

◆ resize_all()

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

Definition at line 13622 of file colourspace.c.

Referenced by after_foreign_play().

◆ resize_layer()

boolean resize_layer ( weed_layer_t layer,
int  width,
int  height,
LiVESInterpType  interp,
int  opal_hint,
int  oclamp_hint 
)

widths in PIXELS

widths in PIXELS

width is in PIXELS (not macropixels)

opal_hint and oclamp_hint may be set to hint the desired output palette and YUV clamping this is simply to ensure more efficient resizing, and may be ignored

  • setting opal_hint to WEED_PALETTE_END will attempt to minimise palette changes

"current_palette" should be checked on return as it may change

Returns
FALSE if we were unable to resize

Definition at line 12537 of file colourspace.c.

◆ rgb2hsv()

void rgb2hsv ( uint8_t  r,
uint8_t  g,
uint8_t  b,
double *  h,
double *  s,
double *  v 
)

Definition at line 1090 of file colourspace.c.

◆ round_special()

int32_t round_special ( int32_t  val)

Definition at line 544 of file colourspace.c.

Referenced by test_palette_conversions().

◆ rowstrides_differ()

boolean rowstrides_differ ( int  n1,
int *  n1_array,
int  n2,
int *  n2_array 
)

Definition at line 9647 of file colourspace.c.

◆ weed_layer_copy()

weed_layer_t* weed_layer_copy ( weed_layer_t dlayer,
weed_layer_t slayer 
)

copy source layer slayer to dest layer dlayer

if dlayer is NULL, we return a new layer, otherwise we return dlayer for a newly created layer, this is a deep copy, since the pixel_data array is also copied for an existing dlayer, we copy pixel_data by reference. all the other relevant attributes are also copied

deep copy

shallow copy

Definition at line 13739 of file colourspace.c.

Referenced by load_rfx_preview(), and save_to_scrap_file().

◆ weed_layer_create()

weed_layer_t* weed_layer_create ( int  width,
int  height,
int *  rowstrides,
int  current_palette 
)

create a layer, setting the most important properties

Definition at line 13708 of file colourspace.c.

◆ weed_layer_create_full()

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 
)

Definition at line 13722 of file colourspace.c.

◆ weed_layer_free()

weed_layer_t* weed_layer_free ( weed_layer_t layer)

frees pixel_data for a layer, then the layer itself

if plant is freed returns (void *)NULL for convenience

Definition at line 13883 of file colourspace.c.

Referenced by close_current_file(), get_frames_sizes(), load_frame_image(), load_rfx_preview(), on_multitrack_activate(), and render_events().

◆ weed_layer_get_audio_data()

float** weed_layer_get_audio_data ( weed_layer_t ,
int *  naudchans 
)

Definition at line 13921 of file colourspace.c.

◆ weed_layer_get_audio_length()

int weed_layer_get_audio_length ( weed_layer_t layer)

Definition at line 14004 of file colourspace.c.

Referenced by weed_apply_audio_effects_rt().

◆ weed_layer_get_audio_rate()

int weed_layer_get_audio_rate ( weed_layer_t layer)

Definition at line 13992 of file colourspace.c.

Referenced by weed_apply_audio_effects_rt().

◆ weed_layer_get_flags()

int weed_layer_get_flags ( weed_layer_t )

Definition at line 9699 of file colourspace.c.

◆ weed_layer_get_gamma()

int weed_layer_get_gamma ( weed_layer_t )

Definition at line 12002 of file colourspace.c.

Referenced by render_text_overlay().

◆ weed_layer_get_height()

int weed_layer_get_height ( weed_layer_t )

Definition at line 13953 of file colourspace.c.

Referenced by get_frames_sizes().

◆ weed_layer_get_naudchans()

int weed_layer_get_naudchans ( weed_layer_t layer)

Definition at line 13998 of file colourspace.c.

Referenced by weed_apply_audio_effects_rt().

◆ weed_layer_get_palette()

int weed_layer_get_palette ( weed_layer_t )

◆ weed_layer_get_palette_yuv()

int weed_layer_get_palette_yuv ( weed_layer_t ,
int *  clamping,
int *  sampling,
int *  subspace 
)

Definition at line 13983 of file colourspace.c.

◆ weed_layer_get_pixel_data()

void** weed_layer_get_pixel_data ( weed_layer_t ,
int *  nplanes 
)

Definition at line 13908 of file colourspace.c.

Referenced by weed_layer_copy(), and weed_layer_pixel_data_free().

◆ weed_layer_get_pixel_data_packed()

uint8_t* weed_layer_get_pixel_data_packed ( weed_layer_t )

Definition at line 13915 of file colourspace.c.

◆ weed_layer_get_rowstride()

int weed_layer_get_rowstride ( weed_layer_t )

for packed palettes

Definition at line 13935 of file colourspace.c.

Referenced by render_text_to_layer().

◆ weed_layer_get_rowstrides()

int* weed_layer_get_rowstrides ( weed_layer_t ,
int *  nplanes 
)

Definition at line 13928 of file colourspace.c.

Referenced by compact_rowstrides(), and copy_pixel_data().

◆ weed_layer_get_width()

int weed_layer_get_width ( weed_layer_t )

◆ weed_layer_get_width_pixels()

int weed_layer_get_width_pixels ( weed_layer_t )

Definition at line 13947 of file colourspace.c.

◆ weed_layer_get_yuv_clamping()

int weed_layer_get_yuv_clamping ( weed_layer_t )

Definition at line 13959 of file colourspace.c.

Referenced by vpp_try_match_palette(), and weed_layer_get_palette_yuv().

◆ weed_layer_get_yuv_sampling()

int weed_layer_get_yuv_sampling ( weed_layer_t )

Definition at line 13965 of file colourspace.c.

Referenced by weed_layer_get_palette_yuv().

◆ weed_layer_get_yuv_subspace()

int weed_layer_get_yuv_subspace ( weed_layer_t )

Definition at line 13971 of file colourspace.c.

Referenced by weed_layer_get_palette_yuv().

◆ weed_layer_is_audio()

int weed_layer_is_audio ( weed_layer_t )

Definition at line 9675 of file colourspace.c.

◆ weed_layer_is_video()

int weed_layer_is_video ( weed_layer_t )

Definition at line 9669 of file colourspace.c.

◆ weed_layer_new()

weed_layer_t* weed_layer_new ( int  layer_type)

Definition at line 9655 of file colourspace.c.

Referenced by get_frames_sizes(), and lives_layer_new_for_frame().

◆ weed_layer_nullify_pixel_data()

weed_layer_t* weed_layer_nullify_pixel_data ( weed_layer_t )

Definition at line 9753 of file colourspace.c.

Referenced by render_events(), and weed_layer_pixel_data_free().

◆ weed_layer_pixel_data_free()

void weed_layer_pixel_data_free ( weed_layer_t layer)

free pixel_data from layer

we do not free if WEED_LEAF_HOST_ORIG_PDATA is set (data is an alpha in which "belongs" to another out param)

take care of WEED_LEAF_HOST_PIXEL_DATA_CONTIGUOUS take care of WEED_LEAF_HOST_PIXBUF_SRC take care of WEED_LEAF_HOST_SURFACE_SRC

sets WEED_LEAF_PIXEL_DATA to NULL for the layer

this function should always be used to free WEED_LEAF_PIXEL_DATA

Definition at line 13819 of file colourspace.c.

Referenced by cconx_convert_pixel_data(), load_frame_image(), render_events(), and weed_layer_unref().

◆ weed_layer_ref()

int weed_layer_ref ( weed_layer_t )

Definition at line 13899 of file colourspace.c.

◆ weed_layer_set_audio_data()

weed_layer_t* weed_layer_set_audio_data ( weed_layer_t ,
float **  data,
int  arate,
int  naudchans,
weed_size_t  nsamps 
)

Definition at line 9681 of file colourspace.c.

Referenced by push_audio_to_channel().

◆ weed_layer_set_flags()

weed_layer_t* weed_layer_set_flags ( weed_layer_t ,
int  flags 
)

Definition at line 9692 of file colourspace.c.

◆ weed_layer_set_gamma()

weed_layer_t* weed_layer_set_gamma ( weed_layer_t ,
int  gamma_type 
)

Definition at line 9784 of file colourspace.c.

Referenced by render_text_overlay().

◆ weed_layer_set_height()

weed_layer_t* weed_layer_set_height ( weed_layer_t ,
int  height 
)

Definition at line 9724 of file colourspace.c.

◆ weed_layer_set_palette()

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 is NULL or not weed_layer then NULL is returned

Definition at line 9777 of file colourspace.c.

Referenced by weed_layer_set_palette_yuv().

◆ weed_layer_set_palette_yuv()

weed_layer_t* weed_layer_set_palette_yuv ( weed_layer_t ,
int  palette,
int  clamping,
int  sampling,
int  subspace 
)

Definition at line 9812 of file colourspace.c.

◆ weed_layer_set_pixel_data()

weed_layer_t* weed_layer_set_pixel_data ( weed_layer_t ,
void **  pixel_data,
int  nplanes 
)

Definition at line 9739 of file colourspace.c.

◆ weed_layer_set_pixel_data_packed()

weed_layer_t* weed_layer_set_pixel_data_packed ( weed_layer_t ,
void *  pixel_data 
)

Definition at line 9746 of file colourspace.c.

◆ weed_layer_set_rowstride()

weed_layer_t* weed_layer_set_rowstride ( weed_layer_t ,
int  rowstride 
)

Definition at line 9770 of file colourspace.c.

◆ weed_layer_set_rowstrides()

weed_layer_t* weed_layer_set_rowstrides ( weed_layer_t ,
int *  rowstrides,
int  nplanes 
)

Definition at line 9763 of file colourspace.c.

◆ weed_layer_set_size()

weed_layer_t* weed_layer_set_size ( weed_layer_t ,
int  width,
int  height 
)

Definition at line 9731 of file colourspace.c.

◆ weed_layer_set_width()

weed_layer_t* weed_layer_set_width ( weed_layer_t ,
int  width 
)

width in macropixels of the layer palette

Definition at line 9717 of file colourspace.c.

◆ weed_layer_set_yuv_clamping()

weed_layer_t* weed_layer_set_yuv_clamping ( weed_layer_t ,
int  clamping 
)

Definition at line 9791 of file colourspace.c.

Referenced by weed_layer_set_palette_yuv().

◆ weed_layer_set_yuv_sampling()

weed_layer_t* weed_layer_set_yuv_sampling ( weed_layer_t ,
int  sampling 
)

Definition at line 9798 of file colourspace.c.

Referenced by weed_layer_set_palette_yuv().

◆ weed_layer_set_yuv_subspace()

weed_layer_t* weed_layer_set_yuv_subspace ( weed_layer_t ,
int  subspace 
)

Definition at line 9805 of file colourspace.c.

Referenced by weed_layer_set_palette_yuv().

◆ weed_layer_unref()

int weed_layer_unref ( weed_layer_t )

Definition at line 13888 of file colourspace.c.

Referenced by weed_layer_free().

◆ weed_palette_is_lower_quality()

boolean weed_palette_is_lower_quality ( int  p1,
int  p2 
)

Definition at line 2143 of file colourspace.c.

◆ weed_palette_is_painter_palette()

boolean weed_palette_is_painter_palette ( int  pal)

Definition at line 2130 of file colourspace.c.