Skip to content

Commit

Permalink
Add --save_wibble and associated code to export the TBC jotter inform…
Browse files Browse the repository at this point in the history
…aiton.

Added the --wow as this will be the next stage.
  • Loading branch information
IanSmallshire committed Jun 2, 2024
1 parent d2cea8b commit 1ebf61d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
32 changes: 32 additions & 0 deletions lddecode/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3379,6 +3379,11 @@ def __init__(
self.ac3 = extra_options.get("AC3", False)
self.write_rf_tbc = extra_options.get("write_RF_TBC", False)

self.wow = extra_options.get('wow', False)
self.wibble = extra_options.get('wibble', False)



self.has_analog_audio = True
if system == "PAL":
if analog_audio == 0:
Expand Down Expand Up @@ -3414,6 +3419,8 @@ def __init__(
self.AC3Collector = StridedCollector(cut_begin=1024, cut_end=0)
self.ac3_processes, self.outfile_ac3 = ac3_pipe(fname_out + ".ac3")
self.do_rftbc = True
if self.wibble:
self.outfile_wibble = open(fname_out + ".wow", "wb")

self.pipe_rftbc = extra_options.get("pipe_RF_TBC", None)
if self.pipe_rftbc:
Expand Down Expand Up @@ -3503,6 +3510,7 @@ def close(self):
"outfile_efm",
"outfile_rftbc",
"outfile_ac3",
"outfile_wibble",
]:
setattr(self, outfiles, None)

Expand Down Expand Up @@ -4087,9 +4095,14 @@ def buildmetadata(self, f, check_phase=True):
"endx": dropout_ends,
}

if self.wibble:
self.export_wibble(f)


# This is a bitmap, not a counter
decodeFaults = 0


fi["fieldPhaseID"] = f.fieldPhaseID

if prevfi is not None:
Expand Down Expand Up @@ -4323,3 +4336,22 @@ def build_json(self):
jout["fields"] = self.fieldinfo.copy()

return jout

def export_wibble(self, f):
x = f.wowfactor
x -= 1 # now in range from -0.001 to +0.001
x *= 16384000 # scale to 16 bits integer
x = x.astype(np.int16)

is_first = f.isFirstField
if self.system == 'PAL':
line_count = 312 if is_first else 313
line_offset = 3 if is_first else 4 # todo check & see comment about 0-based lines *before* downscaling
else:
line_count = 263 if is_first else 262
line_offset = 1 if is_first else 1 # TODO the 1s here need to be checked as not confirmed the values.

# trim the wow data to only include the current field as the RF is larger to allow detection of the syncs.
wow = x[line_offset:line_count + line_offset]

wow.tofile(self.outfile_wibble)
13 changes: 12 additions & 1 deletion lddecode/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,16 @@ def main(args=None):
default=False,
help="Enable line_profiler on select functions",
)

parser.add_argument(
"--save_wibble",
action="store_true",
help="Save the wibble calculated by the TBC jitter.",
)
parser.add_argument(
"--wow",
action="store_true",
help="Calulate the WOW caused by an off centre Laserdisc.",
)

args = parser.parse_args(args)
# print(args)
Expand Down Expand Up @@ -303,6 +312,8 @@ def main(args=None):
"audio_filterwidth": args.audio_filterwidth,
"AC3": args.AC3,
"use_profiler": args.use_profiler,
"wibble": args.save_wibble,
"wow": args.wow
}

if vid_standard == "NTSC" and args.NTSC_color_notch_filter:
Expand Down

0 comments on commit 1ebf61d

Please sign in to comment.