@@ -1682,11 +1682,27 @@ def process_chroma(
16821682 if field .burst_detected_line == - 1 :
16831683 # skip chroma if the color killer is active for the whole field
16841684 return uphet
1685+
1686+ if (
1687+ not field .rf .options .disable_phase_correction
1688+ and field .rf .color_system == "NTSC"
1689+ ):
1690+ field .fieldPhaseID , target_phase = ntsc_color_framing_map [
1691+ (field .isFirstField , (field .field_number // 2 ) % 2 )
1692+ ]
1693+ chroma_shift_direction = 1 if target_phase else - 1
1694+ else :
1695+ chroma_shift_direction = 0
16851696
16861697 # Run TBC/downscale on chroma (if new field, else uses cache)
16871698 # Cached if chroma process is run multiple times on one field due to track detection.
16881699 if field .chroma_tbc_buffer is None :
1689- chroma , _ , _ = ldd .Field .downscale (field , channel = "demod_burst" )
1700+ # shift the chroma to reverse group delay caused by the color under heterodyne filter
1701+ # this is dependent on color framing, and is disabled if color framing is disabled
1702+ # TODO: may need tuning / needs validation
1703+ chroma_subcarrier_delay_cycles = field .rf .chroma_afc .fsc_mhz * 1e6 / (2.0 * np .pi * field .rf .chroma_afc .color_under )
1704+ chroma_subcarrier_delay_samples = chroma_subcarrier_delay_cycles * 4
1705+ chroma , _ , _ = ldd .Field .downscale (field , channel = "demod_burst" , shift = chroma_subcarrier_delay_samples * chroma_shift_direction )
16901706
16911707 # If chroma AFC is enabled
16921708 if field .rf .do_cafc :
@@ -1755,9 +1771,6 @@ def process_chroma(
17551771 not field .rf .options .disable_phase_correction
17561772 and field .rf .color_system == "NTSC"
17571773 ):
1758- field .fieldPhaseID , target_phase = ntsc_color_framing_map [
1759- (field .isFirstField , (field .field_number // 2 ) % 2 )
1760- ]
17611774 target_phase_even = target_phase
17621775 target_phase_odd = target_phase
17631776
0 commit comments