happycube / ld-decode

Software defined LaserDisc decoder
GNU General Public License v3.0
307 stars 80 forks source link

Don't write invalid JSON when no valid burst is found #809

Closed atsampson closed 1 year ago

atsampson commented 1 year ago

On the SFTP, in adamsampson/Faults/issue809, there's the first few frames of Easy Rider (LD10005) side 2.

Decoding this causes FieldPAL.calc_burstmedian to return NaN. This appears to be because the disc's mastered a bit hot - in the first field, all the lines trip the test for excessive burst amplitude in get_burstlevel.

The NaN eventually gets written to burstMedianIre in the JSON file... but Python's json.dump writes it as NaN, which isn't permitted by the JSON spec.

These two commits pass allow_nan=False to json.dump, and fix the test in calc_burstmedian so it returns 0 when no burst is found. It might be worth looking at the get_burstlevel heuristic to see if there's a better way of handling discs like this, though?