Skip to main content
Participating Frequently
May 3, 2014
Question

i have started to try to write a plug-in,but i am in trouble

  • May 3, 2014
  • 4 replies
  • 1303 views

After a long time study,i start to write a plug-ins.I try to write the plug in this website [removed by moderator]

But,i am in trouble now.There are many different place ,because this plug was written in 1999.

If someone can correct the code for me,so that i can compare to learn.Or someone has finsh this piug can show me the code to compare mine.

This link is the unfinished plug(in the skeleton)

This topic has been closed for replies.

4 replies

May 5, 2014

Well, you have to be a bit more specific than that - what exactly is not working? What problems do you have with the FIXED slider?

Try to remove all the redundant code from the sample and start with the basic structure. And yes, it still is a good idea to check the AE SDK examples for basic parameter usage, most types are covered there.

Your test project seems to be a mixture of a very old skeleton template (before the 2010 update in the SDK) and the Shifter example.

ZiggesAuthor
Participating Frequently
May 8, 2014

I add a FIXED slider,but i can't adjust the data in AE.

This project is an old example indeed.

May 5, 2014

Eh, why don't you start with the example plugins from the official AE SDK in a current version?

ZiggesAuthor
Participating Frequently
May 5, 2014

I have done this,but this way can't make me understand how to finish a plug-in completely.

For example,i can't understand why my FIXED slider don't work,and i just replace it with SLIDER.

So i try to fix the old code to make me clear.

Maybe this way can understand how to write a plug-in deeply.

ZiggesAuthor
Participating Frequently
May 3, 2014
/*Skeleton.cpp

This is a compiling husk of a project. Fill it in with interesting
pixel processing code.

Revision history:

1.0 (seemed like a good idea at the time)bbb6/1/2002

1.0 Okay, I'm leaving the version at 1.0,bbb2/15/2006
for obvious reasons; you're going to
copy these files directly! This is the
first XCode version, though.

*/

#include "Skeleton.h"

static PF_Err

About (
PF_InData*in_data,
PF_OutData*out_data,
PF_ParamDef*params[],
PF_LayerDef*output )

{

PF_Errerr= PF_Err_NONE;

AEGP_SuiteHandler suites(in_data->pica_basicP);
suites.ANSICallbacksSuite1()->sprintf(out_data->return_msg,
"%s v%d.%d\r%s",
STR(StrID_Name),
MAJOR_VERSION,
MINOR_VERSION,
STR(StrID_Description));
return PF_Err_NONE;

}

static PF_Err

GlobalSetup (
PF_InData*in_data,
PF_OutData*out_data,
PF_ParamDef*params[],
PF_LayerDef*output )

{

PF_Errerr= PF_Err_NONE;

out_data->my_version = PF_VERSION(MAJOR_VERSION,
MINOR_VERSION,
BUG_VERSION,
STAGE_VERSION,
BUILD_VERSION);

out_data->out_flags |=
PF_OutFlag_USE_OUTPUT_EXTENT;
return PF_Err_NONE;

}

static PF_Err

ParamsSetup (
PF_InData*in_data,
PF_OutData*out_data,
PF_ParamDef*params[],
PF_LayerDef*output )

