head	1.40;
access;
symbols
	start:1.1.1.1
	salsaman:1.1.1;
locks; strict;
comment	@# @;


1.40
date	2009.07.28.15.10.20;	author gfinch;	state Exp;
branches;
next	1.39;

1.39
date	2009.07.22.22.23.32;	author gfinch;	state Exp;
branches;
next	1.38;

1.38
date	2009.06.02.01.05.00;	author gfinch;	state Exp;
branches;
next	1.37;

1.37
date	2009.01.17.21.22.43;	author gfinch;	state Exp;
branches;
next	1.36;

1.36
date	2008.12.01.00.43.43;	author gfinch;	state Exp;
branches;
next	1.35;

1.35
date	2008.11.27.22.52.59;	author gfinch;	state Exp;
branches;
next	1.34;

1.34
date	2008.11.26.16.45.06;	author gfinch;	state Exp;
branches;
next	1.33;

1.33
date	2008.11.25.19.19.07;	author gfinch;	state Exp;
branches;
next	1.32;

1.32
date	2008.09.19.19.31.59;	author gfinch;	state Exp;
branches;
next	1.31;

1.31
date	2008.06.11.08.08.37;	author gfinch;	state Exp;
branches;
next	1.30;

1.30
date	2008.06.06.07.55.22;	author gfinch;	state Exp;
branches;
next	1.29;

1.29
date	2008.04.26.07.37.27;	author gfinch;	state Exp;
branches;
next	1.28;

1.28
date	2008.04.07.20.14.35;	author gfinch;	state Exp;
branches;
next	1.27;

1.27
date	2008.03.30.21.51.44;	author gfinch;	state Exp;
branches;
next	1.26;

1.26
date	2008.03.21.19.58.02;	author gfinch;	state Exp;
branches;
next	1.25;

1.25
date	2008.02.20.07.29.44;	author gfinch;	state Exp;
branches;
next	1.24;

1.24
date	2008.02.18.05.53.30;	author gfinch;	state Exp;
branches;
next	1.23;

1.23
date	2008.02.15.20.54.10;	author gfinch;	state Exp;
branches;
next	1.22;

1.22
date	2008.02.14.23.25.28;	author gfinch;	state Exp;
branches;
next	1.21;

1.21
date	2008.02.12.07.32.55;	author gfinch;	state Exp;
branches;
next	1.20;

1.20
date	2008.01.31.21.57.17;	author gfinch;	state Exp;
branches;
next	1.19;

1.19
date	2007.06.29.17.18.14;	author gfinch;	state Exp;
branches;
next	1.18;

1.18
date	2006.11.23.05.09.38;	author gfinch;	state Exp;
branches;
next	1.17;

1.17
date	2006.10.25.18.01.49;	author gfinch;	state Exp;
branches;
next	1.16;

1.16
date	2006.09.28.02.36.45;	author gfinch;	state Exp;
branches;
next	1.15;

1.15
date	2006.07.24.04.50.16;	author gfinch;	state Exp;
branches;
next	1.14;

1.14
date	2006.06.12.00.54.34;	author gfinch;	state Exp;
branches;
next	1.13;

1.13
date	2006.03.27.15.27.26;	author gfinch;	state Exp;
branches;
next	1.12;

1.12
date	2006.02.17.03.38.53;	author gfinch;	state Exp;
branches;
next	1.11;

1.11
date	2006.02.15.13.37.29;	author gfinch;	state Exp;
branches;
next	1.10;

1.10
date	2006.02.12.03.39.31;	author gfinch;	state Exp;
branches;
next	1.9;

1.9
date	2006.01.28.20.58.15;	author gfinch;	state Exp;
branches;
next	1.8;

1.8
date	2005.12.30.03.39.50;	author gfinch;	state Exp;
branches;
next	1.7;

1.7
date	2005.07.23.17.08.46;	author gfinch;	state Exp;
branches;
next	1.6;

1.6
date	2005.04.05.10.56.06;	author gfinch;	state Exp;
branches;
next	1.5;

1.5
date	2005.04.02.14.09.26;	author gfinch;	state Exp;
branches;
next	1.4;

1.4
date	2005.02.01.02.52.15;	author gfinch;	state Exp;
branches;
next	1.3;

1.3
date	2005.01.02.02.43.52;	author gfinch;	state Exp;
branches;
next	1.2;

1.2
date	2004.12.01.21.53.35;	author gfinch;	state Exp;
branches;
next	1.1;

1.1
date	2004.09.19.04.06.38;	author gfinch;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2004.09.19.04.06.38;	author gfinch;	state Exp;
branches;
next	;


desc
@@


1.40
log
@fix for loop cont crash
@
text
@#!/usr/bin/perl

# build-lives-rfx-plugin - Copyright G. Finch (salsaman) 2005 - 2009
# Released under the GPL 3 or later - see file COPYING or www.gnu.org for details

#usage : build-lives-rfx-plugin <script_file> <output_directory>
# if <output_directory> is omitted, plugins will be generated in /tmp



########################################################
# this will auto-generate a LiVES-Perl plugin from the info in $file

$rfx_version="1.7";


