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

/*
 * Mirror algorithm taken from DScaler.
 * Copyright (c) 2002 Rob Muller. 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 "mirror.h"
#include "kdetvimagefilter.h"
#include "kdetvimagefiltercontext.h"
#include "kdetvcpudetection.h"
#include "x86-64_macros.inc"

class MirrorImageFilter : public KdetvImageFilter
{
public:
    MirrorImageFilter()
        : KdetvImageFilter(i18n("Mirror"))
    {
    }

    virtual ~MirrorImageFilter()
    {
    }

    virtual KdetvImageFilterContext* operator<< (KdetvImageFilterContext* ctx);

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

extern KdetvImageFilterContext* mirrorImageFilterMMX(KdetvImageFilterContext* ctx);

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

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

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

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

extern "C" {
    KDETV_EXPORT MirrorPlugin* create_mirror(Kdetv* ktv)
    {
        return new MirrorPlugin(ktv, "mirrorimage", 0, "Mirror image");
    }
}

#include "mirror.moc"
