/*
 * CineMatte.ifx
 * Written by Gerald Bonnstetter
 *
 * AutoFX script to run the CineMatte hook.
 *
 * Inputs:
 *    Word(Arg(1),1) = Frame number (1 - N)
 *    Word(Arg(1),2) = Main filename ("-" if not specified)
 *    Word(Arg(1),3) = Swap filename ("-" if not specified)
 *    Word(Arg(1),4) = Sequence number
 *    Word(Arg(1),5) = Total number of frames (N)
 *
 * Returns:
 *    0 if successful, non-zero on failure
 *
 */

OPTIONS RESULTS

base  = 'Autofx_CineMatte_'

framenum = Word(Arg(1),1)
mainname = Word(Arg(1),2)
swapname = Word(Arg(1),3)
seqnum   = Word(Arg(1),4)
framemax = Word(Arg(1),5)

lpath     = GETCLIP(base||'Path')
lfile     = GETCLIP(base||'File')
colors = GETCLIP(base||'Colors')
output = GETCLIP(base||'Output')

SELECT
 WHEN colors = 0 THEN colors = 'BlueScreen'
 WHEN colors = 1 THEN colors = 'GreenScreen'
 WHEN colors = 2 THEN colors = 'RedScreen'
 WHEN colors = 3 THEN colors = 'CyanScreen'
 WHEN colors = 4 THEN colors = 'MagentaScreen'
 WHEN colors = 5 THEN colors = 'YellowScreen'
 WHEN colors = 6 THEN colors = 'AutoDetectScreen'
 WHEN colors = 7 THEN colors = 'DetectAnyColor'
END

SELECT
 WHEN output = 0 THEN output = 'OutputMatteAndKeyedFG'
 WHEN output = 1 THEN output = 'OutputComposite'
 WHEN output = 2 THEN output = 'OutputMatteAndComposite'
 WHEN output = 3 THEN output = 'OutputMatte'
 WHEN output = 4 THEN output = 'OutputKeyedFG'
END

Hook CineMatte colors output || ' File ' || lpath || '/' || lfile

EXIT