if ($ARGV[0] eq "-get") {
    $section=$ARGV[1];
    $file=$ARGV[2];
    my @@result=&rc_read($section,$file);
    foreach (@@result) {
	print "$_\n";
    }
    exit 0;
}


$file=$ARGV[0];

my $define=(&rc_read("define",$file))[0];
if ($define eq "") {
    print "  - <define> section missing from script file.\n";
    exit 5;
}

my $version=substr($define,1);

unless ($version eq $rfx_version) {
    print "\n\n  - Invalid script RFX version $version, this builder is for $rfx_version\n";
    exit 4;
}

my $delim=substr($define,0,1);
my $delimit=$delim;
if ($delim =~ /[\^\$\.\*\+\?\|\(\)\[\]\{\}\\]/) {
    $delim="\\".$delim;
}

my $plugin_name=(&rc_read("name",$file))[0];
my $author_name=(&rc_read("author",$file))[0];
my $lang_code=(&rc_read("language_code",$file))[0];
unless ($lang_code eq "240"||hex($lang_code)==240) {
    print "  - Invalid language code for this builder !\n";
    exit 3;
}

my $plugin_version=(&rc_read("version",$file))[0];
my $description=(&rc_read("description",$file))[0];
my @@requires=&rc_read("requires",$file);
my @@params=&rc_read("params",$file);
my @@param_window=&rc_read("param_window",$file);
my $properties=(&rc_read("properties",$file))[0];
my @@pre=&rc_read("pre",$file);
my @@loop=&rc_read("loop",$file);
my @@post=&rc_read("post",$file);
my @@onchange=&rc_read("onchange",$file);

$properties=hex($properties)|0x8000; # mark as built with build-plugin

my $min_frames=(split(/$delim/,$description))[2];
my $in_channels=(split(/$delim/,$description))[3];

if ($min_frames==-1) {
    $is_util=1;
}
else {
    $is_util=0;
}


$builder_version="1.0.1-cvs";

if ($in_channels==0&&$properties&0x0004) {
    #batch mode generator
    $is_batch_gen=1;
}
else {
    $is_batch_gen=0;
}


#########################################################

# generate into /tmp
# LiVES will call this to generate in plugins/effects/rendered/test

if (!defined($ARGV[1])) {
    $prefix_dir="/tmp";
}
else {
    $prefix_dir=$ARGV[1];
}

my $plugin_file="$prefix_dir/$plugin_name";

if (defined($DEBUG)) {
    print "Creating plugin file $plugin_file\n";
}

########################################################

open OUT,"> $plugin_file";

print OUT "#!/usr/bin/perl\n\n";
print OUT "#######################################################################\n";
print OUT "# LiVES $plugin_name plugin, version $version\n";
print OUT "# RFX version $rfx_version\n";
print OUT "# autogenerated from script by $author_name\n\n";
print OUT "# rendered plugins should accept:\n";
print OUT "# <plugin_name> version (return <plugin_name> version <version>)\n";
print OUT "# <plugin_name> get_define\n";
print OUT "# <plugin_name> get_capabilities\n";
print OUT "# <plugin_name> get_description (e.g. \"Edge detect|Edge detecting|1|1|\")\n";
print OUT "# <plugin_name> clear (clean up any plugin generated temp files)\n";
print OUT "# and optionally any of: \n";
print OUT "# <plugin_name> get_parameters\n";
print OUT "# <plugin_name> get_param_window\n";
print OUT "# <plugin_name> get_onchange\n";
print OUT "# <plugin_name> onchange_<when> (for any triggers, e.g. onchange_init)\n";
print OUT "#\n";
print OUT "# they must accept:\n";
print OUT "# <plugin_name> process <parameters>\n\n";
print OUT "# You should not skip any frames, if a frame is not changed you must do:\n";
print OUT "# `cp \$in \$out`\n";
print OUT "#\n";
print OUT "# for *non-Perl* plugins, LiVES will call:\n";
print OUT "# <plugin_name> process \"<dir>\" <in_ext> <out_ext> <start> <end>\n";
print OUT "#  <width> <height> <parameters>\n";
print OUT "# first you should chdir to <dir>\n";
print OUT "# then you should create all output frames %8d\$out_ext in numerical \n";
print OUT "# from start to end inclusive,\n";
print OUT "# each time calling sig_progress (see smogrify) - writes current frame number to \n";
print OUT "# <dir>/.status\n";
print OUT "# and checking for pause\n";
print OUT "#\n";
print OUT "# Any errors should be transmitted as in sig_error - \n";
print OUT "# write \"error|msg1|msg2|msg3|\" to <dir>/.status\n";
print OUT "# msgn must not contain \"\\n\", but can be omitted\n\n";
print OUT "# output frames should be named %8d\$out_ext in the same directory\n";
print OUT "# after processing, you should leave no gaps in out frames, you should not resize\n";
print OUT "# or change the palette from RGB24 (LiVES will check and autocorrect this soon)\n\n";
print OUT "# Also you must implement your own: &sig_error and &sig_progress\n\n\n";
print OUT "#######################################################################\n\n";


