mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-30 20:40:20 -04:00 
			
		
		
		
	DATV: various fixes and enhancements to ldpc_tool handling. Implements #804
This commit is contained in:
		
							parent
							
								
									233f512f9c
								
							
						
					
					
						commit
						d73f093dab
					
				| @ -54,7 +54,7 @@ DATVDemodSink::DATVDemodSink() : | |||||||
| { | { | ||||||
|     //*************** DATV PARAMETERS  ***************
 |     //*************** DATV PARAMETERS  ***************
 | ||||||
|     m_blnInitialized=false; |     m_blnInitialized=false; | ||||||
|     CleanUpDATVFramework(false); |     ResetDATVFrameworkPointers(); | ||||||
|     m_objVideoStream = new DATVideostream(); |     m_objVideoStream = new DATVideostream(); | ||||||
|     m_objRFFilter = new fftfilt(-256000.0 / 1024000.0, 256000.0 / 1024000.0, m_rfFilterFftLength); |     m_objRFFilter = new fftfilt(-256000.0 / 1024000.0, 256000.0 / 1024000.0, m_rfFilterFftLength); | ||||||
| } | } | ||||||
| @ -81,7 +81,7 @@ DATVDemodSink::~DATVDemodSink() | |||||||
|         m_objRenderThread->wait(2000); |         m_objRenderThread->wait(2000); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     CleanUpDATVFramework(true); |     CleanUpDATVFramework(); | ||||||
| 
 | 
 | ||||||
|     delete m_objRFFilter; |     delete m_objRFFilter; | ||||||
| } | } | ||||||
| @ -154,7 +154,6 @@ bool DATVDemodSink::videoDecodeOK() | |||||||
| 
 | 
 | ||||||
