// -*- c++ -*-
/***************************************************************************
                           sharpnessimagefilter.h
                           ----------------------
    begin                : Sat Jul 31 2004
    copyright            : (C) 2004 by Dirk Ziegelmeier
    email                : dziegel@gmx.de
 ***************************************************************************/

/*
 * Sharpness algorithm taken from DScaler.
 * Copyright (c) 2001 Tom Barry. All rights reserved.
 *
 * Ported by: Dirk Ziegelmeier
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 */

#ifndef SHARPNESSIMAGEFILTER_H
#define SHARPNESSIMAGEFILTER_H


#include "kdetvimagefilter.h"
#include "kdetvimagefiltercontext.h"

class SharpnessImageFilter : public KdetvImageFilter
{
public:
    SharpnessImageFilter()
        : KdetvImageFilter(i18n("Sharpness")),
          UsePrefetch(USEPREFETCH_DEFAULT),
          Sharpness(SHARPNESS_DEFAULT)
    {
    }

    virtual ~SharpnessImageFilter()
    {
    }

    virtual KdetvImage::ImageFormat inputFormats()
    {
        return KdetvImage::FORMAT_YUYV;
    };

    virtual KdetvImageFilterContext* operator<< (KdetvImageFilterContext* ctx)
    {
        KdetvCpuDetection::Capabilities cap = KdetvCpuDetection::capabilities();
        if(cap & KdetvCpuDetection::Cap_SSE) {
            if(UsePrefetch) {
                filterSSE_P(ctx);
            } else {
                filterSSE(ctx);
            }
        } else if(cap & KdetvCpuDetection::Cap_3DNOW) {
            if(UsePrefetch) {
                filter3DNOW_P(ctx);
            } else {
                filter3DNOW(ctx);
            }
        } else if(cap & KdetvCpuDetection::Cap_MMX) {
            filterMMX(ctx);
        }

        return ctx;
    }

protected:
    friend class SharpnessPlugin;

    void filterSSE_P(KdetvImageFilterContext* ctx);
    void filter3DNOW_P(KdetvImageFilterContext* ctx);
    void filterSSE(KdetvImageFilterContext* ctx);
    void filter3DNOW(KdetvImageFilterContext* ctx);
    void filterMMX(KdetvImageFilterContext* ctx);

    bool UsePrefetch;
    long Sharpness;
};

#endif
