output min, median and max papr

This commit is contained in:
Ahmet Inan 2025-07-11 22:39:35 +02:00
commit 77f3720507
2 changed files with 9 additions and 6 deletions

View file

@ -16,6 +16,7 @@ struct Common
static const int code_max = 16;
static const int bits_max = 1 << code_max;
static const int data_max = 4096;
static const int symbols_max = 44;
static const int mls0_poly = 0x331;
static const int mls0_seed = 214;
static const int mls1_poly = 0x43;

View file

@ -11,6 +11,7 @@ Copyright 2021 Ahmet Inan <inan@aicodix.de>
#include "xorshift.hh"
#include "complex.hh"
#include "utils.hh"
#include "quick.hh"
#include "bitman.hh"
#include "decibel.hh"
#include "fft.hh"
@ -41,7 +42,7 @@ struct Encoder : public Common
cmplx prev[tone_count];
cmplx temp[tone_count];
value weight[guard_len];
value worst_papr = -1000;
value papr[symbols_max];
static int bin(int carrier)
{
@ -112,9 +113,9 @@ struct Encoder : public Common
mean += power;
}
mean /= symbol_len;
value papr(peak / mean);
if (papr < best_papr) {
best_papr = papr;
value cand_papr(peak / mean);
if (cand_papr < best_papr) {
best_papr = cand_papr;
for (int i = 0; differential && symbol_number >= 0 && i < tone_count; ++i)
prev[i] = temp[i];
for (int i = 0; i < symbol_len; ++i)
@ -124,7 +125,7 @@ struct Encoder : public Common
if (symbol_number >= 0) {
for (int i = 0; i < symbol_len; ++i)
tdom[i] = best[i];
worst_papr = std::max(worst_papr, best_papr);
papr[symbol_number] = best_papr;
}
clipping_and_filtering(scale);
if (symbol_number != -1) {
@ -292,9 +293,10 @@ struct Encoder : public Common
}
symbol(j);
}
DSP::quick_sort(papr, symbol_count);
std::cerr << "PAPR (dB): " << std::fixed << std::setprecision(1) << DSP::decibel(papr[0]) << " .. " << DSP::decibel(papr[symbol_count/2]) << " .. " << DSP::decibel(papr[symbol_count-1]) << std::endl;
}
finish();
std::cerr << "PAPR (dB): " << DSP::decibel(worst_papr) << std::endl;
}
};