fixes to atv demod for testing only
Some checks failed
Build Binaries / build_debian_bullseye_amd64 (push) Failing after 5s
Build Binaries / build_debian_bookworm_amd64 (push) Failing after 4s
Build Binaries / build_debian_trixie_amd64 (push) Failing after 5s
Build Binaries / build_debian_sid_amd64 (push) Failing after 4s
Build Binaries / build_ubuntu_focal_amd64 (push) Failing after 4s
Build Binaries / build_ubuntu_jammy_amd64 (push) Failing after 3s
Build Binaries / build_ubuntu_noble_amd64 (push) Failing after 4s
Build Binaries / build_android (push) Failing after 5s
Build Binaries / check_spelling (push) Failing after 3s
Build Binaries / check_formatting (push) Successful in 3s
Build Binaries / build_windows (push) Has been cancelled
Build Binaries / build_debian_bookworm_aarch64 (push) Has been cancelled
Build Binaries / build_debian_trixie_aarch64 (push) Has been cancelled
Build Binaries / build_macos_intel (push) Has been cancelled
Build Binaries / build_macos_arm (push) Has been cancelled
Build Binaries / build_debian_bullseye_aarch64 (push) Has been cancelled
Build Binaries / build_debian_sid_aarch64 (push) Has been cancelled
Build Binaries / build_ubuntu_focal_aarch64 (push) Has been cancelled
Build Binaries / build_ubuntu_jammy_aarch64 (push) Has been cancelled
Build Binaries / build_ubuntu_noble_aarch64 (push) Has been cancelled
Build Binaries / create_full_archive (push) Has been cancelled
Build Binaries / update_nightly_release (push) Has been cancelled

This commit is contained in:
AlexandreRouma
2025-10-09 00:59:23 -04:00
parent b1d94775fe
commit 4658a1ade6
2 changed files with 51 additions and 49 deletions

View File

