示例#1
0
    void OptionWidget::settingsChanged(int value)
    {
        Q_UNUSED(value);

        if (!m_dontUpdate)
        {
            m_dontUpdate = true;
            int nbChannel = channelsComboBox->currentIndex()+1;

            m_logger->debug("nb channel used: " + QString::number(nbChannel) + ", nb bits: " + QString::number(nbBits()));

            double quality = (1 - ((pow(2, nbBits()) * nbChannel) / 256.0)) * 100.0;
            pourcentLabel->setText(QString::number(quality) + "%");
            m_logger->debug("computed quality: " + QString::number(quality));

            if (quality > 95)
                qualityComboBox->setCurrentIndex(2); // high
            else if (quality > 85)
                qualityComboBox->setCurrentIndex(1); // normal
            else
                qualityComboBox->setCurrentIndex(0); // low

            emit optionHasChanged();
            m_dontUpdate = false;
        }
    }
示例#2
0
 //! Export module configuration
 QMap<QString, QString> OptionWidget::exportConfiguration()
 {
     QMap<QString, QString> map;
     map["nb_bits"] = QString::number(nbBits());
     map["channels"] = QString::number(channels());
     map["header"] = QString::number(headerComboBox->currentIndex());
     map["distribution"] = QString::number(distributionComboBox->currentIndex());
     return map;
 }
示例#3
0
std::string HuffmanCode::bitArrayString( )const
{
    std::string s;
    for(size_t i=0; i<nbBits(); i++)
    {
        s += (bit(i) == 1 ? "1" : "0");
    }
    return s;
}
示例#4
0
///////////////////////////////////////////////////////////////////////////////
// Writes the code for this current node, that represents a symbol
//
// writes: [symbol] [nb bits] [count: # of  symbol on stream] [ byte array ]
// not that the byte array is padded. For example,
// if the symbol contains 11 bits, 2 bytes will be written.
bool HuffmanCode::writeCode(Stream& out)const
{
    bool bOk = true;
    out.writeSymbol(symbol());              // Write the 1 byte symbol.
    out.writeByte(nbBits());                // Write the 1 byte code bit length.
    out.write((uint32_t)leaf()->count());   // Write the count of this bit

    if(bOk) bOk &= out.write(byteArray(), (size_t)nbByte());
    return bOk;
}