<commit_before>#include "QZXingFilter.h"

#include <QZXing.h>
#include <QDebug>
#include <QtConcurrent/QtConcurrent>

namespace {
    uchar gray(uchar r, uchar g, uchar b)
    {
        return (306 * (r & 0xFF) +
                601 * (g & 0xFF) +
                117 * (b & 0xFF) +
                0x200) >> 10;
    }
    uchar yuvToGray(uchar Y, uchar U, uchar V)
    {
        const int C = (int) Y - 16;
        const int D = (int) U - 128;
        const int E = (int) V - 128;
        return gray(
            qBound(0, (298 * C + 409 * E + 128) >> 8, 255),
            qBound(0, (298 * C - 100 * D - 208 * E + 128) >> 8, 255),
            qBound(0, (298 * C + 516 * D + 128) >> 8, 255)
        );
    }
}

QZXingFilter::QZXingFilter(QObject *parent)
    : QAbstractVideoFilter(parent)
    , decoding(false)
    , decoder_p(new QZXing())
{
    /// Conecting signals to handlers that will send signals to QML
    connect(decoder_p, &QZXing::decodingStarted,
            this, &QZXingFilter::handleDecodingStarted);
    connect(decoder_p, &QZXing::decodingFinished,
            this, &QZXingFilter::handleDecodingFinished);
}

QZXingFilter::~QZXingFilter()
{

}

bool QZXingFilter::isDecoding()
{
    return decoding;
}

QZXing *QZXingFilter::getDecoder()
{
    return decoder_p;
}

void QZXingFilter::handleDecodingStarted()
{
    decoding = true;
    emit decodingStarted();
    emit isDecodingChanged();
}

void QZXingFilter::handleDecodingFinished(bool succeeded)
{
    decoding = false;
    emit decodingFinished(succeeded, decoder_p->getProcessTimeOfLastDecoding());
    emit isDecodingChanged();
}

QVideoFilterRunnable * QZXingFilter::createFilterRunnable()<commit_msg>deallocate instance of QZXing on QZXingFilter destruction. update the initialization list to match the declaration order<commit_after>#include "QZXingFilter.h"

#include <QZXing.h>
#include <QDebug>
#include <QtConcurrent/QtConcurrent>

namespace {
    uchar gray(uchar r, uchar g, uchar b)
    {
        return (306 * (r & 0xFF) +
                601 * (g & 0xFF) +
                117 * (b & 0xFF) +
                0x200) >> 10;
    }
    uchar yuvToGray(uchar Y, uchar U, uchar V)
    {
        const int C = (int) Y - 16;
        const int D = (int) U - 128;
        const int E = (int) V - 128;
        return gray(
            qBound(0, (298 * C + 409 * E + 128) >> 8, 255),
            qBound(0, (298 * C - 100 * D - 208 * E + 128) >> 8, 255),
            qBound(0, (298 * C + 516 * D + 128) >> 8, 255)
        );
    }
}

QZXingFilter::QZXingFilter(QObject *parent)
    : QAbstractVideoFilter(parent)
    , decoder_p(new QZXing())
    , decoding(false)
{
    /// Conecting signals to handlers that will send signals to QML
    connect(decoder_p, &QZXing::decodingStarted,
            this, &QZXingFilter::handleDecodingStarted);
    connect(decoder_p, &QZXing::decodingFinished,
            this, &QZXingFilter::handleDecodingFinished);
}

QZXingFilter::~QZXingFilter()
{
    if(decoder_p)
        delete decoder_p;
}

bool QZXingFilter::isDecoding()
{
    return decoding;
}

QZXing *QZXingFilter::getDecoder()
{
    return decoder_p;
}

void QZXingFilter::handleDecodingStarted()
{
    decoding = true;
    emit decodingStarted();
    emit isDecodingChanged();
}

void QZXingFilter::handleDecodingFinished(bool succeeded)
{
    decoding = false;
    emit decodingFinished(succeeded, decoder_p->getProcessTimeOfLastDecoding());
    emit isDecodingChanged();
}

QVideoFilterRunnable * QZXingFilter::createFilterRunnable()
{'fraction_non_alphanumeric': 0.12364672364672365, 'fraction_numerical': 0.040455840455840456, 'mean_word_length': 2.771213748657358, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2089981', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1196, 'n_words': 285}