32 float in,
const float lift,
const float gain,
const float gamma,
const float mul)
34 float x = (((
in - 1.0f) * lift) + 1.0f) * gain;
37 x = std::max(
x, 0.0f);
46 float in,
const float slope,
const float offset,
const float power,
float mul)
48 float x =
in * slope + offset;
51 x = std::max(
x, 0.0f);
66 float lift,
float gain,
float gamma,
float mul,
float r_table[
CB_TABLE_SIZE])
91 template<
typename MaskSampler>
104 result.x = this->lut[0][p0];
105 result.y = this->lut[1][p1];
106 result.z = this->lut[2][p2];
117 template<
typename MaskSampler>
130 input.x, this->lift.x, this->gain.x, this->gamma.x, this->multiplier);
132 input.y, this->lift.y, this->gain.y, this->gamma.y, this->multiplier);
134 input.z, this->lift.z, this->gain.z, this->gamma.z, this->multiplier);
149 input.x, this->slope.x, this->offset.x, this->power.x, this->multiplier);
151 input.y, this->slope.y, this->offset.y, this->power.y, this->multiplier);
153 input.z, this->slope.z, this->offset.z, this->power.z, this->multiplier);
173 for (
int c = 0; c < 3; c++) {
176 if (this->lift[c] > 1.0f) {
177 this->lift[c] =
powf(this->lift[c] - 1.0f, 2.0f) + 1.0f;
179 this->lift[c] = 2.0f - this->lift[c];
205 this->offset = -this->offset;
216 this->multiplier =
data.color_multiply;
217 this->method =
data.color_balance.method;
222 for (
int c = 0; c < 3; c++) {
224 this->lift[c], this->gain[c], this->gamma[c], this->multiplier, this->lut[c]);
231 for (
int c = 0; c < 3; c++) {
233 this->slope[c], this->offset[c], this->power[c], this->multiplier, this->lut[c]);
250 for (
int c = 0; c < 3; c++) {
269 op.
init(*cbmd, context.result.image->byte_data() !=
nullptr);
271 if (
mask !=
nullptr) {
282 const int correction_method =
RNA_enum_get(&color_balance,
"correction_method");
287 layout.
prop(&color_balance,
"correction_method",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
302 template_color_picker(&
split, &color_balance,
"lift",
true,
false,
false,
true);
313 &color_balance,
"invert_gamma",
UI_ITEM_NONE,
IFACE_(
"Invert"), ICON_ARROW_LEFTRIGHT);
314 template_color_picker(&
split, &color_balance,
"gamma",
true,
false,
true,
true);
326 template_color_picker(&
split, &color_balance,
"gain",
true,
false,
true,
true);
338 &color_balance,
"invert_offset",
UI_ITEM_NONE,
IFACE_(
"Invert"), ICON_ARROW_LEFTRIGHT);
339 template_color_picker(&
split, &color_balance,
"offset",
true,
false,
false,
true);
350 &color_balance,
"invert_power",
UI_ITEM_NONE,
IFACE_(
"Invert"), ICON_ARROW_LEFTRIGHT);
351 template_color_picker(&
split, &color_balance,
"power",
true,
false,
false,
true);
362 &color_balance,
"invert_slope",
UI_ITEM_NONE,
IFACE_(
"Invert"), ICON_ARROW_LEFTRIGHT);
363 template_color_picker(&
split, &color_balance,
"slope",
true,
false,
false,
true);
371 C, ptr,
"open_mask_input_panel",
IFACE_(
"Mask Input")))
385 "ColorBalanceModifierData",
#define CTX_N_(context, msgid)
#define BLT_I18NCONTEXT_ID_SEQUENCE
#define PRF_scope_with_name(ui_name, category)
#define BLI_assert_unreachable()
constexpr int64_t first() const
constexpr IndexRange()=default
ccl_device_inline float2 power(const float2 v, const float e)
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
T max(const T &a, const T &b)
ImBuf * modifier_render_mask_input(const ModifierApplyContext &context, const StripModifierData &smd)
void ensure_ibuf_is_sequencer_space(const Scene *scene, ImBuf *ibuf, bool make_float)
static void colorBalance_init_data(StripModifierData *smd)
static constexpr int CB_TABLE_SIZE
static float color_balance_lgg(float in, const float lift, const float gain, const float gamma, const float mul)
void apply_modifier_op(T &op, ImBuf *ibuf, const ImBuf *mask, const float3x3 &mask_transform)
static float color_balance_sop(float in, const float slope, const float offset, const float power, float mul)
void store_pixel_premul(float4 pix, uchar *ptr)
static void make_cb_table_sop(float slope, float offset, float power, float mul, float r_table[CB_TABLE_SIZE])
static void make_cb_table_lgg(float lift, float gain, float gamma, float mul, float r_table[CB_TABLE_SIZE])
static void colorBalance_panel_draw(const bContext *C, Panel *panel)
static void colorBalance_apply(ModifierApplyContext &context, StripModifierData *smd)
StripModifierTypeInfo seqModifierType_ColorBalance
float4 load_pixel_premul(const uchar *ptr)
void draw_mask_input_type_settings(const bContext *C, ui::Layout &layout, PointerRNA *ptr)
static void colorBalance_register(ARegionType *region_type)
PanelType * modifier_panel_register(ARegionType *region_type, const eStripModifierType type, PanelDrawFn draw)
PointerRNA * panel_custom_data_get(const Panel *panel)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
int RNA_enum_get(PointerRNA *ptr, const char *name)
@ SEQ_COLOR_BALANCE_INVERSE_POWER
@ SEQ_COLOR_BALANCE_INVERSE_LIFT
@ SEQ_COLOR_BALANCE_INVERSE_SLOPE
@ SEQ_COLOR_BALANCE_INVERSE_GAIN
@ SEQ_COLOR_BALANCE_INVERSE_GAMMA
@ SEQ_COLOR_BALANCE_INVERSE_OFFSET
@ SEQ_COLOR_BALANCE_METHOD_LIFTGAMMAGAIN
@ SEQ_COLOR_BALANCE_METHOD_SLOPEOFFSETPOWER
VecBase< float, 4 > float4
void IMB_freeImBuf(ImBuf *ibuf)
BMesh const char void * data
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
VecBase< float, 3 > float3
@ eSeqModifierType_ColorBalance
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
StripColorBalance color_balance
eModColorBalanceMethod method
void init_sop(const StripColorBalance &data)
void apply(uchar *image, MaskSampler &mask, int image_x, IndexRange y_range)
void init_lgg(const StripColorBalance &data)
void apply(float *image, MaskSampler &mask, int image_x, IndexRange y_range)
float lut[3][CB_TABLE_SIZE]
void init(const ColorBalanceModifierData &data, bool byte_image)
void use_property_split_set(bool is_sep)
void label(StringRef name, int icon)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
Layout & split(float percentage, bool align)
Layout & column(bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
Layout & grid_flow(bool row_major, int columns_len, bool even_columns, bool even_rows, bool align)
PanelLayout panel_prop(const bContext *C, PointerRNA *open_prop_owner, StringRefNull open_prop_name)