@@ -38,6 +38,7 @@ namespace dsp::demod {
inline int process(int count, complex_t* in, float* out) { inline int process(int count, complex_t* in, float* out) {
volk_32fc_magnitude_32f(out, (lv_32fc_t*)in, count); volk_32fc_magnitude_32f(out, (lv_32fc_t*)in, count);
volk_32f_s32f_multiply_32f(out, out, -1.0f, count);
return count; return count;
} }

View File

@@ -45,6 +45,7 @@ class ATVDecoderModule : public ModuleManager::Instance {
agc.init(vfo->output, 1.0f, 1e6, 0.001f, 1.0f); agc.init(vfo->output, 1.0f, 1e6, 0.001f, 1.0f);
demod.init(&agc.out, SAMPLE_RATE, SAMPLE_RATE / 2.0f); demod.init(&agc.out, SAMPLE_RATE, SAMPLE_RATE / 2.0f);
// demod.init(vfo->output, dsp::demod::AM<float>::CARRIER, 8000000.0f, 50.0 / SAMPLE_RATE, 50.0 / SAMPLE_RATE, 0.0f, SAMPLE_RATE); // demod.init(vfo->output, dsp::demod::AM<float>::CARRIER, 8000000.0f, 50.0 / SAMPLE_RATE, 50.0 / SAMPLE_RATE, 0.0f, SAMPLE_RATE);
// demod.init(vfo->output, SAMPLE_RATE, SAMPLE_RATE / 2.0f);
sync.init(&demod.out, 1.0f, 1e-6, 1.0, 0.05); sync.init(&demod.out, 1.0f, 1e-6, 1.0, 0.05);
sink.init(&sync.out, handler, this); sink.init(&sync.out, handler, this);
@@ -168,67 +169,67 @@ class ATVDecoderModule : public ModuleManager::Instance {
// Save sync type to history // Save sync type to history
_this->syncHistory = (_this->syncHistory << 2) | (longSync << 1) | shortSync; _this->syncHistory = (_this->syncHistory << 2) | (longSync << 1) | shortSync;
// If the line has a colorburst, decode it // // If the line has a colorburst, decode it
dsp::complex_t* buf1 = _this->r2c.out.readBuf; // dsp::complex_t* buf1 = _this->r2c.out.readBuf;
dsp::complex_t* buf2 = _this->r2c.out.writeBuf; // dsp::complex_t* buf2 = _this->r2c.out.writeBuf;
if (true) { // if (true) {
// Convert the line into complex // // Convert the line into complex
_this->r2c.process(count, data, buf1); // _this->r2c.process(count, data, buf1);
// Extract the chroma subcarrier (TODO: Optimise by running only where needed) // // Extract the chroma subcarrier (TODO: Optimise by running only where needed)
for (int i = COLORBURST_START; i < count-(CHROMA_BANDPASS_DELAY+1); i++) { // for (int i = COLORBURST_START; i < count-(CHROMA_BANDPASS_DELAY+1); i++) {
volk_32fc_x2_dot_prod_32fc((lv_32fc_t*)&buf2[i], (lv_32fc_t*)&buf1[i - CHROMA_BANDPASS_DELAY], (lv_32fc_t*)CHROMA_BANDPASS, CHROMA_BANDPASS_SIZE); // volk_32fc_x2_dot_prod_32fc((lv_32fc_t*)&buf2[i], (lv_32fc_t*)&buf1[i - CHROMA_BANDPASS_DELAY], (lv_32fc_t*)CHROMA_BANDPASS, CHROMA_BANDPASS_SIZE);
} // }
// Down convert the chroma subcarrier (TODO: Optimise by running only where needed) // // Down convert the chroma subcarrier (TODO: Optimise by running only where needed)
lv_32fc_t startPhase = { 1.0f, 0.0f }; // lv_32fc_t startPhase = { 1.0f, 0.0f };
lv_32fc_t phaseDelta = { sinf(_this->subcarrierFreq), cosf(_this->subcarrierFreq) }; // lv_32fc_t phaseDelta = { sinf(_this->subcarrierFreq), cosf(_this->subcarrierFreq) };
#if VOLK_VERSION >= 030100 // #if VOLK_VERSION >= 030100
volk_32fc_s32fc_x2_rotator2_32fc((lv_32fc_t*)&buf2[COLORBURST_START], (lv_32fc_t*)&buf2[COLORBURST_START], &phaseDelta, &startPhase, count - COLORBURST_START); // volk_32fc_s32fc_x2_rotator2_32fc((lv_32fc_t*)&buf2[COLORBURST_START], (lv_32fc_t*)&buf2[COLORBURST_START], &phaseDelta, &startPhase, count - COLORBURST_START);
#else // #else
volk_32fc_s32fc_x2_rotator_32fc((lv_32fc_t*)&buf2[COLORBURST_START], (lv_32fc_t*)&buf2[COLORBURST_START], phaseDelta, &startPhase, count - COLORBURST_START); // volk_32fc_s32fc_x2_rotator_32fc((lv_32fc_t*)&buf2[COLORBURST_START], (lv_32fc_t*)&buf2[COLORBURST_START], phaseDelta, &startPhase, count - COLORBURST_START);
#endif // #endif
// Compute the phase of the burst // // Compute the phase of the burst
dsp::complex_t burstAvg = { 0.0f, 0.0f }; // dsp::complex_t burstAvg = { 0.0f, 0.0f };
volk_32fc_accumulator_s32fc((lv_32fc_t*)&burstAvg, (lv_32fc_t*)&buf2[COLORBURST_START], COLORBURST_LEN); // volk_32fc_accumulator_s32fc((lv_32fc_t*)&burstAvg, (lv_32fc_t*)&buf2[COLORBURST_START], COLORBURST_LEN);
float burstAmp = burstAvg.amplitude(); // float burstAmp = burstAvg.amplitude();
if (burstAmp*(1.0f/(float)COLORBURST_LEN) < 0.02f) { // if (burstAmp*(1.0f/(float)COLORBURST_LEN) < 0.02f) {
printf("%d\n", _this->line); // printf("%d\n", _this->line);
} // }
burstAvg *= (1.0f / (burstAmp*burstAmp)); // burstAvg *= (1.0f / (burstAmp*burstAmp));
burstAvg = burstAvg.conj(); // burstAvg = burstAvg.conj();
// Normalize the chroma data (TODO: Optimise by running only where needed) // // Normalize the chroma data (TODO: Optimise by running only where needed)
volk_32fc_s32fc_multiply_32fc((lv_32fc_t*)&buf2[COLORBURST_START], (lv_32fc_t*)&buf2[COLORBURST_START], *((lv_32fc_t*)&burstAvg), count - COLORBURST_START); // volk_32fc_s32fc_multiply_32fc((lv_32fc_t*)&buf2[COLORBURST_START], (lv_32fc_t*)&buf2[COLORBURST_START], *((lv_32fc_t*)&burstAvg), count - COLORBURST_START);
// Compute the frequency error of the burst // // Compute the frequency error of the burst
float phase = buf2[COLORBURST_START].phase(); // float phase = buf2[COLORBURST_START].phase();
float error = 0.0f; // float error = 0.0f;
for (int i = COLORBURST_START+1; i < COLORBURST_START+COLORBURST_LEN; i++) { // for (int i = COLORBURST_START+1; i < COLORBURST_START+COLORBURST_LEN; i++) {
float cphase = buf2[i].phase(); // float cphase = buf2[i].phase();
error += dsp::math::normalizePhase(cphase - phase); // error += dsp::math::normalizePhase(cphase - phase);
phase = cphase; // phase = cphase;
} // }
error *= (1.0f / (float)(COLORBURST_LEN-1)); // error *= (1.0f / (float)(COLORBURST_LEN-1));
// Update the subcarrier freq // // Update the subcarrier freq
_this->subcarrierFreq += error*0.0001f; // _this->subcarrierFreq += error*0.0001f;
} // }
// Render the line if it's visible // Render the line if it's visible
if (_this->ypos >= 34 && _this->ypos <= 34+576-1) { if (_this->ypos >= 34 && _this->ypos <= 34+576-1) {
uint32_t* currentLine = &((uint32_t *)_this->img.buffer)[(_this->ypos - 34)*768]; uint32_t* currentLine = &((uint32_t *)_this->img.buffer)[(_this->ypos - 34)*768];
if (_this->colorMode) { if (_this->colorMode) {
for (int i = 155; i < (155+768); i++) { // for (int i = 155; i < (155+768); i++) {
int imval1 = std::clamp<float>(fabsf(buf2[i-155+COLORBURST_START].re*5.0f) * 255.0f, 0, 255); // int imval1 = std::clamp<float>(fabsf(buf2[i-155+COLORBURST_START].re*5.0f) * 255.0f, 0, 255);
int imval2 = std::clamp<float>(fabsf(buf2[i-155+COLORBURST_START].im*5.0f) * 255.0f, 0, 255); // int imval2 = std::clamp<float>(fabsf(buf2[i-155+COLORBURST_START].im*5.0f) * 255.0f, 0, 255);
currentLine[i-155] = 0xFF000000 | (imval2 << 8) | imval1; // currentLine[i-155] = 0xFF000000 | (imval2 << 8) | imval1;
} // }
} }
else { else {
for (int i = 155; i < (155+768); i++) { for (int i = 155; i < (155+768); i++) {
int imval = std::clamp<float>(data[i-155+COLORBURST_START] * 255.0f, 0, 255); int imval = std::clamp<float>(data[i] * 255.0f, 0, 255);
currentLine[i-155] = 0xFF000000 | (imval << 16) | (imval << 8) | imval; currentLine[i-155] = 0xFF000000 | (imval << 16) | (imval << 8) | imval;
} }
} }