print OUT "use POSIX;\n\n";

print OUT "my \$command=\$ARGV[0];\n\n";
print OUT "if (\$command eq \"get_capabilities\") {\n";
print OUT "    # capabilities is a bitmap field\n";
print OUT "    # 0x0001 == slow (hint to GUI)\n";
print OUT "    # 0x0002 == may resize (all frames to $nwidth x $nheight)\n";
print OUT "    # 0x0004 == block mode generator\n";
print OUT "    # 0x8000 == reserved\n";
print OUT "    print \"$properties\\n\";\n";
print OUT "    exit 0;\n";
print OUT "}\n\n";
print OUT "if (\$command eq \"version\") {\n";
print OUT "    print \"$plugin_name version $plugin_version : builder version $builder_version\\n\";\n";
print OUT "    exit 0;\n";
print OUT "}\n\n";
print OUT "if (\$command eq \"get_define\") {\n";
print OUT "    print \"$delimit$version\\n\";\n";
print OUT "    exit 0;\n";
print OUT "}\n\n";
print OUT "if (\$command eq \"get_description\") {\n";
print OUT "    #format here is \"Menu entry|Action description|min_frames|number_of_in_channels|\"\n";
print OUT "    # min_frames==-1 indicates a special \"no processing\" effect. This allows more\n";
print OUT "    #general parameter windows which are not really effects (e.g. frame_calculator)\n";
print OUT "    print \"$description\\n\";\n";
print OUT "    exit 0;\n";
print OUT "}\n\n\n";
print OUT "if (\$command eq \"get_parameters\") {\n";
print OUT "    # \"name|label|type|other fields...\"\n";
    print OUT "    # eg. print \"radius|_radius|num0|1|1|100|\";\n";
    print OUT "    # types can be numx,colRGB24,bool,string or string_list\n";

    foreach (@@params) {
	unless ($_ eq "") {
	    @@bits=split(/$delim/);
	    # note: ARGV[0]=="process"
	    if ($bits[2] eq "string") {
		$bits[3]=&quotescape (&escape($bits[3]));
	    }
	    print OUT "    print \"".join($delimit,@@bits)."$delimit\\n\";\n";
	}
    }

print OUT "    exit 0;\n";
print OUT "}\n\n";
print OUT "if (\$command eq \"get_param_window\") {\n";

    foreach (@@param_window) {
	unless ($_ eq "") {
	    $_ =~ s/\"/\\\"/g;
	    print OUT "    print \"$_$delimit\\n\";\n";
	}
    }

print OUT "    exit 0;\n";
print OUT "}\n\n";

print OUT "if (\$command eq \"get_onchange\") {\n";
if (@@onchange) {
    &gen_onchange(0);
}
print OUT "    exit 0;\n";
print OUT "}\n\n";

print OUT "#######################################################\n\n";
print OUT "if (\$command eq \"process\") {\n\n";
print OUT "# in case of error, you should do:\n";
print OUT "# &sig_error(\"msg1\",\"msg2\",\"msg3\",\"msg4\"); [ msg's are optional, but must not\n"; 
print OUT "# contain newlines (\\n) ]\n\n";

if (@@requires) {
    &gen_requires(0);
}

if (@@params) {
    print OUT "\n###### handle parameters #############\n";
    print OUT "# autogenerated from get_parameters\n\n";

    &gen_get_params;
    &gen_param_checks;
}

for ($i=0;$i<@@params;$i++) {
    unless ($params[$i] eq "") {
	if (&param_get_type($i) eq "colRGB24") {
	    $pname=&param_get_name($i);
	    print OUT "\$p$i=int(\$p$i);\n";
	    print OUT "if (\$p$i>0xFFFFFF||\$p$i<0) {\n";
	    print OUT "    &sig_error(\"Invalid colour for $pname.\");\n";
	    print OUT "    exit 1;\n";
	    print OUT "}\n";
	    print OUT "\$p$i"."_red=int(\$p$i/65536);\n";
	    print OUT "\$p$i"."-=\$p$i"."_red*65536;\n";
	    print OUT "\$p$i"."_green=int(\$p$i/256);\n";
	    print OUT "\$p$i"."-=\$p$i"."_green*256;\n";
	    print OUT "\$p$i"."_blue=\$p$i;\n";
	}
    }
}

if ($in_channels==2) {
    print OUT "        \$nwidth=\$width;\n\$nheight=\$height;\n";
}


print OUT "\n";

if ($in_channels==0&&!$is_batch_gen) {
    # script writer MUST set this themselves
    print OUT "    \$end=0;\n";
}

if (@@pre) {
    &gen_pre; 
}

