mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-07-07 09:44:44 +02:00
add sddc source prototype + add new ATV decoder + fix windows builds
This commit is contained in:
65
decoder_modules/atv_decoder/src/amplitude.h
Normal file
65
decoder_modules/atv_decoder/src/amplitude.h
Normal file
@ -0,0 +1,65 @@
|
||||
#pragma once
|
||||
#include <dsp/processor.h>
|
||||
#include <dsp/math/fast_atan2.h>
|
||||
#include <dsp/math/hz_to_rads.h>
|
||||
#include <dsp/math/normalize_phase.h>
|
||||
|
||||
namespace dsp::demod {
|
||||
class Amplitude : public Processor<complex_t, float> {
|
||||
using base_type = Processor<complex_t, float>;
|
||||
public:
|
||||
Amplitude() {}
|
||||
|
||||
Amplitude(stream<complex_t>* in, double deviation) { init(in, deviation); }
|
||||
|
||||
Amplitude(stream<complex_t>* in, double deviation, double samplerate) { init(in, deviation, samplerate); }
|
||||
|
||||
|
||||
virtual void init(stream<complex_t>* in, double deviation) {
|
||||
_invDeviation = 1.0 / deviation;
|
||||
base_type::init(in);
|
||||
}
|
||||
|
||||
virtual void init(stream<complex_t>* in, double deviation, double samplerate) {
|
||||
init(in, math::hzToRads(deviation, samplerate));
|
||||
}
|
||||
|
||||
void setDeviation(double deviation) {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
_invDeviation = 1.0 / deviation;
|
||||
}
|
||||
|
||||
void setDeviation(double deviation, double samplerate) {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
_invDeviation = 1.0 / math::hzToRads(deviation, samplerate);
|
||||
}
|
||||
|
||||
inline int process(int count, complex_t* in, float* out) {
|
||||
volk_32fc_magnitude_32f(out, (lv_32fc_t*)in, count);
|
||||
return count;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
phase = 0.0f;
|
||||
}
|
||||
|
||||
int run() {
|
||||
int count = base_type::_in->read();
|
||||
if (count < 0) { return -1; }
|
||||
|
||||
process(count, base_type::_in->readBuf, base_type::out.writeBuf);
|
||||
|
||||
base_type::_in->flush();
|
||||
if (!base_type::out.swap(count)) { return -1; }
|
||||
return count;
|
||||
}
|
||||
|
||||
protected:
|
||||
float _invDeviation;
|
||||
float phase = 0.0f;
|
||||
};
|
||||
}
|
176
decoder_modules/atv_decoder/src/burst_blanking.txt
Normal file
176
decoder_modules/atv_decoder/src/burst_blanking.txt
Normal file
@ -0,0 +1,176 @@
|
||||
617 + 6 -> I
|
||||
|
||||
304 + 6 -> II
|
||||
|
||||
616 + 6 -> III
|
||||
|
||||
305 + 6 -> IV
|
||||
|
||||
|
||||
|
||||
304
|
||||
305
|
||||
306
|
||||
307
|
||||
308
|
||||
309
|
||||
310
|
||||
311
|
||||
312
|
||||
|
||||
616
|
||||
617
|
||||
618
|
||||
619
|
||||
620
|
||||
621
|
||||
622
|
||||
623
|
||||
624
|
||||
|
||||
305
|
||||
306
|
||||
307
|
||||
308
|
||||
309
|
||||
310
|
||||
311
|
||||
312
|
||||
313
|
||||
|
||||
617
|
||||
618
|
||||
619
|
||||
620
|
||||
621
|
||||
622
|
||||
623
|
||||
624
|
||||
0
|
||||
|
||||
304
|
||||
305
|
||||
306
|
||||
307
|
||||
308
|
||||
309
|
||||
310
|
||||
311
|
||||
312
|
||||
616
|
||||
617
|
||||
618
|
||||
619
|
||||
620
|
||||
621
|
||||
622
|
||||
623
|
||||
624
|
||||
305
|
||||
306
|
||||
307
|
||||
308
|
||||
309
|
||||
310
|
||||
311
|
||||
312
|
||||
313
|
||||
617
|
||||
618
|
||||
619
|
||||
620
|
||||
621
|
||||
622
|
||||
623
|
||||
624
|
||||
0
|
||||
304
|
||||
305
|
||||
306
|
||||
307
|
||||
308
|
||||
309
|
||||
310
|
||||
311
|
||||
312
|
||||
616
|
||||
617
|
||||
618
|
||||
619
|
||||
620
|
||||
621
|
||||
622
|
||||
623
|
||||
624
|
||||
305
|
||||
306
|
||||
307
|
||||
308
|
||||
309
|
||||
310
|
||||
311
|
||||
312
|
||||
313
|
||||
617
|
||||
618
|
||||
619
|
||||
620
|
||||
621
|
||||
622
|
||||
623
|
||||
624
|
||||
0
|
||||
304
|
||||
305
|
||||
306
|
||||
307
|
||||
308
|
||||
309
|
||||
310
|
||||
311
|
||||
312
|
||||
616
|
||||
617
|
||||
618
|
||||
619
|
||||
620
|
||||
621
|
||||
622
|
||||
623
|
||||
624
|
||||
305
|
||||
306
|
||||
307
|
||||
308
|
||||
309
|
||||
310
|
||||
311
|
||||
312
|
||||
313
|
||||
617
|
||||
618
|
||||
619
|
||||
620
|
||||
621
|
||||
622
|
||||
623
|
||||
624
|
||||
0
|
||||
304
|
||||
305
|
||||
306
|
||||
307
|
||||
308
|
||||
309
|
||||
310
|
||||
311
|
||||
312
|
||||
616
|
||||
617
|
||||
618
|
||||
619
|
||||
620
|
||||
621
|
||||
622
|
||||
623
|
||||
624
|
@ -1,63 +0,0 @@
|
||||
#pragma once
|
||||
#include <dsp/loop/pll.h>
|
||||
#include "chrominance_filter.h"
|
||||
|
||||
// TODO: Should be 60 but had to try something
|
||||
#define BURST_START (63+CHROMA_FIR_DELAY)
|
||||
#define BURST_END (BURST_START+28)
|
||||
|
||||
#define A_PHASE ((135.0/180.0)*FL_M_PI)
|
||||
#define B_PHASE ((-135.0/180.0)*FL_M_PI)
|
||||
|
||||
namespace dsp::loop {
|
||||
class ChromaPLL : public PLL {
|
||||
using base_type = PLL;
|
||||
public:
|
||||
ChromaPLL() {}
|
||||
|
||||
ChromaPLL(stream<complex_t>* in, double bandwidth, double initPhase = 0.0, double initFreq = 0.0, double minFreq = -FL_M_PI, double maxFreq = FL_M_PI) {
|
||||
base_type::init(in, bandwidth, initFreq, initPhase, minFreq, maxFreq);
|
||||
}
|
||||
|
||||
inline int process(int count, complex_t* in, complex_t* out, bool aphase = false) {
|
||||
// Process the pre-burst section
|
||||
for (int i = 0; i < BURST_START; i++) {
|
||||
out[i] = in[i] * math::phasor(-pcl.phase);
|
||||
pcl.advancePhase();
|
||||
}
|
||||
|
||||
// Process the burst itself
|
||||
if (aphase) {
|
||||
for (int i = BURST_START; i < BURST_END; i++) {
|
||||
complex_t outVal = in[i] * math::phasor(-pcl.phase);
|
||||
out[i] = outVal;
|
||||
pcl.advance(math::normalizePhase(outVal.phase() - A_PHASE));
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i = BURST_START; i < BURST_END; i++) {
|
||||
complex_t outVal = in[i] * math::phasor(-pcl.phase);
|
||||
out[i] = outVal;
|
||||
pcl.advance(math::normalizePhase(outVal.phase() - B_PHASE));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Process the post-burst section
|
||||
for (int i = BURST_END; i < count; i++) {
|
||||
out[i] = in[i] * math::phasor(-pcl.phase);
|
||||
pcl.advancePhase();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
inline int processBlank(int count, complex_t* in, complex_t* out) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
out[i] = in[i] * math::phasor(-pcl.phase);
|
||||
pcl.advancePhase();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
};
|
||||
}
|
@ -1,239 +0,0 @@
|
||||
#pragma once
|
||||
#include <dsp/types.h>
|
||||
|
||||
inline const dsp::complex_t CHROMA_FIR[] = {
|
||||
{-0.000005461290583903, -0.000011336784355655},
|
||||
{ 0.000020060944485414, 0.000009851315045203},
|
||||
{-0.000034177222729438, 0.000007245841504981},
|
||||
{ 0.000027694034878705, -0.000033114740542635},
|
||||
{-0.000001217597841648, 0.000039141482370942},
|
||||
{-0.000008324593371228, -0.000011315001355976},
|
||||
{-0.000038085228233509, -0.000010585909953738},
|
||||
{ 0.000114833396071141, -0.000047778708840608},
|
||||
{-0.000115428390169113, 0.000205816198882814},
|
||||
{-0.000055467806072871, -0.000356692479491626},
|
||||
{ 0.000349316846854190, 0.000326162940234916},
|
||||
{-0.000558465829929114, -0.000048001521408724},
|
||||
{ 0.000488176200631416, -0.000319593757302922},
|
||||
{-0.000169437838021935, 0.000501610900725908},
|
||||
{-0.000131793335799502, -0.000373003580727547},
|
||||
{ 0.000166817395492786, 0.000105930895534474},
|
||||
{ 0.000030499908326112, -0.000003048682668943},
|
||||
{-0.000174999505027919, 0.000168008090089458},
|
||||
{ 0.000054431163395030, -0.000385174790951272},
|
||||
{ 0.000215876012859739, 0.000372695852521209},
|
||||
{-0.000325534912280750, -0.000130173041693966},
|
||||
{ 0.000154951430569290, -0.000045395998708328},
|
||||
{ 0.000054324657659002, -0.000076028700470037},
|
||||
{ 0.000015664427565764, 0.000348002612845696},
|
||||
{-0.000345943017888332, -0.000402175417043307},
|
||||
{ 0.000568731727879741, 0.000112347863435682},
|
||||
{-0.000416485880859085, 0.000211750352828909},
|
||||
{ 0.000087462353623011, -0.000188197153014309},
|
||||
{-0.000032082305030264, -0.000136804226080664},
|
||||
{ 0.000379089999045955, 0.000303466839685362},
|
||||
{-0.000726760198519770, -0.000007022279302816},
|
||||
{ 0.000619888661818195, -0.000476871323359809},
|
||||
{-0.000151885493742993, 0.000595641190573181},
|
||||
{-0.000100626407015494, -0.000227947144491108},
|
||||
{-0.000201935458823941, -0.000107628631934340},
|
||||
{ 0.000680260922139900, -0.000120771182888852},
|
||||
{-0.000666108629277491, 0.000744775901128973},
|
||||
{ 0.000067236591919755, -0.001044125966364420},
|
||||
{ 0.000447037274751822, 0.000651912509450913},
|
||||
{-0.000262675893448686, -0.000082499729563337},
|
||||
{-0.000349821460486320, 0.000132102793530818},
|
||||
{ 0.000507024815168287, -0.000837598610490618},
|
||||
{ 0.000163814255478652, 0.001346530693477834},
|
||||
{-0.000970457632383793, -0.000968411010101160},
|
||||
{ 0.000974834882891140, 0.000116507082762032},
|
||||
{-0.000225464280571542, 0.000137131865995708},
|
||||
{-0.000211542240694642, 0.000563783548428947},
|
||||
{-0.000414412310798766, -0.001309793399193736},
|
||||
{ 0.001497010004594478, 0.001021907858926259},
|
||||
{-0.001752019159639658, 0.000116536066154131},
|
||||
{ 0.000872822027879430, -0.000783952720205569},
|
||||
{-0.000032439446797970, 0.000184988059956734},
|
||||
{ 0.000446259382722895, 0.000833040920509238},
|
||||
{-0.001741577737284306, -0.000764423771425237},
|
||||
{ 0.002306569133792772, -0.000593352416441601},
|
||||
{-0.001336084746214192, 0.001744394557524181},
|
||||
{-0.000015810020735495, -0.001342809547658260},
|
||||
{ 0.000007636494885364, 0.000009498318627546},
|
||||
{ 0.001403876768349702, 0.000326101441888391},
|
||||
{-0.002351020828600226, 0.001098649819278302},
|
||||
{ 0.001389314639579544, -0.002746943712072884},
|
||||
{ 0.000526319899588909, 0.002635084366837732},
|
||||
{-0.001109526585744687, -0.000950323796527721},
|
||||
{-0.000307792427984886, -0.000013203419520794},
|
||||
{ 0.001737955094951111, -0.001247368808692850},
|
||||
{-0.000974502437588420, 0.003352512117661680},
|
||||
{-0.001462571137390936, -0.003635296917435679},
|
||||
{ 0.002783459090201693, 0.001604420226187745},
|
||||
{-0.001471518558760170, 0.000211117948702137},
|
||||
{-0.000575340825070194, 0.000601820846100026},
|
||||
{ 0.000302090333345692, -0.003088058972305493},
|
||||
{ 0.002496092353182990, 0.003912508340989065},
|
||||
{-0.004645661091012423, -0.001630427298020200},
|
||||
{ 0.003556824805628799, -0.001209822327859352},
|
||||
{-0.000744999556260706, 0.001143238699138109},
|
||||
{ 0.000144278726929409, 0.001638049051599065},
|
||||
{-0.003025291044450178, -0.003226370992887968},
|
||||
{ 0.006047866290490120, 0.000927406808799887},
|
||||
{-0.005338456415106141, 0.003008811999350399},
|
||||
{ 0.001642959659014839, -0.003972384205231079},
|
||||
{ 0.000273874932822212, 0.000977326273749033},
|
||||
{ 0.002315022846573390, 0.001695671268241410},
|
||||
{-0.006240953957978884, 0.000207330368698293},
|
||||
{ 0.006164252120861735, -0.005177351717451013},
|
||||
{-0.001560310257561104, 0.007437030759707700},
|
||||
{-0.002131333814462852, -0.004317129694157112},
|
||||
{ 0.000280518918541908, 0.000134405998842553},
|
||||
{ 0.004612116481180659, -0.001024468120657814},
|
||||
{-0.005599300279638699, 0.006828277067771868},
|
||||
{ 0.000228879728552504, -0.010675998154712657},
|
||||
{ 0.005692081512980654, 0.007582243186569848},
|
||||
{-0.005100500569859509, -0.001364751685737153},
|
||||
{-0.000902490398043454, 0.000385770160220703},
|
||||
{ 0.003673858819546609, -0.006701685283451640},
|
||||
{ 0.002079056046131593, 0.012568579063417429},
|
||||
{-0.010730008156911677, -0.009826454574016218},
|
||||
{ 0.012092401380903161, 0.000921764172237851},
|
||||
{-0.004714530989129091, 0.003151948807627123},
|
||||
{-0.001055930168838909, 0.003228576712467020},
|
||||
{-0.004343270165991213, -0.011924332879354394},
|
||||
{ 0.016499994418955999, 0.010255324919126899},
|
||||
{-0.021047239750251585, 0.002309419513135448},
|
||||
{ 0.011855513874047341, -0.011604071033866310},
|
||||
{-0.000777842281358575, 0.005916341648175263},
|
||||
{ 0.004380939277688377, 0.007397670455730446},
|
||||
{-0.021891594662401131, -0.008509480947490166},
|
||||
{ 0.032787638290674201, -0.009950745850861956},
|
||||
{-0.021022579272463194, 0.030030850567389102},
|
||||
{-0.001508145650189953, -0.027571914870304640},
|
||||
{ 0.004056649693022923, 0.004624901687718579},
|
||||
{ 0.025728742586666287, 0.004824671348397606},
|
||||
{-0.058002700931665603, 0.030198618296813803},
|
||||
{ 0.043631619628438784, -0.096308304333327280},
|
||||
{ 0.033451363423624300, 0.136687079396426990},
|
||||
{-0.129387018420204200, -0.101540513046619400},
|
||||
{ 0.172881344826560730, -0.000000000000005297},
|
||||
{-0.129387018420198010, 0.101540513046627330},
|
||||
{ 0.033451363423615862, -0.136687079396429050},
|
||||
{ 0.043631619628444723, 0.096308304333324601},
|
||||
{-0.058002700931667456, -0.030198618296810247},
|
||||
{ 0.025728742586665992, -0.004824671348399184},
|
||||
{ 0.004056649693022639, -0.004624901687718827},
|
||||
{-0.001508145650188251, 0.027571914870304734},
|
||||
{-0.021022579272465047, -0.030030850567387805},
|
||||
{ 0.032787638290674812, 0.009950745850859947},
|
||||
{-0.021891594662400610, 0.008509480947491507},
|
||||
{ 0.004380939277687923, -0.007397670455730714},
|
||||
{-0.000777842281358940, -0.005916341648175215},
|
||||
{ 0.011855513874048058, 0.011604071033865578},
|
||||
{-0.021047239750251731, -0.002309419513134139},
|
||||
{ 0.016499994418955360, -0.010255324919127926},
|
||||
{-0.004343270165990471, 0.011924332879354665},
|
||||
{-0.001055930168839110, -0.003228576712466955},
|
||||
{-0.004714530989129287, -0.003151948807626830},
|
||||
{ 0.012092401380903103, -0.000921764172238603},
|
||||
{-0.010730008156911072, 0.009826454574016881},
|
||||
{ 0.002079056046130817, -0.012568579063417559},
|
||||
{ 0.003673858819547020, 0.006701685283451416},
|
||||
{-0.000902490398043478, -0.000385770160220647},
|
||||
{-0.005100500569859424, 0.001364751685737466},
|
||||
{ 0.005692081512980187, -0.007582243186570198},
|
||||
{ 0.000228879728553163, 0.010675998154712643},
|
||||
{-0.005599300279639117, -0.006828277067771524},
|
||||
{ 0.004612116481180722, 0.001024468120657532},
|
||||
{ 0.000280518918541900, -0.000134405998842571},
|
||||
{-0.002131333814462586, 0.004317129694157243},
|
||||
{-0.001560310257561563, -0.007437030759707604},
|
||||
{ 0.006164252120862052, 0.005177351717450635},
|
||||
{-0.006240953957978898, -0.000207330368697911},
|
||||
{ 0.002315022846573286, -0.001695671268241552},
|
||||
{ 0.000273874932822152, -0.000977326273749050},
|
||||
{ 0.001642959659015084, 0.003972384205230976},
|
||||
{-0.005338456415106324, -0.003008811999350072},
|
||||
{ 0.006047866290490063, -0.000927406808800258},
|
||||
{-0.003025291044449980, 0.003226370992888153},
|
||||
{ 0.000144278726929308, -0.001638049051599074},
|
||||
{-0.000744999556260777, -0.001143238699138063},
|
||||
{ 0.003556824805628873, 0.001209822327859134},
|
||||
{-0.004645661091012323, 0.001630427298020484},
|
||||
{ 0.002496092353182751, -0.003912508340989219},
|
||||
{ 0.000302090333345882, 0.003088058972305475},
|
||||
{-0.000575340825070231, -0.000601820846099991},
|
||||
{-0.001471518558760183, -0.000211117948702046},
|
||||
{ 0.002783459090201593, -0.001604420226187919},
|
||||
{-0.001462571137390710, 0.003635296917435769},
|
||||
{-0.000974502437588628, -0.003352512117661619},
|
||||
{ 0.001737955094951189, 0.001247368808692742},
|
||||
{-0.000307792427984885, 0.000013203419520814},
|
||||
{-0.001109526585744628, 0.000950323796527789},
|
||||
{ 0.000526319899588746, -0.002635084366837765},
|
||||
{ 0.001389314639579712, 0.002746943712072799},
|
||||
{-0.002351020828600294, -0.001098649819278158},
|
||||
{ 0.001403876768349682, -0.000326101441888477},
|
||||
{ 0.000007636494885364, -0.000009498318627546},
|
||||
{-0.000015810020735412, 0.001342809547658261},
|
||||
{-0.001336084746214299, -0.001744394557524099},
|
||||
{ 0.002306569133792808, 0.000593352416441460},
|
||||
{-0.001741577737284259, 0.000764423771425344},
|
||||
{ 0.000446259382722843, -0.000833040920509266},
|
||||
{-0.000032439446797982, -0.000184988059956732},
|
||||
{ 0.000872822027879478, 0.000783952720205515},
|
||||
{-0.001752019159639665, -0.000116536066154024},
|
||||
{ 0.001497010004594416, -0.001021907858926351},
|
||||
{-0.000414412310798685, 0.001309793399193761},
|
||||
{-0.000211542240694677, -0.000563783548428934},
|
||||
{-0.000225464280571550, -0.000137131865995694},
|
||||
{ 0.000974834882891133, -0.000116507082762092},
|
||||
{-0.000970457632383734, 0.000968411010101219},
|
||||
{ 0.000163814255478569, -0.001346530693477844},
|
||||
{ 0.000507024815168339, 0.000837598610490586},
|
||||
{-0.000349821460486328, -0.000132102793530797},
|
||||
{-0.000262675893448681, 0.000082499729563353},
|
||||
{ 0.000447037274751782, -0.000651912509450940},
|
||||
{ 0.000067236591919819, 0.001044125966364416},
|
||||
{-0.000666108629277537, -0.000744775901128932},
|
||||
{ 0.000680260922139908, 0.000120771182888810},
|
||||
{-0.000201935458823935, 0.000107628631934352},
|
||||
{-0.000100626407015480, 0.000227947144491114},
|
||||
{-0.000151885493743030, -0.000595641190573172},
|
||||
{ 0.000619888661818225, 0.000476871323359771},
|
||||
{-0.000726760198519770, 0.000007022279302861},
|
||||
{ 0.000379089999045936, -0.000303466839685386},
|
||||
{-0.000032082305030256, 0.000136804226080666},
|
||||
{ 0.000087462353623023, 0.000188197153014303},
|
||||
{-0.000416485880859098, -0.000211750352828883},
|
||||
{ 0.000568731727879734, -0.000112347863435717},
|
||||
{-0.000345943017888307, 0.000402175417043329},
|
||||
{ 0.000015664427565742, -0.000348002612845697},
|
||||
{ 0.000054324657659007, 0.000076028700470034},
|
||||
{ 0.000154951430569292, 0.000045395998708319},
|
||||
{-0.000325534912280742, 0.000130173041693986},
|
||||
{ 0.000215876012859716, -0.000372695852521222},
|
||||
{ 0.000054431163395054, 0.000385174790951269},
|
||||
{-0.000174999505027930, -0.000168008090089447},
|
||||
{ 0.000030499908326113, 0.000003048682668941},
|
||||
{ 0.000166817395492779, -0.000105930895534485},
|
||||
{-0.000131793335799479, 0.000373003580727555},
|
||||
{-0.000169437838021966, -0.000501610900725898},
|
||||
{ 0.000488176200631435, 0.000319593757302892},
|
||||
{-0.000558465829929111, 0.000048001521408758},
|
||||
{ 0.000349316846854170, -0.000326162940234938},
|
||||
{-0.000055467806072849, 0.000356692479491629},
|
||||
{-0.000115428390169126, -0.000205816198882806},
|
||||
{ 0.000114833396071144, 0.000047778708840601},
|
||||
{-0.000038085228233508, 0.000010585909953741},
|
||||
{-0.000008324593371228, 0.000011315001355977},
|
||||
{-0.000001217597841650, -0.000039141482370942},
|
||||
{ 0.000027694034878707, 0.000033114740542633},
|
||||
{-0.000034177222729439, -0.000007245841504979},
|
||||
{ 0.000020060944485413, -0.000009851315045204},
|
||||
{-0.000005461290583903, 0.000011336784355656},
|
||||
};
|
||||
|
||||
#define CHROMA_FIR_SIZE (sizeof(CHROMA_FIR)/sizeof(dsp::complex_t))
|
||||
#define CHROMA_FIR_DELAY ((CHROMA_FIR_SIZE-1)/2)
|
131
decoder_modules/atv_decoder/src/filters.h
Normal file
131
decoder_modules/atv_decoder/src/filters.h
Normal file
@ -0,0 +1,131 @@
|
||||
#pragma once
|
||||
#include <dsp/types.h>
|
||||
|
||||
const dsp::complex_t CHROMA_BANDPASS[123] = {
|
||||
{ -0.000007675039564594f, -0.000017362992335168f },
|
||||
{ 0.000050180791439308f, -0.000005054021864311f },
|
||||
{ -0.000022529111707761f, 0.000102942513429095f },
|
||||
{ -0.000157609487484146f, -0.000092618697641464f },
|
||||
{ 0.000205649042029007f, -0.000181710515677257f },
|
||||
{ 0.000143445458895462f, 0.000331994546004200f },
|
||||
{ -0.000414693079508517f, 0.000038265188132615f },
|
||||
{ 0.000090081630021837f, -0.000395731646002122f },
|
||||
{ 0.000257705918065856f, 0.000154354504676150f },
|
||||
{ -0.000064051192147575f, 0.000055648228186439f },
|
||||
{ 0.000089938060647145f, 0.000213032074676941f },
|
||||
{ -0.000604775098099200f, 0.000050706635726124f },
|
||||
{ 0.000223309865890358f, -0.000944433958755193f },
|
||||
{ 0.001049943574694384f, 0.000640863688898729f },
|
||||
{ -0.000983491651119595f, 0.000840133365053179f },
|
||||
{ -0.000417178588714773f, -0.001011686459999295f },
|
||||
{ 0.000616677332283103f, -0.000046513429902547f },
|
||||
{ 0.000018549463752019f, -0.000075619948809012f },
|
||||
{ 0.000734408386201158f, 0.000456742966201638f },
|
||||
{ -0.001192460562555901f, 0.001001510577200253f },
|
||||
{ -0.000729137747758392f, -0.001811046261815935f },
|
||||
{ 0.001878272869910273f, -0.000125879189667096f },
|
||||
{ -0.000312873903977849f, 0.001230889889574772f },
|
||||
{ -0.000142534831707354f, -0.000090307321579771f },
|
||||
{ -0.000942796972567241f, 0.000778470227412111f },
|
||||
{ -0.000945381510920278f, -0.002406055808135091f },
|
||||
{ 0.003537159230775561f, -0.000207350791625892f },
|
||||
{ -0.000956199555190230f, 0.003634225577771235f },
|
||||
{ -0.002543835202533561f, -0.001641705037372486f },
|
||||
{ 0.001064108471592447f, -0.000863770138941644f },
|
||||
{ -0.000335799601479829f, -0.000876091753216939f },
|
||||
{ 0.003390761989356699f, -0.000170321604912419f },
|
||||
{ -0.001408130728751909f, 0.005175554625981795f },
|
||||
{ -0.005203055300834108f, -0.003419861284250694f },
|
||||
{ 0.004342719678657084f, -0.003465264906764298f },
|
||||
{ 0.001143432997855297f, 0.003059520699490539f },
|
||||
{ 0.000304096484476364f, -0.000012725974706621f },
|
||||
{ -0.001193870642975282f, 0.004247469277548632f },
|
||||
{ -0.006681021498855877f, -0.004471771356204969f },
|
||||
{ 0.007965721969864534f, -0.006247895626072559f },
|
||||
{ 0.003365883969059717f, 0.009241201835481184f },
|
||||
{ -0.006835562188141396f, 0.000228798228738161f },
|
||||
{ 0.000409900284971528f, -0.001412838961851673f },
|
||||
{ -0.004331406608345981f, -0.002951876085350234f },
|
||||
{ 0.009290089917766562f, -0.007161958719089258f },
|
||||
{ 0.005418326020709935f, 0.015272361365960607f },
|
||||
{ -0.017077565432843410f, 0.000428641984774326f },
|
||||
{ 0.003850771342644978f, -0.012869517593577566f },
|
||||
{ 0.004380859690202961f, 0.003039552423897447f },
|
||||
{ 0.004761181766399753f, -0.003607421240356480f },
|
||||
{ 0.005926935731028822f, 0.017160134858844222f },
|
||||
{ -0.028153584885925551f, 0.000471042980325370f },
|
||||
{ 0.009655944938035437f, -0.031314555422639050f },
|
||||
{ 0.023930146568136038f, 0.016901617811072800f },
|
||||
{ -0.012998853255109976f, 0.009678807314399702f },
|
||||
{ 0.002043176559434885f, 0.006079907699564680f },
|
||||
{ -0.036686455817128191f, 0.000306882557812233f },
|
||||
{ 0.021529138474771701f, -0.067800343150283604f },
|
||||
{ 0.085421344938160879f, 0.061409588050754214f },
|
||||
{ -0.108166660998898100f, 0.079141989828113088f },
|
||||
{ -0.047617308971534079f, -0.145721049254261960f },
|
||||
{ 0.160079041453427080f, -0.000000000000000427f },
|
||||
{ -0.047617308971533295f, 0.145721049254262240f },
|
||||
{ -0.108166660998898530f, -0.079141989828112505f },
|
||||
{ 0.085421344938160546f, -0.061409588050754672f },
|
||||
{ 0.021529138474772065f, 0.067800343150283493f },
|
||||
{ -0.036686455817128191f, -0.000306882557812037f },
|
||||
{ 0.002043176559434853f, -0.006079907699564691f },
|
||||
{ -0.012998853255110026f, -0.009678807314399631f },
|
||||
{ 0.023930146568135951f, -0.016901617811072928f },
|
||||
{ 0.009655944938035604f, 0.031314555422638994f },
|
||||
{ -0.028153584885925554f, -0.000471042980325220f },
|
||||
{ 0.005926935731028730f, -0.017160134858844253f },
|
||||
{ 0.004761181766399772f, 0.003607421240356455f },
|
||||
{ 0.004380859690202943f, -0.003039552423897470f },
|
||||
{ 0.003850771342645046f, 0.012869517593577545f },
|
||||
{ -0.017077565432843413f, -0.000428641984774235f },
|
||||
{ 0.005418326020709854f, -0.015272361365960637f },
|
||||
{ 0.009290089917766600f, 0.007161958719089209f },
|
||||
{ -0.004331406608345964f, 0.002951876085350257f },
|
||||
{ 0.000409900284971536f, 0.001412838961851670f },
|
||||
{ -0.006835562188141398f, -0.000228798228738125f },
|
||||
{ 0.003365883969059667f, -0.009241201835481201f },
|
||||
{ 0.007965721969864567f, 0.006247895626072517f },
|
||||
{ -0.006681021498855855f, 0.004471771356205005f },
|
||||
{ -0.001193870642975304f, -0.004247469277548626f },
|
||||
{ 0.000304096484476364f, 0.000012725974706619f },
|
||||
{ 0.001143432997855281f, -0.003059520699490545f },
|
||||
{ 0.004342719678657102f, 0.003465264906764274f },
|
||||
{ -0.005203055300834089f, 0.003419861284250722f },
|
||||
{ -0.001408130728751936f, -0.005175554625981787f },
|
||||
{ 0.003390761989356700f, 0.000170321604912401f },
|
||||
{ -0.000335799601479825f, 0.000876091753216940f },
|
||||
{ 0.001064108471592452f, 0.000863770138941638f },
|
||||
{ -0.002543835202533552f, 0.001641705037372499f },
|
||||
{ -0.000956199555190250f, -0.003634225577771230f },
|
||||
{ 0.003537159230775563f, 0.000207350791625874f },
|
||||
{ -0.000945381510920265f, 0.002406055808135096f },
|
||||
{ -0.000942796972567245f, -0.000778470227412106f },
|
||||
{ -0.000142534831707354f, 0.000090307321579771f },
|
||||
{ -0.000312873903977856f, -0.001230889889574770f },
|
||||
{ 0.001878272869910274f, 0.000125879189667086f },
|
||||
{ -0.000729137747758382f, 0.001811046261815939f },
|
||||
{ -0.001192460562555906f, -0.001001510577200246f },
|
||||
{ 0.000734408386201156f, -0.000456742966201642f },
|
||||
{ 0.000018549463752019f, 0.000075619948809012f },
|
||||
{ 0.000616677332283103f, 0.000046513429902543f },
|
||||
{ -0.000417178588714767f, 0.001011686459999298f },
|
||||
{ -0.000983491651119600f, -0.000840133365053174f },
|
||||
{ 0.001049943574694380f, -0.000640863688898734f },
|
||||
{ 0.000223309865890363f, 0.000944433958755192f },
|
||||
{ -0.000604775098099200f, -0.000050706635726121f },
|
||||
{ 0.000089938060647144f, -0.000213032074676941f },
|
||||
{ -0.000064051192147576f, -0.000055648228186438f },
|
||||
{ 0.000257705918065856f, -0.000154354504676151f },
|
||||
{ 0.000090081630021839f, 0.000395731646002121f },
|
||||
{ -0.000414693079508517f, -0.000038265188132613f },
|
||||
{ 0.000143445458895461f, -0.000331994546004200f },
|
||||
{ 0.000205649042029008f, 0.000181710515677256f },
|
||||
{ -0.000157609487484145f, 0.000092618697641465f },
|
||||
{ -0.000022529111707761f, -0.000102942513429094f },
|
||||
{ 0.000050180791439308f, 0.000005054021864311f },
|
||||
{ -0.000007675039564594f, 0.000017362992335168f }
|
||||
};
|
||||
|
||||
#define CHROMA_BANDPASS_SIZE (sizeof(CHROMA_BANDPASS)/sizeof(dsp::complex_t))
|
||||
#define CHROMA_BANDPASS_DELAY (CHROMA_BANDPASS_SIZE/2)
|
@ -22,8 +22,16 @@
|
||||
|
||||
#define SYNC_LEVEL (-0.428)
|
||||
|
||||
#define COLORBURST_START 84
|
||||
#define COLORBURST_LEN 33
|
||||
|
||||
#define MAX_LOCK 1000
|
||||
|
||||
dsp::complex_t PHASE_REF[2] = {
|
||||
{ -0.707106781186547f, 0.707106781186547f },
|
||||
{ -0.707106781186547f, -0.707106781186547f }
|
||||
};
|
||||
|
||||
class LineSync : public dsp::Processor<float, float> {
|
||||
using base_type = dsp::Processor<float, float>;
|
||||
public:
|
||||
|
@ -16,15 +16,14 @@
|
||||
#include <dsp/filter/fir.h>
|
||||
#include <dsp/taps/from_array.h>
|
||||
|
||||
#include "chrominance_filter.h"
|
||||
|
||||
#include "chroma_pll.h"
|
||||
|
||||
#include "linesync_old.h"
|
||||
#include "amplitude.h"
|
||||
#include <dsp/demod/am.h>
|
||||
#include <dsp/loop/fast_agc.h>
|
||||
|
||||
#include "filters.h"
|
||||
#include <dsp/math/normalize_phase.h>
|
||||
#include <fstream>
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
SDRPP_MOD_INFO{/* Name: */ "atv_decoder",
|
||||
@ -51,6 +50,8 @@ class ATVDecoderModule : public ModuleManager::Instance {
|
||||
|
||||
r2c.init(NULL);
|
||||
|
||||
file = std::ofstream("chromasub_diff.bin", std::ios::binary | std::ios::out);
|
||||
|
||||
agc.start();
|
||||
demod.start();
|
||||
sync.start();
|
||||
@ -82,6 +83,8 @@ class ATVDecoderModule : public ModuleManager::Instance {
|
||||
|
||||
bool isEnabled() { return enabled; }
|
||||
|
||||
std::ofstream file;
|
||||
|
||||
private:
|
||||
static void menuHandler(void *ctx) {
|
||||
ATVDecoderModule *_this = (ATVDecoderModule *)ctx;
|
||||
@ -118,10 +121,17 @@ class ATVDecoderModule : public ModuleManager::Instance {
|
||||
style::endDisabled();
|
||||
}
|
||||
|
||||
if (ImGui::Button("Close Debug")) {
|
||||
_this->file.close();
|
||||
}
|
||||
|
||||
ImGui::Text("Gain: %f", _this->gain);
|
||||
ImGui::Text("Offset: %f", _this->offset);
|
||||
ImGui::Text("Subcarrier: %f", _this->subcarrierFreq);
|
||||
}
|
||||
|
||||
uint32_t pp = 0;
|
||||
|
||||
static void handler(float *data, int count, void *ctx) {
|
||||
ATVDecoderModule *_this = (ATVDecoderModule *)ctx;
|
||||
|
||||
@ -158,12 +168,69 @@ class ATVDecoderModule : public ModuleManager::Instance {
|
||||
// Save sync type to history
|
||||
_this->syncHistory = (_this->syncHistory << 2) | (longSync << 1) | shortSync;
|
||||
|
||||
// If the line has a colorburst, decode it
|
||||
dsp::complex_t* buf1 = _this->r2c.out.readBuf;
|
||||
dsp::complex_t* buf2 = _this->r2c.out.writeBuf;
|
||||
if (true) {
|
||||
// Convert the line into complex
|
||||
_this->r2c.process(count, data, buf1);
|
||||
|
||||
// Extract the chroma subcarrier (TODO: Optimise by running only where needed)
|
||||
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);
|
||||
}
|
||||
|
||||
// Down convert the chroma subcarrier (TODO: Optimise by running only where needed)
|
||||
lv_32fc_t startPhase = { 1.0f, 0.0f };
|
||||
lv_32fc_t phaseDelta = { sinf(_this->subcarrierFreq), cosf(_this->subcarrierFreq) };
|
||||
#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);
|
||||
#else
|
||||
volk_32fc_s32fc_x2_rotator_32fc((lv_32fc_t*)&buf2[COLORBURST_START], (lv_32fc_t*)&buf2[COLORBURST_START], phaseDelta, &startPhase, count - COLORBURST_START);
|
||||
#endif
|
||||
|
||||
// Compute the phase of the burst
|
||||
dsp::complex_t burstAvg = { 0.0f, 0.0f };
|
||||
volk_32fc_accumulator_s32fc((lv_32fc_t*)&burstAvg, (lv_32fc_t*)&buf2[COLORBURST_START], COLORBURST_LEN);
|
||||
float burstAmp = burstAvg.amplitude();
|
||||
if (burstAmp*(1.0f/(float)COLORBURST_LEN) < 0.02f) {
|
||||
printf("%d\n", _this->line);
|
||||
}
|
||||
burstAvg *= (1.0f / (burstAmp*burstAmp));
|
||||
burstAvg = burstAvg.conj();
|
||||
|
||||
// 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);
|
||||
|
||||
// Compute the frequency error of the burst
|
||||
float phase = buf2[COLORBURST_START].phase();
|
||||
float error = 0.0f;
|
||||
for (int i = COLORBURST_START+1; i < COLORBURST_START+COLORBURST_LEN; i++) {
|
||||
float cphase = buf2[i].phase();
|
||||
error += dsp::math::normalizePhase(cphase - phase);
|
||||
phase = cphase;
|
||||
}
|
||||
error *= (1.0f / (float)(COLORBURST_LEN-1));
|
||||
|
||||
// Update the subcarrier freq
|
||||
_this->subcarrierFreq += error*0.0001f;
|
||||
}
|
||||
|
||||
// Render the line if it's visible
|
||||
if (_this->ypos >= 34 && _this->ypos <= 34+576-1) {
|
||||
uint32_t* currentLine = &((uint32_t *)_this->img.buffer)[(_this->ypos - 34)*768];
|
||||
for (int i = 155; i < (155+768); i++) {
|
||||
int imval = std::clamp<float>(data[i] * 255.0f, 0, 255);
|
||||
currentLine[i-155] = 0xFF000000 | (imval << 16) | (imval << 8) | imval;
|
||||
if (_this->colorMode) {
|
||||
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 imval2 = std::clamp<float>(fabsf(buf2[i-155+COLORBURST_START].im*5.0f) * 255.0f, 0, 255);
|
||||
currentLine[i-155] = 0xFF000000 | (imval2 << 8) | imval1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i = 155; i < (155+768); i++) {
|
||||
int imval = std::clamp<float>(data[i-155+COLORBURST_START] * 255.0f, 0, 255);
|
||||
currentLine[i-155] = 0xFF000000 | (imval << 16) | (imval << 8) | imval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,6 +255,7 @@ class ATVDecoderModule : public ModuleManager::Instance {
|
||||
|
||||
// Start the odd field
|
||||
_this->ypos = 1;
|
||||
_this->line++;
|
||||
}
|
||||
else if (rollToEven || syncToEven) {
|
||||
// Update the vertical lock state
|
||||
@ -201,12 +269,14 @@ class ATVDecoderModule : public ModuleManager::Instance {
|
||||
|
||||
// Start the even field
|
||||
_this->ypos = 0;
|
||||
_this->line = 0;
|
||||
|
||||
// Swap the video buffer
|
||||
_this->img.swap();
|
||||
}
|
||||
else {
|
||||
_this->ypos += 2;
|
||||
_this->line++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,8 +284,10 @@ class ATVDecoderModule : public ModuleManager::Instance {
|
||||
float offset = 0.0f;
|
||||
float gain = 1.0f;
|
||||
uint16_t syncHistory = 0;
|
||||
int line = 0;
|
||||
int ypos = 0;
|
||||
int vlock = 0;
|
||||
float subcarrierFreq = 0.0f;
|
||||
|
||||
std::string name;
|
||||
bool enabled = true;
|
||||
|
Reference in New Issue
Block a user