
// NOTE: this file calls PNG filter row functions that are optimized for
//       speed (ffpng). See png_pred.js for the JavaScript implementation
//       of those same functions.

// use with:
// $ ffgac -i <input> -pred <pred> -pred_script ffpng_pred.js -y output.png
// where <pred> can be any one of:
// - none
// - sub
// - up
// - avg
// - paeth
// - mixed

const PNG_FILTER_VALUE_NONE  = 0;
const PNG_FILTER_VALUE_SUB   = 1;
const PNG_FILTER_VALUE_UP    = 2;
const PNG_FILTER_VALUE_AVG   = 3;
const PNG_FILTER_VALUE_PAETH = 4;

function filter_row(args)
{
    let dst = args.dst;
    let pred = args.pred;
    let src = args.src;
    let top = args.top;
    let size = args.size;
    let bpp = args.bpp;

    switch ( pred )
    {
    case PNG_FILTER_VALUE_NONE:  ffpng.none (dst, src, top, size, bpp); break;
    case PNG_FILTER_VALUE_SUB:   ffpng.sub  (dst, src, top, size, bpp); break;
    case PNG_FILTER_VALUE_UP:    ffpng.up   (dst, src, top, size, bpp); break;
    case PNG_FILTER_VALUE_AVG:   ffpng.avg  (dst, src, top, size, bpp); break;
    case PNG_FILTER_VALUE_PAETH: ffpng.paeth(dst, src, top, size, bpp); break;
    }
}