{

PF_Errerr= PF_Err_NONE;
PF_ParamDefdef;

AEFX_CLR_STRUCT(def);
PF_ADD_LAYER(  "Displacement Layer:",
           PF_LayerDefault_MYSELF,
   LAYER_DISK_ID);

AEFX_CLR_STRUCT(def);

PF_ADD_ANGLE(  "Angle of Displacement",
            0,
            ANGLE_DISK_ID);

AEFX_CLR_STRUCT(def);

PF_ADD_SLIDER("1",0,100,0,100,30,AMOUNT_DISK_ID1);

PF_ADD_SLIDER("2",0,200,0,200,60,AMOUNT_DISK_ID2);

PF_ADD_SLIDER("3",0,100,0,100,30,AMOUNT_DISK_ID3);

/*PF_ADD_FIXED("Amount of Displacement",
SHIFT_BLEND_MIN,
SHIFT_BLEND_MAX,
SHIFT_BLEND_MIN,
SHIFT_BLEND_MAX,
SHIFT_BLEND_DFLT,
1,1,0,
AMOUNT_DISK_ID1);*/

/*AEFX_CLR_STRUCT(def);

PF_ADD_FIXED("Source Gamma",
BIAS_MIN,
BIAS_BIG_MAX,
BIAS_MIN,
BIAS_MAX,
BIAS_DFLT,
1,0,0,
AMOUNT_DISK_ID2);

AEFX_CLR_STRUCT(def);

PF_ADD_FIXED("Blend With Original",
SHIFT_BLEND_MIN,
SHIFT_BLEND_MAX,
SHIFT_BLEND_MIN,
SHIFT_BLEND_MAX,
SHIFT_BLEND_DFLT,
1,1,0,
AMOUNT_DISK_ID3);*/

//PF_ADD_COLOR(STR(StrID_Color_Param_Name),
//PF_HALF_CHAN8,
//PF_MAX_CHAN8,
//PF_MAX_CHAN8,
//COLOR_DISK_ID);
//AEFX_CLR_STRUCT(def);

//PF_ADD_CHECKBOX(STR(StrID_Checkbox_Param_Name),
//STR(StrID_Checkbox_Description),
//FALSE,
//0,
//DOWNSAMPLE_DISK_ID);

//PF_ADD_CHECKBOX(STR(StrID_3D_Param_Name),
//STR(StrID_3D_Param_Description),
//FALSE,
//0,
//THREED_DISK_ID);

out_data->num_params = SHIFT_NUM_PARAMS ;

return err;

}

/*static PF_Err

FrameSetup (

PF_InData*in_data,
PF_OutData*out_data,
PF_ParamDef*params[],
PF_LayerDef*output )

{

// Output buffer resizing may only occur during PF_Cmd_FRAME_SETUP.

doubleborder_x=0,
border_y=0,
border=params[SKELETON_AMOUNT]->u.sd.value;
if (params[SKELETON_DOWNSAMPLE]->u.bd.value) {
// shrink the border to accomodate decreased resolutions.
border_x = border * ((double)in_data->downsample_x.num / (double)in_data->downsample_x.den);
border_y = border * ((double)in_data->downsample_y.num / (double)in_data->downsample_y.den);
} else {
border_x = border_y = border;
}
// add 2 times the border width and height to the input width and
// height to get the output size.
out_data->width  = 2 * (long)border_x + params[0]->u.ld.width;
out_data->height = 2 * (long)border_y + params[0]->u.ld.height;
// The origin of the input buffer corresponds to the (border_x,
// border_y) pixel in the output buffer.
out_data->origin.h = (short)border_x;
out_data->origin.v = (short)border_y;

return PF_Err_NONE;

}*/

//11111111111111111111111111111111111111111111111111111111

typedef struct {

PF_Fixedx_off;// displacement in x
PF_Fixedy_off;// displacement in y
doublegamma;
longwidth;
longheight;
PF_EffectWorld *p;

// structures and function pointer
// needed for for image resampling:

PF_SampPBsamp_pb;
PF_InData *in_data;
PF_ParamDef *checkedOutLayer;

} ShiftInfo;

/*typedef union {

PF_LayerDefld;
PF_SliderDefsd;
PF_FixedSliderDeffd;
PF_AngleDefad;
PF_CheckBoxDefbd;
PF_ColorDefcd;
PF_PointDeftd;
PF_PopupDefpd;
PF_CustomDefmd;

} PF_ParamDefUnion;*/

//11111111111111111111111111111111111111111111111111111111

//222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222

static PF_Err DisplaceImage (long refcon,

long x, long y,
PF_Pixel *in, PF_Pixel *out)

