/* This file was generated by scramble.py. */
#include "tests/wp.h"
#include "scramble.h"
int test_wp(char const *filename, char const *what)
{
    Wavelet *wavelet = ALLOCATE0(sizeof *wavelet);
    char const *algo = "haar";
    char const *key = None;
    if (hasword(what, "haar"))
    {
        wavelet->transform = haar_transform_no_key;
    }
    else if (hasword(what, "d4"))
    {
        wavelet->transform = daubechies_d4_transform_no_key;
        algo = "d4";
    }
    else if (hasword(what, "zou"))
    {
        wavelet->transform = zou_transform;
        for (int i = 0; i < (int)strlen(what); i++)
        {
            if (! strncmp(what + i, "key", 3))
            {
                int j;
                for (j = 0; ; j++)
                {
                    char c = what[i + 3 + j];
                    if (! c)
                    {
                        break;
                    }
                    if (c == ' ')
                    {
                        break;
                    }
                }
                char k[j + 1];
                strncpy(k, what + i + 3, j);
                k[j]= '\0';
                wavelet->key = strdup(k);
                key = wavelet->key;
            }
        }
        algo = "zou";
    }
    else if (hasword(what, "qsw"))
    {
        wavelet->transform = qsw_transform_no_key;
        algo = "qsw";
    }
    else
    {
        wavelet->transform = haar_transform_no_key;
    }
    WPNode *tree = wptree_create_pyramidal_tree(wavelet, 5, 512, 64, False);
    if (! filename)
    {
        fprintf(stderr, "Error: No filename!\n");
        return -1;
    }
    printf("%s %s %s\n", filename, algo, key);
    Image *v = get_test_image(filename);
    char name[MAX_PATH] = "";
    if (v->name)
    {
        get_image_name_algo_key(v, "wp", algo, key, name);
    }
    if (! name[0])
    {
        if (key && key[0])
        {
            sprintf(name, "%s_wp_%s_%s.tiff", filename, algo, key);
        }
        else
        {
            sprintf(name, "%s_wp_%s.tiff", filename, algo);
        }
    }
    Image *result = wptree_transform(tree, v);
    Image *r2 = image_copy(result);
    shift_multiply_image(r2, 127.5, 1);
    Image *b = VtoB(r2);
    save_tiff_luminance(name, b);
    return 0;
}
/* This file was generated by scramble.py. */