unless ($is_batch_gen) {
    print OUT "\n################# loop through frames #################\n";
	if ($in_channels==2) {
	    print OUT "    \$frame2=\$start2;\n";
	}
    print OUT "    for (\$frame=\$start;\$frame<=\$end;\$frame++) {\n";
    print OUT "	# sig progress will update the progress bar from \$start->\$end\n";
	print OUT "	\$name=&mkname(\$frame);\n";

    unless ($in_channels==0) {
	print OUT "	\$in=\"\$name\$img_ext\";\n";
    }
    
    if ($in_channels==2) {
	print OUT "        \$name2=&mkname(\$frame2);\n";
	print OUT "        \$in2=\"\$clipboard/\$name2\$img_ext\";\n";
	print OUT "        unless (-f \$in2) {\n";
	print OUT "            # end of clipboard reached, loop back to start\n";
	    print OUT "            \$frame2=\$start2;\n";
	print OUT "            \$name2=&mkname(\$frame2);\n";
	print OUT "            \$in2=\"\$clipboard/\$name2\$img_ext\";\n";
	print OUT "	}\n";
    }


    print OUT "	\$out=\"\$name\$out_ext\";\n\n";

    if ($in_channels>0) {
	print OUT " while (! -f \$in) {\n";
	print OUT "     sleep 1;\n";
	print OUT " }\n\n";
    }

}

print OUT "##################### the all-important bit #######################\n\n";
    
    &gen_loop;

print OUT "\n###################################################################\n";

unless ($is_batch_gen) {
    if ($in_channels==2) {
	print OUT "        \$frame2++;\n";
    }
    
    print OUT "        if (! -f \$out) {\n";
    print OUT "            print STDERR \"Warning: effect plugin $plugin_name skipped frame \$frame !\";\n";
    print OUT "            `cp \$in \$out`;\n";
    print OUT "        }\n";
    if ($in_channels==0) {
	print OUT "	&sig_progress(\$frame,\$nwidth,\$nheight,\$fps,\$end);\n";
    }
    else {
	print OUT "	&sig_progress(\$frame);\n";
    }
    
    for ($i=0;$i<@@params;$i++) {
	unless ($params[$i] eq "") {
	    if (&param_get_type($i) eq "colRGB24") {
		# clamp RGB values
		print OUT "        if (\$p$i"."_red>255) {\n";
		print OUT "            \$p$i"."_red=255;\n";
		print OUT "        }\n";
		print OUT "        elsif (\$p$i"."_red<0) {\n";
		print OUT "            \$p$i"."_red=0;\n";
		print OUT "        }\n";
		print OUT "        if (\$p$i"."_green>255) {\n";
		print OUT "            \$p$i"."_green=255;\n";
		print OUT "        }\n";
		print OUT "        elsif (\$p$i"."_green<0) {\n";
		print OUT "            \$p$i"."_green=0;\n";
		print OUT "        }\n";
		print OUT "        if (\$p$i"."_blue>255) {\n";
		print OUT "            \$p$i"."_blue=255;\n";
		print OUT "        }\n";
		print OUT "        elsif (\$p$i"."_blue<0) {\n";
		print OUT "            \$p$i"."_blue=0;\n";
		print OUT "        }\n";
	    }
	}
    }
    
    print OUT "    }\n";
}


print OUT "    return 1;\n";
print OUT "}\n\n\n";

print OUT "\n########## Post loop code ############\n";

print OUT "if (\$command eq \"clear\") {\n";
if (@@post) {
    &gen_post;
}
print OUT "}\n";


if (@@onchange) {
    print OUT "\n########## Triggers ############\n";
    &gen_onchange(1);
}

close OUT;

system ("chmod 755 $plugin_file");

####################################3



sub gen_requires {
    my ($type)=@@_;
    print OUT "##### check requirements first #######\n";

    foreach (@@requires) {
	unless ($_ eq "") {
	    print OUT "    if (&location(\"$_\") eq \"\") {\n";
	    if ($type==0) {
		print OUT "      &sig_error(\"You must install '$_' before you can use this effect.\");\n";
	    }
	    else {
		print OUT "      print \"You must install '$_' before you can use this utility.\";\n";
	    }
	    print OUT "      exit 1;\n";
	    print OUT "    }\n";
	}
    }
}




sub gen_get_params {
    my $i=0;
    my (@@bits,$type);
    foreach (@@params) {
	unless ($_ eq "") {
	    @@bits=split (/$delim/,$_);
	    # note: ARGV[0]=="process"
	    $def=($bits[3]);
	    if ($bits[2] eq "string") {
		$def="\"".&quotescape($def)."\"";
	    }
	    print OUT "    unless (defined(\$ARGV[".($i+1)."])) {\n";
	    print OUT "      \$p$i=$def;\n";
	    print OUT "    }\n";
	    print OUT "    else {\n";

	    print OUT "      \$p$i=\$ARGV[".($i+1)."];\n";

	    print OUT "    }\n";
	    $i++;
	}
    }
}


