Huffman frame packing
This commit is contained in:
parent
90ce372081
commit
2c73ccde9b
@ -1071,8 +1071,32 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
|
||||
auto frames = buildFT8MessageFrames("OH8STN:KN4CRD?");
|
||||
qDebug() << frames.first() << Varicode::unpackDirectedMessage(frames.first());
|
||||
qDebug() << Varicode::packGrid("EM73tu") << Varicode::unpackGrid(Varicode::packGrid("EM73tu"));
|
||||
|
||||
auto allbits = Varicode::huffEncode(QString("When simple things need instructions, it is a certain sign of poor design.\x04").toUpper());
|
||||
qDebug() << "FTFrames" << qCeil((allbits.length()+(6+6+1))/13.0);
|
||||
int lasti = 0;
|
||||
int i = 0;
|
||||
int frames = 0;
|
||||
QVector<bool> nextFrame;
|
||||
foreach(auto bits, allbits){
|
||||
if(nextFrame.length() + bits.length() > (frames == 0 ? (8-3) : 64)){
|
||||
// emit frame
|
||||
qDebug() << "frame ready at" << i << "chars" << i-lasti << "size" << nextFrame.length() << "->" << Varicode::bitsToStr(nextFrame);
|
||||
nextFrame.clear();
|
||||
lasti = i;
|
||||
frames++;
|
||||
}
|
||||
|
||||
nextFrame += bits;
|
||||
i++;
|
||||
}
|
||||
qDebug() << "frame ready at" << i << "size" << nextFrame.length() << "->" << Varicode::bitsToStr(nextFrame);
|
||||
frames++;
|
||||
qDebug() << "HuffFrames" << frames;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// this must be the last statement of constructor
|
||||
if (!m_valid) throw std::runtime_error {"Fatal initialization exception"};
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ QString Varicode::packDirectedMessage(const QString &text, int *n){
|
||||
quint8 packed_cmd = directed_cmds.indexOf(cmd.at(0));
|
||||
quint8 packed_extra = fromCRC;
|
||||
|
||||
// 3 + 28 + 28 + 5 = 64
|
||||
// [3][28][28][5],[5] = 69
|
||||
auto bits = (
|
||||
Varicode::intToBits(packed_flag, 3) +
|
||||
Varicode::intToBits(packed_from, 28) +
|
||||
@ -509,6 +509,7 @@ QStringList Varicode::unpackDirectedMessage(const QString &text){
|
||||
return unpacked;
|
||||
}
|
||||
|
||||
// [3][28][28][5],[5] = 69
|
||||
auto bits = Varicode::bitsToStr(Varicode::intToBits(Varicode::unpack64bits(text.left(12)), 64));
|
||||
quint8 extra = Varicode::unpack5bits(text.right(1));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user