{

PF_Err err = PF_Err_NONE;

register ShiftInfo*si = (ShiftInfo *)refcon;
PF_InData*in_data = si->in_data;
PF_Fixednew_x, new_y;
doubleluma,tmpx,tmpy;
// check to see if we're near the edge...
if ( LONG2FIX(x) < si->x_off ||
LONG2FIX(y) < si->y_off ||
LONG2FIX(si->width - x) < si->x_off ||
LONG2FIX(si->height - y) < si->y_off)
{
*out = *in;// just copy input & return
return 0;
}
// what fraction are we thru the image?
tmpx = (double)x/(double)si->width;
tmpy = (double)y/(double)si->height;
// interpolate to the same spot in map layer image (Fixed)
tmpx *= (double)si->checkedOutLayer->u.ld.width;
new_x = LONG2FIX(tmpx);
tmpy *= (double)si->checkedOutLayer->u.ld.height;
new_y = LONG2FIX(tmpy);
// set src pointer to map layer:
si->samp_pb.src = &si->checkedOutLayer->u.ld;
// sample into the map layer:
err = PF_SUBPIXEL_SAMPLE(new_x, new_y, &si->samp_pb, out);
// reset src to INPUT layer:
si->samp_pb.src = si->p;
// get map-layer pixel luminance
luma = LUMA(out);
// apply gamma correction
luma = bias(si->gamma,luma);

// make the displacement "grey-pt relative"
// so map-layer pixels that are white move
// the input one way, black the other way...
luma -= 0.5;
new_x = (long)x ;// convert to Fixed
new_y = (long)y ;// convert to Fixed
if (luma > 0.5){// dark? move up or left
new_x -= (si->x_off * luma);
new_y -= (si->y_off * luma);
}
else {// light? move down or right
new_x += (si->x_off * luma);
new_y += (si->y_off * luma);
}
// resample original image at the offset point
// and write to output...
err = PF_SUBPIXEL_SAMPLE(new_x, new_y, &si->samp_pb, out);

return err;

}

//2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222

static PF_Err

Render (

PF_InData*in_data,
PF_OutData*out_data,
PF_ParamDef*params[],
PF_LayerDef*output )

{

PF_Errerr= PF_Err_NONE;
AEGP_SuiteHandlersuites(in_data->pica_basicP);

/*Put interesting code here. */
ShiftInfosi;
PF_Fixedblend;
A_longlines;
PF_EffectWorld*input;
PF_ParamDefcheckout;
doubleangle,sin_angle,cos_angle;
angle = (double)params[DISP_ANGLE]->u.ad.value;
angle /= (double)(1L << 16);
angle *= PF_RAD_PER_DEGREE;
sin_angle = PF_SIN(angle);
cos_angle = PF_COS(angle);
si.x_off =
params[SHIFT_DISPLACE_AMT]->u.fd.value * sin_angle * 100.;
si.y_off =
params[SHIFT_DISPLACE_AMT]->u.fd.value * cos_angle * 100.;
si.gamma =
(double) params[SHIFT_GAMMA]->u.fd.value / (double)(1L << 16);
blend = params[SHIFT_BLEND]->u.fd.value;

si.width = params[0]->u.ld.width;
si.height = params[0]->u.ld.height;
si.p = input =
si.samp_pb.src = &params[0]->u.ld;
si.in_data = in_data;

// get access to our map layer
err = PF_CHECKOUT_PARAM(in_data,
DISP_LAYER,
in_data->current_time,
in_data->time_step,
in_data->time_scale,
&checkout);

if (err)
return err;
si.checkedOutLayer = &checkout;
if (!checkout.u.ld.data) {// nothing to do
err = PF_COPY(input, output, NULL, NULL);

} else {// otherwise, iterate and blend

// calculate how many lines we'll iterate over
lines =
output->extent_hint.bottom - output->extent_hint.top;

// PF_ITERATE checks for user aborts, so...
if (err) return err;
err = PF_BLEND(output, input, blend, output);
}
// Premiere Pro/Elements doesn't support the PF World Transform Suite,
// but it does support many of the callbacks in utils
/*if (in_data->appl_id != 'PrMr') {
ERR(suites.WorldTransformSuite1()->copy(in_data->effect_ref,
&params[SKELETON_INPUT]->u.ld,
output,
NULL,
NULL));
} else {
ERR(PF_COPY(&params[SKELETON_INPUT]->u.ld,
output,
NULL,
NULL));
}*/

return err;

}