sub gen_param_checks {
# generate some errors if params are out of range
# fix decimal places and booleans
# TODO - check for valid colours
    my ($pname,$min,$max,$type,$dp,@@bits,$fix);
    my $i=0;
    foreach (@@params) {
	unless ($_ eq "") {
	    @@bits=split(/$delim/);
	    $type=$bits[2];
	    if (substr($type,0,3) eq "num") {
		$pname=$bits[0];
		$min=$bits[4];
		$max=$bits[5];
		$dp=substr($type,3);
		$fix=10**$dp;
		if ($dp>0) {
		    $fix.=".";
		}
		print OUT "    \$!=0;\n";

#use POSIX::strtod to account for locales LC_NUMERIC

		print OUT "    \$p$i=int(POSIX::strtod(\$p$i)*$fix+.5)/$fix;\n";
		print OUT "    if (\$p$i<$min) {\n";
		print OUT "       &sig_error(\"$pname must be >= $min\");\n";
		print OUT "       exit 1;\n";
		print OUT "    }\n";
		print OUT "    if (\$p$i>$max) {\n";
		print OUT "       &sig_error(\"$pname must be <= $max\");\n";
		print OUT "       exit 1;\n";
		print OUT "    }\n";
	    }
	    if ($type eq "bool") {
		print OUT "    \$p$i=~(~\$p$i);\n";
	    }
	    $i++;
	}
    }
}

sub gen_pre {
    foreach (@@pre) {
	print OUT "    ".$_."\n";
    }
}

sub gen_loop {
    foreach (@@loop) {
	print OUT "        ".$_."\n";
    }
}

sub gen_post {
    foreach (@@post) {
	print OUT "    ".$_."\n";
    }
}



sub rc_read {
    # return an array value from our .rc file
    my ($key,$rcfile)=@@_;
    my $string="";
    my (@@result,$part);

    unless (defined(open IN,"$rcfile")) {
	print "  - Unable to read values from script file, $rcfile\n";
	exit 2;
    }
    $part=0;
    while (<IN>) {
	if ($_=~ /(.*)(<\/$key>)/) {
	    return @@result;
	}
	if ($part==1||$_=~ /(<$key>)(.*)/) {
	    if ($part==1) {
		chomp($_);
		$string=$_;
		@@result=(@@result,$string);
	    }
	    else {
		$part=1;
	    }
	}
    }
    return @@result;
}



sub gen_onchange {
    my ($pass)=@@_;
    my ($i,$acount,$which,$code,$type);
    my (%hash)=();

    foreach (@@onchange) {
	unless ($_ eq "") {
	    $which=(split(/$delim/))[0];
	    if ($which>@@params||($which>0&&$params[$which-1] eq "")) {
		print "  - onchange value $which > num parameters.\n";
		exit 1;
	    }
	    if ($pass==0) {
		if (!defined($hash{$which})) {
		    print OUT "    print \"$which$delimit\\n\";\n";
		    $hash{$which}=1;
		}
	    }
	    else {
		$code=substr($_,length($which)+1);
		push(@@{ $hash{$which} }, $code);
	    }
	}
    }
	
    if ($pass==1) {
	foreach $which (keys %hash) {
	    print OUT "\nif (\$command eq \"onchange_$which\") {\n";

	    if (@@requires&&$is_util&&$which eq "init") {
		# for utilities, we generate requires here, since there is no process
		&gen_requires(1);
	    }

	    $acount=1;
	    for ($i=0;$i<@@params;$i++) {
		unless ($params[$i] eq "") {
		    $type=&param_get_type($i);
		    if ($type eq "colRGB24") {
			# with RGBA we would also have _alpha
			print OUT "    \$p$i"."_red=\@@ARGV[".$acount++."];\n";
			print OUT "    \$p$i"."_green=\@@ARGV[".$acount++."];\n";
			print OUT "    \$p$i"."_blue=\@@ARGV[".$acount++."];\n";
		    }
		    else {
			print OUT "    \$p$i"."=\@@ARGV[".$acount++."];\n";
			unless ($type eq "bool" || $type eq "string" || $type eq "string_list") {
			    print OUT "    \$p$i"."_min=\@@ARGV[".$acount++."];\n";
			    print OUT "    \$p$i"."_max=\@@ARGV[".$acount++."];\n";
			}
		    }
		}
	    }
	    print OUT "    \$width=\@@ARGV[".$acount++."];\n";
	    print OUT "    \$height=\@@ARGV[".$acount++."];\n";
	    print OUT "    \$start=\@@ARGV[".$acount++."];\n";
	    print OUT "    \$end=\@@ARGV[".$acount++."];\n";
	    print OUT "    \$last=\@@ARGV[".$acount++."];\n";
	    print OUT "    \$length=\$end-\$start+1;\n";
	    if ($in_channels==2) {
		print OUT "    \$width2=\@@ARGV[".$acount++."];\n";
		print OUT "    \$height2=\@@ARGV[".$acount++."];\n";
	    }
	    print OUT "\n";
	    foreach (@@{$hash{$which}}) { 
		print OUT "    $_\n";
	    }
	    my ($has_params)=0;
	    for ($i=0;$i<@@params;$i++) {
		unless ($params[$i] eq "") {
		    $type=&param_get_type($i);
		    if (!$has_params) {
			&escquotes(@@params);
			print OUT "\n    print \"";
			$has_params=1;
		    }
		    if ($type eq "colRGB24") {
			print OUT "\$p$i"."_red ";
			print OUT "\$p$i"."_green ";
			print OUT "\$p$i"."_blue ";
		    }
		    else {
			if ($type eq "string") {
			    print OUT "\\\"\$p$i\\\" ";
			}
			else {
			    print OUT "\$p$i ";
			}
			unless ($type eq "bool" || $type eq "string" || $type eq "string_list") {
			    print OUT "\$p$i"."_min ";
			    print OUT "\$p$i"."_max ";
			}
		    }
		}
	    }
	    if ($has_params) {
		print OUT "\";\n";
	    }
	    print OUT "    exit 0;\n";
	    print OUT "}\n";
	}
    }
}