| bool DATVDemodSink::PlayVideo(bool blnStartStop) | bool DATVDemodSink::PlayVideo(bool blnStartStop) | ||||||
| { | { | ||||||
| 
 |  | ||||||
|     if (m_objVideoStream == nullptr) { |     if (m_objVideoStream == nullptr) { | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| @ -195,262 +194,248 @@ bool DATVDemodSink::PlayVideo(bool blnStartStop) | |||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void DATVDemodSink::CleanUpDATVFramework(bool blnRelease) | void DATVDemodSink::CleanUpDATVFramework() | ||||||
| { | { | ||||||
|     if (blnRelease == true) |     if (m_objScheduler != nullptr) | ||||||
|     { |     { | ||||||
|         if (m_objScheduler != nullptr) |         m_objScheduler->shutdown(); | ||||||
|         { |         delete m_objScheduler; | ||||||
|             m_objScheduler->shutdown(); |     } | ||||||
|             delete m_objScheduler; |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         // NOTCH FILTER
 |     // NOTCH FILTER
 | ||||||
| 
 | 
 | ||||||
|         if (r_auto_notch != nullptr) { |     if (r_auto_notch != nullptr) { | ||||||
|             delete r_auto_notch; |         delete r_auto_notch; | ||||||
|         } |     } | ||||||
|         if (p_autonotched != nullptr) { |     if (p_autonotched != nullptr) { | ||||||
|             delete p_autonotched; |         delete p_autonotched; | ||||||
|         } |     } | ||||||
| 
 | 
 | ||||||
|         // FREQUENCY CORRECTION : DEROTATOR
 |     // FREQUENCY CORRECTION : DEROTATOR
 | ||||||
|         if (p_derot != nullptr) { |     if (p_derot != nullptr) { | ||||||
|             delete p_derot; |         delete p_derot; | ||||||
|         } |     } | ||||||
|         if (r_derot != nullptr) { |     if (r_derot != nullptr) { | ||||||
|             delete r_derot; |         delete r_derot; | ||||||
|         } |     } | ||||||
| 
 | 
 | ||||||
|         // CNR ESTIMATION
 |     // CNR ESTIMATION
 | ||||||
|         if (p_cnr != nullptr) { |     if (p_cnr != nullptr) { | ||||||
|             delete p_cnr; |         delete p_cnr; | ||||||
|         } |     } | ||||||
|         if (r_cnr != nullptr) { |     if (r_cnr != nullptr) { | ||||||
|             delete r_cnr; |         delete r_cnr; | ||||||
|         } |     } | ||||||
|  |     if (r_cnrGauge != nullptr) { | ||||||
|  |         delete r_cnrGauge; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|         //FILTERING
 |     //FILTERING
 | ||||||
|         if (r_resample != nullptr) { |     if (r_resample != nullptr) { | ||||||
|             delete r_resample; |         delete r_resample; | ||||||
|         } |     } | ||||||
|         if (p_resampled != nullptr) { |     if (p_resampled != nullptr) { | ||||||
|             delete p_resampled; |         delete p_resampled; | ||||||
|         } |     } | ||||||
|         if (coeffs != nullptr) { |     if (coeffs != nullptr) { | ||||||
|             delete coeffs; |         delete coeffs; | ||||||
|         } |     } | ||||||
| 
 | 
 | ||||||
|         // OUTPUT PREPROCESSED DATA
 |     // OUTPUT PREPROCESSED DATA
 | ||||||
|         if (sampler != nullptr) { |     if (sampler != nullptr) { | ||||||
|             delete sampler; |         delete sampler; | ||||||
|         } |     } | ||||||
|         if (coeffs_sampler != nullptr) { |     if (coeffs_sampler != nullptr) { | ||||||
|             delete coeffs_sampler; |         delete coeffs_sampler; | ||||||
|         } |     } | ||||||
|         if (p_symbols != nullptr) { |     if (p_symbols != nullptr) { | ||||||
|             delete p_symbols; |         delete p_symbols; | ||||||
|         } |     } | ||||||
|         if (p_freq != nullptr) { |     if (p_freq != nullptr) { | ||||||
|             delete p_freq; |         delete p_freq; | ||||||
|         } |     } | ||||||
|         if (p_ss != nullptr) { |     if (p_ss != nullptr) { | ||||||
|             delete p_ss; |         delete p_ss; | ||||||
|         } |     } | ||||||
|         if (p_mer != nullptr) { |     if (p_mer != nullptr) { | ||||||
|             delete p_mer; |         delete p_mer; | ||||||
|         } |     } | ||||||
|         if (p_sampled != nullptr) { |     if (r_merGauge != nullptr) { | ||||||
|             delete p_sampled; |         delete r_merGauge; | ||||||
|         } |     } | ||||||
|  |     if (p_sampled != nullptr) { | ||||||
|  |         delete p_sampled; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|         //DECIMATION
 |     //DECIMATION
 | ||||||
|         if (p_decimated != nullptr) { |     if (p_decimated != nullptr) { | ||||||
|             delete p_decimated; |         delete p_decimated; | ||||||
|         } |     } | ||||||
|         if (p_decim != nullptr) { |     if (p_decim != nullptr) { | ||||||
|             delete p_decim; |         delete p_decim; | ||||||
|         } |     } | ||||||
|         if (r_ppout != nullptr) { |     if (r_ppout != nullptr) { | ||||||
|             delete r_ppout; |         delete r_ppout; | ||||||
|         } |     } | ||||||
| 
 | 
 | ||||||
|         //GENERIC CONSTELLATION RECEIVER
 |     //GENERIC CONSTELLATION RECEIVER
 | ||||||
|         if (m_objDemodulator != nullptr) { |     if (m_objDemodulator != nullptr) { | ||||||
|             delete m_objDemodulator; |         delete m_objDemodulator; | ||||||
|         } |     } | ||||||
| 
 | 
 | ||||||
|         //DECONVOLUTION AND SYNCHRONIZATION
 |     //DECONVOLUTION AND SYNCHRONIZATION
 | ||||||
|         if (p_bytes != nullptr) { |     if (p_bytes != nullptr) { | ||||||
|             delete p_bytes; |         delete p_bytes; | ||||||
|         } |     } | ||||||
|         if (r_deconv != nullptr) { |     if (r_deconv != nullptr) { | ||||||
|             delete r_deconv; |         delete r_deconv; | ||||||
|         } |     } | ||||||
|         if (r != nullptr) { |     if (r != nullptr) { | ||||||
|             delete r; |         delete r; | ||||||
|         } |     } | ||||||
|         if (p_descrambled != nullptr) { |     if (p_descrambled != nullptr) { | ||||||
|             delete p_descrambled; |         delete p_descrambled; | ||||||
|         } |     } | ||||||
|         if (p_frames != nullptr) { |     if (p_frames != nullptr) { | ||||||
|             delete p_frames; |         delete p_frames; | ||||||
|         } |     } | ||||||
|         if (r_etr192_descrambler != nullptr) { |     if (r_etr192_descrambler != nullptr) { | ||||||
|             delete r_etr192_descrambler; |         delete r_etr192_descrambler; | ||||||
|         } |     } | ||||||
|         if (r_sync != nullptr) { |     if (r_sync != nullptr) { | ||||||
|             delete r_sync; |         delete r_sync; | ||||||
|         } |     } | ||||||
|         if (p_mpegbytes != nullptr) { |     if (p_mpegbytes != nullptr) { | ||||||
|             delete p_mpegbytes; |         delete p_mpegbytes; | ||||||
|         } |     } | ||||||
|         if (p_lock != nullptr) { |     if (p_lock != nullptr) { | ||||||
|             delete p_lock; |         delete p_lock; | ||||||
|         } |     } | ||||||
|         if (p_locktime != nullptr) { |     if (p_locktime != nullptr) { | ||||||
|             delete p_locktime; |         delete p_locktime; | ||||||
|         } |     } | ||||||
|         if (r_sync_mpeg != nullptr) { |     if (r_sync_mpeg != nullptr) { | ||||||
|             delete r_sync_mpeg; |         delete r_sync_mpeg; | ||||||
|         } |     } | ||||||
| 
 | 
 | ||||||
|         // DEINTERLEAVING
 |     // DEINTERLEAVING
 | ||||||
|         if (p_rspackets != nullptr) { |     if (p_rspackets != nullptr) { | ||||||
|             delete p_rspackets; |         delete p_rspackets; | ||||||
|         } |     } | ||||||
|         if (r_deinter != nullptr) { |     if (r_deinter != nullptr) { | ||||||
|             delete r_deinter; |         delete r_deinter; | ||||||
|         } |     } | ||||||
|         if (p_vbitcount != nullptr) { |     if (p_vbitcount != nullptr) { | ||||||
|             delete p_vbitcount; |         delete p_vbitcount; | ||||||
|         } |     } | ||||||
|         if (p_verrcount != nullptr) { |     if (p_verrcount != nullptr) { | ||||||
|             delete p_verrcount; |         delete p_verrcount; | ||||||
|         } |     } | ||||||
|         if (p_rtspackets != nullptr) { |     if (p_rtspackets != nullptr) { | ||||||
|             delete p_rtspackets; |         delete p_rtspackets; | ||||||
|         } |     } | ||||||
|         if (r_rsdec != nullptr) { |     if (r_rsdec != nullptr) { | ||||||
|             delete r_rsdec; |         delete r_rsdec; | ||||||
|         } |     } | ||||||
| 
 | 
 | ||||||
|         //BER ESTIMATION
 |     //BER ESTIMATION
 | ||||||
|         if (p_vber != nullptr) { |     if (p_vber != nullptr) { | ||||||
|             delete p_vber; |         delete p_vber; | ||||||
|         } |     } | ||||||
|         if (r_vber != nullptr) { |     if (r_vber != nullptr) { | ||||||
|             delete r_vber; |         delete r_vber; | ||||||
|         } |     } | ||||||
| 
 | 
 | ||||||
|         // DERANDOMIZATION
 |     // DERANDOMIZATION
 | ||||||
|         if (p_tspackets != nullptr) { |     if (p_tspackets != nullptr) { | ||||||
|             delete p_tspackets; |         delete p_tspackets; | ||||||
|         } |     } | ||||||
|         if (r_derand != nullptr) { |     if (r_derand != nullptr) { | ||||||
|             delete r_derand; |         delete r_derand; | ||||||
|         } |     } | ||||||
| 
 | 
 | ||||||
|         //OUTPUT : To remove
 |     //OUTPUT
 | ||||||
|         if (r_stdout != nullptr) { |     if (r_videoplayer != nullptr) { | ||||||
|             delete r_stdout; |         delete r_videoplayer; | ||||||
|         } |     } | ||||||
|         if (r_videoplayer != nullptr) { |  | ||||||
|             delete r_videoplayer; |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         //CONSTELLATION
 |     //CONSTELLATION
 | ||||||
|         if (r_scope_symbols != nullptr) { |     if (r_scope_symbols != nullptr) { | ||||||
|             delete r_scope_symbols; |         delete r_scope_symbols; | ||||||
|         } |     } | ||||||
|         if (r_merGauge != nullptr) { |  | ||||||
|             delete r_merGauge; |  | ||||||
|         } |  | ||||||
|         if (r_cnrGauge != nullptr) { |  | ||||||
|             delete r_cnrGauge; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         // INPUT
 |  | ||||||
|         if (p_rawiq != nullptr) { |  | ||||||
|             delete p_rawiq; |  | ||||||
|         } |  | ||||||
|         if (p_rawiq_writer != nullptr) { |  | ||||||
|             delete p_rawiq_writer; |  | ||||||
|         } |  | ||||||
|         //if(p_preprocessed!=nullptr) delete p_preprocessed;
 |  | ||||||
| 
 |  | ||||||
|         //DVB-S2
 |  | ||||||
| 
 |  | ||||||
|         if(p_slots_dvbs2  != nullptr) |  | ||||||
|         { |  | ||||||
|             delete (leansdr::pipebuf< leansdr::plslot<leansdr::llr_ss> >*) p_slots_dvbs2; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if(p_cstln  != nullptr) |  | ||||||
|         { |  | ||||||
|             delete p_cstln; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if(p_cstln_pls != nullptr) |  | ||||||
|         { |  | ||||||
|             delete p_cstln_pls; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if(p_framelock != nullptr) |  | ||||||
|         { |  | ||||||
|             delete p_framelock; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if(m_objDemodulatorDVBS2 != nullptr) |  | ||||||
|         { |  | ||||||
|             delete (leansdr::s2_frame_receiver<leansdr::f32, leansdr::llr_ss>*) m_objDemodulatorDVBS2; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if(p_fecframes != nullptr) |  | ||||||
|         { |  | ||||||
|             delete (leansdr::pipebuf< leansdr::fecframe<leansdr::hard_sb> >*) p_fecframes; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if(p_bbframes != nullptr) |  | ||||||
|         { |  | ||||||
|             delete (leansdr::pipebuf<leansdr::bbframe>*) p_bbframes; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if(p_s2_deinterleaver != nullptr) |  | ||||||
|         { |  | ||||||
|             delete (leansdr::s2_deinterleaver<leansdr::llr_ss,leansdr::hard_sb>*) p_s2_deinterleaver; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if(r_fecdec != nullptr) |  | ||||||
|         { |  | ||||||
|             delete (leansdr::s2_fecdec<bool, leansdr::hard_sb>*) r_fecdec; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
| #ifdef LINUX |  | ||||||
|         if(r_fecdecsoft != nullptr) |  | ||||||
|         { |  | ||||||
|             delete (leansdr::s2_fecdec_soft<leansdr::llr_t,leansdr::llr_sb>*) r_fecdecsoft; |  | ||||||
|         } |  | ||||||
|         if(r_fecdechelper != nullptr) |  | ||||||
|         { |  | ||||||
|             delete (leansdr::s2_fecdec_helper<leansdr::llr_t,leansdr::llr_sb>*) r_fecdechelper; |  | ||||||
|         } |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
|         if(p_deframer != nullptr) |  | ||||||
|         { |  | ||||||
|             delete (leansdr::s2_deframer*) p_deframer; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if(r_scope_symbols_dvbs2 != nullptr) |  | ||||||
|         { |  | ||||||
|             delete r_scope_symbols_dvbs2; |  | ||||||
|         } |  | ||||||
|     } // blnRelease
 |  | ||||||
| 
 |  | ||||||
|     m_objScheduler=nullptr; |  | ||||||
| 
 | 
 | ||||||
|     // INPUT
 |     // INPUT
 | ||||||
|  |     if (p_rawiq != nullptr) { | ||||||
|  |         delete p_rawiq; | ||||||
|  |     } | ||||||
|  |     if (p_rawiq_writer != nullptr) { | ||||||
|  |         delete p_rawiq_writer; | ||||||
|  |     } | ||||||
|  |     //if(p_preprocessed!=nullptr) delete p_preprocessed;
 | ||||||
|  | 
 | ||||||
|  |     //DVB-S2
 | ||||||
|  | 
 | ||||||
|  |     if (p_slots_dvbs2  != nullptr) { | ||||||
|  |         delete (leansdr::pipebuf< leansdr::plslot<leansdr::llr_ss> >*) p_slots_dvbs2; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (p_cstln  != nullptr) { | ||||||
|  |         delete p_cstln; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (p_cstln_pls != nullptr) { | ||||||
|  |         delete p_cstln_pls; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (p_framelock != nullptr) { | ||||||
|  |         delete p_framelock; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (m_objDemodulatorDVBS2 != nullptr) { | ||||||
|  |         delete (leansdr::s2_frame_receiver<leansdr::f32, leansdr::llr_ss>*) m_objDemodulatorDVBS2; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (p_fecframes != nullptr) { | ||||||
|  |         delete (leansdr::pipebuf< leansdr::fecframe<leansdr::hard_sb> >*) p_fecframes; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (p_bbframes != nullptr) { | ||||||
|  |         delete (leansdr::pipebuf<leansdr::bbframe>*) p_bbframes; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (p_s2_deinterleaver != nullptr) { | ||||||
|  |         delete (leansdr::s2_deinterleaver<leansdr::llr_ss,leansdr::hard_sb>*) p_s2_deinterleaver; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (r_fecdec != nullptr) { | ||||||
|  |         delete (leansdr::s2_fecdec<bool, leansdr::hard_sb>*) r_fecdec; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | #ifdef LINUX | ||||||
|  |     if (r_fecdecsoft != nullptr) { | ||||||
|  |         delete (leansdr::s2_fecdec_soft<leansdr::llr_t,leansdr::llr_sb>*) r_fecdecsoft; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (r_fecdechelper != nullptr) { | ||||||
|  |         delete (leansdr::s2_fecdec_helper<leansdr::llr_t,leansdr::llr_sb>*) r_fecdechelper; | ||||||
|  |     } | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  |     if (p_deframer != nullptr) { | ||||||
|  |         delete (leansdr::s2_deframer*) p_deframer; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (r_scope_symbols_dvbs2 != nullptr) { | ||||||
|  |         delete r_scope_symbols_dvbs2; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     ResetDATVFrameworkPointers(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void DATVDemodSink::ResetDATVFrameworkPointers() | ||||||
|  | { | ||||||
|  |     // INPUT
 | ||||||
|  |     m_objScheduler = nullptr; | ||||||
| 
 | 
 | ||||||
|     p_rawiq = nullptr; |     p_rawiq = nullptr; | ||||||
|     p_rawiq_writer = nullptr; |     p_rawiq_writer = nullptr; | ||||||
| @ -468,6 +453,7 @@ void DATVDemodSink::CleanUpDATVFramework(bool blnRelease) | |||||||
|     // CNR ESTIMATION
 |     // CNR ESTIMATION
 | ||||||
|     p_cnr = nullptr; |     p_cnr = nullptr; | ||||||
|     r_cnr = nullptr; |     r_cnr = nullptr; | ||||||
|  |     r_cnrGauge = nullptr; | ||||||
| 
 | 
 | ||||||
|     //FILTERING
 |     //FILTERING
 | ||||||
|     r_resample = nullptr; |     r_resample = nullptr; | ||||||
| @ -484,6 +470,7 @@ void DATVDemodSink::CleanUpDATVFramework(bool blnRelease) | |||||||
|     p_freq = nullptr; |     p_freq = nullptr; | ||||||
|     p_ss = nullptr; |     p_ss = nullptr; | ||||||
|     p_mer = nullptr; |     p_mer = nullptr; | ||||||
|  |     r_merGauge = nullptr; | ||||||
|     p_sampled = nullptr; |     p_sampled = nullptr; | ||||||
| 
 | 
 | ||||||
|     //DECIMATION
 |     //DECIMATION
 | ||||||
| @ -509,7 +496,6 @@ void DATVDemodSink::CleanUpDATVFramework(bool blnRelease) | |||||||
|     p_locktime = nullptr; |     p_locktime = nullptr; | ||||||
|     r_sync_mpeg = nullptr; |     r_sync_mpeg = nullptr; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     // DEINTERLEAVING
 |     // DEINTERLEAVING
 | ||||||
|     p_rspackets = nullptr; |     p_rspackets = nullptr; | ||||||
|     r_deinter = nullptr; |     r_deinter = nullptr; | ||||||
| @ -519,26 +505,19 @@ void DATVDemodSink::CleanUpDATVFramework(bool blnRelease) | |||||||
|     p_rtspackets = nullptr; |     p_rtspackets = nullptr; | ||||||
|     r_rsdec = nullptr; |     r_rsdec = nullptr; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     //BER ESTIMATION
 |     //BER ESTIMATION
 | ||||||
|     p_vber = nullptr; |     p_vber = nullptr; | ||||||
|     r_vber  = nullptr; |     r_vber  = nullptr; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     // DERANDOMIZATION
 |     // DERANDOMIZATION
 | ||||||
|     p_tspackets = nullptr; |     p_tspackets = nullptr; | ||||||
|     r_derand = nullptr; |     r_derand = nullptr; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     //OUTPUT : To remove void *
 |     //OUTPUT : To remove void *
 | ||||||
|     r_stdout = nullptr; |  | ||||||
|     r_videoplayer = nullptr; |     r_videoplayer = nullptr; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     //CONSTELLATION
 |     //CONSTELLATION
 | ||||||
|     r_scope_symbols = nullptr; |     r_scope_symbols = nullptr; | ||||||
|     r_merGauge = nullptr; |  | ||||||
|     r_cnrGauge = nullptr; |  | ||||||
| 
 | 
 | ||||||
|     //DVB-S2
 |     //DVB-S2
 | ||||||
|     p_slots_dvbs2 = nullptr; |     p_slots_dvbs2 = nullptr; | ||||||
| @ -550,8 +529,10 @@ void DATVDemodSink::CleanUpDATVFramework(bool blnRelease) | |||||||
|     p_bbframes = nullptr; |     p_bbframes = nullptr; | ||||||
|     p_s2_deinterleaver = nullptr; |     p_s2_deinterleaver = nullptr; | ||||||
|     r_fecdec = nullptr; |     r_fecdec = nullptr; | ||||||
|  | #ifdef LINUX | ||||||
|     r_fecdecsoft = nullptr; |     r_fecdecsoft = nullptr; | ||||||
|     r_fecdechelper = nullptr; |     r_fecdechelper = nullptr; | ||||||
|  | #endif | ||||||
|     p_deframer = nullptr; |     p_deframer = nullptr; | ||||||
|     r_scope_symbols_dvbs2 = nullptr; |     r_scope_symbols_dvbs2 = nullptr; | ||||||
| } | } | ||||||
| @ -560,7 +541,7 @@ void DATVDemodSink::InitDATVFramework() | |||||||
| { | { | ||||||
|     m_blnDVBInitialized = false; |     m_blnDVBInitialized = false; | ||||||
|     m_lngReadIQ = 0; |     m_lngReadIQ = 0; | ||||||
|     CleanUpDATVFramework(false); |     CleanUpDATVFramework(); | ||||||
| 
 | 
 | ||||||
|     qDebug()  << "DATVDemodSink::InitDATVFramework:" |     qDebug()  << "DATVDemodSink::InitDATVFramework:" | ||||||
|         <<  " Standard: " << m_settings.m_standard |         <<  " Standard: " << m_settings.m_standard | ||||||
| @ -675,7 +656,6 @@ void DATVDemodSink::InitDATVFramework() | |||||||
|         p_preprocessed = p_autonotched; |         p_preprocessed = p_autonotched; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     // FREQUENCY CORRECTION
 |     // FREQUENCY CORRECTION
 | ||||||
| 
 | 
 | ||||||
|     //******** -> if ( m_objCfg.Fderot>0 )
 |     //******** -> if ( m_objCfg.Fderot>0 )
 | ||||||
| @ -696,7 +676,6 @@ void DATVDemodSink::InitDATVFramework() | |||||||
| 
 | 
 | ||||||
|     //******** -> if ( m_objCfg.resample )
 |     //******** -> if ( m_objCfg.resample )
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     // DECIMATION
 |     // DECIMATION
 | ||||||
|     // (Unless already done in resampler)
 |     // (Unless already done in resampler)
 | ||||||
| 
 | 
 | ||||||
| @ -704,7 +683,6 @@ void DATVDemodSink::InitDATVFramework() | |||||||
| 
 | 
 | ||||||
|     //Resampling FS
 |     //Resampling FS
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     // Generic constellation receiver
 |     // Generic constellation receiver
 | ||||||
| 
 | 
 | ||||||
|     p_symbols = new leansdr::pipebuf<leansdr::eucl_ss>(m_objScheduler, "PSK soft-symbols", BUF_SYMBOLS); |     p_symbols = new leansdr::pipebuf<leansdr::eucl_ss>(m_objScheduler, "PSK soft-symbols", BUF_SYMBOLS); | ||||||
| @ -898,7 +876,7 @@ void DATVDemodSink::InitDATVS2Framework() | |||||||
| 
 | 
 | ||||||
|     m_blnDVBInitialized = false; |     m_blnDVBInitialized = false; | ||||||
|     m_lngReadIQ = 0; |     m_lngReadIQ = 0; | ||||||
|     CleanUpDATVFramework(true); |     CleanUpDATVFramework(); | ||||||
| 
 | 
 | ||||||
|     qDebug()  << "DATVDemodSink::InitDATVS2Framework:" |     qDebug()  << "DATVDemodSink::InitDATVS2Framework:" | ||||||
|         <<  " Standard: " << m_settings.m_standard |         <<  " Standard: " << m_settings.m_standard | ||||||
| @ -1026,7 +1004,6 @@ void DATVDemodSink::InitDATVS2Framework() | |||||||
| 
 | 
 | ||||||
|     //******** -> if ( m_objCfg.resample )
 |     //******** -> if ( m_objCfg.resample )
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     // DECIMATION
 |     // DECIMATION
 | ||||||
|     // (Unless already done in resampler)
 |     // (Unless already done in resampler)
 | ||||||
| 
 | 
 | ||||||
| @ -1034,7 +1011,6 @@ void DATVDemodSink::InitDATVS2Framework() | |||||||
| 
 | 
 | ||||||
|     //Resampling FS
 |     //Resampling FS
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     // Generic constellation receiver
 |     // Generic constellation receiver
 | ||||||
| 
 | 
 | ||||||
|     p_freq = new leansdr::pipebuf<leansdr::f32> (m_objScheduler, "freq", BUF_SLOW); |     p_freq = new leansdr::pipebuf<leansdr::f32> (m_objScheduler, "freq", BUF_SLOW); | ||||||
| @ -1076,24 +1052,22 @@ void DATVDemodSink::InitDATVS2Framework() | |||||||
|     p_framelock = new leansdr::pipebuf<int>(m_objScheduler, "frame lock", BUF_SLOW); |     p_framelock = new leansdr::pipebuf<int>(m_objScheduler, "frame lock", BUF_SLOW); | ||||||
| 
 | 
 | ||||||
|     m_objDemodulatorDVBS2 = new leansdr::s2_frame_receiver<leansdr::f32, leansdr::llr_ss>( |     m_objDemodulatorDVBS2 = new leansdr::s2_frame_receiver<leansdr::f32, leansdr::llr_ss>( | ||||||
|                         m_objScheduler, |         m_objScheduler, | ||||||
|                         sampler, |         sampler, | ||||||
|                         *p_preprocessed, |         *p_preprocessed, | ||||||
|                         *(leansdr::pipebuf< leansdr::plslot<leansdr::llr_ss> > *) p_slots_dvbs2, |         *(leansdr::pipebuf< leansdr::plslot<leansdr::llr_ss> > *) p_slots_dvbs2, | ||||||
|                         /* p_freq */ nullptr, |         /* p_freq */ nullptr, | ||||||
|                         /* p_ss */ nullptr, |         /* p_ss */ nullptr, | ||||||
|                         p_mer, |         p_mer, | ||||||
|                         p_cstln, |         p_cstln, | ||||||
|                         /* p_cstln_pls */ nullptr, |         /* p_cstln_pls */ nullptr, | ||||||
|                         /*p_iqsymbols*/ nullptr, |         /*p_iqsymbols*/ nullptr, | ||||||
|                         /* p_framelock */nullptr); |         /* p_framelock */nullptr | ||||||
|  |     ); | ||||||
| 
 | 
 | ||||||
|     objDemodulatorDVBS2 = (leansdr::s2_frame_receiver<leansdr::f32, leansdr::llr_ss> *) m_objDemodulatorDVBS2; |     objDemodulatorDVBS2 = (leansdr::s2_frame_receiver<leansdr::f32, leansdr::llr_ss> *) m_objDemodulatorDVBS2; | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     objDemodulatorDVBS2->omega0 = m_objCfg.Fs/m_objCfg.Fm; |     objDemodulatorDVBS2->omega0 = m_objCfg.Fs/m_objCfg.Fm; | ||||||
| //objDemodulatorDVBS2->mu=1;
 |     //objDemodulatorDVBS2->mu=1;
 | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
|     m_objCfg.Ftune=0.0f; |     m_objCfg.Ftune=0.0f; | ||||||
|     objDemodulatorDVBS2->Ftune = m_objCfg.Ftune / m_objCfg.Fm; |     objDemodulatorDVBS2->Ftune = m_objCfg.Ftune / m_objCfg.Fm; | ||||||
| @ -1102,12 +1076,8 @@ void DATVDemodSink::InitDATVS2Framework() | |||||||
|   demod.strongpls = cfg.strongpls; |   demod.strongpls = cfg.strongpls; | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
|     //objDemodulatorDVBS2->Fm = m_objCfg.Fm; deprecated
 |  | ||||||
|     objDemodulatorDVBS2->meas_decimation = decimation(m_objCfg.Fs, m_objCfg.Finfo); |     objDemodulatorDVBS2->meas_decimation = decimation(m_objCfg.Fs, m_objCfg.Finfo); | ||||||
| 
 |  | ||||||
|     objDemodulatorDVBS2->strongpls = false; |     objDemodulatorDVBS2->strongpls = false; | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     objDemodulatorDVBS2->cstln = make_dvbs2_constellation(m_objCfg.constellation, m_objCfg.fec); |     objDemodulatorDVBS2->cstln = make_dvbs2_constellation(m_objCfg.constellation, m_objCfg.fec); | ||||||
|     m_cstlnSetByModcod = false; |     m_cstlnSetByModcod = false; | ||||||
| 
 | 
 | ||||||
| @ -1116,7 +1086,6 @@ void DATVDemodSink::InitDATVS2Framework() | |||||||
|     if (m_objRegisteredTVScreen) |     if (m_objRegisteredTVScreen) | ||||||
|     { |     { | ||||||
|         qDebug("DATVDemodSink::InitDATVS2Framework: Register DVBS 2 TVSCREEN"); |         qDebug("DATVDemodSink::InitDATVS2Framework: Register DVBS 2 TVSCREEN"); | ||||||
| 
 |  | ||||||
|         m_objRegisteredTVScreen->resizeTVScreen(256,256); |         m_objRegisteredTVScreen->resizeTVScreen(256,256); | ||||||
|         r_scope_symbols_dvbs2 = new leansdr::datvdvbs2constellation<leansdr::f32>(m_objScheduler, *p_cstln /* *p_sampled */ /* *p_cstln */, -128,128, nullptr, m_objRegisteredTVScreen); |         r_scope_symbols_dvbs2 = new leansdr::datvdvbs2constellation<leansdr::f32>(m_objScheduler, *p_cstln /* *p_sampled */ /* *p_cstln */, -128,128, nullptr, m_objRegisteredTVScreen); | ||||||
|         r_scope_symbols_dvbs2->decimation = 1; |         r_scope_symbols_dvbs2->decimation = 1; | ||||||
| @ -1249,13 +1218,11 @@ void DATVDemodSink::InitDATVS2Framework() | |||||||
|     p_lock = new leansdr::pipebuf<int> (m_objScheduler, "lock", BUF_SLOW); |     p_lock = new leansdr::pipebuf<int> (m_objScheduler, "lock", BUF_SLOW); | ||||||
|     p_locktime = new leansdr::pipebuf<leansdr::u32> (m_objScheduler, "locktime", BUF_S2PACKETS); |     p_locktime = new leansdr::pipebuf<leansdr::u32> (m_objScheduler, "locktime", BUF_S2PACKETS); | ||||||
|     p_tspackets = new leansdr::pipebuf<leansdr::tspacket>(m_objScheduler, "TS packets", BUF_S2PACKETS); |     p_tspackets = new leansdr::pipebuf<leansdr::tspacket>(m_objScheduler, "TS packets", BUF_S2PACKETS); | ||||||
| 
 |  | ||||||
|     p_deframer = new leansdr::s2_deframer(m_objScheduler,*(leansdr::pipebuf<leansdr::bbframe> *) p_bbframes, *p_tspackets, p_lock, p_locktime); |     p_deframer = new leansdr::s2_deframer(m_objScheduler,*(leansdr::pipebuf<leansdr::bbframe> *) p_bbframes, *p_tspackets, p_lock, p_locktime); | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  if ( cfg.fd_gse >= 0 ) deframer.fd_gse = cfg.fd_gse; |  if ( cfg.fd_gse >= 0 ) deframer.fd_gse = cfg.fd_gse; | ||||||
| */ | */ | ||||||
|     //**********************************************
 |  | ||||||
| 
 | 
 | ||||||
|     // OUTPUT
 |     // OUTPUT
 | ||||||
|     r_videoplayer = new leansdr::datvvideoplayer<leansdr::tspacket>(m_objScheduler, *p_tspackets, m_objVideoStream, &m_udpStream); |     r_videoplayer = new leansdr::datvvideoplayer<leansdr::tspacket>(m_objScheduler, *p_tspackets, m_objVideoStream, &m_udpStream); | ||||||
| @ -1268,7 +1235,6 @@ void DATVDemodSink::feed(const SampleVector::const_iterator& begin, const Sample | |||||||
|     float fltI; |     float fltI; | ||||||
|     float fltQ; |     float fltQ; | ||||||
|     leansdr::cf32 objIQ; |     leansdr::cf32 objIQ; | ||||||
|     //Complex objC;
 |  | ||||||
|     fftfilt::cmplx *objRF; |     fftfilt::cmplx *objRF; | ||||||
|     int intRFOut; |     int intRFOut; | ||||||
|     double magSq; |     double magSq; | ||||||
| @ -1276,7 +1242,6 @@ void DATVDemodSink::feed(const SampleVector::const_iterator& begin, const Sample | |||||||
|     int lngWritable=0; |     int lngWritable=0; | ||||||
| 
 | 
 | ||||||
|     //********** Bis repetita : Let's rock and roll buddy ! **********
 |     //********** Bis repetita : Let's rock and roll buddy ! **********
 | ||||||
| 
 |  | ||||||
| #ifdef EXTENDED_DIRECT_SAMPLE | #ifdef EXTENDED_DIRECT_SAMPLE | ||||||
| 
 | 
 | ||||||
|     qint16 * ptrBuffer; |     qint16 * ptrBuffer; | ||||||
| @ -1306,10 +1271,7 @@ void DATVDemodSink::feed(const SampleVector::const_iterator& begin, const Sample | |||||||
|         fltQ = it->imag(); |         fltQ = it->imag(); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|         //********** demodulation **********
 |         //********** demodulation **********
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|         if (m_blnNeedConfigUpdate) |         if (m_blnNeedConfigUpdate) | ||||||
|         { |         { | ||||||
|             qDebug("DATVDemodSink::feed: Settings applied. Standard : %d...", m_settings.m_standard); |             qDebug("DATVDemodSink::feed: Settings applied. Standard : %d...", m_settings.m_standard); | ||||||
| @ -1327,13 +1289,9 @@ void DATVDemodSink::feed(const SampleVector::const_iterator& begin, const Sample | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|         //********** iq stream ****************
 |         //********** iq stream ****************
 | ||||||
| 
 |  | ||||||
|         Complex objC(fltI,fltQ); |         Complex objC(fltI,fltQ); | ||||||
| 
 |  | ||||||
|         objC *= m_objNCO.nextIQ(); |         objC *= m_objNCO.nextIQ(); | ||||||
| 
 |  | ||||||
|         intRFOut = m_objRFFilter->runFilt(objC, &objRF); // filter RF before demod
 |         intRFOut = m_objRFFilter->runFilt(objC, &objRF); // filter RF before demod
 | ||||||
| 
 | 
 | ||||||
|         for (int intI = 0 ; intI < intRFOut; intI++) |         for (int intI = 0 ; intI < intRFOut; intI++) | ||||||
|  | |||||||
| @ -142,7 +142,8 @@ private: | |||||||
| 
 | 
 | ||||||
|     inline int decimation(float Fin, float Fout) { int d = Fin / Fout; return std::max(d, 1); } |     inline int decimation(float Fin, float Fout) { int d = Fin / Fout; return std::max(d, 1); } | ||||||
| 
 | 
 | ||||||
|     void CleanUpDATVFramework(bool blnRelease); |     void CleanUpDATVFramework(); | ||||||
|  |     void ResetDATVFrameworkPointers(); | ||||||
|     void InitDATVFramework(); |     void InitDATVFramework(); | ||||||
|     void InitDATVS2Framework(); |     void InitDATVS2Framework(); | ||||||
| 
 | 
 | ||||||
| @ -274,7 +275,6 @@ private: | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     //OUTPUT
 |     //OUTPUT
 | ||||||
|     leansdr::file_writer<leansdr::tspacket> *r_stdout; |  | ||||||
|     leansdr::datvvideoplayer<leansdr::tspacket> *r_videoplayer; |     leansdr::datvvideoplayer<leansdr::tspacket> *r_videoplayer; | ||||||
| 
 | 
 | ||||||
|     //CONSTELLATION
 |     //CONSTELLATION
 | ||||||
|  | |||||||
| @ -123,12 +123,12 @@ template<typename T> struct datvdvbs2constellation: runnable | |||||||
|     std::vector<int> cstln_cols; |     std::vector<int> cstln_cols; | ||||||
| 
 | 
 | ||||||
|     datvdvbs2constellation( |     datvdvbs2constellation( | ||||||
|             scheduler *sch, |         scheduler *sch, | ||||||
|             pipebuf<complex<T> > &_in, |         pipebuf<complex<T> > &_in, | ||||||
|             T _xymin, |         T _xymin, | ||||||
|             T _xymax, |         T _xymax, | ||||||
|             const char *_name = nullptr, |         const char *_name = nullptr, | ||||||
|             TVScreen *objDATVScreen = nullptr) : |         TVScreen *objDATVScreen = nullptr) : | ||||||
|         runnable(sch, _name ? _name : _in.name), |         runnable(sch, _name ? _name : _in.name), | ||||||
|         xymin(_xymin), |         xymin(_xymin), | ||||||
|         xymax(_xymax), |         xymax(_xymax), | ||||||
|  | |||||||
| @ -255,7 +255,7 @@ bool DATVideoRender::PreprocessStream() | |||||||
|     MetaData.Program = ""; |     MetaData.Program = ""; | ||||||
|     MetaData.Stream = ""; |     MetaData.Stream = ""; | ||||||
| 
 | 
 | ||||||
|     if (m_formatCtx->programs) |     if (m_formatCtx->programs && m_formatCtx->programs[m_videoStreamIndex]) | ||||||
|     { |     { | ||||||
|         buffer = nullptr; |         buffer = nullptr; | ||||||
|         av_dict_get_string(m_formatCtx->programs[m_videoStreamIndex]->metadata, &buffer, ':', '\n'); |         av_dict_get_string(m_formatCtx->programs[m_videoStreamIndex]->metadata, &buffer, ':', '\n'); | ||||||
|  | |||||||
| @ -29,10 +29,10 @@ namespace leansdr | |||||||
| template<typename T> struct datvvideoplayer: runnable | template<typename T> struct datvvideoplayer: runnable | ||||||
| { | { | ||||||
|     datvvideoplayer( |     datvvideoplayer( | ||||||
|             scheduler *sch, |         scheduler *sch, | ||||||
|             pipebuf<T> &_in, |         pipebuf<T> &_in, | ||||||
|             DATVideostream *objVideoStream, |         DATVideostream *objVideoStream, | ||||||
|             DATVUDPStream *udpStream) : |         DATVUDPStream *udpStream) : | ||||||
|         runnable(sch, _in.name), |         runnable(sch, _in.name), | ||||||
|         in(_in), |         in(_in), | ||||||
|         m_objVideoStream(objVideoStream), |         m_objVideoStream(objVideoStream), | ||||||
|  | |||||||
| @ -181,8 +181,8 @@ int main(int argc, char **argv) | |||||||
| 
 | 
 | ||||||
| 			if (num_decodes == 20) | 			if (num_decodes == 20) | ||||||
| 			{ | 			{ | ||||||
| 				fprintf(stderr, "ldpc_tool: trials: %d%% max: %d%% at converging to a code word\n", | 				fprintf(stderr, "ldpc_tool: trials: %d%% max: %d%% at converging to a code word (max trials: %d)\n", | ||||||
| 					(trials_count*100)/(num_decodes*max_trials), (max_count*100)/num_decodes); | 					(trials_count*100)/(num_decodes*max_trials), (max_count*100)/num_decodes, max_trials); | ||||||
| 				trials_count = 0; | 				trials_count = 0; | ||||||
| 				max_count = 0; | 				max_count = 0; | ||||||
| 				num_decodes = 0; | 				num_decodes = 0; | ||||||
|  | |||||||
| @ -111,17 +111,20 @@ static const int DVBS_G2 = 0133; | |||||||
| template <typename Tbyte, Tbyte BYTE_ERASED> | template <typename Tbyte, Tbyte BYTE_ERASED> | ||||||
| struct deconvol_sync : runnable | struct deconvol_sync : runnable | ||||||
| { | { | ||||||
|     deconvol_sync(scheduler *sch, |     deconvol_sync( | ||||||
|                   pipebuf<eucl_ss> &_in, |         scheduler *sch, | ||||||
|                   pipebuf<Tbyte> &_out, |         pipebuf<eucl_ss> &_in, | ||||||
|                   uint32_t gX, |         pipebuf<Tbyte> &_out, | ||||||
|                   uint32_t gY, |         uint32_t gX, | ||||||
|                   uint32_t pX, |         uint32_t gY, | ||||||
|                   uint32_t pY) : runnable(sch, "deconvol_sync"), |         uint32_t pX, | ||||||
|                                  fastlock(false), |         uint32_t pY | ||||||
|                                  in(_in), |     ) : | ||||||
|                                  out(_out, SIZE_RSPACKET), |         runnable(sch, "deconvol_sync"), | ||||||
|                                  skip(0) |         fastlock(false), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out, SIZE_RSPACKET), | ||||||
|  |         skip(0) | ||||||
|     { |     { | ||||||
|         conv = new uint32_t[2]; |         conv = new uint32_t[2]; | ||||||
|         conv[0] = gX; |         conv[0] = gX; | ||||||
| @ -151,6 +154,14 @@ struct deconvol_sync : runnable | |||||||
|         locked = &syncs[0]; |         locked = &syncs[0]; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     ~deconvol_sync() | ||||||
|  |     { | ||||||
|  |         delete[] deconv2; | ||||||
|  |         delete[] deconv; | ||||||
|  |         delete[] punct; | ||||||
|  |         delete[] conv; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     typedef uint64_t signal_t; |     typedef uint64_t signal_t; | ||||||
|     typedef uint64_t iq_t; |     typedef uint64_t iq_t; | ||||||
| 
 | 
 | ||||||
| @ -582,10 +593,11 @@ struct deconvol_sync : runnable | |||||||
| 
 | 
 | ||||||
| typedef deconvol_sync<u8, 0> deconvol_sync_simple; | typedef deconvol_sync<u8, 0> deconvol_sync_simple; | ||||||
| 
 | 
 | ||||||
| deconvol_sync_simple *make_deconvol_sync_simple(scheduler *sch, | deconvol_sync_simple *make_deconvol_sync_simple( | ||||||
|                                                 pipebuf<eucl_ss> &_in, |     scheduler *sch, | ||||||
|                                                 pipebuf<u8> &_out, |     pipebuf<eucl_ss> &_in, | ||||||
|                                                 enum code_rate rate); |     pipebuf<u8> &_out, | ||||||
|  |     enum code_rate rate); | ||||||
| 
 | 
 | ||||||
| // CONVOLUTIONAL ENCODER
 | // CONVOLUTIONAL ENCODER
 | ||||||
| 
 | 
 | ||||||
| @ -665,13 +677,16 @@ struct dvb_convol : runnable | |||||||
|     typedef u8 uncoded_byte; |     typedef u8 uncoded_byte; | ||||||
|     typedef u8 hardsymbol; |     typedef u8 hardsymbol; | ||||||
| 
 | 
 | ||||||
|     dvb_convol(scheduler *sch, |     dvb_convol( | ||||||
|                pipebuf<uncoded_byte> &_in, |         scheduler *sch, | ||||||
|                pipebuf<hardsymbol> &_out, |         pipebuf<uncoded_byte> &_in, | ||||||
|                code_rate fec, |         pipebuf<hardsymbol> &_out, | ||||||
|                int bits_per_symbol) : runnable(sch, "dvb_convol"), |         code_rate fec, | ||||||
|                                       in(_in), |         int bits_per_symbol | ||||||
|                                       out(_out, 64) // BPSK 7/8: 7 bytes in, 64 symbols out
 |     ) : | ||||||
|  |         runnable(sch, "dvb_convol"), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out, 64) // BPSK 7/8: 7 bytes in, 64 symbols out
 | ||||||
|     { |     { | ||||||
|         fec_spec *fs = &fec_specs[fec]; |         fec_spec *fs = &fec_specs[fec]; | ||||||
| 
 | 
 | ||||||
| @ -719,13 +734,16 @@ struct dvb_deconvol_sync : runnable | |||||||
|     int resync_period; |     int resync_period; | ||||||
|     static const int chunk_size = 64; // At least 2*sizeof(Thist)/8
 |     static const int chunk_size = 64; // At least 2*sizeof(Thist)/8
 | ||||||
| 
 | 
 | ||||||
|     dvb_deconvol_sync(scheduler *sch, |     dvb_deconvol_sync( | ||||||
|                       pipebuf<Tin> &_in, |         scheduler *sch, | ||||||
|                       pipebuf<decoded_byte> &_out) : runnable(sch, "deconvol_sync_multipoly"), |         pipebuf<Tin> &_in, | ||||||
|                                                      resync_period(32), |         pipebuf<decoded_byte> &_out | ||||||
|                                                      in(_in), |     ) : | ||||||
|                                                      out(_out, chunk_size), |         runnable(sch, "deconvol_sync_multipoly"), | ||||||
|                                                      resync_phase(0) |         resync_period(32), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out, chunk_size), | ||||||
|  |         resync_phase(0) | ||||||
|     { |     { | ||||||
|         init_syncs(); |         init_syncs(); | ||||||
|         locked = &syncs[0]; |         locked = &syncs[0]; | ||||||
| @ -736,7 +754,7 @@ struct dvb_deconvol_sync : runnable | |||||||
|         while (in.readable() >= chunk_size * 8 && out.writable() >= chunk_size) |         while (in.readable() >= chunk_size * 8 && out.writable() >= chunk_size) | ||||||
|         { |         { | ||||||
|             int errors_best = 1 << 30; |             int errors_best = 1 << 30; | ||||||
|             sync_t *best = NULL; |             sync_t *best = nullptr; | ||||||
| 
 | 
 | ||||||
|             for (sync_t *s = syncs; s < syncs + NSYNCS; ++s) |             for (sync_t *s = syncs; s < syncs + NSYNCS; ++s) | ||||||
|             { |             { | ||||||
| @ -833,29 +851,42 @@ struct mpeg_sync : runnable | |||||||
|     bool fastlock; |     bool fastlock; | ||||||
|     int resync_period; |     int resync_period; | ||||||
| 
 | 
 | ||||||
|     mpeg_sync(scheduler *sch, |     mpeg_sync( | ||||||
|               pipebuf<Tbyte> &_in, |         scheduler *sch, | ||||||
|               pipebuf<Tbyte> &_out, |         pipebuf<Tbyte> &_in, | ||||||
|               deconvol_sync<Tbyte, 0> *_deconv, |         pipebuf<Tbyte> &_out, | ||||||
|               pipebuf<int> *_state_out = NULL, |         deconvol_sync<Tbyte, 0> *_deconv, | ||||||
|               pipebuf<unsigned long> *_locktime_out = NULL) : runnable(sch, "sync_detect"), |         pipebuf<int> *_state_out = nullptr, | ||||||
|                                                               scan_syncs(8), |         pipebuf<unsigned long> *_locktime_out = nullptr | ||||||
|                                                               want_syncs(4), |     ) : | ||||||
|                                                               lock_timeout(4), |         runnable(sch, "sync_detect"), | ||||||
|                                                               fastlock(false), |         scan_syncs(8), | ||||||
|                                                               resync_period(1), |         want_syncs(4), | ||||||
|                                                               in(_in), |         lock_timeout(4), | ||||||
|                                                               out(_out, SIZE_RSPACKET * (scan_syncs + 1)), |         fastlock(false), | ||||||
|                                                               deconv(_deconv), |         resync_period(1), | ||||||
|                                                               polarity(0), |         in(_in), | ||||||
|                                                               resync_phase(0), |         out(_out, SIZE_RSPACKET * (scan_syncs + 1)), | ||||||
|                                                               bitphase(0), |         deconv(_deconv), | ||||||
|                                                               synchronized(false), |         polarity(0), | ||||||
|                                                               next_sync_count(0), |         resync_phase(0), | ||||||
|                                                               report_state(true) |         bitphase(0), | ||||||
|  |         synchronized(false), | ||||||
|  |         next_sync_count(0), | ||||||
|  |         report_state(true) | ||||||
|     { |     { | ||||||
|         state_out = _state_out ? new pipewriter<int>(*_state_out) : NULL; |         state_out = _state_out ? new pipewriter<int>(*_state_out) : nullptr; | ||||||
|         locktime_out = _locktime_out ? new pipewriter<unsigned long>(*_locktime_out) : NULL; |         locktime_out = _locktime_out ? new pipewriter<unsigned long>(*_locktime_out) : nullptr; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     ~mpeg_sync() | ||||||
|  |     { | ||||||
|  |         if (state_out) { | ||||||
|  |             delete state_out; | ||||||
|  |         } | ||||||
|  |         if (locktime_out) { | ||||||
|  |             delete locktime_out; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void run() |     void run() | ||||||
| @ -1096,11 +1127,14 @@ struct rspacket | |||||||
| 
 | 
 | ||||||
| struct interleaver : runnable | struct interleaver : runnable | ||||||
| { | { | ||||||
|     interleaver(scheduler *sch, |     interleaver( | ||||||
|                 pipebuf<rspacket<u8>> &_in, |         scheduler *sch, | ||||||
|                 pipebuf<u8> &_out) : runnable(sch, "interleaver"), |         pipebuf<rspacket<u8>> &_in, | ||||||
|                                      in(_in), |         pipebuf<u8> &_out | ||||||
|                                      out(_out, SIZE_RSPACKET) |     ) : | ||||||
|  |         runnable(sch, "interleaver"), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out, SIZE_RSPACKET) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -1112,8 +1146,7 @@ struct interleaver : runnable | |||||||
|             u8 *pout = out.wr(); |             u8 *pout = out.wr(); | ||||||
|             int delay = 0; |             int delay = 0; | ||||||
| 
 | 
 | ||||||
|             for (int i = 0; i < SIZE_RSPACKET; ++i, ++pout, delay = (delay + 1) % 12) |             for (int i = 0; i < SIZE_RSPACKET; ++i, ++pout, delay = (delay + 1) % 12) { | ||||||
|             { |  | ||||||
|                 *pout = pin[11 - delay].data[i]; |                 *pout = pin[11 - delay].data[i]; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
| @ -1133,11 +1166,14 @@ struct interleaver : runnable | |||||||
| template <typename Tbyte> | template <typename Tbyte> | ||||||
| struct deinterleaver : runnable | struct deinterleaver : runnable | ||||||
| { | { | ||||||
|     deinterleaver(scheduler *sch, |     deinterleaver( | ||||||
|                   pipebuf<Tbyte> &_in, |         scheduler *sch, | ||||||
|                   pipebuf<rspacket<Tbyte>> &_out) : runnable(sch, "deinterleaver"), |         pipebuf<Tbyte> &_in, | ||||||
|                                                     in(_in), |         pipebuf<rspacket<Tbyte>> &_out | ||||||
|                                                     out(_out) |     ) : | ||||||
|  |         runnable(sch, "deinterleaver"), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -1148,8 +1184,7 @@ struct deinterleaver : runnable | |||||||
|             Tbyte *pin = in.rd() + 17 * 11 * 12, *pend = pin + SIZE_RSPACKET; |             Tbyte *pin = in.rd() + 17 * 11 * 12, *pend = pin + SIZE_RSPACKET; | ||||||
|             Tbyte *pout = out.wr()->data; |             Tbyte *pout = out.wr()->data; | ||||||
| 
 | 
 | ||||||
|             for (int delay = 17 * 11; pin < pend; ++pin, ++pout, delay = (delay - 17 + 17 * 12) % (17 * 12)) |             for (int delay = 17 * 11; pin < pend; ++pin, ++pout, delay = (delay - 17 + 17 * 12) % (17 * 12)) { | ||||||
|             { |  | ||||||
|                 *pout = pin[-delay * 12]; |                 *pout = pin[-delay * 12]; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
| @ -1175,11 +1210,14 @@ struct tspacket | |||||||
| 
 | 
 | ||||||
| struct rs_encoder : runnable | struct rs_encoder : runnable | ||||||
| { | { | ||||||
|     rs_encoder(scheduler *sch, |     rs_encoder( | ||||||
|                pipebuf<tspacket> &_in, |         scheduler *sch, | ||||||
|                pipebuf<rspacket<u8>> &_out) : runnable(sch, "RS encoder"), |         pipebuf<tspacket> &_in, | ||||||
|                                               in(_in), |         pipebuf<rspacket<u8>> &_out | ||||||
|                                               out(_out) |     ) : | ||||||
|  |         runnable(sch, "RS encoder"), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -1213,16 +1251,29 @@ struct rs_decoder : runnable | |||||||
| { | { | ||||||
|     rs_engine rs; |     rs_engine rs; | ||||||
| 
 | 
 | ||||||
|     rs_decoder(scheduler *sch, |     rs_decoder( | ||||||
|                pipebuf<rspacket<Tbyte>> &_in, |         scheduler *sch, | ||||||
|                pipebuf<tspacket> &_out, |         pipebuf<rspacket<Tbyte>> &_in, | ||||||
|                pipebuf<int> *_bitcount = NULL, |         pipebuf<tspacket> &_out, | ||||||
|                pipebuf<int> *_errcount = NULL) : runnable(sch, "RS decoder"), |         pipebuf<int> *_bitcount = nullptr, | ||||||
|                                                  in(_in), |         pipebuf<int> *_errcount = nullptr | ||||||
|                                                  out(_out) |     ) : | ||||||
|  |         runnable(sch, "RS decoder"), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out) | ||||||
|     { |     { | ||||||
|         bitcount = _bitcount ? new pipewriter<int>(*_bitcount) : NULL; |         bitcount = _bitcount ? new pipewriter<int>(*_bitcount) : nullptr; | ||||||
|         errcount = _errcount ? new pipewriter<int>(*_errcount) : NULL; |         errcount = _errcount ? new pipewriter<int>(*_errcount) : nullptr; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     ~rs_decoder() | ||||||
|  |     { | ||||||
|  |         if (bitcount) { | ||||||
|  |             delete bitcount; | ||||||
|  |         } | ||||||
|  |         if (errcount) { | ||||||
|  |             delete errcount; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void run() |     void run() | ||||||
| @ -1307,11 +1358,14 @@ struct rs_decoder : runnable | |||||||
| 
 | 
 | ||||||
| struct randomizer : runnable | struct randomizer : runnable | ||||||
| { | { | ||||||
|     randomizer(scheduler *sch, |     randomizer( | ||||||
|                pipebuf<tspacket> &_in, |         scheduler *sch, | ||||||
|                pipebuf<tspacket> &_out) : runnable(sch, "derandomizer"), |         pipebuf<tspacket> &_in, | ||||||
|                                           in(_in), |         pipebuf<tspacket> &_out | ||||||
|                                           out(_out) |     ) : | ||||||
|  |         runnable(sch, "derandomizer"), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out) | ||||||
|     { |     { | ||||||
|         precompute_pattern(); |         precompute_pattern(); | ||||||
|         pos = pattern; |         pos = pattern; | ||||||
| @ -1367,11 +1421,14 @@ struct randomizer : runnable | |||||||
| 
 | 
 | ||||||
| struct derandomizer : runnable | struct derandomizer : runnable | ||||||
| { | { | ||||||
|     derandomizer(scheduler *sch, |     derandomizer( | ||||||
|                  pipebuf<tspacket> &_in, |         scheduler *sch, | ||||||
|                  pipebuf<tspacket> &_out) : runnable(sch, "derandomizer"), |         pipebuf<tspacket> &_in, | ||||||
|                                             in(_in), |         pipebuf<tspacket> &_out | ||||||
|                                             out(_out) |     ) : | ||||||
|  |         runnable(sch, "derandomizer"), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out) | ||||||
|     { |     { | ||||||
|         precompute_pattern(); |         precompute_pattern(); | ||||||
|         pos = pattern; |         pos = pattern; | ||||||
| @ -1525,17 +1582,20 @@ struct viterbi_sync : runnable | |||||||
|   public: |   public: | ||||||
|     int resync_period; |     int resync_period; | ||||||
| 
 | 
 | ||||||
|     viterbi_sync(scheduler *sch, |     viterbi_sync( | ||||||
|                  pipebuf<eucl_ss> &_in, |         scheduler *sch, | ||||||
|                  pipebuf<unsigned char> &_out, |         pipebuf<eucl_ss> &_in, | ||||||
|                  cstln_lut<eucl_ss, 256> *_cstln, |         pipebuf<unsigned char> &_out, | ||||||
|                  code_rate cr) : runnable(sch, "viterbi_sync"), |         cstln_lut<eucl_ss, 256> *_cstln, | ||||||
|                                  in(_in), |         code_rate cr | ||||||
|                                  out(_out, chunk_size), |     ) : | ||||||
|                                  cstln(_cstln), |         runnable(sch, "viterbi_sync"), | ||||||
|                                  current_sync(0), |         in(_in), | ||||||
|                                  resync_phase(0), |         out(_out, chunk_size), | ||||||
|                                  resync_period(32) // 1/32 = 9% synchronization overhead TBD
 |         cstln(_cstln), | ||||||
|  |         current_sync(0), | ||||||
|  |         resync_phase(0), | ||||||
|  |         resync_period(32) // 1/32 = 9% synchronization overhead TBD
 | ||||||
|     { |     { | ||||||
|         bits_per_symbol = log2i(cstln->nsymbols); |         bits_per_symbol = log2i(cstln->nsymbols); | ||||||
|         fec = &fec_specs[cr]; |         fec = &fec_specs[cr]; | ||||||
| @ -1659,6 +1719,11 @@ struct viterbi_sync : runnable | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     ~viterbi_sync() | ||||||
|  |     { | ||||||
|  |         delete syncs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     TCS *init_map(bool conj, float angle) |     TCS *init_map(bool conj, float angle) | ||||||
|     { |     { | ||||||
|         // Each constellation has its own pattern for labels.
 |         // Each constellation has its own pattern for labels.
 | ||||||
|  | |||||||
| @ -299,11 +299,14 @@ const modcod_info *check_modcod(int m) | |||||||
| template <typename T> | template <typename T> | ||||||
| struct s2_frame_transmitter : runnable | struct s2_frame_transmitter : runnable | ||||||
| { | { | ||||||
|     s2_frame_transmitter(scheduler *sch, |     s2_frame_transmitter( | ||||||
|                          pipebuf<plslot<hard_ss>> &_in, |         scheduler *sch, | ||||||
|                          pipebuf<complex<T>> &_out) |         pipebuf<plslot<hard_ss>> &_in, | ||||||
|         : runnable(sch, "S2 frame transmitter"), |         pipebuf<complex<T>> &_out | ||||||
|           in(_in), out(_out, modcod_info::MAX_SYMBOLS_PER_FRAME) |     ) : | ||||||
|  |         runnable(sch, "S2 frame transmitter"), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out, modcod_info::MAX_SYMBOLS_PER_FRAME) | ||||||
|     { |     { | ||||||
|         float amp = cstln_amp / sqrtf(2); |         float amp = cstln_amp / sqrtf(2); | ||||||
|         qsymbols[0].re = +amp; |         qsymbols[0].re = +amp; | ||||||
| @ -437,65 +440,17 @@ static int pl_errors = 0, pl_symbols = 0; | |||||||
| template <typename T, typename SOFTSYMB> | template <typename T, typename SOFTSYMB> | ||||||
| struct s2_frame_receiver : runnable | struct s2_frame_receiver : runnable | ||||||
| { | { | ||||||
|     sampler_interface<T> *sampler; |     enum { | ||||||
|     int meas_decimation; |  | ||||||
|     float Ftune; // Tuning bias in cycles per symbol
 |  | ||||||
|     float Fm;    // Baud rate in Hz, for debug messages only. TBD remove.
 |  | ||||||
|     bool strongpls; |  | ||||||
|     static const int MAX_SYMBOLS_PER_FRAME = |  | ||||||
|         (1 + modcod_info::MAX_SLOTS_PER_FRAME) * plslot<hard_ss>::LENGTH + |  | ||||||
|         ((modcod_info::MAX_SLOTS_PER_FRAME - 1) / 16) * pilot_length; |  | ||||||
|     s2_frame_receiver(scheduler *sch, |  | ||||||
|                       sampler_interface<T> *_sampler, |  | ||||||
|                       pipebuf<complex<T>> &_in, |  | ||||||
|                       pipebuf<plslot<SOFTSYMB>> &_out, |  | ||||||
|                       pipebuf<float> *_freq_out = nullptr, |  | ||||||
|                       pipebuf<float> *_ss_out = nullptr, |  | ||||||
|                       pipebuf<float> *_mer_out = nullptr, |  | ||||||
|                       pipebuf<complex<float>> *_cstln_out = nullptr, |  | ||||||
|                       pipebuf<complex<float>> *_cstln_pls_out = nullptr, |  | ||||||
|                       pipebuf<complex<float>> *_symbols_out = nullptr, |  | ||||||
|                       pipebuf<int> *_state_out = nullptr) |  | ||||||
|         : runnable(sch, "S2 frame receiver"), |  | ||||||
|           sampler(_sampler), |  | ||||||
|           meas_decimation(1048576), |  | ||||||
|           Ftune(0), Fm(0), |  | ||||||
|           strongpls(false), |  | ||||||
|           in_power(0), ev_power(0), agc_gain(1), agc_bw(1e-3), |  | ||||||
|           nsyncs(0), |  | ||||||
|           cstln(nullptr), |  | ||||||
|           in(_in), out(_out, 1 + modcod_info::MAX_SLOTS_PER_FRAME), |  | ||||||
|           meas_count(0), |  | ||||||
|           freq_out(opt_writer(_freq_out)), |  | ||||||
|           ss_out(opt_writer(_ss_out)), |  | ||||||
|           mer_out(opt_writer(_mer_out)), |  | ||||||
|           cstln_out(opt_writer(_cstln_out, 1024)), |  | ||||||
|           cstln_pls_out(opt_writer(_cstln_pls_out, 1024)), |  | ||||||
|           symbols_out(opt_writer(_symbols_out, MAX_SYMBOLS_PER_FRAME)), |  | ||||||
|           state_out(opt_writer(_state_out)), |  | ||||||
|           report_state(false), |  | ||||||
|           scrambling(0), |  | ||||||
|           m_modcodType(-1), |  | ||||||
|           m_modcodRate(-1) |  | ||||||
|     { |  | ||||||
|         // Constellation for PLS
 |  | ||||||
|         qpsk = new cstln_lut<SOFTSYMB, 256>(cstln_base::QPSK); |  | ||||||
|         add_syncs(qpsk); |  | ||||||
| 
 |  | ||||||
|         init_coarse_freq(); |  | ||||||
| 
 |  | ||||||
| #if TEST_DIVERSITY |  | ||||||
|         fprintf(stderr, "** DEBUG: Diversity test mode (slower)\n"); |  | ||||||
| #endif |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     enum |  | ||||||
|     { |  | ||||||
|         COARSE_FREQ, |         COARSE_FREQ, | ||||||
|         FRAME_SEARCH, |         FRAME_SEARCH, | ||||||
|         FRAME_LOCKED, |         FRAME_LOCKED, | ||||||
|     } state; |     } state; | ||||||
| 
 | 
 | ||||||
|  |     sampler_interface<T> *sampler; | ||||||
|  |     int meas_decimation; | ||||||
|  |     float Ftune; // Tuning bias in cycles per symbol
 | ||||||
|  |     float Fm;    // Baud rate in Hz, for debug messages only. TBD remove.
 | ||||||
|  |     bool strongpls; | ||||||
|     float min_freqw16, max_freqw16; |     float min_freqw16, max_freqw16; | ||||||
| 
 | 
 | ||||||
|     // State during COARSE_FREQ
 |     // State during COARSE_FREQ
 | ||||||
| @ -509,6 +464,61 @@ struct s2_frame_receiver : runnable | |||||||
|     float mu;    // Time to next symbol, in samples
 |     float mu;    // Time to next symbol, in samples
 | ||||||
|     float omega0; // Samples per symbol
 |     float omega0; // Samples per symbol
 | ||||||
| 
 | 
 | ||||||
|  |     static const int MAX_SYMBOLS_PER_FRAME = | ||||||
|  |         (1 + modcod_info::MAX_SLOTS_PER_FRAME) * plslot<hard_ss>::LENGTH + | ||||||
|  |         ((modcod_info::MAX_SLOTS_PER_FRAME - 1) / 16) * pilot_length; | ||||||
|  | 
 | ||||||
|  |     s2_frame_receiver( | ||||||
|  |         scheduler *sch, | ||||||
|  |         sampler_interface<T> *_sampler, | ||||||
|  |         pipebuf<complex<T>> &_in, | ||||||
|  |         pipebuf<plslot<SOFTSYMB>> &_out, | ||||||
|  |         pipebuf<float> *_freq_out = nullptr, | ||||||
|  |         pipebuf<float> *_ss_out = nullptr, | ||||||
|  |         pipebuf<float> *_mer_out = nullptr, | ||||||
|  |         pipebuf<complex<float>> *_cstln_out = nullptr, | ||||||
|  |         pipebuf<complex<float>> *_cstln_pls_out = nullptr, | ||||||
|  |         pipebuf<complex<float>> *_symbols_out = nullptr, | ||||||
|  |         pipebuf<int> *_state_out = nullptr | ||||||
|  |     ) : | ||||||
|  |         runnable(sch, "S2 frame receiver"), | ||||||
|  |         sampler(_sampler), | ||||||
|  |         meas_decimation(1048576), | ||||||
|  |         Ftune(0), Fm(0), | ||||||
|  |         strongpls(false), | ||||||
|  |         in_power(0), ev_power(0), agc_gain(1), agc_bw(1e-3), | ||||||
|  |         nsyncs(0), | ||||||
|  |         cstln(nullptr), | ||||||
|  |         in(_in), out(_out, 1 + modcod_info::MAX_SLOTS_PER_FRAME), | ||||||
|  |         meas_count(0), | ||||||
|  |         freq_out(opt_writer(_freq_out)), | ||||||
|  |         ss_out(opt_writer(_ss_out)), | ||||||
|  |         mer_out(opt_writer(_mer_out)), | ||||||
|  |         cstln_out(opt_writer(_cstln_out, 1024)), | ||||||
|  |         cstln_pls_out(opt_writer(_cstln_pls_out, 1024)), | ||||||
|  |         symbols_out(opt_writer(_symbols_out, MAX_SYMBOLS_PER_FRAME)), | ||||||
|  |         state_out(opt_writer(_state_out)), | ||||||
|  |         report_state(false), | ||||||
|  |         scrambling(0), | ||||||
|  |         m_modcodType(-1), | ||||||
|  |         m_modcodRate(-1) | ||||||
|  |     { | ||||||
|  |         // Constellation for PLS
 | ||||||
|  |         qpsk = new cstln_lut<SOFTSYMB, 256>(cstln_base::QPSK); | ||||||
|  |         add_syncs(qpsk); | ||||||
|  | 
 | ||||||
|  |         init_coarse_freq(); | ||||||
|  | 
 | ||||||
|  | #if TEST_DIVERSITY | ||||||
|  |         fprintf(stderr, "** DEBUG: Diversity test mode (slower)\n"); | ||||||
|  | #endif | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     ~s2_frame_receiver() | ||||||
|  |     { | ||||||
|  |         delete qpsk; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     void run() |     void run() | ||||||
|     { |     { | ||||||
|         // Require enough samples to detect one plheader,
 |         // Require enough samples to detect one plheader,
 | ||||||
| @ -1237,11 +1247,14 @@ struct fecframe | |||||||
| 
 | 
 | ||||||
| struct s2_interleaver : runnable | struct s2_interleaver : runnable | ||||||
| { | { | ||||||
|     s2_interleaver(scheduler *sch, |     s2_interleaver( | ||||||
|                    pipebuf<fecframe<hard_sb>> &_in, |         scheduler *sch, | ||||||
|                    pipebuf<plslot<hard_ss>> &_out) |         pipebuf<fecframe<hard_sb>> &_in, | ||||||
|         : runnable(sch, "S2 interleaver"), |         pipebuf<plslot<hard_ss>> &_out | ||||||
|           in(_in), out(_out, 1 + 360) |     ) : | ||||||
|  |         runnable(sch, "S2 interleaver"), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out, 1 + 360) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|     void run() |     void run() | ||||||
| @ -1566,13 +1579,17 @@ struct s2_interleaver : runnable | |||||||
| template <typename SOFTSYMB, typename SOFTBYTE> | template <typename SOFTSYMB, typename SOFTBYTE> | ||||||
| struct s2_deinterleaver : runnable | struct s2_deinterleaver : runnable | ||||||
| { | { | ||||||
|     s2_deinterleaver(scheduler *sch, |     s2_deinterleaver( | ||||||
|                      pipebuf<plslot<SOFTSYMB>> &_in, |         scheduler *sch, | ||||||
|                      pipebuf<fecframe<SOFTBYTE>> &_out) |         pipebuf<plslot<SOFTSYMB>> &_in, | ||||||
|         : runnable(sch, "S2 deinterleaver"), |         pipebuf<fecframe<SOFTBYTE>> &_out | ||||||
|           in(_in), out(_out) |     ) : | ||||||
|  |         runnable(sch, "S2 deinterleaver"), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|     void run() |     void run() | ||||||
|     { |     { | ||||||
|         while (in.readable() >= 1 && out.writable() >= 1) |         while (in.readable() >= 1 && out.writable() >= 1) | ||||||
| @ -2044,10 +2061,14 @@ struct s2_bch_engines | |||||||
| struct s2_fecenc : runnable | struct s2_fecenc : runnable | ||||||
| { | { | ||||||
|     typedef ldpc_engine<bool, hard_sb, 8, uint16_t> s2_ldpc_engine; |     typedef ldpc_engine<bool, hard_sb, 8, uint16_t> s2_ldpc_engine; | ||||||
|     s2_fecenc(scheduler *sch, |     s2_fecenc( | ||||||
|               pipebuf<bbframe> &_in, pipebuf<fecframe<hard_sb>> &_out) |         scheduler *sch, | ||||||
|         : runnable(sch, "S2 fecenc"), |         pipebuf<bbframe> &_in, | ||||||
|           in(_in), out(_out) |         pipebuf<fecframe<hard_sb>> &_out | ||||||
|  |     ) : | ||||||
|  |         runnable(sch, "S2 fecenc"), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out) | ||||||
|     { |     { | ||||||
|         if (sch->debug) |         if (sch->debug) | ||||||
|             s2ldpc.print_node_stats(); |             s2ldpc.print_node_stats(); | ||||||
| @ -2097,15 +2118,18 @@ template <typename SOFTBIT, typename SOFTBYTE> | |||||||
| struct s2_fecdec : runnable | struct s2_fecdec : runnable | ||||||
| { | { | ||||||
|     int bitflips; |     int bitflips; | ||||||
|     s2_fecdec(scheduler *sch, |     s2_fecdec( | ||||||
|               pipebuf<fecframe<SOFTBYTE>> &_in, pipebuf<bbframe> &_out, |         scheduler *sch, | ||||||
|               pipebuf<int> *_bitcount = nullptr, |         pipebuf<fecframe<SOFTBYTE>> &_in, pipebuf<bbframe> &_out, | ||||||
|               pipebuf<int> *_errcount = nullptr) |         pipebuf<int> *_bitcount = nullptr, | ||||||
|         : runnable(sch, "S2 fecdec"), |         pipebuf<int> *_errcount = nullptr | ||||||
|           bitflips(0), |     ) : | ||||||
|           in(_in), out(_out), |         runnable(sch, "S2 fecdec"), | ||||||
|           bitcount(opt_writer(_bitcount, 1)), |         bitflips(0), | ||||||
|           errcount(opt_writer(_errcount, 1)) |         in(_in), | ||||||
|  |         out(_out), | ||||||
|  |         bitcount(opt_writer(_bitcount, 1)), | ||||||
|  |         errcount(opt_writer(_errcount, 1)) | ||||||
|     { |     { | ||||||
|         if (sch->debug) |         if (sch->debug) | ||||||
|             s2ldpc.print_node_stats(); |             s2ldpc.print_node_stats(); | ||||||
| @ -2186,21 +2210,24 @@ struct s2_fecdec : runnable | |||||||
| template <typename SOFTBIT, typename SOFTBYTE> | template <typename SOFTBIT, typename SOFTBYTE> | ||||||
| struct s2_fecdec_soft : runnable | struct s2_fecdec_soft : runnable | ||||||
| { | { | ||||||
|     s2_fecdec_soft(scheduler *sch, |     s2_fecdec_soft( | ||||||
|                    pipebuf<fecframe<SOFTBYTE>> &_in, |         scheduler *sch, | ||||||
|                    pipebuf<bbframe> &_out, |         pipebuf<fecframe<SOFTBYTE>> &_in, | ||||||
|                    int _modcod, |         pipebuf<bbframe> &_out, | ||||||
|                    bool _shortframes = true, |         int _modcod, | ||||||
|                    int _max_trials = 25, |         bool _shortframes = true, | ||||||
|                    pipebuf<int> *_bitcount = nullptr, |         int _max_trials = 25, | ||||||
|                    pipebuf<int> *_errcount = nullptr) |         pipebuf<int> *_bitcount = nullptr, | ||||||
|         : runnable(sch, "S2 fecdec soft"), |         pipebuf<int> *_errcount = nullptr | ||||||
|           in(_in), out(_out), |     ) : | ||||||
|           modcod(_modcod < 0 ? 0 : _modcod > 31 ? 31 : _modcod), |         runnable(sch, "S2 fecdec soft"), | ||||||
|           shortframes(_shortframes ? 1 : 0), |         in(_in), | ||||||
|           max_trials(_max_trials), |         out(_out), | ||||||
|           bitcount(opt_writer(_bitcount, 1)), |         modcod(_modcod < 0 ? 0 : _modcod > 31 ? 31 : _modcod), | ||||||
|           errcount(opt_writer(_errcount, 1)) |         shortframes(_shortframes ? 1 : 0), | ||||||
|  |         max_trials(_max_trials), | ||||||
|  |         bitcount(opt_writer(_bitcount, 1)), | ||||||
|  |         errcount(opt_writer(_errcount, 1)) | ||||||
|     { |     { | ||||||
|         const char *tabname = ldpctool::LDPCInterface::mc_tabnames[shortframes][modcod]; |         const char *tabname = ldpctool::LDPCInterface::mc_tabnames[shortframes][modcod]; | ||||||
|         fprintf(stderr, "s2_fecdec_soft::s2_fecdec_soft: tabname: %s\n", tabname); |         fprintf(stderr, "s2_fecdec_soft::s2_fecdec_soft: tabname: %s\n", tabname); | ||||||
| @ -2357,20 +2384,23 @@ struct s2_fecdec_helper : runnable | |||||||
|     bool must_buffer; |     bool must_buffer; | ||||||
|     int max_trials; |     int max_trials; | ||||||
| 
 | 
 | ||||||
|     s2_fecdec_helper(scheduler *sch, |     s2_fecdec_helper( | ||||||
|                      pipebuf<fecframe<SOFTBYTE>> &_in, |         scheduler *sch, | ||||||
|                      pipebuf<bbframe> &_out, |         pipebuf<fecframe<SOFTBYTE>> &_in, | ||||||
|                      const char *_command, |         pipebuf<bbframe> &_out, | ||||||
|                      pipebuf<int> *_bitcount = nullptr, |         const char *_command, | ||||||
|                      pipebuf<int> *_errcount = nullptr) |         pipebuf<int> *_bitcount = nullptr, | ||||||
|         : runnable(sch, "S2 fecdec io"), |         pipebuf<int> *_errcount = nullptr | ||||||
|           batch_size(16), |     ) : | ||||||
|           nhelpers(1), |         runnable(sch, "S2 fecdec io"), | ||||||
|           must_buffer(false), |         batch_size(16), | ||||||
|           max_trials(8), |         nhelpers(1), | ||||||
|           in(_in), out(_out), |         must_buffer(false), | ||||||
|           bitcount(opt_writer(_bitcount, 1)), |         max_trials(8), | ||||||
|           errcount(opt_writer(_errcount, 1)) |         in(_in), | ||||||
|  |         out(_out), | ||||||
|  |         bitcount(opt_writer(_bitcount, 1)), | ||||||
|  |         errcount(opt_writer(_errcount, 1)) | ||||||
|     { |     { | ||||||
|         command = strdup(_command); |         command = strdup(_command); | ||||||
|         for (int mc = 0; mc < 32; ++mc) |         for (int mc = 0; mc < 32; ++mc) | ||||||
| @ -2459,6 +2489,7 @@ struct s2_fecdec_helper : runnable | |||||||
|                 lseek(h->fd_tx, 0, SEEK_SET); // allow new writes on this worker
 |                 lseek(h->fd_tx, 0, SEEK_SET); // allow new writes on this worker
 | ||||||
|                 continue; // next worker
 |                 continue; // next worker
 | ||||||
|             } |             } | ||||||
|  | 
 | ||||||
|             if (nw < 0) |             if (nw < 0) | ||||||
|                 fatal("write(LDPC helper"); |                 fatal("write(LDPC helper"); | ||||||
|             else if (nw != iosize) |             else if (nw != iosize) | ||||||
| @ -2524,9 +2555,9 @@ struct s2_fecdec_helper : runnable | |||||||
|                             int cs; |                             int cs; | ||||||
|                             waitpid(h->pid, &cs, 0); |                             waitpid(h->pid, &cs, 0); | ||||||
|                         } |                         } | ||||||
|                         // reset pipes
 |                         // close pipes
 | ||||||
|                         lseek(h->fd_tx, 0, SEEK_SET); |                         close(h->fd_tx); | ||||||
|                         lseek(h->fd_rx, 0, SEEK_SET); |                         close(h->fd_rx); | ||||||
|                     } |                     } | ||||||
| 
 | 
 | ||||||
|                     delete p->procs; |                     delete p->procs; | ||||||
| @ -2638,7 +2669,7 @@ struct s2_fecdec_helper : runnable | |||||||
|         } |         } | ||||||
|         else if (nr != iosize) |         else if (nr != iosize) | ||||||
|         { |         { | ||||||
|             fprintf(stderr, "s2_fecdec_helper::receive_frame: %d bytes read vs %d", nr, iosize); |             fprintf(stderr, "s2_fecdec_helper::receive_frame: %d bytes read vs %d\n", nr, iosize); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         --job->h->b_out; |         --job->h->b_out; | ||||||
| @ -2700,9 +2731,15 @@ struct s2_framer : runnable | |||||||
| { | { | ||||||
|     uint8_t rolloff_code; // 0=0.35, 1=0.25, 2=0.20, 3=reserved
 |     uint8_t rolloff_code; // 0=0.35, 1=0.25, 2=0.20, 3=reserved
 | ||||||
|     s2_pls pls; |     s2_pls pls; | ||||||
|     s2_framer(scheduler *sch, pipebuf<tspacket> &_in, pipebuf<bbframe> &_out) | 
 | ||||||
|         : runnable(sch, "S2 framer"), |     s2_framer( | ||||||
|           in(_in), out(_out) |         scheduler *sch, | ||||||
|  |         pipebuf<tspacket> &_in, | ||||||
|  |         pipebuf<bbframe> &_out | ||||||
|  |     ) : | ||||||
|  |         runnable(sch, "S2 framer"), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out) | ||||||
|     { |     { | ||||||
|         pls.modcod = 4; |         pls.modcod = 4; | ||||||
|         pls.sf = false; |         pls.sf = false; | ||||||
| @ -2782,17 +2819,22 @@ struct s2_framer : runnable | |||||||
| 
 | 
 | ||||||
| struct s2_deframer : runnable | struct s2_deframer : runnable | ||||||
| { | { | ||||||
|     s2_deframer(scheduler *sch, pipebuf<bbframe> &_in, pipebuf<tspacket> &_out, |     s2_deframer( | ||||||
|                 pipebuf<int> *_state_out = nullptr, |         scheduler *sch, | ||||||
|                 pipebuf<unsigned long> *_locktime_out = nullptr) |         pipebuf<bbframe> &_in, | ||||||
|         : runnable(sch, "S2 deframer"), |         pipebuf<tspacket> &_out, | ||||||
|           missing(-1), |         pipebuf<int> *_state_out = nullptr, | ||||||
|           in(_in), out(_out, MAX_TS_PER_BBFRAME), |         pipebuf<unsigned long> *_locktime_out = nullptr | ||||||
|           current_state(false), |     ) : | ||||||
|           state_out(opt_writer(_state_out, 2)), |         runnable(sch, "S2 deframer"), | ||||||
|           report_state(true), |         missing(-1), | ||||||
|           locktime(0), |         in(_in), | ||||||
|           locktime_out(opt_writer(_locktime_out, MAX_TS_PER_BBFRAME)) |         out(_out, MAX_TS_PER_BBFRAME), | ||||||
|  |         current_state(false), | ||||||
|  |         state_out(opt_writer(_state_out, 2)), | ||||||
|  |         report_state(true), | ||||||
|  |         locktime(0), | ||||||
|  |         locktime_out(opt_writer(_locktime_out, MAX_TS_PER_BBFRAME)) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|     void run() |     void run() | ||||||
|  | |||||||
| @ -107,7 +107,7 @@ struct runnable_common | |||||||
| 
 | 
 | ||||||
| struct window_placement | struct window_placement | ||||||
| { | { | ||||||
|     const char *name; // NULL to terminate
 |     const char *name; // nullptr to terminate
 | ||||||
|     int x, y, w, h; |     int x, y, w, h; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -120,12 +120,13 @@ struct scheduler | |||||||
|     window_placement *windows; |     window_placement *windows; | ||||||
|     bool verbose, debug, debug2; |     bool verbose, debug, debug2; | ||||||
| 
 | 
 | ||||||
|     scheduler() : npipes(0), |     scheduler() : | ||||||
|                   nrunnables(0), |         npipes(0), | ||||||
|                   windows(NULL), |         nrunnables(0), | ||||||
|                   verbose(false), |         windows(nullptr), | ||||||
|                   debug(false), |         verbose(false), | ||||||
|                   debug2(false) |         debug(false), | ||||||
|  |         debug2(false) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -208,20 +209,26 @@ struct pipebuf : pipebuf_common | |||||||
|     T *wr; |     T *wr; | ||||||
|     T *end; |     T *end; | ||||||
| 
 | 
 | ||||||
|     int sizeofT() |     pipebuf(scheduler *sch, const char *name, unsigned long size) : | ||||||
|  |         pipebuf_common(name), | ||||||
|  |         nrd(0), | ||||||
|  |         min_write(1), | ||||||
|  |         total_written(0), | ||||||
|  |         total_read(0) | ||||||
|     { |     { | ||||||
|         return sizeof(T); |         buf = new T[size]; | ||||||
|  |         wr = buf; | ||||||
|  |         end = buf + size; | ||||||
|  |         sch->add_pipe(this); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pipebuf(scheduler *sch, const char *name, unsigned long size) : pipebuf_common(name), |     ~pipebuf() | ||||||
|                                                                     buf(new T[size]), |  | ||||||
|                                                                     nrd(0), wr(buf), |  | ||||||
|                                                                     end(buf + size), |  | ||||||
|                                                                     min_write(1), |  | ||||||
|                                                                     total_written(0), |  | ||||||
|                                                                     total_read(0) |  | ||||||
|     { |     { | ||||||
|         sch->add_pipe(this); |         delete[] buf; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     int sizeofT() { | ||||||
|  |         return sizeof(T); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     int add_reader() |     int add_reader() | ||||||
| @ -307,9 +314,8 @@ struct pipewriter | |||||||
| 
 | 
 | ||||||
|     void written(unsigned long n) |     void written(unsigned long n) | ||||||
|     { |     { | ||||||
|         if (buf.wr + n > buf.end) |         if (buf.wr + n > buf.end) { | ||||||
|         { |             fprintf(stderr, "pipewriter::written: bug: overflow to %s\n", buf.name); | ||||||
|             fprintf(stderr, "Bug: overflow to %s\n", buf.name); |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         buf.wr += n; |         buf.wr += n; | ||||||
| @ -328,13 +334,13 @@ struct pipewriter | |||||||
| template <typename T> | template <typename T> | ||||||
| pipewriter<T> *opt_writer(pipebuf<T> *buf, unsigned long min_write = 1) | pipewriter<T> *opt_writer(pipebuf<T> *buf, unsigned long min_write = 1) | ||||||
| { | { | ||||||
|     return buf ? new pipewriter<T>(*buf, min_write) : NULL; |     return buf ? new pipewriter<T>(*buf, min_write) : nullptr; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template <typename T> | template <typename T> | ||||||
| bool opt_writable(pipewriter<T> *p, int n = 1) | bool opt_writable(pipewriter<T> *p, int n = 1) | ||||||
| { | { | ||||||
|     return (p == NULL) || p->writable() >= n; |     return (p == nullptr) || p->writable() >= n; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template <typename T> | template <typename T> | ||||||
|  | |||||||
| @ -48,20 +48,23 @@ struct auto_notch : runnable | |||||||
|     int decimation; |     int decimation; | ||||||
|     float k; |     float k; | ||||||
| 
 | 
 | ||||||
|     auto_notch(scheduler *sch, |     auto_notch( | ||||||
|                pipebuf<complex<T>> &_in, |         scheduler *sch, | ||||||
|                pipebuf<complex<T>> &_out, |         pipebuf<complex<T>> &_in, | ||||||
|                int _nslots, |         pipebuf<complex<T>> &_out, | ||||||
|                T _agc_rms_setpoint) : runnable(sch, "auto_notch"), |         int _nslots, | ||||||
|                                       decimation(1024 * 4096), |         T _agc_rms_setpoint | ||||||
|                                       k(0.002), // k(0.01)
 |     ) : | ||||||
|                                       fft(4096), |         runnable(sch, "auto_notch"), | ||||||
|                                       in(_in), |         decimation(1024 * 4096), | ||||||
|                                       out(_out, fft.n), |         k(0.002), // k(0.01)
 | ||||||
|                                       nslots(_nslots), |         fft(4096), | ||||||
|                                       phase(0), |         in(_in), | ||||||
|                                       gain(1), |         out(_out, fft.n), | ||||||
|                                       agc_rms_setpoint(_agc_rms_setpoint) |         nslots(_nslots), | ||||||
|  |         phase(0), | ||||||
|  |         gain(1), | ||||||
|  |         agc_rms_setpoint(_agc_rms_setpoint) | ||||||
|     { |     { | ||||||
|         __slots = new slot[nslots]; |         __slots = new slot[nslots]; | ||||||
| 
 | 
 | ||||||
| @ -74,6 +77,10 @@ struct auto_notch : runnable | |||||||
| 
 | 
 | ||||||
|     ~auto_notch() |     ~auto_notch() | ||||||
|     { |     { | ||||||
|  |         for (int s = 0; s < nslots; ++s) { | ||||||
|  |             delete[] __slots[s].expj; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         delete[] __slots; |         delete[] __slots; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -226,12 +233,16 @@ struct ss_estimator : runnable | |||||||
|     unsigned long window_size; // Samples per estimation
 |     unsigned long window_size; // Samples per estimation
 | ||||||
|     unsigned long decimation;  // Output rate
 |     unsigned long decimation;  // Output rate
 | ||||||
| 
 | 
 | ||||||
|     ss_estimator(scheduler *sch, pipebuf<complex<T>> &_in, pipebuf<T> &_out) : runnable(sch, "SS estimator"), |     ss_estimator( | ||||||
|                                                                                window_size(1024), |         scheduler *sch, | ||||||
|                                                                                decimation(1024), |         pipebuf<complex<T>> &_in, pipebuf<T> &_out | ||||||
|                                                                                in(_in), |     ) : | ||||||
|                                                                                out(_out), |         runnable(sch, "SS estimator"), | ||||||
|                                                                                phase(0) |         window_size(1024), | ||||||
|  |         decimation(1024), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out), | ||||||
|  |         phase(0) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -268,18 +279,21 @@ struct ss_amp_estimator : runnable | |||||||
|     unsigned long window_size; // Samples per estimation
 |     unsigned long window_size; // Samples per estimation
 | ||||||
|     unsigned long decimation;  // Output rate
 |     unsigned long decimation;  // Output rate
 | ||||||
| 
 | 
 | ||||||
|     ss_amp_estimator(scheduler *sch, |     ss_amp_estimator( | ||||||
|                      pipebuf<complex<T>> &_in, |         scheduler *sch, | ||||||
|                      pipebuf<T> &_out_ss, |         pipebuf<complex<T>> &_in, | ||||||
|                      pipebuf<T> &_out_ampmin, |         pipebuf<T> &_out_ss, | ||||||
|                      pipebuf<T> &_out_ampmax) : runnable(sch, "SS estimator"), |         pipebuf<T> &_out_ampmin, | ||||||
|                                                 window_size(1024), |         pipebuf<T> &_out_ampmax | ||||||
|                                                 decimation(1024), |     ) : | ||||||
|                                                 in(_in), |         runnable(sch, "SS estimator"), | ||||||
|                                                 out_ss(_out_ss), |         window_size(1024), | ||||||
|                                                 out_ampmin(_out_ampmin), |         decimation(1024), | ||||||
|                                                 out_ampmax(_out_ampmax), |         in(_in), | ||||||
|                                                 phase(0) |         out_ss(_out_ss), | ||||||
|  |         out_ampmin(_out_ampmin), | ||||||
|  |         out_ampmax(_out_ampmax), | ||||||
|  |         phase(0) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -332,14 +346,17 @@ struct simple_agc : runnable | |||||||
|     float estimated; // Input power
 |     float estimated; // Input power
 | ||||||
|     static const int chunk_size = 128; |     static const int chunk_size = 128; | ||||||
| 
 | 
 | ||||||
|     simple_agc(scheduler *sch, |     simple_agc( | ||||||
|                pipebuf<complex<T>> &_in, |         scheduler *sch, | ||||||
|                pipebuf<complex<T>> &_out) : runnable(sch, "AGC"), |         pipebuf<complex<T>> &_in, | ||||||
|                                             out_rms(1), |         pipebuf<complex<T>> &_out | ||||||
|                                             bw(0.001), |     ) : | ||||||
|                                             estimated(0), |         runnable(sch, "AGC"), | ||||||
|                                             in(_in), |         out_rms(1), | ||||||
|                                             out(_out, chunk_size) |         bw(0.001), | ||||||
|  |         estimated(0), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out, chunk_size) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -484,12 +501,16 @@ struct cstln_base | |||||||
| template <typename SOFTSYMB, int R> | template <typename SOFTSYMB, int R> | ||||||
| struct cstln_lut : cstln_base | struct cstln_lut : cstln_base | ||||||
| { | { | ||||||
|     cstln_lut(cstln_base::predef type, |     cstln_lut( | ||||||
|               float mer = 10, |         cstln_base::predef type, | ||||||
|               float gamma1 = 0, |         float mer = 10, | ||||||
|               float gamma2 = 0, |         float gamma1 = 0, | ||||||
|               float gamma3 = 0) |         float gamma2 = 0, | ||||||
|  |         float gamma3 = 0 | ||||||
|  |     ) | ||||||
|     { |     { | ||||||
|  |         symbols = nullptr; | ||||||
|  | 
 | ||||||
|         switch (type) |         switch (type) | ||||||
|         { |         { | ||||||
|         case BPSK: |         case BPSK: | ||||||
| @ -679,6 +700,13 @@ struct cstln_lut : cstln_base | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     ~cstln_lut() | ||||||
|  |     { | ||||||
|  |         if (symbols) { | ||||||
|  |             delete[] symbols; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     struct result |     struct result | ||||||
|     { |     { | ||||||
|         SOFTSYMB ss; |         SOFTSYMB ss; | ||||||
| @ -958,15 +986,21 @@ struct linear_sampler : sampler_interface<T> | |||||||
| template <typename T, typename Tc> | template <typename T, typename Tc> | ||||||
| struct fir_sampler : sampler_interface<T> | struct fir_sampler : sampler_interface<T> | ||||||
| { | { | ||||||
|     fir_sampler(int _ncoeffs, Tc *_coeffs, int _subsampling = 1) : ncoeffs(_ncoeffs), |     fir_sampler(int _ncoeffs, Tc *_coeffs, int _subsampling = 1) : | ||||||
|                                                                    coeffs(_coeffs), |         ncoeffs(_ncoeffs), | ||||||
|                                                                    subsampling(_subsampling), |         coeffs(_coeffs), | ||||||
|                                                                    shifted_coeffs(new complex<T>[ncoeffs]), |         subsampling(_subsampling), | ||||||
|                                                                    update_freq_phase(0) |         update_freq_phase(0) | ||||||
|     { |     { | ||||||
|  |         shifted_coeffs = new complex<T>[ncoeffs]; | ||||||
|         do_update_freq(0); // In case application never calls update_freq()
 |         do_update_freq(0); // In case application never calls update_freq()
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     ~fir_sampler() | ||||||
|  |     { | ||||||
|  |         delete[] shifted_coeffs; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     int readahead() |     int readahead() | ||||||
|     { |     { | ||||||
|         return ncoeffs - 1; |         return ncoeffs - 1; | ||||||
| @ -1050,36 +1084,39 @@ struct cstln_receiver : runnable | |||||||
|     static const unsigned int chunk_size = 128; |     static const unsigned int chunk_size = 128; | ||||||
|     float kest; |     float kest; | ||||||
| 
 | 
 | ||||||
|     cstln_receiver(scheduler *sch, |     cstln_receiver( | ||||||
|                    sampler_interface<T> *_sampler, |         scheduler *sch, | ||||||
|                    pipebuf<complex<T>> &_in, |         sampler_interface<T> *_sampler, | ||||||
|                    pipebuf<SOFTSYMB> &_out, |         pipebuf<complex<T>> &_in, | ||||||
|                    pipebuf<float> *_freq_out = NULL, |         pipebuf<SOFTSYMB> &_out, | ||||||
|                    pipebuf<float> *_ss_out = NULL, |         pipebuf<float> *_freq_out = nullptr, | ||||||
|                    pipebuf<float> *_mer_out = NULL, |         pipebuf<float> *_ss_out = nullptr, | ||||||
|                    pipebuf<cf32> *_cstln_out = NULL) : runnable(sch, "Constellation receiver"), |         pipebuf<float> *_mer_out = nullptr, | ||||||
|                                                        sampler(_sampler), |         pipebuf<cf32> *_cstln_out = nullptr | ||||||
|                                                        cstln(NULL), |     ) : | ||||||
|                                                        meas_decimation(1048576), |         runnable(sch, "Constellation receiver"), | ||||||
|                                                        pll_adjustment(1.0), |         sampler(_sampler), | ||||||
|                                                        allow_drift(false), |         cstln(nullptr), | ||||||
|                                                        kest(0.01), |         meas_decimation(1048576), | ||||||
|                                                        in(_in), |         pll_adjustment(1.0), | ||||||
|                                                        out(_out, chunk_size), |         allow_drift(false), | ||||||
|                                                        est_insp(cstln_amp * cstln_amp), |         kest(0.01), | ||||||
|                                                        agc_gain(1), |         in(_in), | ||||||
|                                                        mu(0), |         out(_out, chunk_size), | ||||||
|                                                        phase(0), |         est_insp(cstln_amp * cstln_amp), | ||||||
|                                                        est_sp(0), |         agc_gain(1), | ||||||
|                                                        est_ep(0), |         mu(0), | ||||||
|                                                        meas_count(0) |         phase(0), | ||||||
|  |         est_sp(0), | ||||||
|  |         est_ep(0), | ||||||
|  |         meas_count(0) | ||||||
|     { |     { | ||||||
|         set_omega(1); |         set_omega(1); | ||||||
|         set_freq(0); |         set_freq(0); | ||||||
|         freq_out = _freq_out ? new pipewriter<float>(*_freq_out) : NULL; |         freq_out = _freq_out ? new pipewriter<float>(*_freq_out) : nullptr; | ||||||
|         ss_out = _ss_out ? new pipewriter<float>(*_ss_out) : NULL; |         ss_out = _ss_out ? new pipewriter<float>(*_ss_out) : nullptr; | ||||||
|         mer_out = _mer_out ? new pipewriter<float>(*_mer_out) : NULL; |         mer_out = _mer_out ? new pipewriter<float>(*_mer_out) : nullptr; | ||||||
|         cstln_out = _cstln_out ? new pipewriter<cf32>(*_cstln_out) : NULL; |         cstln_out = _cstln_out ? new pipewriter<cf32>(*_cstln_out) : nullptr; | ||||||
| 
 | 
 | ||||||
|         for (int i = 0; i < 3; i++) |         for (int i = 0; i < 3; i++) | ||||||
|         { |         { | ||||||
| @ -1088,6 +1125,22 @@ struct cstln_receiver : runnable | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     ~cstln_receiver() | ||||||
|  |     { | ||||||
|  |         if (freq_out) { | ||||||
|  |             delete freq_out; | ||||||
|  |         } | ||||||
|  |         if (ss_out) { | ||||||
|  |             delete ss_out; | ||||||
|  |         } | ||||||
|  |         if (mer_out) { | ||||||
|  |             delete mer_out; | ||||||
|  |         } | ||||||
|  |         if (cstln_out) { | ||||||
|  |             delete cstln_out; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     void set_omega(float _omega, float tol = 10e-6) |     void set_omega(float _omega, float tol = 10e-6) | ||||||
|     { |     { | ||||||
|         omega = _omega; |         omega = _omega; | ||||||
| @ -1170,7 +1223,7 @@ struct cstln_receiver : runnable | |||||||
|             // These are scoped outside the loop for SS and MER estimation.
 |             // These are scoped outside the loop for SS and MER estimation.
 | ||||||
|             complex<float> sg{0.0f, 0.0f}; // Symbol before AGC;
 |             complex<float> sg{0.0f, 0.0f}; // Symbol before AGC;
 | ||||||
|             complex<float> s;  // For MER estimation and constellation viewer
 |             complex<float> s;  // For MER estimation and constellation viewer
 | ||||||
|             complex<signed char> *cstln_point = NULL; |             complex<signed char> *cstln_point = nullptr; | ||||||
| 
 | 
 | ||||||
|             while (pin < pend) |             while (pin < pend) | ||||||
|             { |             { | ||||||
| @ -1292,8 +1345,7 @@ struct cstln_receiver : runnable | |||||||
|                 if (ss_out) |                 if (ss_out) | ||||||
|                     ss_out->write(sqrtf(est_insp)); |                     ss_out->write(sqrtf(est_insp)); | ||||||
|                 if (mer_out) |                 if (mer_out) | ||||||
|                     mer_out->write( |                     mer_out->write(est_ep ? 10 * log10f(est_sp / est_ep) : 0); | ||||||
|                         est_ep ? 10 * logf(est_sp / est_ep) / logf(10) : 0); |  | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|         } // Work to do
 |         } // Work to do
 | ||||||
| @ -1342,28 +1394,41 @@ struct fast_qpsk_receiver : runnable | |||||||
|     bool allow_drift; // Follow carrier beyond safe limits
 |     bool allow_drift; // Follow carrier beyond safe limits
 | ||||||
|     static const unsigned int chunk_size = 128; |     static const unsigned int chunk_size = 128; | ||||||
| 
 | 
 | ||||||
|     fast_qpsk_receiver(scheduler *sch, |     fast_qpsk_receiver( | ||||||
|                        pipebuf<complex<T>> &_in, |         scheduler *sch, | ||||||
|                        pipebuf<hardsymbol> &_out, |         pipebuf<complex<T>> &_in, | ||||||
|                        pipebuf<float> *_freq_out = NULL, |         pipebuf<hardsymbol> &_out, | ||||||
|                        pipebuf<complex<T>> *_cstln_out = NULL) : runnable(sch, "Fast QPSK receiver"), |         pipebuf<float> *_freq_out = nullptr, | ||||||
|                                                                  meas_decimation(1048576), |         pipebuf<complex<T>> *_cstln_out = nullptr | ||||||
|                                                                  pll_adjustment(1.0), |     ) : | ||||||
|                                                                  allow_drift(false), |         runnable(sch, "Fast QPSK receiver"), | ||||||
|                                                                  in(_in), |         meas_decimation(1048576), | ||||||
|                                                                  out(_out, chunk_size), |         pll_adjustment(1.0), | ||||||
|                                                                  mu(0), |         allow_drift(false), | ||||||
|                                                                  phase(0), |         in(_in), | ||||||
|                                                                  meas_count(0) |         out(_out, chunk_size), | ||||||
|  |         mu(0), | ||||||
|  |         phase(0), | ||||||
|  |         meas_count(0) | ||||||
|     { |     { | ||||||
|         set_omega(1); |         set_omega(1); | ||||||
|         set_freq(0); |         set_freq(0); | ||||||
|         freq_out = _freq_out ? new pipewriter<float>(*_freq_out) : NULL; |         freq_out = _freq_out ? new pipewriter<float>(*_freq_out) : nullptr; | ||||||
|         cstln_out = _cstln_out ? new pipewriter<complex<T>>(*_cstln_out) : NULL; |         cstln_out = _cstln_out ? new pipewriter<complex<T>>(*_cstln_out) : nullptr; | ||||||
|         memset(hist, 0, sizeof(hist)); |         memset(hist, 0, sizeof(hist)); | ||||||
|         init_lookup_tables(); |         init_lookup_tables(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     ~fast_qpsk_receiver() | ||||||
|  |     { | ||||||
|  |         if (freq_out) { | ||||||
|  |             delete freq_out; | ||||||
|  |         } | ||||||
|  |         if (cstln_out) { | ||||||
|  |             delete cstln_out; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     void set_omega(float _omega, float tol = 10e-6) |     void set_omega(float _omega, float tol = 10e-6) | ||||||
|     { |     { | ||||||
|         omega = _omega; |         omega = _omega; | ||||||
| @ -1621,12 +1686,15 @@ struct cstln_transmitter : runnable | |||||||
| { | { | ||||||
|     cstln_lut<hard_ss, 256> *cstln; |     cstln_lut<hard_ss, 256> *cstln; | ||||||
| 
 | 
 | ||||||
|     cstln_transmitter(scheduler *sch, |     cstln_transmitter( | ||||||
|                       pipebuf<u8> &_in, |         scheduler *sch, | ||||||
|                       pipebuf<complex<Tout>> &_out) : runnable(sch, "cstln_transmitter"), |         pipebuf<u8> &_in, | ||||||
|                                                       in(_in), |         pipebuf<complex<Tout>> &_out | ||||||
|                                                       out(_out), |     ) : | ||||||
|                                                       cstln(0) |         runnable(sch, "cstln_transmitter"), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out), | ||||||
|  |         cstln(nullptr) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -1663,13 +1731,16 @@ struct cstln_transmitter : runnable | |||||||
| template <typename T> | template <typename T> | ||||||
| struct rotator : runnable | struct rotator : runnable | ||||||
| { | { | ||||||
|     rotator(scheduler *sch, |     rotator( | ||||||
|             pipebuf<complex<T>> &_in, |         scheduler *sch, | ||||||
|             pipebuf<complex<T>> &_out, |         pipebuf<complex<T>> &_in, | ||||||
|             float freq) : runnable(sch, "rotator"), |         pipebuf<complex<T>> &_out, | ||||||
|                           in(_in), |         float freq | ||||||
|                           out(_out), |     ) : | ||||||
|                           index(0) |         runnable(sch, "rotator"), | ||||||
|  |         in(_in), | ||||||
|  |         out(_out), | ||||||
|  |         index(0) | ||||||
|     { |     { | ||||||
|         int ifreq = freq * 65536; |         int ifreq = freq * 65536; | ||||||
|         if (sch->debug) |         if (sch->debug) | ||||||
| @ -1721,29 +1792,34 @@ struct rotator : runnable | |||||||
| template <typename T> | template <typename T> | ||||||
| struct cnr_fft : runnable | struct cnr_fft : runnable | ||||||
| { | { | ||||||
|     cnr_fft(scheduler *sch, |     cnr_fft( | ||||||
|             pipebuf<complex<T>> &_in, |         scheduler *sch, | ||||||
|             pipebuf<float> &_out, |         pipebuf<complex<T>> &_in, | ||||||
|             float _bandwidth, int nfft = 4096) : runnable(sch, "cnr_fft"), |         pipebuf<float> &_out, | ||||||
|                                                  bandwidth(_bandwidth), |         float _bandwidth, int nfft = 4096 | ||||||
|                                                  freq_tap(NULL), |     ) : | ||||||
|                                                  tap_multiplier(1), |         runnable(sch, "cnr_fft"), | ||||||
|                                                  decimation(1048576), |         bandwidth(_bandwidth), | ||||||
|                                                  kavg(0.1), |         freq_tap(nullptr), | ||||||
|                                                  in(_in), |         tap_multiplier(1), | ||||||
|                                                  out(_out), |         decimation(1048576), | ||||||
|                                                  fft(nfft), |         kavg(0.1), | ||||||
|                                                  avgpower(NULL), |         in(_in), | ||||||
|                                                  phase(0) |         out(_out), | ||||||
|  |         fft(nfft), | ||||||
|  |         avgpower(nullptr), | ||||||
|  |         phase(0) | ||||||
|     { |     { | ||||||
|         if (bandwidth > 0.25) |         if (bandwidth > 0.25) | ||||||
|             fail("CNR estimator requires Fsampling > 4x Fsignal"); |             fail("CNR estimator requires Fsampling > 4x Fsignal"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     float bandwidth; |     ~cnr_fft() | ||||||
|     float *freq_tap, tap_multiplier; |     { | ||||||
|     int decimation; |         if (avgpower) { | ||||||
|     float kavg; |             delete[] avgpower; | ||||||
|  |         } | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     void run() |     void run() | ||||||
|     { |     { | ||||||
| @ -1761,6 +1837,11 @@ struct cnr_fft : runnable | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     float bandwidth; | ||||||
|  |     float *freq_tap, tap_multiplier; | ||||||
|  |     int decimation; | ||||||
|  |     float kavg; | ||||||
|  | 
 | ||||||
|   private: |   private: | ||||||
|     void do_cnr() |     void do_cnr() | ||||||
|     { |     { | ||||||
| @ -1826,23 +1907,33 @@ struct cnr_fft : runnable | |||||||
| template <typename T, int NFFT> | template <typename T, int NFFT> | ||||||
| struct spectrum : runnable | struct spectrum : runnable | ||||||
| { | { | ||||||
|     spectrum(scheduler *sch, |  | ||||||
|              pipebuf<complex<T>> &_in, |  | ||||||
|              pipebuf<float[NFFT]> &_out) : runnable(sch, "spectrum"), |  | ||||||
|                                            decimation(1048576), |  | ||||||
|                                            kavg(0.1), |  | ||||||
|                                            decim(1), in(_in), |  | ||||||
|                                            out(_out), |  | ||||||
|                                            fft(NFFT), |  | ||||||
|                                            avgpower(NULL), |  | ||||||
|                                            phase(0) |  | ||||||
|     { |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     int decimation; |     int decimation; | ||||||
|     float kavg; |     float kavg; | ||||||
|     int decim; |     int decim; | ||||||
| 
 | 
 | ||||||
|  |     spectrum( | ||||||
|  |         scheduler *sch, | ||||||
|  |         pipebuf<complex<T>> &_in, | ||||||
|  |         pipebuf<float[NFFT]> &_out | ||||||
|  |     ) : | ||||||
|  |         runnable(sch, "spectrum"), | ||||||
|  |         decimation(1048576), | ||||||
|  |         kavg(0.1), | ||||||
|  |         decim(1), in(_in), | ||||||
|  |         out(_out), | ||||||
|  |         fft(NFFT), | ||||||
|  |         avgpower(nullptr), | ||||||
|  |         phase(0) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     ~spectrum() | ||||||
|  |     { | ||||||
|  |         if (avgpower) { | ||||||
|  |             delete avgpower; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     void run() |     void run() | ||||||
|     { |     { | ||||||
|         while (in.readable() >= fft.n * decim && out.writable() >= 1) |         while (in.readable() >= fft.n * decim && out.writable() >= 1) | ||||||
|  | |||||||
| @ -124,6 +124,7 @@ template <typename TUS, | |||||||
|           typename TPM> |           typename TPM> | ||||||
| struct viterbi_dec_interface | struct viterbi_dec_interface | ||||||
| { | { | ||||||
|  |     virtual ~viterbi_dec_interface() {} | ||||||
|     virtual TUS update(TBM *costs, TPM *quality = NULL) = 0; |     virtual TUS update(TBM *costs, TPM *quality = NULL) = 0; | ||||||
|     virtual TUS update(TCS s, TBM cost, TPM *quality = NULL) = 0; |     virtual TUS update(TCS s, TBM cost, TPM *quality = NULL) = 0; | ||||||
| }; | }; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user