/*static PF_Err
DescribeDependencies(
PF_InData*in_data,
PF_OutData*out_data,
PF_ParamDef*params[],
void*extra)

{

PF_Errerr= PF_Err_NONE;
PF_ExtDependenciesExtra*extraP = (PF_ExtDependenciesExtra*)extra;
PF_HandlemsgH= NULL;

AEGP_SuiteHandler suites(in_data->pica_basicP);
switch (extraP->check_type)
{

case PF_DepCheckType_ALL_DEPENDENCIES:

msgH = suites.HandleSuite1()->host_new_handle((A_long)strlen(STR(StrID_DependString1)) + 1);
suites.ANSICallbacksSuite1()->strcpy(reinterpret_cast<char*>(DH(msgH)),STR(StrID_DependString1));
break;

case PF_DepCheckType_MISSING_DEPENDENCIES:
// about one ninth of the time, something's missing

if (rand() % 9){
msgH = suites.HandleSuite1()->host_new_handle((A_long)strlen(STR(StrID_DependString2)) + 1);
suites.ANSICallbacksSuite1()->strcpy(reinterpret_cast<char*>(DH(msgH)),STR(StrID_DependString2));
}
break;

default:
msgH = suites.HandleSuite1()->host_new_handle((A_long)strlen(STR(StrID_NONE)) + 1);
if (msgH){
suites.ANSICallbacksSuite1()->strcpy(reinterpret_cast<char*>(DH(msgH)),STR(StrID_NONE));
}
break;

}

extraP->dependencies_strH = msgH;

return err;

}*/

/*static PF_Err

QueryDynamicFlags(
PF_InData*in_data,
PF_OutData*out_data,
PF_ParamDef*params[],
void*extra)

{

PF_Errerr= PF_Err_NONE,
err2= PF_Err_NONE;
PF_ParamDef def;

AEFX_CLR_STRUCT(def);
//The parameter array passed with PF_Cmd_QUERY_DYNAMIC_FLAGS
//contains invalid values; use PF_CHECKOUT_PARAM() to obtain
//real values.
//
ERR(PF_CHECKOUT_PARAM(in_data,
SKELETON_USE_3D,
in_data->current_time,
in_data->time_step,
in_data->time_scale,
&def));
if (!err){
// if it's checked
if (def.u.bd.value){
out_data->out_flags2 |= PF_OutFlag2_I_USE_3D_LIGHTS;
out_data->out_flags2 |= PF_OutFlag2_I_USE_3D_CAMERA;
} else {
out_data->out_flags2 &= ~PF_OutFlag2_I_USE_3D_LIGHTS;
out_data->out_flags2 &= ~PF_OutFlag2_I_USE_3D_CAMERA;
}
}
ERR2(PF_CHECKIN_PARAM(in_data, &def));
return err;

}*/

static PF_Err GlobalSetdown (

PF_InData*in_data,
PF_OutData*out_data,
PF_ParamDef*params[],
PF_LayerDef*output )

{

return PF_Err_NONE;

}

DllExport

PF_Err

EntryPointFunc (

PF_Cmdcmd,
PF_InData*in_data,
PF_OutData*out_data,
PF_ParamDef*params[],
PF_LayerDef*output,
void*extra)

{

PF_Errerr = PF_Err_NONE;
switch (cmd) {
case PF_Cmd_ABOUT:

err = About(in_data,
out_data,
params,
output);
break;
case PF_Cmd_GLOBAL_SETUP:

err = GlobalSetup(in_data,
out_data,
params,
output);
break;
case PF_Cmd_PARAMS_SETUP:

err = ParamsSetup(in_data,
out_data,
params,
output);
break;
//case PF_Cmd_FRAME_SETUP:

//err = FrameSetup(in_data,
//out_data,
//params,
//output);
//break;
case PF_Cmd_RENDER:

err = Render(in_data,
out_data,
params,
output);
break;
//case PF_Cmd_GET_EXTERNAL_DEPENDENCIES:

//

//err = DescribeDependencies(in_data,
//out_data,
//params,
//extra);
//break;
//case PF_Cmd_QUERY_DYNAMIC_FLAGS:

//err = QueryDynamicFlags(in_data,
//out_data,
//params,
//extra);
//break;
case PF_Cmd_GLOBAL_SETDOWN:
err = GlobalSetdown(in_data,out_data,params,output);
break;
}
return err;

}