sub param_get_type {
    (split(/$delim/,$params[$_[0]]))[2];
}

sub param_get_name {
    (split(/$delim/,$params[$_[0]]))[0];
}



sub escape {
    my ($string)=$_[0];
    $string=~ s/\\/\\\\/g;
    return $string;
}

sub quotescape {
    my ($string)=$_[0];
    $string=~ s/([\"\$\@@])/\\$1/g;
    return $string;
}


sub escquotes {
    for ($i=0;$i<@@params;$i++) {
	unless ($params[$i] eq "") {
	    $type=&param_get_type($i);
	    if ($type eq "string") {
		print OUT "    \$p$i=~ s/\\\"/\\\\\\\"/g;\n";
	    }
	}
    }
}
@


1.39
log
@synch to 1.0.0
@
text
@d81 1
a81 1
$builder_version="1.0.0";
@


1.38
log
@synch with 0.9.9.9
@
text
@d3 1
a3 1
# build-lives-rfx-plugin - Copyright G. Finch (salsaman) 2005
d81 1
a81 1
$builder_version="1.0.0-cvs";
@


1.37
log
@fix for rendered gens
@
text
@d81 1
a81 1
$builder_version="0.9.9-cvs";
@


1.36
log
@auto-deinterlace, other updates
@
text
@d299 5
a303 4
    print OUT "while (! -f \$in) {\n";
    print OUT "  sleep 1;\n";
    print OUT "}\n\n";

@


1.35
log
@RFX in virtual files
@
text
@d156 1
d420 1
d422 1
d449 5
a453 1
		print OUT "    \$p$i=int(\$p$i*$fix+.5)/$fix;\n";
@


1.34
log
@rfx preview for virtual clips
@
text
@d298 4
@


1.33
log
@updates and virtual file rfx pt 1
@
text
@a297 4
    print OUT " while (! -f \$in) {\n";
    print OUT "    sleep 1;\n";
    print OUT " }\n\n";

@


1.32
log
@0.9.9.2 synch
@
text
@d297 6
@


1.31
log
@share to lib changes
@
text
@d81 1
a81 1
$builder_version="0.9.8.12";
@


1.30
log
@small updates
@
text
@a35 1

d39 1
a39 1
    print "  - Invalid script RFX version $version, this builder is for $rfx_version\n";
@


1.29
log
@more fixes 3
@
text
@d82 1
a82 1
$builder_version="0.9.8.10";
@


1.28
log
@fix multitrack params regression
@
text
@d125 1
a225 3
print OUT "    \$livesexitcode=1;\n";
print OUT "    \$SIG{'HUP'}=\"dopost\";\n\n";

a351 2
print OUT "    \$livesexitcode=0;\n";
print OUT "    &dopost;\n";
d357 1
a357 1
print OUT "sub dopost {\n";
a360 3
print OUT "    if (\$livesexitcode) {\n";
print OUT "        exit \$livesexitcode;\n";
print OUT "    }\n";
@


1.27
log
@fixes for merge
@
text
@d82 1
a82 1
$builder_version="0.9.9-cvs";
@


1.26
log
@updates
@
text
@d265 1
a265 1
if ($in_channels==2) {
@


1.25
log
@various fixes
@
text
@d282 4
a285 2
    print OUT "	\$in=\"\$name\$img_ext\";\n";
    
@


1.24
log
@various fixes
@
text
@d82 1
a82 1
$builder_version="0.9.8-cvs";
@


1.23
log
@rendered generators part 6
@
text
@d71 1
d74 8
d229 1
a229 1
    &gen_requires;
d247 1
d383 1
d389 7
a395 1
	    print OUT "      &sig_error(\"You must install '$_' before you can use this effect.\");\n";
d449 1
d453 1
d543 6
@


1.22
log
@rendered generators part 5
@
text
@d75 9
d264 11
a274 1
print OUT "\n################# loop through frames #################\n";
d276 8
a283 1
	print OUT "    \$frame2=\$start2;\n";
a284 4
print OUT "    for (\$frame=\$start;\$frame<=\$end;\$frame++) {\n";
print OUT "	# sig progress will update the progress bar from \$start->\$end\n";
print OUT "	\$name=&mkname(\$frame);\n";
print OUT "	\$in=\"\$name\$img_ext\";\n";
d287 1
a287 9
if ($in_channels==2) {
    print OUT "        \$name2=&mkname(\$frame2);\n";
    print OUT "        \$in2=\"\$clipboard/\$name2\$img_ext\";\n";
    print OUT "        unless (-f \$in2) {\n";
    print OUT "            # end of clipboard reached, loop back to start\n";
	print OUT "            \$frame2=\$start2;\n";
    print OUT "            \$name2=&mkname(\$frame2);\n";
    print OUT "            \$in2=\"\$clipboard/\$name2\$img_ext\";\n";
    print OUT "	}\n";
a289 2

print OUT "	\$out=\"\$name\$out_ext\";\n\n";
d296 39
a334 37
if ($in_channels==2) {
    print OUT "        \$frame2++;\n";
}

print OUT "        if (! -f \$out) {\n";
print OUT "            print STDERR \"Warning: effect plugin $plugin_name skipped frame \$frame !\";\n";
print OUT "            `cp \$in \$out`;\n";
print OUT "        }\n";
if ($in_channels==0) {
    print OUT "	&sig_progress(\$frame,\$nwidth,\$nheight,\$fps,\$end);\n";
}
else {
    print OUT "	&sig_progress(\$frame);\n";
}

for ($i=0;$i<@@params;$i++) {
    unless ($params[$i] eq "") {
	if (&param_get_type($i) eq "colRGB24") {
	    # clamp RGB values
	    print OUT "        if (\$p$i"."_red>255) {\n";
	    print OUT "            \$p$i"."_red=255;\n";
	    print OUT "        }\n";
	    print OUT "        elsif (\$p$i"."_red<0) {\n";
	    print OUT "            \$p$i"."_red=0;\n";
	    print OUT "        }\n";
	    print OUT "        if (\$p$i"."_green>255) {\n";
	    print OUT "            \$p$i"."_green=255;\n";
	    print OUT "        }\n";
	    print OUT "        elsif (\$p$i"."_green<0) {\n";
	    print OUT "            \$p$i"."_green=0;\n";
	    print OUT "        }\n";
	    print OUT "        if (\$p$i"."_blue>255) {\n";
	    print OUT "            \$p$i"."_blue=255;\n";
	    print OUT "        }\n";
	    print OUT "        elsif (\$p$i"."_blue<0) {\n";
	    print OUT "            \$p$i"."_blue=0;\n";
	    print OUT "        }\n";
d337 2
d341 1
a341 1
print OUT "    }\n";
@


1.21
log
@rendered gens more updates
@
text
@d293 1
a293 1
    print OUT "	&sig_progress(\$frame,\$nwidth,\$nheight,\$end);\n";
@


1.20
log
@rendered generators pt 1
@
text
@d293 1
a293 1
    print OUT "	&sig_progress(\$frame,\$end);\n";
@


1.19
log
@update to gpl 3; other fixes
@
text
@d144 1
d246 5
d287 1
d292 6
a297 1
print OUT "	&sig_progress(\$frame);\n";
@


1.18
log
@updates + license update
@
text
@d4 1
a4 1
# Released under the GPL 2.0 or higher - see file COPYING or www.gnu.org for details
@


1.17
log
@trim_frames/builder updates
@
text
@d4 1
a4 1
# Released under the GPL 2.0 - see file COPYING or www.gnu.org for details
@


1.16
log
@update to 0.9.8-cvs, threaded dialog mutexes
@
text
@d370 1
a370 1
	    print OUT "    unless (defined(\$ARGV[$i+1])) {\n";
d374 1
a374 1
	    print OUT "      \$p$i=\$ARGV[$i+1];\n";
@


1.15
log
@post 0.9.6 fixes
@
text
@d73 1
a73 1
$builder_version="0.9.7-cvs";
@


1.14
log
@synch to 0.9.6-pre4
@
text
@d73 1
a73 1
$builder_version="0.9.6-cvs";
@


1.13
log
@multitrack updates
@
text
@d73 1
a73 1
$builder_version="0.9.6-pre3";
@


1.12
log
@add layout_blends/RFX layout tweaks
@
text
@d73 1
a73 1
$builder_version="0.9.6-cvs";
@


1.11
log
@updates
@
text
@d73 1
a73 1
$builder_version="0.9.6-pre1";
@


1.10
log
@rendered effects preview
@
text
@d73 1
a73 1
$builder_version="0.9.6-cvs";
@


1.9
log
@RFX spec updates
@
text
@a254 1
    print OUT "	&sig_progress(\$frame);\n";
d271 1
a271 1
print OUT "	\$out=\"\$name.mgk\";\n\n";
d285 1
@


1.8
log
@sync with 0.9.5 test release
@
text
@d14 3
d28 21
a48 1
$file=@@ARGV[0];
d51 1
d57 1
d71 1
a71 1
my $in_channels=(split(/\|/,$description))[3];
d73 1
a73 1
$builder_version="0.9.5";
d99 3
a101 1
print OUT "# LiVES $plugin_name plugin v0.1\n\n";
d104 1
d152 4
d157 1
a157 1
print OUT "    #format here is \"Menu entry|Action description|min_frames|script_file_name|\"\n";
d160 1
a160 1
print OUT "    print \"$description|\\n\";\n";
d164 2
a165 2
print OUT "    # \"name|group|type|default|min|max|\"\n";
    print OUT "    # eg. print \"Radius|0|num0|1|1|100|\";\n";
d170 1
a170 1
	    @@bits=split(/\|/);
d172 2
a173 2
	    if (@@bits[2] eq "string" || @@bits[2] eq "string_list") {
		@@bits[3]=&quotescape (&escape(@@bits[3]));
d175 1
a175 1
	    print OUT "    print \"".join("|",@@bits)."|\\n\";\n";
d186 1
a186 1
	    print OUT "    print \"$_|\\n\";\n";
d221 4
a224 4
for ($i=1;$i<=@@params;$i++) {
    unless (@@params[i-1] eq "") {
	if (&param_get_type($i-1) eq "colRGB24") {
	    $pname=&param_get_name($i-1);
d283 1
a283 1
print OUT "            print \"Warning: effect plugin $plugin_name skipped frame \$frame !\";\n";
d287 3
a289 3
for ($i=1;$i<=@@params;$i++) {
    unless (@@params[$i-1] eq "") {
	if (&param_get_type($i-1) eq "colRGB24") {
d360 1
a360 1
    my $i=1;
d364 1
a364 1
	    @@bits=split(/\|/);
d366 2
a367 2
	    $def=(@@bits[3]);
	    if (@@bits[2] eq "string" || @@bits[2] eq "string_list") {
d370 1
a370 1
	    print OUT "    unless (defined(\$ARGV[$i])) {\n";
d374 1
a374 1
	    print OUT "      \$p$i=\$ARGV[$i];\n";
d387 1
a387 1
    my $i=1;
d390 2
a391 2
	    @@bits=split(/\|/);
	    $type=@@bits[2];
d393 3
a395 3
		$pname=@@bits[0];
		$min=@@bits[4];
		$max=@@bits[5];
d475 2
a476 2
	    $which=(split(/\|/))[0];
	    if ($which>@@params||($which>0&&@@params[$which-1] eq "")) {
d482 1
a482 1
		    print OUT "    print \"$which|\\n\";\n";
d497 3
a499 3
	    for ($i=1;$i<=@@params;$i++) {
		unless (@@params[i-1] eq "") {
		    $type=&param_get_type($i-1);
d530 3
a532 3
	    for ($i=1;$i<=@@params;$i++) {
		unless (@@params[i-1] eq "") {
		    $type=&param_get_type($i-1);
d544 1
a544 1
			if ($type eq "string" || $type eq "string_list") {
d569 1
a569 1
    (split(/\|/,@@params[@@_[0]]))[2];
d573 1
a573 1
    (split(/\|/,@@params[@@_[0]]))[0];
d579 1
a579 1
    my ($string)=@@_[0];
d585 1
a585 1
    my ($string)=@@_[0];
d592 4
a595 4
    for ($i=1;$i<=@@params;$i++) {
	unless (@@params[i-1] eq "") {
	    $type=&param_get_type($i-1);
	    if ($type eq "string" || $type eq "string_list") {
@


1.7
log
@make sure all files have license/copyright
@
text
@d48 1
a48 1
$builder_version="0.9.5-pre3";
@


1.6
log
@update
@
text
@d3 2
@


1.5
log
@RFX string_list part 1
@
text
@d5 1
a5 1
# if <output_directory> is omitted, plugins will be genereated in /tmp
d10 1
a10 1
# this will auto-generate a render plugin from the info in $file
d112 1
a112 1
print OUT "    # 0x0001 == fast (hint to GUI)\n";
d132 1
a132 1
    print OUT "    # types can be numx,colRGB24,bool,string...more will be added\n";
@


1.4
log
@run RFX post-loop code on cancel/keep
@
text
@d46 1
a46 1
$builder_version="0.9.1-pre4";
d138 1
a138 1
	    if (@@bits[2] eq "string") {
d333 1
a333 1
	    if (@@bits[2] eq "string") {
d474 1
a474 1
			unless ($type eq "bool" || $type eq "string") {
d510 1
a510 1
			if ($type eq "string") {
d516 1
a516 1
			unless ($type eq "bool" || $type eq "string") {
d561 1
a561 1
	    if ($type eq "string") {
@


1.3
log
@add RFX string support
@
text
@d172 3
d280 4
d285 3
d291 4
a295 2
print OUT "    return 1;\n";
print OUT "}\n";
@


1.2
log
@fix build-plugins
@
text
@d132 1
a132 1
    print OUT "    # types can be numx,colRGB24,bool...more will be added\n";
d136 6
a141 1
	    print OUT "    print \"$_|\\n\";\n";
d315 1
a315 1
    my @@bits;
d320 4
d325 1
a325 1
	    print OUT "      \$p$i=@@bits[3];\n";
d424 1
a424 1
    my ($i,$acount,$which,$code);
d453 2
a454 1
		    if (&param_get_type($i-1) eq "colRGB24") {
d462 1
a462 1
			unless (&param_get_type($i-1) eq "bool") {
d486 1
d488 1
d492 1
a492 1
		    if (&param_get_type($i-1) eq "colRGB24") {
d498 7
a504 2
			print OUT "\$p$i ";
			unless (&param_get_type($i-1) eq "bool") {
d529 26
@


1.1
log
@Initial revision
@
text
@d287 1
a287 1
system ("chmod a+x $plugin_file");
@


1.1.1.1
log
@Initial Import
@
text
@@
