diff --git a/.clang-format-ignore b/.clang-format-ignore index e43de3c..1cae346 100644 --- a/.clang-format-ignore +++ b/.clang-format-ignore @@ -28,7 +28,7 @@ Source/Effects/FsExpsPos/* Source/Effects/FsExtract_Edge/* Source/Effects/FsExtract-Hi/* #Source/Effects/FsFillColor/* -Source/Effects/FsFilter/* +#Source/Effects/FsFilter/* Source/Effects/FsFlare/* Source/Effects/FsFrame/* Source/Effects/FsGrad_Test/* diff --git a/Source/Effects/FsFilter/Filter.cpp b/Source/Effects/FsFilter/Filter.cpp index 1b40892..551673b 100644 --- a/Source/Effects/FsFilter/Filter.cpp +++ b/Source/Effects/FsFilter/Filter.cpp @@ -1,406 +1,341 @@ -//----------------------------------------------------------------------------------- -/* - F's Plugins for VS2010/VS2012 -*/ -//----------------------------------------------------------------------------------- - - +// clang-format off #include "Filter.h" #include #include "Filter_def.h" - - -//------------------------------------------------------------------------------------------------- -//AfterEffextsにパラメータを通達する -//Param_Utils.hを参照のこと -static PF_Err ParamsSetup ( - PF_InData *in_data, - PF_OutData *out_data, - PF_ParamDef *params[], - PF_LayerDef *output) -{ - PF_Err err = PF_Err_NONE; - PF_ParamDef def; - - //---------------------------------------------------------------- - AEFX_CLR_STRUCT(def); - PF_ADD_CHECKBOX(STR_BASE_ENABLED, - STR_ON, - TRUE, - 0, - ID_BASE_ENABLED - ); - //---------------------------------------------------------------- - AEFX_CLR_STRUCT(def); - PF_ADD_FLOAT_SLIDER(STR_BASE_OPACITY, //Name - 0, //VALID_MIN - 100, //VALID_MAX - 0, //SLIDER_MIN - 100, //SLIDER_MAX - 1, //CURVE_TOLERANCE - 100, //DFLT - 1, //PREC - 0, //DISP - 0, //WANT_PHASE - ID_BASE_OPACITY - ); - //---------------------------------------------------------------- - AEFX_CLR_STRUCT(def); - PF_ADD_FLOAT_SLIDER(STR_FILTER_OPACITY, //Name - 0, //VALID_MIN - 300, //VALID_MAX - 0, //SLIDER_MIN - 150, //SLIDER_MAX - 1, //CURVE_TOLERANCE - 100, //DFLT - 1, //PREC - 0, //DISP - 0, //WANT_PHASE - ID_FILTER_OPACITY - ); - //---------------------------------------------------------------- +#include "Filter_Entry.h" +// clang-format on + +// Pass parameters to After Effects +// See Param_Utils.h +static PF_Err ParamsSetup(PF_InData *in_data, PF_OutData *out_data, + PF_ParamDef *params[], PF_LayerDef *output) { + PF_Err err = PF_Err_NONE; + PF_ParamDef def; + + //---------------------------------------------------------------- + AEFX_CLR_STRUCT(def); + PF_ADD_CHECKBOX(STR_BASE_ENABLED, STR_ON, TRUE, 0, ID_BASE_ENABLED); + //---------------------------------------------------------------- + AEFX_CLR_STRUCT(def); + PF_ADD_FLOAT_SLIDER(STR_BASE_OPACITY, // Name + 0, // VALID_MIN + 100, // VALID_MAX + 0, // SLIDER_MIN + 100, // SLIDER_MAX + 1, // CURVE_TOLERANCE + 100, // DFLT + 1, // PREC + 0, // DISP + 0, // WANT_PHASE + ID_BASE_OPACITY); + //---------------------------------------------------------------- + AEFX_CLR_STRUCT(def); + PF_ADD_FLOAT_SLIDER(STR_FILTER_OPACITY, // Name + 0, // VALID_MIN + 300, // VALID_MAX + 0, // SLIDER_MIN + 150, // SLIDER_MAX + 1, // CURVE_TOLERANCE + 100, // DFLT + 1, // PREC + 0, // DISP + 0, // WANT_PHASE + ID_FILTER_OPACITY); + //---------------------------------------------------------------- #pragma region paramset - char num[255] = { "\0" }; - for (int i = 0; i < PARAMSET_COUNT; i++) - { + char num[255] = {"\0"}; + for (int i = 0; i < PARAMSET_COUNT; i++) { #pragma region topic - SPRINTF(STR_TOPIC, i + 1); - AEFX_CLR_STRUCT(def); - def.flags = PF_ParamFlag_START_COLLAPSED; - PF_ADD_TOPIC(num, ID_NUM(i,ID_TOPIC)); + SPRINTF(STR_TOPIC, i + 1); + AEFX_CLR_STRUCT(def); + def.flags = PF_ParamFlag_START_COLLAPSED; + PF_ADD_TOPIC(num, ID_NUM(i, ID_TOPIC)); #pragma endregion - //---------------------------------------------------------------- + //---------------------------------------------------------------- #pragma region enabled - //enabled - SPRINTF(STR_ENABLED, i + 1); - AEFX_CLR_STRUCT(def); - PF_ADD_CHECKBOX(num, - STR_ON, - FLT_Enabled[i], - 0, - ID_NUM(i, ID_BASE_ENABLED) - ); + // enabled + SPRINTF(STR_ENABLED, i + 1); + AEFX_CLR_STRUCT(def); + PF_ADD_CHECKBOX(num, STR_ON, FLT_Enabled[i], 0, ID_NUM(i, ID_BASE_ENABLED)); #pragma endregion - //---------------------------------------------------------------- + //---------------------------------------------------------------- #pragma region extract - SPRINTF(STR_EXTRACT, i + 1); - AEFX_CLR_STRUCT(def); - PF_ADD_POPUP(num, - STR_EXTRACT_COUNT, //メニューの数 - FLT_EXTRACT_MODE[i], //デフォルト - STR_EXTRACT_ITEMS, - ID_NUM(i, ID_EXTRACT) - ); + SPRINTF(STR_EXTRACT, i + 1); + AEFX_CLR_STRUCT(def); + PF_ADD_POPUP(num, + STR_EXTRACT_COUNT, // Number of menus + FLT_EXTRACT_MODE[i], // Default + STR_EXTRACT_ITEMS, ID_NUM(i, ID_EXTRACT)); #pragma endregion - //---------------------------------------------------------------- + //---------------------------------------------------------------- #pragma region border_hi - SPRINTF(STR_BORDER_HI, i + 1); - AEFX_CLR_STRUCT(def); - PF_ADD_FLOAT_SLIDER(num, //Name - 50, //VALID_MIN - 100, //VALID_MAX - 75, //SLIDER_MIN - 100, //SLIDER_MAX - 1, //CURVE_TOLERANCE - FLT_BORDER_HI[i], //DFLT - 1, //PREC - 0, //DISP - 0, //WANT_PHASE - ID_NUM(i, ID_BORDER_HI) - ); + SPRINTF(STR_BORDER_HI, i + 1); + AEFX_CLR_STRUCT(def); + PF_ADD_FLOAT_SLIDER(num, // Name + 50, // VALID_MIN + 100, // VALID_MAX + 75, // SLIDER_MIN + 100, // SLIDER_MAX + 1, // CURVE_TOLERANCE + FLT_BORDER_HI[i], // DFLT + 1, // PREC + 0, // DISP + 0, // WANT_PHASE + ID_NUM(i, ID_BORDER_HI)); #pragma endregion - //---------------------------------------------------------------- + //---------------------------------------------------------------- #pragma region softness_hi - SPRINTF(STR_SOFTNESS_HI, i + 1); - AEFX_CLR_STRUCT(def); - PF_ADD_FLOAT_SLIDER(num, //Name - 0, //VALID_MIN - 50, //VALID_MAX - 0, //SLIDER_MIN - 50, //SLIDER_MAX - 1, //CURVE_TOLERANCE - FLT_SOFTNESS_HI[i], //DFLT - 1, //PREC - 0, //DISP - 0, //WANT_PHASE - ID_NUM(i, ID_SOFTNESS_HI) - ); + SPRINTF(STR_SOFTNESS_HI, i + 1); + AEFX_CLR_STRUCT(def); + PF_ADD_FLOAT_SLIDER(num, // Name + 0, // VALID_MIN + 50, // VALID_MAX + 0, // SLIDER_MIN + 50, // SLIDER_MAX + 1, // CURVE_TOLERANCE + FLT_SOFTNESS_HI[i], // DFLT + 1, // PREC + 0, // DISP + 0, // WANT_PHASE + ID_NUM(i, ID_SOFTNESS_HI)); #pragma endregion - //---------------------------------------------------------------- + //---------------------------------------------------------------- #pragma region border_lo - SPRINTF(STR_BORDER_LO, i + 1); - AEFX_CLR_STRUCT(def); - PF_ADD_FLOAT_SLIDER(num, //Name - 0, //VALID_MIN - 50, //VALID_MAX - 0, //SLIDER_MIN - 30, //SLIDER_MAX - 1, //CURVE_TOLERANCE - FLT_BORDER_LO[i], //DFLT - 1, //PREC - 0, //DISP - 0, //WANT_PHASE - ID_NUM(i, ID_BORDER_LO) - ); + SPRINTF(STR_BORDER_LO, i + 1); + AEFX_CLR_STRUCT(def); + PF_ADD_FLOAT_SLIDER(num, // Name + 0, // VALID_MIN + 50, // VALID_MAX + 0, // SLIDER_MIN + 30, // SLIDER_MAX + 1, // CURVE_TOLERANCE + FLT_BORDER_LO[i], // DFLT + 1, // PREC + 0, // DISP + 0, // WANT_PHASE + ID_NUM(i, ID_BORDER_LO)); #pragma endregion - //---------------------------------------------------------------- + //---------------------------------------------------------------- #pragma region softness_lo - SPRINTF(STR_SOFTNESS_LO, i + 1); - AEFX_CLR_STRUCT(def); - PF_ADD_FLOAT_SLIDER(num, //Name - 0, //VALID_MIN - 30, //VALID_MAX - 0, //SLIDER_MIN - 30, //SLIDER_MAX - 1, //CURVE_TOLERANCE - FLT_SOFTNESS_LO[i], //DFLT - 1, //PREC - 0, //DISP - 0, //WANT_PHASE - ID_NUM(i, ID_SOFTNESS_LO) - ); + SPRINTF(STR_SOFTNESS_LO, i + 1); + AEFX_CLR_STRUCT(def); + PF_ADD_FLOAT_SLIDER(num, // Name + 0, // VALID_MIN + 30, // VALID_MAX + 0, // SLIDER_MIN + 30, // SLIDER_MAX + 1, // CURVE_TOLERANCE + FLT_SOFTNESS_LO[i], // DFLT + 1, // PREC + 0, // DISP + 0, // WANT_PHASE + ID_NUM(i, ID_SOFTNESS_LO)); #pragma endregion #pragma region brightness - SPRINTF(STR_BRIGHT, i + 1); - AEFX_CLR_STRUCT(def); - PF_ADD_FLOAT_SLIDER(num, //Name - -50, //VALID_MIN - 50, //VALID_MAX - -20, //SLIDER_MIN - 20, //SLIDER_MAX - 1, //CURVE_TOLERANCE - FLT_BRIGHTNESS[i], //DFLT - 1, //PREC - 0, //DISP - 0, //WANT_PHASE - ID_NUM(i, ID_SOFTNESS_LO) - ); + SPRINTF(STR_BRIGHT, i + 1); + AEFX_CLR_STRUCT(def); + PF_ADD_FLOAT_SLIDER(num, // Name + -50, // VALID_MIN + 50, // VALID_MAX + -20, // SLIDER_MIN + 20, // SLIDER_MAX + 1, // CURVE_TOLERANCE + FLT_BRIGHTNESS[i], // DFLT + 1, // PREC + 0, // DISP + 0, // WANT_PHASE + ID_NUM(i, ID_SOFTNESS_LO)); #pragma endregion - //---------------------------------------------------------------- + //---------------------------------------------------------------- #pragma region minmax - SPRINTF(STR_MINMAX, i + 1); - AEFX_CLR_STRUCT(def); - PF_ADD_SLIDER(num, //パラメータの名前 - 0, //数値入力する場合の最小値 - 10, //数値入力する場合の最大値 - 0, //スライダーの最小値 - 5, //スライダーの最大値 - FLT_MINMAX[i], //デフォルトの値 - ID_NUM(i, ID_MINMAX) - ); + SPRINTF(STR_MINMAX, i + 1); + AEFX_CLR_STRUCT(def); + PF_ADD_SLIDER(num, // Parameter name + 0, // Minimum value for numerical input + 10, // Maximum value for numerical input + 0, // Minimum value of slider + 5, // Maximum value of slider + FLT_MINMAX[i], // Default value + ID_NUM(i, ID_MINMAX)); #pragma endregion - //---------------------------------------------------------------- + //---------------------------------------------------------------- #pragma region max - SPRINTF(STR_MAX, i + 1); - AEFX_CLR_STRUCT(def); - PF_ADD_SLIDER(num, //パラメータの名前 - 0, //数値入力する場合の最小値 - 50, //数値入力する場合の最大値 - 0, //スライダーの最小値 - 20, //スライダーの最大値 - FLT_MAX[i], //デフォルトの値 - ID_NUM(i, ID_MAX) - ); + SPRINTF(STR_MAX, i + 1); + AEFX_CLR_STRUCT(def); + PF_ADD_SLIDER(num, // Parameter name + 0, // Minimum value for numerical input + 50, // Maximum value for numerical input + 0, // Minimum value of slider + 20, // Maximum value of slider + FLT_MAX[i], // Default value + ID_NUM(i, ID_MAX)); #pragma endregion - //---------------------------------------------------------------- + //---------------------------------------------------------------- #pragma region blur - SPRINTF(STR_BLUR, i + 1); - AEFX_CLR_STRUCT(def); - PF_ADD_SLIDER(num, //パラメータの名前 - 0, //数値入力する場合の最小値 - 200, //数値入力する場合の最大値 - 0, //スライダーの最小値 - 50, //スライダーの最大値 - FLT_BLUR[i], //デフォルトの値 - ID_NUM(i, ID_BLUR) - ); + SPRINTF(STR_BLUR, i + 1); + AEFX_CLR_STRUCT(def); + PF_ADD_SLIDER(num, // Parameter name + 0, // Minimum value for numerical input + 200, // Maximum value for numerical input + 0, // Minimum value of slider + 50, // Maximum value of slider + FLT_BLUR[i], // Default value + ID_NUM(i, ID_BLUR)); #pragma endregion - //---------------------------------------------------------------- + //---------------------------------------------------------------- #pragma region opacity - SPRINTF(STR_OPACITY, i + 1); - AEFX_CLR_STRUCT(def); - PF_ADD_FLOAT_SLIDER(num, //Name - 0, //VALID_MIN - 100, //VALID_MAX - 0, //SLIDER_MIN - 100, //SLIDER_MAX - 1, //CURVE_TOLERANCE - FLT_OPACITY[i], //DFLT - 1, //PREC - 0, //DISP - 0, //WANT_PHASE - ID_NUM(i, ID_OPACITY) - ); + SPRINTF(STR_OPACITY, i + 1); + AEFX_CLR_STRUCT(def); + PF_ADD_FLOAT_SLIDER(num, // Name + 0, // VALID_MIN + 100, // VALID_MAX + 0, // SLIDER_MIN + 100, // SLIDER_MAX + 1, // CURVE_TOLERANCE + FLT_OPACITY[i], // DFLT + 1, // PREC + 0, // DISP + 0, // WANT_PHASE + ID_NUM(i, ID_OPACITY)); #pragma endregion - //---------------------------------------------------------------- + //---------------------------------------------------------------- #pragma region blend - SPRINTF(STR_BLEND, i + 1); - AEFX_CLR_STRUCT(def); - PF_ADD_POPUP(num, - STR_BLEND_COUNT, //メニューの数 - FLT_BLEND_MODE[i], //デフォルト - STR_BLEND_ITEMS, - ID_NUM(i, ID_BLEND) - ); + SPRINTF(STR_BLEND, i + 1); + AEFX_CLR_STRUCT(def); + PF_ADD_POPUP(num, + STR_BLEND_COUNT, // Number of menus + FLT_BLEND_MODE[i], // Default + STR_BLEND_ITEMS, ID_NUM(i, ID_BLEND)); #pragma endregion - //---------------------------------------------------------------- + //---------------------------------------------------------------- #pragma region topic_end - AEFX_CLR_STRUCT(def); - PF_END_TOPIC(ID_NUM(i, ID_TOPIC_END)); + AEFX_CLR_STRUCT(def); + PF_END_TOPIC(ID_NUM(i, ID_TOPIC_END)); #pragma endregion - //---------------------------------------------------------------- - - } + //---------------------------------------------------------------- + } #pragma endregion - //---------------------------------------------------------------- - //---------------------------------------------------------------- - AEFX_CLR_STRUCT(def); - PF_ADD_FLOAT_SLIDER(STR_NOISE, //Name - 0, //VALID_MIN - 100, //VALID_MAX - 0, //SLIDER_MIN - 5, //SLIDER_MAX - 1, //CURVE_TOLERANCE - 0, //DFLT - 1, //PREC - 0, //DISP - 0, //WANT_PHASE - ID_NOISE - ); - //---------------------------------------------------------------- - AEFX_CLR_STRUCT(def); - PF_ADD_CHECKBOX(STR_ALPHA_ON, - STR_ON, - FALSE, - 0, - ID_ALPHA_ON - ); - //---------------------------------------------------------------- - out_data->num_params = ID_NUM_PARAMS; - - return err; + //---------------------------------------------------------------- + //---------------------------------------------------------------- + AEFX_CLR_STRUCT(def); + PF_ADD_FLOAT_SLIDER(STR_NOISE, // Name + 0, // VALID_MIN + 100, // VALID_MAX + 0, // SLIDER_MIN + 5, // SLIDER_MAX + 1, // CURVE_TOLERANCE + 0, // DFLT + 1, // PREC + 0, // DISP + 0, // WANT_PHASE + ID_NOISE); + //---------------------------------------------------------------- + AEFX_CLR_STRUCT(def); + PF_ADD_CHECKBOX(STR_ALPHA_ON, STR_ON, FALSE, 0, ID_ALPHA_ON); + //---------------------------------------------------------------- + out_data->num_params = ID_NUM_PARAMS; + + return err; } //------------------------------------------------------------------------------------------------- -static PF_Err -HandleChangedParam( - PF_InData *in_data, - PF_OutData *out_data, - PF_ParamDef *params[], - PF_LayerDef *outputP, - PF_UserChangedParamExtra *extraP) -{ - PF_Err err = PF_Err_NONE; - return err; +static PF_Err HandleChangedParam(PF_InData *in_data, PF_OutData *out_data, + PF_ParamDef *params[], PF_LayerDef *outputP, + PF_UserChangedParamExtra *extraP) { + PF_Err err = PF_Err_NONE; + return err; } //----------------------------------------------------------------------------------- -static PF_Err -QueryDynamicFlags( - PF_InData *in_data, - PF_OutData *out_data, - PF_ParamDef *params[], - void *extra) -{ - PF_Err err = PF_Err_NONE; - return err; +static PF_Err QueryDynamicFlags(PF_InData *in_data, PF_OutData *out_data, + PF_ParamDef *params[], void *extra) { + PF_Err err = PF_Err_NONE; + return err; } //======================================================================================= -static -PF_Err -FrameSetup( - PF_InData *in_data, - PF_OutData *out_data, - PF_ParamDef *params[], - PF_LayerDef *output) -{ - PF_Err err = PF_Err_NONE; - return PF_Err_NONE; +static PF_Err FrameSetup(PF_InData *in_data, PF_OutData *out_data, + PF_ParamDef *params[], PF_LayerDef *output) { + PF_Err err = PF_Err_NONE; + return PF_Err_NONE; } - //------------------------------------------------------------------------------------------------- -static PF_Err GetParams(CAE *ae, ParamInfo *infoP) -{ - PF_Err err = PF_Err_NONE; - - ERR(ae->GetCHECKBOX(ID_BASE_ENABLED, &infoP->base_enabled)); - ERR(ae->GetFLOAT(ID_BASE_OPACITY, &infoP->base_opacity)); - infoP->base_opacity /= 100; - - ERR(ae->GetFLOAT(ID_FILTER_OPACITY, &infoP->filter_opacity)); - infoP->filter_opacity /= 100; - - - - for (int i = 0; i < PARAMSET_COUNT; i++) - { - ERR(ae->GetCHECKBOX(ID_NUM(i,ID_BASE_ENABLED), &infoP->paramset[i].enabled)); - ERR(ae->GetPOPUP(ID_NUM(i, ID_EXTRACT), &infoP->paramset[i].extract_mode)); - ERR(ae->GetFLOAT(ID_NUM(i, ID_BORDER_HI), &infoP->paramset[i].border_hi)); - infoP->paramset[i].border_hi /= 100; - ERR(ae->GetFLOAT(ID_NUM(i, ID_SOFTNESS_HI), &infoP->paramset[i].softness_hi)); - infoP->paramset[i].softness_hi /= 100; - ERR(ae->GetFLOAT(ID_NUM(i, ID_BORDER_LO), &infoP->paramset[i].border_lo)); - infoP->paramset[i].border_lo /= 100; - ERR(ae->GetFLOAT(ID_NUM(i, ID_SOFTNESS_LO), &infoP->paramset[i].softness_lo)); - infoP->paramset[i].softness_lo /= 100; - ERR(ae->GetFLOAT(ID_NUM(i, ID_BRIGHT), &infoP->paramset[i].brightness)); - infoP->paramset[i].brightness /= 100; - - - ERR(ae->GetADD(ID_NUM(i, ID_MINMAX), &infoP->paramset[i].minmax)); - infoP->paramset[i].minmax = ae->downScaleNoClip(infoP->paramset[i].minmax); - ERR(ae->GetADD(ID_NUM(i, ID_MAX), &infoP->paramset[i].max)); - infoP->paramset[i].max = ae->downScaleNoClip(infoP->paramset[i].max); - ERR(ae->GetADD(ID_NUM(i, ID_BLUR), &infoP->paramset[i].blur)); - infoP->paramset[i].blur = ae->downScaleNoClip(infoP->paramset[i].blur); - - ERR(ae->GetFLOAT(ID_NUM(i, ID_OPACITY), &infoP->paramset[i].opacity)); - infoP->paramset[i].opacity /= 100; - infoP->paramset[i].opacity *= infoP->filter_opacity; - if (infoP->paramset[i].opacity < 0) infoP->paramset[i].opacity = 0; - else if (infoP->paramset[i].opacity > 1) infoP->paramset[i].opacity = 1; - - ERR(ae->GetPOPUP(ID_NUM(i, ID_BLEND), &infoP->paramset[i].blend_mode)); - - } - ERR(ae->GetFLOAT(ID_NOISE, &infoP->noise)); - infoP->noise /= 100; - ERR(ae->GetCHECKBOX(ID_ALPHA_ON, &infoP->alpha_on)); - - return err; +static PF_Err GetParams(CAE *ae, ParamInfo *infoP) { + PF_Err err = PF_Err_NONE; + + ERR(ae->GetCHECKBOX(ID_BASE_ENABLED, &infoP->base_enabled)); + ERR(ae->GetFLOAT(ID_BASE_OPACITY, &infoP->base_opacity)); + infoP->base_opacity /= 100; + + ERR(ae->GetFLOAT(ID_FILTER_OPACITY, &infoP->filter_opacity)); + infoP->filter_opacity /= 100; + + for (int i = 0; i < PARAMSET_COUNT; i++) { + ERR(ae->GetCHECKBOX(ID_NUM(i, ID_BASE_ENABLED), + &infoP->paramset[i].enabled)); + ERR(ae->GetPOPUP(ID_NUM(i, ID_EXTRACT), &infoP->paramset[i].extract_mode)); + ERR(ae->GetFLOAT(ID_NUM(i, ID_BORDER_HI), &infoP->paramset[i].border_hi)); + infoP->paramset[i].border_hi /= 100; + ERR(ae->GetFLOAT(ID_NUM(i, ID_SOFTNESS_HI), + &infoP->paramset[i].softness_hi)); + infoP->paramset[i].softness_hi /= 100; + ERR(ae->GetFLOAT(ID_NUM(i, ID_BORDER_LO), &infoP->paramset[i].border_lo)); + infoP->paramset[i].border_lo /= 100; + ERR(ae->GetFLOAT(ID_NUM(i, ID_SOFTNESS_LO), + &infoP->paramset[i].softness_lo)); + infoP->paramset[i].softness_lo /= 100; + ERR(ae->GetFLOAT(ID_NUM(i, ID_BRIGHT), &infoP->paramset[i].brightness)); + infoP->paramset[i].brightness /= 100; + + ERR(ae->GetADD(ID_NUM(i, ID_MINMAX), &infoP->paramset[i].minmax)); + infoP->paramset[i].minmax = ae->downScaleNoClip(infoP->paramset[i].minmax); + ERR(ae->GetADD(ID_NUM(i, ID_MAX), &infoP->paramset[i].max)); + infoP->paramset[i].max = ae->downScaleNoClip(infoP->paramset[i].max); + ERR(ae->GetADD(ID_NUM(i, ID_BLUR), &infoP->paramset[i].blur)); + infoP->paramset[i].blur = ae->downScaleNoClip(infoP->paramset[i].blur); + + ERR(ae->GetFLOAT(ID_NUM(i, ID_OPACITY), &infoP->paramset[i].opacity)); + infoP->paramset[i].opacity /= 100; + infoP->paramset[i].opacity *= infoP->filter_opacity; + if (infoP->paramset[i].opacity < 0) + infoP->paramset[i].opacity = 0; + else if (infoP->paramset[i].opacity > 1) + infoP->paramset[i].opacity = 1; + + ERR(ae->GetPOPUP(ID_NUM(i, ID_BLEND), &infoP->paramset[i].blend_mode)); + } + ERR(ae->GetFLOAT(ID_NOISE, &infoP->noise)); + infoP->noise /= 100; + ERR(ae->GetCHECKBOX(ID_ALPHA_ON, &infoP->alpha_on)); + + return err; } //------------------------------------------------------------------------------------------------- -static PF_Err - Exec (CAE *ae , ParamInfo *infoP) -{ - PF_Err err = PF_Err_NONE; - - FsSrand(ae->frame()); - - switch(ae->pixelFormat()) - { - case PF_PixelFormat_ARGB128: - break; - case PF_PixelFormat_ARGB64: - ERR(Exec16(ae, infoP)); - break; - case PF_PixelFormat_ARGB32: - ERR(Exec08(ae, infoP)); - break; - } - return err; +static PF_Err Exec(CAE *ae, ParamInfo *infoP) { + PF_Err err = PF_Err_NONE; + + FsSrand(ae->frame()); + + switch (ae->pixelFormat()) { + case PF_PixelFormat_ARGB128: + break; + case PF_PixelFormat_ARGB64: + ERR(Exec16(ae, infoP)); + break; + case PF_PixelFormat_ARGB32: + ERR(Exec08(ae, infoP)); + break; + } + return err; } -#include "Filter_Entry.h" diff --git a/Source/Effects/FsFilter/Filter.h b/Source/Effects/FsFilter/Filter.h index 0e13796..c0448d8 100644 --- a/Source/Effects/FsFilter/Filter.h +++ b/Source/Effects/FsFilter/Filter.h @@ -1,13 +1,6 @@ -//----------------------------------------------------------------------------------- -/* - Filter for VS2010 -*/ -//----------------------------------------------------------------------------------- - #pragma once -#ifndef Filter_H -#define Filter_H +// clang-format off #include "../FsLibrary_next/FsAEHeader.h" #include "../FsLibrary_next/FsVersion.h" #include "../FsLibrary_next/FsUtils.h" @@ -17,116 +10,110 @@ #include "Filter_Target.h" -//CAEクラスの読み込み +// Loading CAE class #include "../FsLibrary_next/CAE.h" +// clang-format on #ifdef AE_OS_WIN -#define SPRINTF(STR,IDX) sprintf_s(num, "%s%d", STR, IDX) +#define SPRINTF(STR, IDX) sprintf_s(num, "%s%d", STR, IDX) #else -#define SPRINTF(STR,IDX) sprintf_(num, "%s%d", STR, IDX) +#define SPRINTF(STR, IDX) sprintf_(num, "%s%d", STR, IDX) #endif -enum -{ - ID_TOPIC =0, - ID_ENABLED, - ID_EXTRACT, // none Light Dark - ID_BORDER_HI, - ID_SOFTNESS_HI, - ID_BORDER_LO, - ID_SOFTNESS_LO, - ID_BRIGHT, - - ID_MINMAX, - ID_MAX, - ID_BLUR, - ID_OPACITY, - ID_BLEND, - ID_TOPIC_END, - ID_COUNT +enum { + ID_TOPIC = 0, + ID_ENABLED, + ID_EXTRACT, // none Light Dark + ID_BORDER_HI, + ID_SOFTNESS_HI, + ID_BORDER_LO, + ID_SOFTNESS_LO, + ID_BRIGHT, + + ID_MINMAX, + ID_MAX, + ID_BLUR, + ID_OPACITY, + ID_BLEND, + ID_TOPIC_END, + ID_COUNT }; -enum -{ - ID_INPUT=0, - ID_BASE_ENABLED, - ID_BASE_OPACITY, - ID_FILTER_OPACITY, - ID_BASE_END +enum { + ID_INPUT = 0, + ID_BASE_ENABLED, + ID_BASE_OPACITY, + ID_FILTER_OPACITY, + ID_BASE_END }; #define PARAMSET_COUNT 4 -#define ID_NUM(n,idx) (ID_BASE_END + idx + ID_COUNT * n) -#define ID_NOISE (ID_BASE_END + ID_COUNT *PARAMSET_COUNT) -#define ID_ALPHA_ON (ID_NOISE+1) - -#define ID_NUM_PARAMS (ID_NOISE+2) - -//ID_NUM_PARAMS - -//UIの表示文字列 -#define STR_ON "on" -#define STR_BASE_ENABLED "BaseEnabled" -#define STR_BASE_OPACITY "BaseOpacity" - -#define STR_TOPIC "Filter_" -#define STR_ENABLED "Enabled_" -#define STR_EXTRACT "Extract_" -#define STR_EXTRACT_ITEMS "None|Hi|Low" -#define STR_EXTRACT_COUNT 3 -#define STR_EXTRACT_DFLT 1 -#define STR_BORDER_HI "border_hi_" -#define STR_SOFTNESS_HI "softness_hi_" -#define STR_BORDER_LO "border_lo_" -#define STR_SOFTNESS_LO "softness_lo_" -#define STR_BRIGHT "Brightness_" - -#define STR_MINMAX "MinToMax_" -#define STR_MAX "Max_" -#define STR_BLUR "Blur_" -#define STR_OPACITY "Opacity_" -#define STR_BLEND "Blend_" -#define STR_BLEND_ITEMS "Normal|Add|Screen|Lighten|LighterColor|Multiply|Darken|DarkerColor|Overlay" -#define STR_BLEND_COUNT 9 -#define STR_BLEND_DFLT 1 -#define STR_FILTER_OPACITY "FilterOpacity" - -#define STR_NOISE "Noise" -#define STR_ALPHA_ON "Alpha_ON" - -enum EXTRACT_MODE -{ - NONE=1, - HI, - LO -}; - -//UIのパラメータ +#define ID_NUM(n, idx) (ID_BASE_END + idx + ID_COUNT * n) +#define ID_NOISE (ID_BASE_END + ID_COUNT * PARAMSET_COUNT) +#define ID_ALPHA_ON (ID_NOISE + 1) + +#define ID_NUM_PARAMS (ID_NOISE + 2) + +// ID_NUM_PARAMS + +// UI display string +#define STR_ON "on" +#define STR_BASE_ENABLED "BaseEnabled" +#define STR_BASE_OPACITY "BaseOpacity" + +#define STR_TOPIC "Filter_" +#define STR_ENABLED "Enabled_" +#define STR_EXTRACT "Extract_" +#define STR_EXTRACT_ITEMS "None|Hi|Low" +#define STR_EXTRACT_COUNT 3 +#define STR_EXTRACT_DFLT 1 +#define STR_BORDER_HI "border_hi_" +#define STR_SOFTNESS_HI "softness_hi_" +#define STR_BORDER_LO "border_lo_" +#define STR_SOFTNESS_LO "softness_lo_" +#define STR_BRIGHT "Brightness_" + +#define STR_MINMAX "MinToMax_" +#define STR_MAX "Max_" +#define STR_BLUR "Blur_" +#define STR_OPACITY "Opacity_" +#define STR_BLEND "Blend_" +#define STR_BLEND_ITEMS \ + "Normal|Add|Screen|Lighten|LighterColor|Multiply|Darken|DarkerColor|Overlay" +#define STR_BLEND_COUNT 9 +#define STR_BLEND_DFLT 1 +#define STR_FILTER_OPACITY "FilterOpacity" + +#define STR_NOISE "Noise" +#define STR_ALPHA_ON "Alpha_ON" + +enum EXTRACT_MODE { NONE = 1, HI, LO }; + +// UI parameters typedef struct ParamSetInfo { - PF_Boolean enabled; - A_long extract_mode; - PF_FpLong border_hi; - PF_FpLong softness_hi; - PF_FpLong border_lo; - PF_FpLong softness_lo; - PF_FpLong brightness; - A_long minmax; - A_long max; - A_long blur; - PF_FpLong opacity; - A_long blend_mode; - -}ParamSetInfo, *ParamSetInfoP, **ParamSetInfoH; + PF_Boolean enabled; + A_long extract_mode; + PF_FpLong border_hi; + PF_FpLong softness_hi; + PF_FpLong border_lo; + PF_FpLong softness_lo; + PF_FpLong brightness; + A_long minmax; + A_long max; + A_long blur; + PF_FpLong opacity; + A_long blend_mode; + +} ParamSetInfo, *ParamSetInfoP, **ParamSetInfoH; typedef struct ParamInfo { - PF_Boolean base_enabled; - PF_FpLong base_opacity; - ParamSetInfo paramset[PARAMSET_COUNT]; - PF_FpLong noise; - PF_Boolean alpha_on; - PF_FpLong filter_opacity; + PF_Boolean base_enabled; + PF_FpLong base_opacity; + ParamSetInfo paramset[PARAMSET_COUNT]; + PF_FpLong noise; + PF_Boolean alpha_on; + PF_FpLong filter_opacity; } ParamInfo, *ParamInfoP, **ParamInfoH; -//------------------------------------------------------- PF_Err Exec(CAE *ae, ParamInfo *infoP); PF_Err Exec08(CAE *ae, ParamInfo *infoP); PF_Err Exec16(CAE *ae, ParamInfo *infoP); @@ -141,19 +128,9 @@ PF_Err Rev16(PF_EffectWorldPtr world); PF_Err Blur16(CAE *ae, PF_EffectWorldPtr world, A_long blur, PF_Handle bufH); PF_Err Brightness16(PF_EffectWorldPtr world, PF_FpLong brigtness); -//----------------------------------------------------------------------------------- extern "C" { - DllExport - PF_Err - EffectMain( - PF_Cmd cmd, - PF_InData *in_data, - PF_OutData *out_data, - PF_ParamDef *params[], - PF_LayerDef *output, - void *extra); - +DllExport PF_Err EffectMain(PF_Cmd cmd, PF_InData *in_data, + PF_OutData *out_data, PF_ParamDef *params[], + PF_LayerDef *output, void *extra); } - -#endif // Filter_H diff --git a/Source/Effects/FsFilter/FilterBlur16.cpp b/Source/Effects/FsFilter/FilterBlur16.cpp index eaa7f37..0f37af9 100644 --- a/Source/Effects/FsFilter/FilterBlur16.cpp +++ b/Source/Effects/FsFilter/FilterBlur16.cpp @@ -1,183 +1,176 @@ +// clang-format off #include "Filter.h" - -//================================================================================== -static PF_Err MakeTbl(CAE *ae, A_long blur, A_long *tbl) -{ - PF_Err err = PF_Err_NONE; - PF_InData *in_data; - in_data = ae->in_data; - - if (blur == 0) return err; - double zone = (double)blur / 3; - for (A_long i = 0; i <= blur; i++) { - tbl[i] = (A_long)(PF_EXP(-i * i / (2 * zone * zone)) * 0x100); - } - return err; - +// clang-format on + +static PF_Err MakeTbl(CAE *ae, A_long blur, A_long *tbl) { + PF_Err err = PF_Err_NONE; + PF_InData *in_data; + in_data = ae->in_data; + + if (blur == 0) return err; + double zone = (double)blur / 3; + for (A_long i = 0; i <= blur; i++) { + tbl[i] = (A_long)(PF_EXP(-i * i / (2 * zone * zone)) * 0x100); + } + return err; } -static PF_Err BlurHor(PF_EffectWorldPtr g, A_long blue, PF_Pixel16 *scanline, A_long *tbl) -{ - PF_Err err = PF_Err_NONE; - - PF_Pixel16* data = (PF_Pixel16*)g->data; - - A_long w = g->width/2; - A_long wt = g->rowbytes /sizeof(PF_Pixel16); - A_long h = g->height/2; - - A_long adr = 0; - for (A_long y = 0; y < h; y++) - { - //スキャンラインへ転送 - for (A_long x = 0; x < w; x++) { - scanline[x] = data[adr + x]; - } - for (A_long x = 0; x 0) { - r += scanline[x].red * gauss; - g += scanline[x].green * gauss; - b += scanline[x].blue * gauss; - a += scanline[x].alpha * gauss; - } - count += gauss; - for (A_long i = 1; i <= blue; i++) - { - A_long il = x - i; - gauss = tbl[i]; - if (il >= 0) { - if (scanline[il].alpha > 0) { - r += scanline[il].red * gauss; - g += scanline[il].green * gauss; - b += scanline[il].blue * gauss; - a += scanline[il].alpha * gauss; - } - count += gauss; - } - A_long ir = x + i; - if (ir < w) { - if (scanline[ir].alpha > 0) { - r += scanline[ir].red * gauss; - g += scanline[ir].green * gauss; - b += scanline[ir].blue * gauss; - a += scanline[ir].alpha * gauss; - } - count += gauss; - } - } - if (count > 0) { - data[adr + x].red = RoundShort(r / count); - data[adr + x].green = RoundShort(g / count); - data[adr + x].blue = RoundShort(b / count); - data[adr + x].alpha = RoundShort(a / count); - } - } - adr += wt; - } - return err; +static PF_Err BlurHor(PF_EffectWorldPtr g, A_long blue, PF_Pixel16 *scanline, + A_long *tbl) { + PF_Err err = PF_Err_NONE; + + PF_Pixel16 *data = (PF_Pixel16 *)g->data; + + A_long w = g->width / 2; + A_long wt = g->rowbytes / sizeof(PF_Pixel16); + A_long h = g->height / 2; + + A_long adr = 0; + for (A_long y = 0; y < h; y++) { + // Transfer to scanline + for (A_long x = 0; x < w; x++) { + scanline[x] = data[adr + x]; + } + for (A_long x = 0; x < w; x++) { + A_long count = 0; + A_long gauss = 0; + A_long r = 0; + A_long g = 0; + A_long b = 0; + A_long a = 0; + // Center + gauss = tbl[0]; + if (scanline[x].alpha > 0) { + r += scanline[x].red * gauss; + g += scanline[x].green * gauss; + b += scanline[x].blue * gauss; + a += scanline[x].alpha * gauss; + } + count += gauss; + for (A_long i = 1; i <= blue; i++) { + A_long il = x - i; + gauss = tbl[i]; + if (il >= 0) { + if (scanline[il].alpha > 0) { + r += scanline[il].red * gauss; + g += scanline[il].green * gauss; + b += scanline[il].blue * gauss; + a += scanline[il].alpha * gauss; + } + count += gauss; + } + A_long ir = x + i; + if (ir < w) { + if (scanline[ir].alpha > 0) { + r += scanline[ir].red * gauss; + g += scanline[ir].green * gauss; + b += scanline[ir].blue * gauss; + a += scanline[ir].alpha * gauss; + } + count += gauss; + } + } + if (count > 0) { + data[adr + x].red = RoundShort(r / count); + data[adr + x].green = RoundShort(g / count); + data[adr + x].blue = RoundShort(b / count); + data[adr + x].alpha = RoundShort(a / count); + } + } + adr += wt; + } + return err; } -static PF_Err BlurVur(PF_EffectWorldPtr g, A_long blue, PF_Pixel16 *scanline, A_long *tbl) -{ - PF_Err err = PF_Err_NONE; - - PF_Pixel16* data = (PF_Pixel16*)g->data; - - A_long w = g->width / 2; - A_long wt = g->rowbytes /sizeof(PF_Pixel16); - A_long h = g->height / 2; - - A_long adr = 0; - for (A_long x = 0; x < w; x++) - { - //スキャンラインへ転送 - adr = 0; - for (A_long y = 0; y < h; y++) { - scanline[y] = data[x + adr]; - adr += wt; - } - adr = x; - for (A_long y = 0; y < h; y++) { - A_long count = 0; - A_long gauss = 0; - A_long r = 0; - A_long g = 0; - A_long b = 0; - A_long a = 0; - //真ん中 - gauss = tbl[0]; - if (scanline[y].alpha > 0) { - r += scanline[y].red * gauss; - g += scanline[y].green * gauss; - b += scanline[y].blue * gauss; - a += scanline[y].alpha * gauss; - } - count += gauss; - for (A_long i = 1; i <= blue; i++) - { - A_long il = y - i; - gauss = tbl[i]; - if (il >= 0) { - if (scanline[il].alpha > 0) { - r += scanline[il].red * gauss; - g += scanline[il].green * gauss; - b += scanline[il].blue * gauss; - a += scanline[il].alpha * gauss; - } - count += gauss; - } - A_long ir = y + i; - if (ir < h) { - if (scanline[ir].alpha > 0) { - r += scanline[ir].red * gauss; - g += scanline[ir].green * gauss; - b += scanline[ir].blue * gauss; - a += scanline[ir].alpha * gauss; - } - count += gauss; - } - } - if (count > 0) { - data[adr].red = RoundShort(r / count); - data[adr].green = RoundShort(g / count); - data[adr].blue = RoundShort(b / count); - data[adr].alpha = RoundShort(a / count); - } - adr += wt; - } - } - return err; +static PF_Err BlurVur(PF_EffectWorldPtr g, A_long blue, PF_Pixel16 *scanline, + A_long *tbl) { + PF_Err err = PF_Err_NONE; + + PF_Pixel16 *data = (PF_Pixel16 *)g->data; + + A_long w = g->width / 2; + A_long wt = g->rowbytes / sizeof(PF_Pixel16); + A_long h = g->height / 2; + + A_long adr = 0; + for (A_long x = 0; x < w; x++) { + // Transfer to scanline + adr = 0; + for (A_long y = 0; y < h; y++) { + scanline[y] = data[x + adr]; + adr += wt; + } + adr = x; + for (A_long y = 0; y < h; y++) { + A_long count = 0; + A_long gauss = 0; + A_long r = 0; + A_long g = 0; + A_long b = 0; + A_long a = 0; + // Center + gauss = tbl[0]; + if (scanline[y].alpha > 0) { + r += scanline[y].red * gauss; + g += scanline[y].green * gauss; + b += scanline[y].blue * gauss; + a += scanline[y].alpha * gauss; + } + count += gauss; + for (A_long i = 1; i <= blue; i++) { + A_long il = y - i; + gauss = tbl[i]; + if (il >= 0) { + if (scanline[il].alpha > 0) { + r += scanline[il].red * gauss; + g += scanline[il].green * gauss; + b += scanline[il].blue * gauss; + a += scanline[il].alpha * gauss; + } + count += gauss; + } + A_long ir = y + i; + if (ir < h) { + if (scanline[ir].alpha > 0) { + r += scanline[ir].red * gauss; + g += scanline[ir].green * gauss; + b += scanline[ir].blue * gauss; + a += scanline[ir].alpha * gauss; + } + count += gauss; + } + } + if (count > 0) { + data[adr].red = RoundShort(r / count); + data[adr].green = RoundShort(g / count); + data[adr].blue = RoundShort(b / count); + data[adr].alpha = RoundShort(a / count); + } + adr += wt; + } + } + return err; } +PF_Err Blur16(CAE *ae, PF_EffectWorldPtr world, A_long blur, PF_Handle bufH) { + PF_Err err = PF_Err_NONE; + if (blur == 0) return err; + PF_InData *in_data; + in_data = ae->in_data; -PF_Err Blur16(CAE *ae, PF_EffectWorldPtr world, A_long blur, PF_Handle bufH) -{ - PF_Err err = PF_Err_NONE; - if (blur == 0) return err; - PF_InData *in_data; - in_data = ae->in_data; - - //scanline - PF_Pixel16* scanline = *(PF_Pixel16**)bufH; + // scanline + PF_Pixel16 *scanline = *(PF_Pixel16 **)bufH; - A_long w = world->width; - if (w < world->height) w = world->height; - //table - A_long * tbl = (A_long *)(scanline + w); + A_long w = world->width; + if (w < world->height) w = world->height; + // table + A_long *tbl = (A_long *)(scanline + w); - blur = (A_long)PF_CEIL(blur); - if (blur < 1) blur = 1; - MakeTbl(ae, blur, tbl); + blur = (A_long)PF_CEIL(blur); + if (blur < 1) blur = 1; + MakeTbl(ae, blur, tbl); - BlurHor(world, blur, scanline,tbl); - BlurVur(world, blur, scanline, tbl); + BlurHor(world, blur, scanline, tbl); + BlurVur(world, blur, scanline, tbl); - return err; + return err; } diff --git a/Source/Effects/FsFilter/FilterExec08.cpp b/Source/Effects/FsFilter/FilterExec08.cpp index 3bd1eb6..98563fd 100644 --- a/Source/Effects/FsFilter/FilterExec08.cpp +++ b/Source/Effects/FsFilter/FilterExec08.cpp @@ -1,148 +1,121 @@ +// clang-format off #include "Filter.h" - - - -static PF_Err -BaseCopy8( - refconType refcon, - A_long xL, - A_long yL, - PF_Pixel8 *inP, - PF_Pixel8 *outP) -{ - PF_Err err = PF_Err_NONE; - ParamInfo * infoP = reinterpret_cast(refcon); - PF_Pixel bl = { 0,0,0,0 }; - - double a = (double)inP->alpha * infoP->base_opacity; - if (a < 0) a = 0; else if (a > PF_MAX_CHAN8) a = PF_MAX_CHAN8; - if (a <= 0) - { - *outP = bl; - } - else if (a >= PF_MAX_CHAN8) { - *outP = *inP; - } - else { - outP->alpha = (A_u_char)a; - outP->red = RoundByteDouble((double)inP->red * a / PF_MAX_CHAN8); - outP->green = RoundByteDouble((double)inP->green * a / PF_MAX_CHAN8); - outP->blue = RoundByteDouble((double)inP->blue * a / PF_MAX_CHAN8); - } - - - return err; +// clang-format on + +static PF_Err BaseCopy8(refconType refcon, A_long xL, A_long yL, PF_Pixel8 *inP, + PF_Pixel8 *outP) { + PF_Err err = PF_Err_NONE; + ParamInfo *infoP = reinterpret_cast(refcon); + PF_Pixel bl = {0, 0, 0, 0}; + + double a = (double)inP->alpha * infoP->base_opacity; + if (a < 0) + a = 0; + else if (a > PF_MAX_CHAN8) + a = PF_MAX_CHAN8; + if (a <= 0) { + *outP = bl; + } else if (a >= PF_MAX_CHAN8) { + *outP = *inP; + } else { + outP->alpha = RoundByteDouble(a); + outP->red = RoundByteDouble((double)inP->red * a / PF_MAX_CHAN8); + outP->green = RoundByteDouble((double)inP->green * a / PF_MAX_CHAN8); + outP->blue = RoundByteDouble((double)inP->blue * a / PF_MAX_CHAN8); + } + + return err; } -//================================================================================== -PF_Err Exec08(CAE *ae, ParamInfo *infoP) -{ - PF_Err err = PF_Err_NONE; - PF_InData *in_data; - in_data = ae->in_data; - - //baseの処理 Matにする - if (infoP->base_enabled == TRUE) { - ERR(ae->iterate8((refconType)infoP, BaseCopy8)); - } - if ((infoP->paramset[0].enabled == FALSE) - && (infoP->paramset[1].enabled == FALSE) - && (infoP->paramset[2].enabled == FALSE) - && (infoP->paramset[3].enabled == FALSE)) { - } - else { - //16bitの画像作成 - PF_EffectWorld world; - AEFX_CLR_STRUCT(world); - PF_EffectWorldPtr worldP = &world; - - //バッファーの作成 - ERR(ae->NewWorld(ae->output->width, ae->output->height, PF_PixelFormat_ARGB64,worldP)); - - A_long w = ae->output->width; - if (w < ae->output->height) w = ae->output->height; - - PF_Handle bufH = PF_NEW_HANDLE(sizeof(PF_Pixel16)*w * 2); - if (bufH == NULL) return PF_Err_OUT_OF_MEMORY; - - - - ParamSetInfo si; - for (A_long i = 0; i < PARAMSET_COUNT; i++) - { - AEFX_CLR_STRUCT(si); - si = infoP->paramset[i]; - if (si.enabled == FALSE) continue; - if (si.opacity <= 0) continue; - //バッファーに転送 - ERR(World08To16(ae->input, worldP)); - //Matの処理 - ERR(ToPremultiply16(worldP)); - switch (si.extract_mode) - { - case EXTRACT_MODE::HI: - ERR(ExtractHi16(worldP, si.border_hi, si.softness_hi)); - break; - case EXTRACT_MODE::LO: - ERR(ExtractLo16(worldP, si.border_lo, si.softness_lo)); - break; - } - if (si.brightness != 0) - { - ERR(Brightness16(worldP, si.brightness)); - } - if ((si.minmax > 0) || (si.max > 0) || (si.blur > 0)) - { - ERR(ToHarfSize16(worldP)); - if (si.minmax > 0) - { - ERR(Rev16(worldP)); - ERR(Max16(worldP, si.minmax, bufH)); - ERR(Rev16(worldP)); - ERR(Max16(worldP, si.minmax, bufH)); - } - if (si.max > 0) - { - ERR(Max16(worldP, si.max, bufH)); - } - if (si.blur > 0) - { - ERR(Blur16(ae,worldP, si.blur, bufH)); - } - - ERR(ToDoubleSize16(worldP, bufH)); - } - - //outへ転送 Blend処理 - ERR(Blend16To08(worldP, ae->output, si.blend_mode,si.opacity)); - - } - - if (bufH != NULL) - { - PF_DISPOSE_HANDLE(bufH); - } - //バッファーを消す - ERR(ae->DisposeWorld(worldP)); - } - - if (infoP->noise > 0) - { - Noise08(ae->output, infoP->noise); - } - - - - //Matから元に戻す - if (infoP->alpha_on == TRUE) - { - ERR(AlphaON08(ae->output)); - } - else - { - ERR(FromPremultiply08(ae->output)); - } - - return err; - +PF_Err Exec08(CAE *ae, ParamInfo *infoP) { + PF_Err err = PF_Err_NONE; + PF_InData *in_data; + in_data = ae->in_data; + + // Base processing to Mat + if (infoP->base_enabled == TRUE) { + ERR(ae->iterate8((refconType)infoP, BaseCopy8)); + } + if ((infoP->paramset[0].enabled == FALSE) && + (infoP->paramset[1].enabled == FALSE) && + (infoP->paramset[2].enabled == FALSE) && + (infoP->paramset[3].enabled == FALSE)) { + } else { + // Create 16bit image + PF_EffectWorld world; + AEFX_CLR_STRUCT(world); + PF_EffectWorldPtr worldP = &world; + + // Create buffer + ERR(ae->NewWorld(ae->output->width, ae->output->height, + PF_PixelFormat_ARGB64, worldP)); + + A_long w = ae->output->width; + if (w < ae->output->height) w = ae->output->height; + + PF_Handle bufH = PF_NEW_HANDLE(sizeof(PF_Pixel16) * w * 2); + if (bufH == NULL) return PF_Err_OUT_OF_MEMORY; + + ParamSetInfo si; + for (A_long i = 0; i < PARAMSET_COUNT; i++) { + AEFX_CLR_STRUCT(si); + si = infoP->paramset[i]; + if (si.enabled == FALSE) continue; + if (si.opacity <= 0) continue; + // Transfer to buffer + ERR(World08To16(ae->input, worldP)); + // Mat processing + ERR(ToPremultiply16(worldP)); + switch (si.extract_mode) { + case EXTRACT_MODE::HI: + ERR(ExtractHi16(worldP, si.border_hi, si.softness_hi)); + break; + case EXTRACT_MODE::LO: + ERR(ExtractLo16(worldP, si.border_lo, si.softness_lo)); + break; + } + if (si.brightness != 0) { + ERR(Brightness16(worldP, si.brightness)); + } + if ((si.minmax > 0) || (si.max > 0) || (si.blur > 0)) { + ERR(ToHarfSize16(worldP)); + if (si.minmax > 0) { + ERR(Rev16(worldP)); + ERR(Max16(worldP, si.minmax, bufH)); + ERR(Rev16(worldP)); + ERR(Max16(worldP, si.minmax, bufH)); + } + if (si.max > 0) { + ERR(Max16(worldP, si.max, bufH)); + } + if (si.blur > 0) { + ERR(Blur16(ae, worldP, si.blur, bufH)); + } + + ERR(ToDoubleSize16(worldP, bufH)); + } + + // Transfer to out Blend processing + ERR(Blend16To08(worldP, ae->output, si.blend_mode, si.opacity)); + } + + if (bufH != NULL) { + PF_DISPOSE_HANDLE(bufH); + } + // Delete buffer + ERR(ae->DisposeWorld(worldP)); + } + + if (infoP->noise > 0) { + Noise08(ae->output, infoP->noise); + } + + // Restore from Mat + if (infoP->alpha_on == TRUE) { + ERR(AlphaON08(ae->output)); + } else { + ERR(FromPremultiply08(ae->output)); + } + + return err; } \ No newline at end of file diff --git a/Source/Effects/FsFilter/FilterExec16.cpp b/Source/Effects/FsFilter/FilterExec16.cpp index 93177b4..f77075e 100644 --- a/Source/Effects/FsFilter/FilterExec16.cpp +++ b/Source/Effects/FsFilter/FilterExec16.cpp @@ -1,151 +1,125 @@ +// clang-format off #include "Filter.h" -typedef struct OpacityInfo -{ - PF_FpLong opacity; -}OpacityInfo , *OpacityInfoP, **OpacityInfoH; - - -static PF_Err -BaseCopy16( - refconType refcon, - A_long xL, - A_long yL, - PF_Pixel16 *inP, - PF_Pixel16 *outP) -{ - PF_Err err = PF_Err_NONE; - ParamInfo * infoP = reinterpret_cast(refcon); - PF_Pixel16 bl = { 0,0,0,0 }; - - double a = (double)inP->alpha * infoP->base_opacity; - if (a < 0) a = 0; else if (a > PF_MAX_CHAN16) a = PF_MAX_CHAN16; - if (a <= 0) - { - *outP = bl; - } - else if (a >= PF_MAX_CHAN16) { - *outP = *inP; - } - else { - outP->alpha = (A_u_short)a; - outP->red = RoundShortFpLong((double)inP->red * a / PF_MAX_CHAN16); - outP->green = RoundShortFpLong((double)inP->green * a / PF_MAX_CHAN16); - outP->blue = RoundShortFpLong((double)inP->blue * a / PF_MAX_CHAN16); - } - - - return err; +// clang-format on + +typedef struct OpacityInfo { + PF_FpLong opacity; +} OpacityInfo, *OpacityInfoP, **OpacityInfoH; + +static PF_Err BaseCopy16(refconType refcon, A_long xL, A_long yL, + PF_Pixel16 *inP, PF_Pixel16 *outP) { + PF_Err err = PF_Err_NONE; + ParamInfo *infoP = reinterpret_cast(refcon); + PF_Pixel16 bl = {0, 0, 0, 0}; + + double a = (double)inP->alpha * infoP->base_opacity; + if (a < 0) + a = 0; + else if (a > PF_MAX_CHAN16) + a = PF_MAX_CHAN16; + if (a <= 0) { + *outP = bl; + } else if (a >= PF_MAX_CHAN16) { + *outP = *inP; + } else { + outP->alpha = RoundShortFpLong(a); + outP->red = RoundShortFpLong((double)inP->red * a / PF_MAX_CHAN16); + outP->green = RoundShortFpLong((double)inP->green * a / PF_MAX_CHAN16); + outP->blue = RoundShortFpLong((double)inP->blue * a / PF_MAX_CHAN16); + } + + return err; } -//================================================================================== -PF_Err Exec16(CAE *ae, ParamInfo *infoP) -{ - PF_Err err = PF_Err_NONE; - PF_InData *in_data; - in_data = ae->in_data; - - //baseの処理 Matにする - if (infoP->base_enabled == TRUE) { - ERR(ae->iterate16((refconType)infoP, BaseCopy16)); - } - if ((infoP->paramset[0].enabled == FALSE) - && (infoP->paramset[1].enabled == FALSE) - && (infoP->paramset[2].enabled == FALSE) - && (infoP->paramset[3].enabled == FALSE)) { - } - else { - //16bitの画像作成 - PF_EffectWorld world; - AEFX_CLR_STRUCT(world); - PF_EffectWorldPtr worldP = &world; - - //バッファーの作成 - ERR(ae->NewWorld(ae->output->width, ae->output->height, PF_PixelFormat_ARGB64,worldP)); - - A_long w = ae->output->width; - if (w < ae->output->height) w = ae->output->height; - - PF_Handle bufH = PF_NEW_HANDLE(sizeof(PF_Pixel16)*w * 2); - if (bufH == NULL) return PF_Err_OUT_OF_MEMORY; - - - - ParamSetInfo si; - for (A_long i = 0; i < PARAMSET_COUNT; i++) - { - AEFX_CLR_STRUCT(si); - si = infoP->paramset[i]; - if (si.enabled == FALSE) continue; - if (si.opacity <= 0) continue; - //バッファーに転送 - ERR(World16To16(ae->input, worldP)); - //Matの処理 - ERR(ToPremultiply16(worldP)); - switch (si.extract_mode) - { - case EXTRACT_MODE::HI: - ERR(ExtractHi16(worldP, si.border_hi, si.softness_hi)); - break; - case EXTRACT_MODE::LO: - ERR(ExtractLo16(worldP, si.border_lo, si.softness_lo)); - break; - } - if (si.brightness != 0) - { - ERR(Brightness16(worldP, si.brightness)); - } - if ((si.minmax > 0) || (si.max > 0) || (si.blur > 0)) - { - ERR(ToHarfSize16(worldP)); - if (si.minmax > 0) - { - ERR(Rev16(worldP)); - ERR(Max16(worldP, si.minmax, bufH)); - ERR(Rev16(worldP)); - ERR(Max16(worldP, si.minmax, bufH)); - } - if (si.max > 0) - { - ERR(Max16(worldP, si.max, bufH)); - } - if (si.blur > 0) - { - ERR(Blur16(ae,worldP, si.blur, bufH)); - } - - ERR(ToDoubleSize16(worldP, bufH)); - } - - //outへ転送 Blend処理 - ERR(Blend16To16(worldP, ae->output, si.blend_mode,si.opacity)); - - } - - if (bufH != NULL) - { - PF_DISPOSE_HANDLE(bufH); - } - //バッファーを消す - ERR(ae->DisposeWorld(worldP)); - } - - if (infoP->noise > 0) - { - Noise16(ae->output, infoP->noise); - } - - - - //Matから元に戻す - if (infoP->alpha_on == TRUE) - { - ERR(AlphaON16(ae->output)); - } - else - { - ERR(FromPremultiply16(ae->output)); - } - - return err; - +PF_Err Exec16(CAE *ae, ParamInfo *infoP) { + PF_Err err = PF_Err_NONE; + PF_InData *in_data; + in_data = ae->in_data; + + // Base processing to Mat + if (infoP->base_enabled == TRUE) { + ERR(ae->iterate16((refconType)infoP, BaseCopy16)); + } + if ((infoP->paramset[0].enabled == FALSE) && + (infoP->paramset[1].enabled == FALSE) && + (infoP->paramset[2].enabled == FALSE) && + (infoP->paramset[3].enabled == FALSE)) { + } else { + // Create 16bit image + PF_EffectWorld world; + AEFX_CLR_STRUCT(world); + PF_EffectWorldPtr worldP = &world; + + // Create buffer + ERR(ae->NewWorld(ae->output->width, ae->output->height, + PF_PixelFormat_ARGB64, worldP)); + + A_long w = ae->output->width; + if (w < ae->output->height) w = ae->output->height; + + PF_Handle bufH = PF_NEW_HANDLE(sizeof(PF_Pixel16) * w * 2); + if (bufH == NULL) return PF_Err_OUT_OF_MEMORY; + + ParamSetInfo si; + for (A_long i = 0; i < PARAMSET_COUNT; i++) { + AEFX_CLR_STRUCT(si); + si = infoP->paramset[i]; + if (si.enabled == FALSE) continue; + if (si.opacity <= 0) continue; + // Transfer to buffer + ERR(World16To16(ae->input, worldP)); + // Mat processing + ERR(ToPremultiply16(worldP)); + switch (si.extract_mode) { + case EXTRACT_MODE::HI: + ERR(ExtractHi16(worldP, si.border_hi, si.softness_hi)); + break; + case EXTRACT_MODE::LO: + ERR(ExtractLo16(worldP, si.border_lo, si.softness_lo)); + break; + } + if (si.brightness != 0) { + ERR(Brightness16(worldP, si.brightness)); + } + if ((si.minmax > 0) || (si.max > 0) || (si.blur > 0)) { + ERR(ToHarfSize16(worldP)); + if (si.minmax > 0) { + ERR(Rev16(worldP)); + ERR(Max16(worldP, si.minmax, bufH)); + ERR(Rev16(worldP)); + ERR(Max16(worldP, si.minmax, bufH)); + } + if (si.max > 0) { + ERR(Max16(worldP, si.max, bufH)); + } + if (si.blur > 0) { + ERR(Blur16(ae, worldP, si.blur, bufH)); + } + + ERR(ToDoubleSize16(worldP, bufH)); + } + + // Transfer to out Blend processing + ERR(Blend16To16(worldP, ae->output, si.blend_mode, si.opacity)); + } + + if (bufH != NULL) { + PF_DISPOSE_HANDLE(bufH); + } + // Delete buffer + ERR(ae->DisposeWorld(worldP)); + } + + if (infoP->noise > 0) { + Noise16(ae->output, infoP->noise); + } + + // Restore from Mat + if (infoP->alpha_on == TRUE) { + ERR(AlphaON16(ae->output)); + } else { + ERR(FromPremultiply16(ae->output)); + } + + return err; } \ No newline at end of file diff --git a/Source/Effects/FsFilter/FilterMax16.cpp b/Source/Effects/FsFilter/FilterMax16.cpp index 05db45a..9cd0b70 100644 --- a/Source/Effects/FsFilter/FilterMax16.cpp +++ b/Source/Effects/FsFilter/FilterMax16.cpp @@ -1,114 +1,103 @@ +// clang-format off #include "Filter.h" +// clang-format on -static PF_Err MaxAllHor(PF_EffectWorldPtr g, A_long max, PF_Handle bufH) -{ - PF_Err err = PF_Err_NONE; +static PF_Err MaxAllHor(PF_EffectWorldPtr g, A_long max, PF_Handle bufH) { + PF_Err err = PF_Err_NONE; - PF_Pixel16* data = (PF_Pixel16*)g->data; + PF_Pixel16* data = (PF_Pixel16*)g->data; - A_long w = g->width / 2; - A_long wt = g->rowbytes / sizeof(PF_Pixel16); - A_long h = g->height / 2; + A_long w = g->width / 2; + A_long wt = g->rowbytes / sizeof(PF_Pixel16); + A_long h = g->height / 2; - PF_Pixel16* scanline = *(PF_Pixel16**)bufH; - A_u_short* scanlineLv = (A_u_short *)(scanline + wt); + PF_Pixel16* scanline = *(PF_Pixel16**)bufH; + A_u_short* scanlineLv = (A_u_short*)(scanline + wt); - A_long target = 0; - for (A_long y = 0; y < h; y++) - { - A_long ypos = y * wt; + A_long target = 0; + for (A_long y = 0; y < h; y++) { + A_long ypos = y * wt; - A_u_short mv = 0; - //scanline mvで最大値を記憶しておく - for (A_long i = 0; i < w; i++) - { - scanline[i] = data[ypos + i]; - scanlineLv[i] = RoundShort(((A_long)data[ypos + i].red + (A_long)data[ypos + i].green + (A_long)data[ypos + i].blue) / 3); - if (mv < scanlineLv[i]) mv = scanlineLv[i]; - } - if (mv <= 0) continue; // 最大値が0なら必要なし + A_u_short mv = 0; + // Store the maximum value in scanline mv + for (A_long i = 0; i < w; i++) { + scanline[i] = data[ypos + i]; + scanlineLv[i] = RoundShort(((A_long)data[ypos + i].red + + (A_long)data[ypos + i].green + + (A_long)data[ypos + i].blue) / + 3); + if (mv < scanlineLv[i]) mv = scanlineLv[i]; + } + if (mv <= 0) continue; // Not necessary if the maximum value is 0 - for (A_long x = 0; x < w; x++) - { - A_u_short t = 0; - PF_Pixel16 c = { 0,0,0,0 }; - for (A_long i = -max; i <= max; i++) - { - A_long x2 = x + i; - if (x2 < 0) continue; - if (x2 >= w) break; - if (t < scanlineLv[x2]) - { - t = scanlineLv[x2]; - c = scanline[x2]; - } - if (t >= mv) break; - } - data[ypos + x] = c; - - } - } - return err; + for (A_long x = 0; x < w; x++) { + A_u_short t = 0; + PF_Pixel16 c = {0, 0, 0, 0}; + for (A_long i = -max; i <= max; i++) { + A_long x2 = x + i; + if (x2 < 0) continue; + if (x2 >= w) break; + if (t < scanlineLv[x2]) { + t = scanlineLv[x2]; + c = scanline[x2]; + } + if (t >= mv) break; + } + data[ypos + x] = c; + } + } + return err; } -static PF_Err MaxAllVur(PF_EffectWorldPtr g, A_long max, PF_Handle bufH) -{ - PF_Err err = PF_Err_NONE; - PF_Pixel16* data = (PF_Pixel16*)g->data; - A_long w = g->width / 2; - A_long wt = g->rowbytes / sizeof(PF_Pixel16); - A_long h = g->height / 2; - - PF_Pixel16* scanline = *(PF_Pixel16**)bufH; - A_u_short* scanlineLv = (A_u_short *)(scanline + wt); - - - A_long target = 0; - for (A_long x = 0; x < w; x++) - { +static PF_Err MaxAllVur(PF_EffectWorldPtr g, A_long max, PF_Handle bufH) { + PF_Err err = PF_Err_NONE; + PF_Pixel16* data = (PF_Pixel16*)g->data; + A_long w = g->width / 2; + A_long wt = g->rowbytes / sizeof(PF_Pixel16); + A_long h = g->height / 2; - A_u_short mv = 0; - A_long ypos = 0; - //scanline mvで最大値を記憶しておく - for (A_long i = 0; i < h; i++) - { - A_long p = x + ypos; - scanline[i] = data[p]; - scanlineLv[i] = RoundShort(((A_long)data[p].red + (A_long)data[p].green + (A_long)data[p].blue) / 3); - if (mv < scanlineLv[i]) mv = scanlineLv[i]; - ypos += wt; - } - if (mv <= 0) continue; // 最大値が0なら必要なし - ypos = 0; - for (A_long y = 0; y < h; y++) - { - A_u_short t = 0; - PF_Pixel16 c = { 0,0,0,0 }; - for (A_long i = -max; i <= max; i++) - { - A_long y2 = y + i; - if ((y2 >= 0) && (y2 < h)) - { - if (t < scanlineLv[y2]) - { - t = scanlineLv[y2]; - c = scanline[y2]; - } - if (t >= mv) break; + PF_Pixel16* scanline = *(PF_Pixel16**)bufH; + A_u_short* scanlineLv = (A_u_short*)(scanline + wt); - } - } - data[ypos + x] = c; - ypos += wt; - } - } - return err; + A_long target = 0; + for (A_long x = 0; x < w; x++) { + A_u_short mv = 0; + A_long ypos = 0; + // Store the maximum value in scanline mv + for (A_long i = 0; i < h; i++) { + A_long p = x + ypos; + scanline[i] = data[p]; + scanlineLv[i] = RoundShort( + ((A_long)data[p].red + (A_long)data[p].green + (A_long)data[p].blue) / + 3); + if (mv < scanlineLv[i]) mv = scanlineLv[i]; + ypos += wt; + } + if (mv <= 0) continue; // Not necessary if the maximum value is 0 + ypos = 0; + for (A_long y = 0; y < h; y++) { + A_u_short t = 0; + PF_Pixel16 c = {0, 0, 0, 0}; + for (A_long i = -max; i <= max; i++) { + A_long y2 = y + i; + if ((y2 >= 0) && (y2 < h)) { + if (t < scanlineLv[y2]) { + t = scanlineLv[y2]; + c = scanline[y2]; + } + if (t >= mv) break; + } + } + data[ypos + x] = c; + ypos += wt; + } + } + return err; } -PF_Err Max16(PF_EffectWorldPtr world, A_long max, PF_Handle bufH) -{ - PF_Err err = PF_Err_NONE; - if (max == 0) return err; - MaxAllHor(world, max, bufH); - MaxAllVur(world, max, bufH); +PF_Err Max16(PF_EffectWorldPtr world, A_long max, PF_Handle bufH) { + PF_Err err = PF_Err_NONE; + if (max == 0) return err; + MaxAllHor(world, max, bufH); + MaxAllVur(world, max, bufH); - return err; + return err; } diff --git a/Source/Effects/FsFilter/FilterSub16.cpp b/Source/Effects/FsFilter/FilterSub16.cpp index d157d2b..68bb77a 100644 --- a/Source/Effects/FsFilter/FilterSub16.cpp +++ b/Source/Effects/FsFilter/FilterSub16.cpp @@ -1,307 +1,238 @@ +// clang-format off #include "Filter.h" - - -PF_Err ToHarfSize16(PF_EffectWorldPtr world) -{ - PF_Err err = PF_Err_NONE; - A_long ow = world->width; - A_long owt = world->rowbytes / sizeof(PF_Pixel16); - A_long oh = world->height; - - A_long wh = ow / 2; - A_long hh = oh / 2; - PF_Pixel16* data = (PF_Pixel16*)world->data; - PF_Pixel16 bl = { 0,0,0,0 }; - - //まず水平方向 - for (A_long y = 0; y < oh; y++) - { - A_long ypos = y * owt; - for (A_long x = 0; x < wh; x++) - { - PF_Pixel16 c0, c1, c2; - c0 = data[ypos + 2 * x + 0]; - c1 = data[ypos + 2 * x + 1]; - c2.red = (A_u_short)(((long)c0.red + (long)c1.red) / 2); - c2.green = (A_u_short)(((long)c0.green + (long)c1.green) / 2); - c2.blue = (A_u_short)(((long)c0.blue + (long)c1.blue) / 2); - c2.alpha = (A_u_short)(((long)c0.alpha + (long)c1.alpha) / 2); - data[ypos + x] = c2; - - } - for (A_long x = wh; x < ow; x++) - { - data[ypos + x] = bl; - } - - } - //垂直 - for (A_long x = 0; x < ow; x++) - { - A_long ypos = 0; - A_long ypos2 = 0; - - for (A_long y = 0; y < hh; y++) - { - PF_Pixel16 c0, c1, c2; - c0 = data[x + ypos]; - ypos += owt; - c1 = data[x + ypos]; - ypos += owt; - c2.red = (A_u_short)(((long)c0.red + (long)c1.red) / 2); - c2.green = (A_u_short)(((long)c0.green + (long)c1.green) / 2); - c2.blue = (A_u_short)(((long)c0.blue + (long)c1.blue) / 2); - c2.alpha = (A_u_short)(((long)c0.alpha + (long)c1.alpha) / 2); - data[x + ypos2] = c2; - ypos2 += owt; - - } - for (A_long y = hh; y < oh; y++) - { - data[x + ypos2] = bl; - ypos2 += owt; - } - } - - - return err; +// clang-format on + +PF_Err ToHarfSize16(PF_EffectWorldPtr world) { + PF_Err err = PF_Err_NONE; + A_long ow = world->width; + A_long owt = world->rowbytes / sizeof(PF_Pixel16); + A_long oh = world->height; + + A_long wh = ow / 2; + A_long hh = oh / 2; + PF_Pixel16 *data = (PF_Pixel16 *)world->data; + PF_Pixel16 bl = {0, 0, 0, 0}; + + // First, horizontal direction + for (A_long y = 0; y < oh; y++) { + A_long ypos = y * owt; + for (A_long x = 0; x < wh; x++) { + PF_Pixel16 c0, c1, c2; + c0 = data[ypos + 2 * x + 0]; + c1 = data[ypos + 2 * x + 1]; + c2.red = (A_u_short)(((long)c0.red + (long)c1.red) / 2); + c2.green = (A_u_short)(((long)c0.green + (long)c1.green) / 2); + c2.blue = (A_u_short)(((long)c0.blue + (long)c1.blue) / 2); + c2.alpha = (A_u_short)(((long)c0.alpha + (long)c1.alpha) / 2); + data[ypos + x] = c2; + } + for (A_long x = wh; x < ow; x++) { + data[ypos + x] = bl; + } + } + // Vertical + for (A_long x = 0; x < ow; x++) { + A_long ypos = 0; + A_long ypos2 = 0; + + for (A_long y = 0; y < hh; y++) { + PF_Pixel16 c0, c1, c2; + c0 = data[x + ypos]; + ypos += owt; + c1 = data[x + ypos]; + ypos += owt; + c2.red = (A_u_short)(((long)c0.red + (long)c1.red) / 2); + c2.green = (A_u_short)(((long)c0.green + (long)c1.green) / 2); + c2.blue = (A_u_short)(((long)c0.blue + (long)c1.blue) / 2); + c2.alpha = (A_u_short)(((long)c0.alpha + (long)c1.alpha) / 2); + data[x + ypos2] = c2; + ypos2 += owt; + } + for (A_long y = hh; y < oh; y++) { + data[x + ypos2] = bl; + ypos2 += owt; + } + } + + return err; } -//========================================================================================= -PF_Err ToDoubleSize16(PF_EffectWorldPtr world, PF_Handle bufH) -{ - PF_Err err = PF_Err_NONE; - A_long ow = world->width; - A_long owt = world->rowbytes / sizeof(PF_Pixel16); - A_long oh = world->height; - - A_long hw = ow / 2; - A_long hh = oh / 2; - PF_Pixel16* data = (PF_Pixel16*)world->data; - PF_Pixel16 bl = { 0,0,0,0 }; - PF_Pixel16* scanline = *(PF_Pixel16**)bufH; - - //まず水平方向 - for (A_long y = 0; y < oh; y++) - { - A_long ypos = y * owt; - //スキャンラインへ転送 - for (A_long x = 0; x < hw; x++) scanline[x] = data[x + ypos]; - for (A_long x = 0; x < hw; x++) - { - A_long x1 = x; if (x1 >= hw) x1 = hw - 1; - A_long x2 = x + 1; if (x2 >= hw) x2 = hw - 1; - PF_Pixel16 c0 = scanline[x1]; - PF_Pixel16 c1 = scanline[x2]; - PF_Pixel16 c2; - if (x1 == x2) { - c2 = c0; - } - else { - c2.red = (A_u_short)(((long)c0.red + (long)c1.red) / 2); - c2.green = (A_u_short)(((long)c0.green + (long)c1.green) / 2); - c2.blue = (A_u_short)(((long)c0.blue + (long)c1.blue) / 2); - c2.alpha = (A_u_short)(((long)c0.alpha + (long)c1.alpha) / 2); - } - x2 = 2 * x; - data[x2 + ypos] = c0; - x2++; - if (x2 < ow) { - data[x2 + ypos] = c2; - } - } - - } - //垂直 - for (A_long x = 0; x < ow; x++) - { - A_long ypos = 0; - A_long ypos2 = 0; - - //スキャンラインへ転送 - for (A_long y = 0; y < hh; y++) - { - scanline[y] = data[x + ypos]; - ypos += owt; - } - ypos = 0; - for (A_long y = 0; y < hh; y++) - { - A_long y1 = y; if (y1 >= hh) y1 = hh - 1; - A_long y2 = y + 1; if (y2 >= hh) y2 = hh - 1; - PF_Pixel16 c0 = scanline[y1]; - PF_Pixel16 c1 = scanline[y2]; - PF_Pixel16 c2; - if (y1 == y2) { - c2 = c0; - } - else { - c2.red = (A_u_short)(((long)c0.red + (long)c1.red) / 2); - c2.green = (A_u_short)(((long)c0.green + (long)c1.green) / 2); - c2.blue = (A_u_short)(((long)c0.blue + (long)c1.blue) / 2); - c2.alpha = (A_u_short)(((long)c0.alpha + (long)c1.alpha) / 2); - } - data[x + ypos] = c0; - ypos += owt; - if (y * 2 + 1 < oh) { - data[x + ypos] = c2; - } - ypos += owt; - - } - - } - - return err; +PF_Err ToDoubleSize16(PF_EffectWorldPtr world, PF_Handle bufH) { + PF_Err err = PF_Err_NONE; + A_long ow = world->width; + A_long owt = world->rowbytes / sizeof(PF_Pixel16); + A_long oh = world->height; + + A_long hw = ow / 2; + A_long hh = oh / 2; + PF_Pixel16 *data = (PF_Pixel16 *)world->data; + PF_Pixel16 bl = {0, 0, 0, 0}; + PF_Pixel16 *scanline = *(PF_Pixel16 **)bufH; + + // First, horizontal direction + for (A_long y = 0; y < oh; y++) { + A_long ypos = y * owt; + // Transfer to scanline + for (A_long x = 0; x < hw; x++) scanline[x] = data[x + ypos]; + for (A_long x = 0; x < hw; x++) { + A_long x1 = x; + if (x1 >= hw) x1 = hw - 1; + A_long x2 = x + 1; + if (x2 >= hw) x2 = hw - 1; + PF_Pixel16 c0 = scanline[x1]; + PF_Pixel16 c1 = scanline[x2]; + PF_Pixel16 c2; + if (x1 == x2) { + c2 = c0; + } else { + c2.red = (A_u_short)(((long)c0.red + (long)c1.red) / 2); + c2.green = (A_u_short)(((long)c0.green + (long)c1.green) / 2); + c2.blue = (A_u_short)(((long)c0.blue + (long)c1.blue) / 2); + c2.alpha = (A_u_short)(((long)c0.alpha + (long)c1.alpha) / 2); + } + x2 = 2 * x; + data[x2 + ypos] = c0; + x2++; + if (x2 < ow) { + data[x2 + ypos] = c2; + } + } + } + // Vertical + for (A_long x = 0; x < ow; x++) { + A_long ypos = 0; + A_long ypos2 = 0; + + // Transfer to scanline + for (A_long y = 0; y < hh; y++) { + scanline[y] = data[x + ypos]; + ypos += owt; + } + ypos = 0; + for (A_long y = 0; y < hh; y++) { + A_long y1 = y; + if (y1 >= hh) y1 = hh - 1; + A_long y2 = y + 1; + if (y2 >= hh) y2 = hh - 1; + PF_Pixel16 c0 = scanline[y1]; + PF_Pixel16 c1 = scanline[y2]; + PF_Pixel16 c2; + if (y1 == y2) { + c2 = c0; + } else { + c2.red = (A_u_short)(((long)c0.red + (long)c1.red) / 2); + c2.green = (A_u_short)(((long)c0.green + (long)c1.green) / 2); + c2.blue = (A_u_short)(((long)c0.blue + (long)c1.blue) / 2); + c2.alpha = (A_u_short)(((long)c0.alpha + (long)c1.alpha) / 2); + } + data[x + ypos] = c0; + ypos += owt; + if (y * 2 + 1 < oh) { + data[x + ypos] = c2; + } + ypos += owt; + } + } + + return err; } -// **************************************************************************************** -//========================================================================================= -typedef struct ExtractInfo -{ - A_long start; - A_long last; - A_long soft; -}ExtractInfo, *ExtractInfoP, **ExtractInfoH; - -//========================================================================================= -PF_Err -ExtractHiSub( - refconType refcon, - A_long xL, - A_long yL, - PF_Pixel16 *px) -{ - PF_Err err = PF_Err_NONE; - ExtractInfo * infoP = reinterpret_cast(refcon); - PF_Pixel16 bl = { 0,0,0,0 }; - - A_long v = (px->red + px->green + px->blue) / 3; - - if (v<= infoP->start) - { - *px = bl; - } - else if (v < infoP->last) - { - A_long p = PF_MAX_CHAN16 *(v - infoP->start) / infoP->soft; - px->red = RoundShort((A_long)px->red * p / PF_MAX_CHAN16); - px->green = RoundShort((A_long)px->green * p / PF_MAX_CHAN16); - px->blue = RoundShort((A_long)px->blue * p / PF_MAX_CHAN16); - px->alpha = RoundShort((A_long)px->alpha * p / PF_MAX_CHAN16); - } - return err; +typedef struct ExtractInfo { + A_long start; + A_long last; + A_long soft; +} ExtractInfo, *ExtractInfoP, **ExtractInfoH; + +PF_Err ExtractHiSub(refconType refcon, A_long xL, A_long yL, PF_Pixel16 *px) { + PF_Err err = PF_Err_NONE; + ExtractInfo *infoP = reinterpret_cast(refcon); + PF_Pixel16 bl = {0, 0, 0, 0}; + + A_long v = (px->red + px->green + px->blue) / 3; + + if (v <= infoP->start) { + *px = bl; + } else if (v < infoP->last) { + A_long p = PF_MAX_CHAN16 * (v - infoP->start) / infoP->soft; + px->red = RoundShort((A_long)px->red * p / PF_MAX_CHAN16); + px->green = RoundShort((A_long)px->green * p / PF_MAX_CHAN16); + px->blue = RoundShort((A_long)px->blue * p / PF_MAX_CHAN16); + px->alpha = RoundShort((A_long)px->alpha * p / PF_MAX_CHAN16); + } + return err; } -//========================================================================================= -PF_Err ExtractHi16(PF_EffectWorldPtr world, PF_FpLong wp, PF_FpLong sf) -{ - PF_Err err = PF_Err_NONE; - ExtractInfo ei; - ei.last = (A_long)(wp * PF_MAX_CHAN16 + 0.5); - ei.soft = (A_long)(sf * PF_MAX_CHAN16 + 0.5); - ei.start = ei.last - ei.soft; +PF_Err ExtractHi16(PF_EffectWorldPtr world, PF_FpLong wp, PF_FpLong sf) { + PF_Err err = PF_Err_NONE; + ExtractInfo ei; + ei.last = (A_long)(wp * PF_MAX_CHAN16 + 0.5); + ei.soft = (A_long)(sf * PF_MAX_CHAN16 + 0.5); + ei.start = ei.last - ei.soft; - ERR(iterateWorld16(&ei, world, ExtractHiSub)); + ERR(iterateWorld16(&ei, world, ExtractHiSub)); - return err; + return err; } -//========================================================================================= -PF_Err -ExtractLoSub( - refconType refcon, - A_long xL, - A_long yL, - PF_Pixel16 *px) -{ - PF_Err err = PF_Err_NONE; - ExtractInfo * infoP = reinterpret_cast(refcon); - PF_Pixel16 bl = { 0,0,0,0 }; - - A_long v = (px->red + px->green + px->blue) / 3; - - if (v >= infoP->last) - { - *px = bl; - } - else if (v > infoP->start) - { - A_long p = PF_MAX_CHAN16 * (infoP->last -v) / infoP->soft; - px->red = RoundShort((A_long)px->red * p / PF_MAX_CHAN16); - px->green = RoundShort((A_long)px->green * p / PF_MAX_CHAN16); - px->blue = RoundShort((A_long)px->blue * p / PF_MAX_CHAN16); - px->alpha = RoundShort((A_long)px->alpha * p / PF_MAX_CHAN16); - - } - return err; +PF_Err ExtractLoSub(refconType refcon, A_long xL, A_long yL, PF_Pixel16 *px) { + PF_Err err = PF_Err_NONE; + ExtractInfo *infoP = reinterpret_cast(refcon); + PF_Pixel16 bl = {0, 0, 0, 0}; + + A_long v = (px->red + px->green + px->blue) / 3; + + if (v >= infoP->last) { + *px = bl; + } else if (v > infoP->start) { + A_long p = PF_MAX_CHAN16 * (infoP->last - v) / infoP->soft; + px->red = RoundShort((A_long)px->red * p / PF_MAX_CHAN16); + px->green = RoundShort((A_long)px->green * p / PF_MAX_CHAN16); + px->blue = RoundShort((A_long)px->blue * p / PF_MAX_CHAN16); + px->alpha = RoundShort((A_long)px->alpha * p / PF_MAX_CHAN16); + } + return err; } -//========================================================================================= -PF_Err ExtractLo16(PF_EffectWorldPtr world, PF_FpLong bp, PF_FpLong sf) -{ - PF_Err err = PF_Err_NONE; - ExtractInfo ei; - ei.start = (A_long)(bp * PF_MAX_CHAN16 + 0.5); - ei.soft = (A_long)(sf * PF_MAX_CHAN16 + 0.5); - ei.last = ei.start + ei.soft; +PF_Err ExtractLo16(PF_EffectWorldPtr world, PF_FpLong bp, PF_FpLong sf) { + PF_Err err = PF_Err_NONE; + ExtractInfo ei; + ei.start = (A_long)(bp * PF_MAX_CHAN16 + 0.5); + ei.soft = (A_long)(sf * PF_MAX_CHAN16 + 0.5); + ei.last = ei.start + ei.soft; - ERR(iterateWorld16(&ei, world, ExtractLoSub)); + ERR(iterateWorld16(&ei, world, ExtractLoSub)); - return err; + return err; } -//========================================================================================= -//========================================================================================= -PF_Err -RevSub( - refconType refcon, - A_long xL, - A_long yL, - PF_Pixel16 *px) -{ - PF_Err err = PF_Err_NONE; - px->alpha = PF_MAX_CHAN16 - px->alpha; - px->red = PF_MAX_CHAN16 - px->red; - px->green = PF_MAX_CHAN16 - px->green; - px->blue = PF_MAX_CHAN16 - px->blue; - return err; +PF_Err RevSub(refconType refcon, A_long xL, A_long yL, PF_Pixel16 *px) { + PF_Err err = PF_Err_NONE; + px->alpha = PF_MAX_CHAN16 - px->alpha; + px->red = PF_MAX_CHAN16 - px->red; + px->green = PF_MAX_CHAN16 - px->green; + px->blue = PF_MAX_CHAN16 - px->blue; + return err; } -//========================================================================================= -PF_Err Rev16(PF_EffectWorldPtr world) -{ - PF_Err err = PF_Err_NONE; +PF_Err Rev16(PF_EffectWorldPtr world) { + PF_Err err = PF_Err_NONE; - ERR(iterateWorld16(NULL, world, RevSub)); + ERR(iterateWorld16(NULL, world, RevSub)); - return err; + return err; } -//========================================================================================= -typedef struct BrightInfo -{ - A_long brightness; -}BrightInfo, *BrightInfoP, **BrightInfoH; -//========================================================================================= -PF_Err -BrightnessSub( - refconType refcon, - A_long xL, - A_long yL, - PF_Pixel16 *px) -{ - PF_Err err = PF_Err_NONE; - BrightInfo * infoP = reinterpret_cast(refcon); - PF_Pixel16 bl = { 0,0,0,0 }; - - px->red = RoundShort(px->red + infoP->brightness); - px->green = RoundShort(px->green + infoP->brightness); - px->blue = RoundShort(px->blue + infoP->brightness); - - - return err; +typedef struct BrightInfo { + A_long brightness; +} BrightInfo, *BrightInfoP, **BrightInfoH; +PF_Err BrightnessSub(refconType refcon, A_long xL, A_long yL, PF_Pixel16 *px) { + PF_Err err = PF_Err_NONE; + BrightInfo *infoP = reinterpret_cast(refcon); + PF_Pixel16 bl = {0, 0, 0, 0}; + + px->red = RoundShort(px->red + infoP->brightness); + px->green = RoundShort(px->green + infoP->brightness); + px->blue = RoundShort(px->blue + infoP->brightness); + + return err; } -//========================================================================================= -PF_Err Brightness16(PF_EffectWorldPtr world,PF_FpLong brigtness) -{ - PF_Err err = PF_Err_NONE; - BrightInfo bi; - bi.brightness = (A_long)(PF_MAX_CHAN16 * brigtness); - ERR(iterateWorld16(&bi, world, BrightnessSub)); - return err; +PF_Err Brightness16(PF_EffectWorldPtr world, PF_FpLong brigtness) { + PF_Err err = PF_Err_NONE; + BrightInfo bi; + bi.brightness = (A_long)(PF_MAX_CHAN16 * brigtness); + ERR(iterateWorld16(&bi, world, BrightnessSub)); + return err; } - diff --git a/Source/Effects/FsFilter/Filter_Entry.h b/Source/Effects/FsFilter/Filter_Entry.h index 5fd0fc4..241ac5d 100644 --- a/Source/Effects/FsFilter/Filter_Entry.h +++ b/Source/Effects/FsFilter/Filter_Entry.h @@ -1,305 +1,216 @@ #pragma once -#pragma once -#ifndef Filter_Entry_H -#define Filter_Entry_H +// clang-format off #include "../FsLibrary_next/FsAEHeader.h" #include "Filter.h" #include "Filter_Target.h" +// clang-format on -//======================================================================================= -static PF_Err -About( - PF_InData *in_data, - PF_OutData *out_data, - PF_ParamDef *params[], - PF_LayerDef *output) -{ - PF_Err err = PF_Err_NONE; - - CAE ae; - err = ae.About(in_data, out_data, params, output); +static PF_Err About(PF_InData *in_data, PF_OutData *out_data, + PF_ParamDef *params[], PF_LayerDef *output) { + PF_Err err = PF_Err_NONE; + CAE ae; + err = ae.About(in_data, out_data, params, output); - - return PF_Err_NONE; + return PF_Err_NONE; } -//======================================================================================= -static PF_Err -GlobalSetup( - PF_InData *in_dataP, - PF_OutData *out_data, - PF_ParamDef *params[], - PF_LayerDef *output) -{ - PF_Err err = PF_Err_NONE; - CAE ae; - err = ae.GlobalSetup(in_dataP, out_data, params, output); - return err; - +static PF_Err GlobalSetup(PF_InData *in_dataP, PF_OutData *out_data, + PF_ParamDef *params[], PF_LayerDef *output) { + PF_Err err = PF_Err_NONE; + CAE ae; + err = ae.GlobalSetup(in_dataP, out_data, params, output); + return err; } -//------------------------------------------------------------------------------------------------- -static PF_Err GlobalSetdown( - PF_InData *in_data) -{ - PF_Err err = PF_Err_NONE; - CAE ae; - err = ae.GlobalSetdown(in_data); - return PF_Err_NONE; +static PF_Err GlobalSetdown(PF_InData *in_data) { + PF_Err err = PF_Err_NONE; + CAE ae; + err = ae.GlobalSetdown(in_data); + return PF_Err_NONE; } -//------------------------------------------------------------------------------------------------- -static PF_Err SequenceSetup( - PF_InData *in_data, - PF_OutData *out_data, - PF_ParamDef *params[], - PF_LayerDef *output) -{ - - return PF_Err_NONE; +static PF_Err SequenceSetup(PF_InData *in_data, PF_OutData *out_data, + PF_ParamDef *params[], PF_LayerDef *output) { + return PF_Err_NONE; } -//------------------------------------------------------------------------------------------------- -static PF_Err SequenceSetdown( - PF_InData *in_data, - PF_OutData *out_data, - PF_ParamDef *params[], - PF_LayerDef *output) -{ - return PF_Err_NONE; +static PF_Err SequenceSetdown(PF_InData *in_data, PF_OutData *out_data, + PF_ParamDef *params[], PF_LayerDef *output) { + return PF_Err_NONE; } - -//------------------------------------------------------------------------------------------------- -static PF_Err SequenceResetup( - PF_InData *in_data, - PF_OutData *out_data, - PF_ParamDef *params[], - PF_LayerDef *output) -{ - return PF_Err_NONE; +static PF_Err SequenceResetup(PF_InData *in_data, PF_OutData *out_data, + PF_ParamDef *params[], PF_LayerDef *output) { + return PF_Err_NONE; } /* -//======================================================================================= static PF_Err QueryDynamicFlags( - PF_InData *in_data, - PF_OutData *out_data, - PF_ParamDef *params[], - void *extra) + PF_InData *in_data, + PF_OutData *out_data, + PF_ParamDef *params[], + void *extra) { - PF_Err err = PF_Err_NONE; - return err; + PF_Err err = PF_Err_NONE; + return err; } -//======================================================================================= static PF_Err HandleChangedParam( - PF_InData *in_data, - PF_OutData *out_data, - PF_ParamDef *params[], - PF_LayerDef *outputP, - PF_UserChangedParamExtra *extraP) + PF_InData *in_data, + PF_OutData *out_data, + PF_ParamDef *params[], + PF_LayerDef *outputP, + PF_UserChangedParamExtra *extraP) { - PF_Err err = PF_Err_NONE; + PF_Err err = PF_Err_NONE; - return err; + return err; } */ -//----------------------------------------------------------------------------------- -static PF_Err -RespondtoAEGP( - PF_InData *in_data, - PF_OutData *out_data, - PF_ParamDef *params[], - PF_LayerDef *output, - void* extraP) -{ - PF_Err err = PF_Err_NONE; +static PF_Err RespondtoAEGP(PF_InData *in_data, PF_OutData *out_data, + PF_ParamDef *params[], PF_LayerDef *output, + void *extraP) { + PF_Err err = PF_Err_NONE; - AEGP_SuiteHandler suites(in_data->pica_basicP); + AEGP_SuiteHandler suites(in_data->pica_basicP); - suites.ANSICallbacksSuite1()->sprintf(out_data->return_msg, - "%s", - reinterpret_cast(extraP)); + suites.ANSICallbacksSuite1()->sprintf(out_data->return_msg, "%s", + reinterpret_cast(extraP)); - return err; + return err; } -//======================================================================================= -static PF_Err -Render( - PF_InData *in_dataP, - PF_OutData *out_data, - PF_ParamDef *params[], - PF_LayerDef *output) -{ - PF_Err err = PF_Err_NONE; - PF_Handle pixelTable = NULL; - - CAE ae(in_dataP, out_data, params, output, ID_NUM_PARAMS); - err = ae.resultErr(); - if (!err) { - ParamInfo info; - ERR(GetParams(&ae, &info)); - ERR(Exec(&ae, &info)); - } - return err; +static PF_Err Render(PF_InData *in_dataP, PF_OutData *out_data, + PF_ParamDef *params[], PF_LayerDef *output) { + PF_Err err = PF_Err_NONE; + PF_Handle pixelTable = NULL; + + CAE ae(in_dataP, out_data, params, output, ID_NUM_PARAMS); + err = ae.resultErr(); + if (!err) { + ParamInfo info; + ERR(GetParams(&ae, &info)); + ERR(Exec(&ae, &info)); + } + return err; } -//======================================================================================= #if defined(SUPPORT_SMARTFX) -static PF_Err -PreRender( - PF_InData *in_dataP, - PF_OutData *out_dataP, - PF_PreRenderExtra *extraP) -{ - PF_Err err = PF_Err_NONE; - CAE ae(in_dataP, out_dataP, extraP, sizeof(ParamInfo), ID_NUM_PARAMS); - err = ae.resultErr(); - if (!err) { - - ParamInfo *infoP = reinterpret_cast(ae.LockPreRenderData()); - if (infoP) { - ae.SetHostPreRenderData(); - ERR(GetParams(&ae, infoP)); - ERR(ae.UnSetPreRenderData()); - ae.UnlockPreRenderData(); - } - else { - err = PF_Err_OUT_OF_MEMORY; - } - } - return err; +static PF_Err PreRender(PF_InData *in_dataP, PF_OutData *out_dataP, + PF_PreRenderExtra *extraP) { + PF_Err err = PF_Err_NONE; + CAE ae(in_dataP, out_dataP, extraP, sizeof(ParamInfo), ID_NUM_PARAMS); + err = ae.resultErr(); + if (!err) { + ParamInfo *infoP = reinterpret_cast(ae.LockPreRenderData()); + if (infoP) { + ae.SetHostPreRenderData(); + ERR(GetParams(&ae, infoP)); + ERR(ae.UnSetPreRenderData()); + ae.UnlockPreRenderData(); + } else { + err = PF_Err_OUT_OF_MEMORY; + } + } + return err; } #endif -//======================================================================================= #if defined(SUPPORT_SMARTFX) -static PF_Err -SmartRender( - PF_InData *in_data, - PF_OutData *out_data, - PF_SmartRenderExtra *extraP) -{ - - PF_Err err = PF_Err_NONE, - err2 = PF_Err_NONE; - - CAE ae(in_data, out_data, extraP, ID_NUM_PARAMS); - err = ae.resultErr(); - if (!err) { - ParamInfo *infoP = reinterpret_cast(ae.LockPreRenderData()); - if (infoP) { - ERR(Exec(&ae, infoP)); - ERR2(ae.UnsetSmartRender()); - ae.UnlockPreRenderData(); - } - else { - err = PF_Err_OUT_OF_MEMORY; - } - } - return err; - +static PF_Err SmartRender(PF_InData *in_data, PF_OutData *out_data, + PF_SmartRenderExtra *extraP) { + PF_Err err = PF_Err_NONE, err2 = PF_Err_NONE; + + CAE ae(in_data, out_data, extraP, ID_NUM_PARAMS); + err = ae.resultErr(); + if (!err) { + ParamInfo *infoP = reinterpret_cast(ae.LockPreRenderData()); + if (infoP) { + ERR(Exec(&ae, infoP)); + ERR2(ae.UnsetSmartRender()); + ae.UnlockPreRenderData(); + } else { + err = PF_Err_OUT_OF_MEMORY; + } + } + return err; } #endif -//======================================================================================= -extern "C" DllExport -PF_Err PluginDataEntryFunction( - PF_PluginDataPtr inPtr, - PF_PluginDataCB inPluginDataCallBackPtr, - SPBasicSuite* inSPBasicSuitePtr, - const char* inHostName, - const char* inHostVersion) -{ - PF_Err result = PF_Err_INVALID_CALLBACK; +extern "C" DllExport PF_Err PluginDataEntryFunction( + PF_PluginDataPtr inPtr, PF_PluginDataCB inPluginDataCallBackPtr, + SPBasicSuite *inSPBasicSuitePtr, const char *inHostName, + const char *inHostVersion) { + PF_Err result = PF_Err_INVALID_CALLBACK; - result = PF_REGISTER_EFFECT( - inPtr, - inPluginDataCallBackPtr, - FS_NAME, // Name - FS_MATCH_NAME, // Match Name - FS_CATEGORY, // Category - AE_RESERVED_INFO); // Reserved Info + result = PF_REGISTER_EFFECT(inPtr, inPluginDataCallBackPtr, + FS_NAME, // Name + FS_MATCH_NAME, // Match Name + FS_CATEGORY, // Category + AE_RESERVED_INFO); // Reserved Info - return result; + return result; } -//======================================================================================= -PF_Err -EffectMain( - PF_Cmd cmd, - PF_InData *in_dataP, - PF_OutData *out_data, - PF_ParamDef *params[], - PF_LayerDef *output, - void *extraP) -{ - PF_Err err = PF_Err_NONE; - - try { - switch (cmd) - { - case PF_Cmd_ABOUT: - err = About(in_dataP, out_data, params, output); - break; - case PF_Cmd_GLOBAL_SETUP: - err = GlobalSetup(in_dataP, out_data, params, output); - break; - case PF_Cmd_GLOBAL_SETDOWN: - err = GlobalSetdown(in_dataP); - break; - case PF_Cmd_PARAMS_SETUP: - err = ParamsSetup(in_dataP, out_data, params, output); - break; - case PF_Cmd_SEQUENCE_SETUP: - err = SequenceSetup(in_dataP, out_data, params, output); - break; - case PF_Cmd_SEQUENCE_SETDOWN: - err = SequenceSetdown(in_dataP, out_data, params, output); - break; - case PF_Cmd_SEQUENCE_RESETUP: - err = SequenceResetup(in_dataP, out_data, params, output); - break; case PF_Cmd_RENDER: - err = Render(in_dataP, out_data, params, output); - break; +PF_Err EffectMain(PF_Cmd cmd, PF_InData *in_dataP, PF_OutData *out_data, + PF_ParamDef *params[], PF_LayerDef *output, void *extraP) { + PF_Err err = PF_Err_NONE; + + try { + switch (cmd) { + case PF_Cmd_ABOUT: + err = About(in_dataP, out_data, params, output); + break; + case PF_Cmd_GLOBAL_SETUP: + err = GlobalSetup(in_dataP, out_data, params, output); + break; + case PF_Cmd_GLOBAL_SETDOWN: + err = GlobalSetdown(in_dataP); + break; + case PF_Cmd_PARAMS_SETUP: + err = ParamsSetup(in_dataP, out_data, params, output); + break; + case PF_Cmd_SEQUENCE_SETUP: + err = SequenceSetup(in_dataP, out_data, params, output); + break; + case PF_Cmd_SEQUENCE_SETDOWN: + err = SequenceSetdown(in_dataP, out_data, params, output); + break; + case PF_Cmd_SEQUENCE_RESETUP: + err = SequenceResetup(in_dataP, out_data, params, output); + break; + case PF_Cmd_RENDER: + err = Render(in_dataP, out_data, params, output); + break; #if defined(SUPPORT_SMARTFX) - case PF_Cmd_SMART_PRE_RENDER: - err = PreRender(in_dataP, out_data, (PF_PreRenderExtra*)extraP); - break; - case PF_Cmd_SMART_RENDER: - err = SmartRender(in_dataP, out_data, (PF_SmartRenderExtra*)extraP); - break; + case PF_Cmd_SMART_PRE_RENDER: + err = PreRender(in_dataP, out_data, (PF_PreRenderExtra *)extraP); + break; + case PF_Cmd_SMART_RENDER: + err = SmartRender(in_dataP, out_data, (PF_SmartRenderExtra *)extraP); + break; #endif - case PF_Cmd_COMPLETELY_GENERAL: - err = RespondtoAEGP(in_dataP, out_data, params, output, extraP); - break; - case PF_Cmd_DO_DIALOG: - //err = PopDialog(in_dataP,out_data,params,output); - break; - case PF_Cmd_USER_CHANGED_PARAM: - err = HandleChangedParam(in_dataP, - out_data, - params, - output, - reinterpret_cast(extraP)); - break; - case PF_Cmd_QUERY_DYNAMIC_FLAGS: - err = QueryDynamicFlags(in_dataP, - out_data, - params, - reinterpret_cast(extraP)); - break; - case PF_Cmd_FRAME_SETUP: - err = FrameSetup(in_dataP, out_data, params, output); - break; - } - } - catch (PF_Err &thrown_err) { - // Never EVER throw exceptions into AE. - err = thrown_err; - } - return err; + case PF_Cmd_COMPLETELY_GENERAL: + err = RespondtoAEGP(in_dataP, out_data, params, output, extraP); + break; + case PF_Cmd_DO_DIALOG: + // err = PopDialog(in_dataP,out_data,params,output); + break; + case PF_Cmd_USER_CHANGED_PARAM: + err = HandleChangedParam( + in_dataP, out_data, params, output, + reinterpret_cast(extraP)); + break; + case PF_Cmd_QUERY_DYNAMIC_FLAGS: + err = QueryDynamicFlags( + in_dataP, out_data, params, + reinterpret_cast(extraP)); + break; + case PF_Cmd_FRAME_SETUP: + err = FrameSetup(in_dataP, out_data, params, output); + break; + } + } catch (PF_Err &thrown_err) { + // Never EVER throw exceptions into AE. + err = thrown_err; + } + return err; } - -#endif // OpenCVSkelton_Entry_H - diff --git a/Source/Effects/FsFilter/Filter_Target.h b/Source/Effects/FsFilter/Filter_Target.h index 3b01193..426b1ed 100644 --- a/Source/Effects/FsFilter/Filter_Target.h +++ b/Source/Effects/FsFilter/Filter_Target.h @@ -1,60 +1,49 @@ /* - 各種定数を設定 - - PiPLリソースに使う為にマクロ展開は最低限 + Set various constants + Macro expansion is minimal for use with PiPL resources */ #pragma once -#ifndef Filter_Target_H -#define Filter_Target_H +// clang-format off #include "../FsLibrary_next/FsVersion.h" +// clang-format on - - -#define FS_DESCRIPTION "Filter Effect Filter" -#define FS_NAME "F's Filter" -#define FS_MATCH_NAME FS_NAME -#define FS_CREATER "Copyright (c) 2019 bryful ( bryful@gmail.com/twitter:bryful )" +#define FS_DESCRIPTION "Filter Effect Filter" +#define FS_NAME "F's Filter" +#define FS_MATCH_NAME FS_NAME +#define FS_CREATER \ + "Copyright (c) 2019 bryful ( bryful@gmail.com/twitter:bryful )" //----------------------------------------------------------------------------------- -//プラグインが表示されるメニュー名 - //#define FS_CATEGORY "F's Plugins-Channel" - //#define FS_CATEGORY "F's Plugins-Draw" - #define FS_CATEGORY "NF's Plugins-Filter" - //#define FS_CATEGORY "F's Plugins-Cell" - //#define FS_CATEGORY "F's Plugins-Colorize" - //#define FS_CATEGORY "F's Plugins-Script" - //#define FS_CATEGORY "F's Plugins-{Legacy}" - - -//#define SUPPORT_SMARTFX //これを有効にするとSmartFX+Float_Colorに対応する - - +// Menu name where the plugin is displayed +#define FS_CATEGORY "NF's Plugins-Filter" -//value:4 [PF_OutFlag_NON_PARAM_VARY] 全フレームで描画する +// #define SUPPORT_SMARTFX //If this is enabled, it will +// support SmartFX + Float_Color -//value:64 [PF_OutFlag_USE_OUTPUT_EXTENT] 表示画面全部 -//value:16777216 [PF_OutFlag_I_HAVE_EXTERNAL_DEPENDENCIES] +// value:4 [PF_OutFlag_NON_PARAM_VARY] Render all frames -//value:33554432[PF_OutFlag_DEEP_COLOR_AWARE] 16bit - -//#define FS_OUT_FLAGS 50332164 //こっちにすると全フレーム描画する -#define FS_OUT_FLAGS 50332160 //通常はこちら +// value:64 [PF_OutFlag_USE_OUTPUT_EXTENT] +// value:16777216 [PF_OutFlag_I_HAVE_EXTERNAL_DEPENDENCIES] +// value:33554432[PF_OutFlag_DEEP_COLOR_AWARE] 16bit +// #define FS_OUT_FLAGS 50332164 //Render all frames with this +#define FS_OUT_FLAGS 50332160 // Normal setting #if defined(SUPPORT_SMARTFX) -//value:8 [PF_OutFlag2_PARAM_GROUP_START_COLLAPSED_FLAG] グループ -//value:1024 [PF_OutFlag2_SUPPORTS_SMART_RENDER] スマートレンダー -//value:4096 [PF_OutFlag2_FLOAT_COLOR_AWARE] 32bit -#define FS_OUT_FLAGS2 5128 +// value:8 [PF_OutFlag2_PARAM_GROUP_START_COLLAPSED_FLAG] Group +// value:1024 [PF_OutFlag2_SUPPORTS_SMART_RENDER] Smart Render +// value:4096 [PF_OutFlag2_FLOAT_COLOR_AWARE] 32bit +#define FS_OUT_FLAGS2 5128 #else -//value : 8[PF_OutFlag2_PARAM_GROUP_START_COLLAPSED_FLAG] -#define FS_OUT_FLAGS2 8 +// value : 8[PF_OutFlag2_PARAM_GROUP_START_COLLAPSED_FLAG] +#define FS_OUT_FLAGS2 8 #endif -#define FS_ABOUT_STR "function FsAbout()\ +#define FS_ABOUT_STR \ + "function FsAbout()\ {\ this.pluginName = \"%s\";\ this.pluginVersion = \"Version %d.%d\";\ @@ -84,9 +73,3 @@ var dlg = new FsAbout;\ \ dlg.show();\ " - - - - -#endif // Filter_Target_H - diff --git a/Source/Effects/FsFilter/Filter_def.h b/Source/Effects/FsFilter/Filter_def.h index ad4a64d..956dd05 100644 --- a/Source/Effects/FsFilter/Filter_def.h +++ b/Source/Effects/FsFilter/Filter_def.h @@ -1,22 +1,19 @@ #pragma once +PF_Boolean FLT_Enabled[PARAMSET_COUNT] = {FALSE, FALSE, FALSE, FALSE}; -PF_Boolean FLT_Enabled[PARAMSET_COUNT] = { FALSE,FALSE, FALSE, FALSE }; +A_long FLT_EXTRACT_MODE[PARAMSET_COUNT] = {1, 1, 1, 1}; -A_long FLT_EXTRACT_MODE[PARAMSET_COUNT] = { 1, 1, 1, 1 }; +PF_FpLong FLT_BORDER_HI[PARAMSET_COUNT] = {70, 70, 70, 70}; +PF_FpLong FLT_SOFTNESS_HI[PARAMSET_COUNT] = {20, 20, 20, 20}; +PF_FpLong FLT_BORDER_LO[PARAMSET_COUNT] = {30, 30, 30, 30}; +PF_FpLong FLT_SOFTNESS_LO[PARAMSET_COUNT] = {20, 20, 20, 20}; +PF_FpLong FLT_BRIGHTNESS[PARAMSET_COUNT] = {0, 0, 0, 0}; -PF_FpLong FLT_BORDER_HI[PARAMSET_COUNT] = { 70,70,70,70 }; -PF_FpLong FLT_SOFTNESS_HI[PARAMSET_COUNT] = { 20,20,20,20 }; -PF_FpLong FLT_BORDER_LO[PARAMSET_COUNT] = { 30,30,30,30 }; -PF_FpLong FLT_SOFTNESS_LO[PARAMSET_COUNT] = { 20,20,20,20 }; -PF_FpLong FLT_BRIGHTNESS[PARAMSET_COUNT] = { 0,0,0,0 }; +A_long FLT_MINMAX[PARAMSET_COUNT] = {0, 0, 0, 0}; +A_long FLT_MAX[PARAMSET_COUNT] = {0, 0, 0, 0}; +A_long FLT_BLUR[PARAMSET_COUNT] = {0, 0, 0, 0}; +PF_FpLong FLT_OPACITY[PARAMSET_COUNT] = {50, 50, 50, 50}; -A_long FLT_MINMAX[PARAMSET_COUNT] = { 0, 0, 0, 0 }; -A_long FLT_MAX[PARAMSET_COUNT] = { 0, 0, 0, 0 }; -A_long FLT_BLUR[PARAMSET_COUNT] = { 0, 0, 0, 0 }; - -PF_FpLong FLT_OPACITY[PARAMSET_COUNT] = { 50,50,50,50 }; - -A_long FLT_BLEND_MODE[PARAMSET_COUNT] = { 1, 1, 1, 1 }; - +A_long FLT_BLEND_MODE[PARAMSET_COUNT] = {1, 1, 1, 1};