ZiggesAuthor
Participating Frequently
May 4, 2014

https://www.dropbox.com/homet

maybe this link can download my code

ZiggesAuthor
Participating Frequently
May 3, 2014

I am sad to fail to put the link in website,i will put the code online.

#pragma once

#ifndef SKELETON_H

#define SKELETON_H

typedef unsigned char u_char;

typedef unsigned short u_short;

typedef unsigned short u_int16;

typedef unsigned long u_long;

typedef short int int16;

#define PF_TABLE_BITS 12

#define PF_TABLE_SZ_16 4096

#define PF_DEEP_COLOR_AWARE 1 // make sure we get 16bpc pixels;

  // AE_Effect.h checks for this.

#include "AEConfig.h"

#ifdef AE_OS_WIN

  typedef unsigned short PixelType;

  #include <Windows.h>

#endif

#include "entry.h"

#include "AE_Effect.h"

#include "AE_EffectCB.h"

#include "AE_Macros.h"

#include "Param_Utils.h"

#include "AE_EffectCBSuites.h"

#include "String_Utils.h"

#include "AE_GeneralPlug.h"

#include "AEFX_ChannelDepthTpl.h"

#include "AEGP_SuiteHandler.h"

#include "Skeleton_Strings.h"

/* Versioning information */

#define MAJOR_VERSION 2

#define MINOR_VERSION 1

#define BUG_VERSION 0

#define STAGE_VERSION PF_Stage_DEVELOP

#define BUILD_VERSION 0

/* Parameter defaults */

#define SKELETON_AMOUNT_MIN 0

#define SKELETON_AMOUNT_MAX 100

#define SKELETON_AMOUNT_DFLT 50

#define LONG2FIX(x) (((long)x)<<16)

#define LUMA(p) \

  (double)(p->red + 2*p->green + p->blue)/(255. * 4.)

#define bias(a,b) \

  PF_POW( (a), PF_LOG(b) / PF_LOG(0.5) )

#define DEFAULT_ANGLE_VAL (0L << 16)

#define BIAS_MIN (0) // 0.01 Fixed

#define BIAS_MAX (2)

#define BIAS_BIG_MAX (2)

#define BIAS_DFLT (1) // about 0.5 Fixed

#define SHIFT_BLEND_MIN 0

#define SHIFT_BLEND_MAX 100

#define SHIFT_BLEND_DFLT 30

/*enum {

  SKELETON_INPUT = 0,

  SKELETON_AMOUNT,

  SKELETON_COLOR,

  SKELETON_DOWNSAMPLE,

  SKELETON_USE_3D,

  SKELETON_NUM_PARAMS

};*/

  //3333333333333333333333333333333

enum {

  BASE=0,

  DISP_LAYER,

  DISP_ANGLE,

  SHIFT_DISPLACE_AMT,

  SHIFT_GAMMA,

  SHIFT_BLEND,

  SHIFT_NUM_PARAMS

};

//33333333333333333333333333333333333333333333333

enum {

  LAYER_DISK_ID=1,

  ANGLE_DISK_ID=2,

  AMOUNT_DISK_ID1 = 3,

  AMOUNT_DISK_ID2 = 4,

  AMOUNT_DISK_ID3 = 5

  //COLOR_DISK_ID,

  //DOWNSAMPLE_DISK_ID,

  //THREED_DISK_ID,

};

enum {

  PF_Cmd_PARAMS_UPDATE,

  PF_Cmd_PARAMS_SUPERVISE,

  PF_Cmd_NTRP,

  PF_Cmd_PARAMS_CONVERT,

  PF_Cmd_RESERVED,

};

#ifdef __cplusplus

  extern "C" {

#endif

DllExport PF_Err

EntryPointFunc(

  PF_Cmd cmd,

  PF_InData *in_data,

  PF_OutData *out_data,

  PF_ParamDef *params[],

  PF_LayerDef *output,

  void *extra) ;

#ifdef __cplusplus

}

#endif

#endif // SKELETON_H