def __init__(self, line_config, variant=ProtoSecamVariant.SECAM_1957, premod_luma_filter=True): self.line_config = line_config self.config = variant self._premod_luma_filter = premod_luma_filter self._carrier_phase_step = numpy.pi * variant.fsc / line_config.fs self._chroma_precorrect_lowpass = utils.iirdesign( 2.0 * variant.bandwidth3db / line_config.fs, 2.0 * variant.bandwidth20db / line_config.fs, 3.0, 20.0) self._demodulate_resample_factor = 3 self._extract_chroma_up, self._remove_chroma_up = utils.iirsplitter( 2.0 * variant.fsc / (self._demodulate_resample_factor * line_config.fs), 2.0 * variant.bandwidth3db / (self._demodulate_resample_factor * line_config.fs), 2.0 * variant.bandwidth20db / (self._demodulate_resample_factor * line_config.fs), 3.0, 20.0) if variant.fsc < variant.bandwidth20db: post_demod_bandwidth = variant.bandwidth3db else: post_demod_bandwidth = variant.bandwidth20db self._chroma_up_post_demod_filter = utils.iirdesign( 2.0 * min(post_demod_bandwidth, variant.fsc - post_demod_bandwidth) / (self._demodulate_resample_factor * line_config.fs), 2.0 * max(post_demod_bandwidth, variant.fsc - post_demod_bandwidth) / (self._demodulate_resample_factor * line_config.fs), 3.0, 20.0) self._last_frame = -1 self._last_line = -1 self._last_chroma = None
def __init__(self, line_config, variant=SecamVariant.SECAM, alternate_phases=False): self._line_config = line_config self._variant = variant self._fsc_dr = 2.0 * variant.fsc_dr / line_config.fs self._fsc_db = 2.0 * variant.fsc_db / line_config.fs self._fdev_dr = 2.0 * variant.fdev_dr / line_config.fs self._fdev_db = 2.0 * variant.fdev_db / line_config.fs self._flimit_min = 2.0 * (variant.bell_f0 + variant.flimit_minbell) / line_config.fs self._flimit_max = 2.0 * (variant.bell_f0 + variant.flimit_maxbell) / line_config.fs self._bell_f0 = 2.0 * variant.bell_f0 / line_config.fs if not alternate_phases: self._start_phase_inversions = [ False, False, True, False, False, True ] else: self._start_phase_inversions = [ False, False, False, True, True, True ] self._chroma_demod_bell = None if variant.bell_kn != variant.bell_kd: self._chroma_demod_bell = self._chroma_demod_bell_design( self._bell_f0, self._flimit_max, variant.bell_kn, variant.bell_kd) self._chroma_precorrect_lowpass = utils.iirdesign( wp=2.0 * 1300000.0 / line_config.fs, ws=2.0 * 3500000.0 / line_config.fs, gpass=3.0, gstop=30.0) self._chroma_precorrect = None self._reverse_chroma_precorrect = None if variant.lf_precorrect_k != 1.0: self._chroma_precorrect, self._reverse_chroma_precorrect = SecamModem._chroma_precorrect_design( 2.0 * variant.lf_precorrect_f1 / line_config.fs, variant.lf_precorrect_k) center = 0.5 * (self._flimit_min + self._flimit_max) dev = 0.5 * (self._flimit_max - self._flimit_min) self._chroma_demod_filter_order = 3 self._chroma_demod_chroma_filter = utils.iirfilter( 3, [center - dev, center + dev], rp=0.1, btype='bandpass', ftype='cheby1') self._chroma_demod_luma_filter = utils.iirfilter( 3, [center - dev * numpy.e, center + dev * numpy.e], btype='bandstop', ftype='bessel') self._chroma_demod = FmDecoder(center, dev) self._last_frame = -1 self._last_line = -1 self._last_chroma = None
def __init__(self, wc, wp, ws, gpass, gstop): self.carrier_phase_step = 0.5 * numpy.pi * wc self._chroma_precorrect_lowpass = utils.iirdesign(wp, ws, gpass, gstop) self._extract_chroma2x, self._remove_chroma2x = utils.iirsplitter( 0.5 * wc, 0.5 * wp, 0.5 * ws, gpass, gstop) self._demod_lowpass = utils.iirfilter(6, wc - 0.5 * ws, rs=48.0, btype='lowpass', ftype='cheby2')
def _chroma_demod_bell_design(f0, f_max, kn, kd): def gain(f): return numpy.sqrt( (kd * kd * f0 * f0 * f0 * f0 + (1 - 2 * kd * kd) * f * f * f0 * f0 + kd * kd * f * f * f * f) / (kn * kn * f0 * f0 * f0 * f0 + (1 - 2 * kn * kn) * f * f * f0 * f0 + kn * kn * f * f * f * f)) def gain_db(f): return 10.0 * numpy.log10(gain(f)) assert kn != kd wp2 = f0 + 1 / 256.0 wp1 = f0 * f0 / wp2 ws2 = f_max ws1 = f0 * f0 / ws2 return utils.iirdesign([wp1, wp2], [ws1, ws2], -gain_db(wp2), -gain_db(ws2), shift=False)
def __init__(self, line_config, config=pal.PalVariant.PAL, noise_level=0.0): self._carrier_phase_step = 2.0 * numpy.pi * config.fsc / line_config.fs self._noise_level = noise_level self.line_config = line_config self.config = config self._chroma_precorrect_lowpass = utils.iirdesign( 2.0 * config.bandwidth3db / line_config.fs, 2.0 * config.bandwidth20db / line_config.fs, 3.0, 20.0) self._demodulate_resample_factor = 3 self._demodulate_upsampled_baseband_filter, self._demodulate_upsampled_filter = NiirModem._demodulate_am_design( 2.0 * config.fsc / line_config.fs, 2.0 * config.bandwidth3db / line_config.fs, 2.0 * config.bandwidth20db / line_config.fs, 3.0, 20.0, self._demodulate_resample_factor) self._last_frame = -1 self._last_line = -1 self._last_phasemod_up = None
def _demodulate_am_design(wc, wp, ws, gpass, gstop, resample_factor): return utils.iirdesign(wp / resample_factor, ws / resample_factor, gpass, gstop), utils.iirdesign_wc( wc / resample_factor, wp / resample_factor, ws / resample_factor, gpass, gstop)