
/***************************************************************************
                           chromakill.cpp
                           --------------
    begin                : Sat Jul 31 2004
    copyright            : (C) 2004 by Dirk Ziegelmeier
    email                : dziegel@gmx.de
 ***************************************************************************/

/*
 * ChromaKill algorithm taken from DScaler.
 * Copyright (c) 2003 Laurent Garnier. 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.
 */

#include <stdlib.h>

#include <kdebug.h>
#include <klocale.h>
#include <kconfig.h>

#include "chromakill.h"
#include "kdetvimagefilter.h"
#include "kdetvimagefiltercontext.h"
#include "kdetvcpudetection.h"
#include "x86-64_macros.inc"


extern KdetvImageFilterContext* mmxChromaKill(KdetvImageFilterContext* ctx);

class ChromaKillImageFilter : public KdetvImageFilter
{
public:
    ChromaKillImageFilter()
        : KdetvImageFilter(i18n("ChromaKill"))
    {
    }

    virtual ~ChromaKillImageFilter()
    {
    }

    virtual KdetvImageFilterContext* operator<< (KdetvImageFilterContext* ctx)
    {
        // Return if we don't have MMX
        if(!(KdetvCpuDetection::capabilities() & KdetvCpuDetection::Cap_MMX)) {
            return ctx;
        }

        return (mmxChromaKill(ctx));

    }

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

// -----------------------------------------------------------------------

ChromaKillPlugin::ChromaKillPlugin(Kdetv *ktv, const QString& cfgkey, QObject *parent, const char* name)
    : KdetvFilterPlugin(ktv, cfgkey, parent, name)
{
    _filter = new ChromaKillImageFilter();
}

ChromaKillPlugin::~ChromaKillPlugin()
{
    delete _filter;
}

extern "C" {
    KDETV_EXPORT ChromaKillPlugin* create_chromakill(Kdetv* ktv)
    {
        return new ChromaKillPlugin(ktv, "chromakill", 0, "Kill image chroma");
    }
}

#include "chromakill.moc"
