From 84d9831a8a82bf8cb70efd8f79da689cf11ca0e5 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Tue, 24 Dec 2019 18:49:40 +0000 Subject: [PATCH 1/2] Move filtermaker and deemp.h out of the top level. filtermaker is now in scripts, and deemp.h is now part of the filter library. --- Makefile | 4 ++-- filtermaker.py => scripts/filtermaker | 1 + tools/ld-chroma-decoder/comb.cpp | 2 +- tools/ld-chroma-decoder/ld-chroma-decoder.pro | 2 +- deemp.h => tools/library/filter/deemp.h | 0 tools/library/filter/testfilter/testfilter.pro | 7 +++---- 6 files changed, 8 insertions(+), 8 deletions(-) rename filtermaker.py => scripts/filtermaker (99%) mode change 100644 => 100755 rename deemp.h => tools/library/filter/deemp.h (100%) diff --git a/Makefile b/Makefile index 0626e23d7..4bd04a4ec 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,8 @@ clean: install: cp ld-ldf-reader /usr/local/bin -deemp.h: filtermaker.py - python3 filtermaker.py > deemp.h +tools/library/filter/deemp.h: scripts/filtermaker + python3 scripts/filtermaker >$@ ld-ldf-reader: ld-ldf-reader.c clang -o ld-ldf-reader ld-ldf-reader.c -Wno-deprecated-declarations -lavcodec -lavutil -lavformat -O2 diff --git a/filtermaker.py b/scripts/filtermaker old mode 100644 new mode 100755 similarity index 99% rename from filtermaker.py rename to scripts/filtermaker index 8ff373e99..ba5f0628e --- a/filtermaker.py +++ b/scripts/filtermaker @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # RJS: Added amendments to work with refactored code 03-JAN-2018 diff --git a/tools/ld-chroma-decoder/comb.cpp b/tools/ld-chroma-decoder/comb.cpp index 1959e0f57..06c673b49 100644 --- a/tools/ld-chroma-decoder/comb.cpp +++ b/tools/ld-chroma-decoder/comb.cpp @@ -25,7 +25,7 @@ #include "comb.h" -#include "../../deemp.h" +#include "deemp.h" // Public methods ----------------------------------------------------------------------------------------------------- diff --git a/tools/ld-chroma-decoder/ld-chroma-decoder.pro b/tools/ld-chroma-decoder/ld-chroma-decoder.pro index 3598ccf27..4d392367e 100644 --- a/tools/ld-chroma-decoder/ld-chroma-decoder.pro +++ b/tools/ld-chroma-decoder/ld-chroma-decoder.pro @@ -52,7 +52,7 @@ HEADERS += \ transformpal3d.h \ yiq.h \ yiqbuffer.h \ - ../../deemp.h \ + ../library/filter/deemp.h \ ../library/filter/iirfilter.h \ ../library/tbc/lddecodemetadata.h \ ../library/tbc/sourcevideo.h \ diff --git a/deemp.h b/tools/library/filter/deemp.h similarity index 100% rename from deemp.h rename to tools/library/filter/deemp.h diff --git a/tools/library/filter/testfilter/testfilter.pro b/tools/library/filter/testfilter/testfilter.pro index b31f14f3f..06418b1c1 100644 --- a/tools/library/filter/testfilter/testfilter.pro +++ b/tools/library/filter/testfilter/testfilter.pro @@ -5,10 +5,9 @@ SOURCES += \ testfilter.cpp HEADERS += \ + ../deemp.h \ ../firfilter.h \ - ../iirfilter.h \ - ../../../../deemp.h + ../iirfilter.h INCLUDEPATH += \ - .. \ - ../../../.. + .. From 1049f1c7c33685e38ef0d449ffb3f693720558de Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Tue, 24 Dec 2019 18:51:52 +0000 Subject: [PATCH 2/2] Make ld-decode into a Python package. The modules are now all in an "lddecode" package. The scripts that are useful for end-users will be installed. I've done this with distutils.core rather than setuptools because it doesn't need any of the extra stuff setuptools provides, and distutils.core is usefully less picky about where it installs to. I've also trimmed some imports that aren't being used. --- .gitignore | 5 ++- cx-expander.py => cx-expander | 5 +-- ld-cut.py => ld-cut | 5 +-- ld-decode.py => ld-decode | 5 +-- lddecode/__init__.py | 12 ++++++ .../commpy_filters.py | 0 lddecode_core.py => lddecode/core.py | 7 +--- efm_pll.py => lddecode/efm_pll.py | 0 fdls.py => lddecode/fdls.py | 0 fft8.py => lddecode/fft8.py | 0 ld_utils.py => lddecode/plot_utils.py | 2 - lddutils.py => lddecode/utils.py | 3 -- scripts/decode-ralf | 2 +- scripts/{ld-compress.sh => ld-compress} | 0 scripts/test-decode | 2 +- setup.py | 37 +++++++++++++++++++ 16 files changed, 63 insertions(+), 22 deletions(-) rename cx-expander.py => cx-expander (99%) rename ld-cut.py => ld-cut (97%) rename ld-decode.py => ld-decode (98%) create mode 100644 lddecode/__init__.py rename commpy_filters.py => lddecode/commpy_filters.py (100%) rename lddecode_core.py => lddecode/core.py (99%) rename efm_pll.py => lddecode/efm_pll.py (100%) mode change 100755 => 100644 rename fdls.py => lddecode/fdls.py (100%) rename fft8.py => lddecode/fft8.py (100%) mode change 100755 => 100644 rename ld_utils.py => lddecode/plot_utils.py (98%) rename lddutils.py => lddecode/utils.py (99%) rename scripts/{ld-compress.sh => ld-compress} (100%) create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 87afe3838..a8ae61aad 100644 --- a/.gitignore +++ b/.gitignore @@ -13,8 +13,11 @@ tbc-pal32 numpy scipy -# Some odd python thing +# Python build results +/MANIFEST __pycache__ +/build +/dist # Prerequisites *.d diff --git a/cx-expander.py b/cx-expander similarity index 99% rename from cx-expander.py rename to cx-expander index e7063d09f..1b7bd4083 100755 --- a/cx-expander.py +++ b/cx-expander @@ -1,4 +1,4 @@ -#!python3 +#!/usr/bin/env python3 from datetime import datetime import getopt @@ -13,8 +13,7 @@ import scipy.signal as sps import scipy.fftpack as fftpack -from lddutils import * -import lddecode_core as ldd +from lddecode.utils import * ''' diff --git a/ld-cut.py b/ld-cut similarity index 97% rename from ld-cut.py rename to ld-cut index e1ed944d8..5c742fe71 100755 --- a/ld-cut.py +++ b/ld-cut @@ -13,9 +13,8 @@ import traceback import subprocess -from lddutils import * -import lddecode_core -from lddecode_core import * +from lddecode.core import * +from lddecode.utils import * parser = argparse.ArgumentParser(description='Extracts a sample area from raw RF laserdisc captures') parser.add_argument('infile', metavar='infile', type=str, help='source file') diff --git a/ld-decode.py b/ld-decode similarity index 98% rename from ld-decode.py rename to ld-decode index cd775cf23..60279ba41 100755 --- a/ld-decode.py +++ b/ld-decode @@ -12,9 +12,8 @@ import json import traceback -from lddutils import * -import lddecode_core -from lddecode_core import * +from lddecode.core import * +from lddecode.utils import * options_epilog = """FREQ can be a bare number in MHz, or a number with one of the case-insensitive suffixes Hz, kHz, MHz, GHz, fSC (meaning NTSC) or fSCPAL.""" parser = argparse.ArgumentParser(description='Extracts audio and video from raw RF laserdisc captures', epilog=options_epilog) diff --git a/lddecode/__init__.py b/lddecode/__init__.py new file mode 100644 index 000000000..c0a28904f --- /dev/null +++ b/lddecode/__init__.py @@ -0,0 +1,12 @@ +#!/usr/bin/python3 +# Initialisation for the lddecode package. + +__all__ = [ + 'commpy_filters', + 'core', + 'efm_pll', + 'fdls', + 'fft8', + 'plot_utils', + 'utils', +] diff --git a/commpy_filters.py b/lddecode/commpy_filters.py similarity index 100% rename from commpy_filters.py rename to lddecode/commpy_filters.py diff --git a/lddecode_core.py b/lddecode/core.py similarity index 99% rename from lddecode_core.py rename to lddecode/core.py index 5929c001a..4100d5924 100644 --- a/lddecode_core.py +++ b/lddecode/core.py @@ -35,11 +35,8 @@ import numpy.fft as npfft #internal libraries -import commpy_filters - -import fdls -import efm_pll -from lddutils import * +from lddecode import efm_pll +from lddecode.utils import * try: # If Anaconda's numpy is installed, mkl will use all threads for fft etc diff --git a/efm_pll.py b/lddecode/efm_pll.py old mode 100755 new mode 100644 similarity index 100% rename from efm_pll.py rename to lddecode/efm_pll.py diff --git a/fdls.py b/lddecode/fdls.py similarity index 100% rename from fdls.py rename to lddecode/fdls.py diff --git a/fft8.py b/lddecode/fft8.py old mode 100755 new mode 100644 similarity index 100% rename from fft8.py rename to lddecode/fft8.py diff --git a/ld_utils.py b/lddecode/plot_utils.py similarity index 98% rename from ld_utils.py rename to lddecode/plot_utils.py index 853b18ac7..a43582519 100644 --- a/ld_utils.py +++ b/lddecode/plot_utils.py @@ -4,9 +4,7 @@ import scipy.signal as sps import sys -import fdls as fdls import matplotlib.pyplot as plt -import fft8 as fft8 pi = np.pi tau = np.pi * 2 diff --git a/lddutils.py b/lddecode/utils.py similarity index 99% rename from lddutils.py rename to lddecode/utils.py index ed8222b0e..91365af5f 100644 --- a/lddutils.py +++ b/lddecode/utils.py @@ -22,9 +22,6 @@ import matplotlib import matplotlib.pyplot as plt -#internal libraries which may or may not get used -import fdls - def todb(y, zero = False): db = 20 * np.log10(np.abs(y)) if zero: diff --git a/scripts/decode-ralf b/scripts/decode-ralf index 6ff2672f8..bf8101b1d 100644 --- a/scripts/decode-ralf +++ b/scripts/decode-ralf @@ -1,5 +1,5 @@ # ralf includes a bit of extra data on each side - will be useful for seeking and limits later -python3 ld-decode.py ~/ralf_side1_6x_2018-10-09_21-41-14.lds ralf -s 7 -l 244 --NTSCJ --EFM +python3 ld-decode ~/ralf_side1_6x_2018-10-09_21-41-14.lds ralf -s 7 -l 244 --NTSCJ --EFM # # -I 0 sets ire to 0, HE-010 is a Japanese LD ld-chroma-decoder --3d -l 245 ralf.tbc ralf.rgb diff --git a/scripts/ld-compress.sh b/scripts/ld-compress similarity index 100% rename from scripts/ld-compress.sh rename to scripts/ld-compress diff --git a/scripts/test-decode b/scripts/test-decode index 7070b8e60..58c3d8895 100755 --- a/scripts/test-decode +++ b/scripts/test-decode @@ -65,7 +65,7 @@ def run_ld_decode(args): clean(args, ['.tbc', '.tbc.json', '.efm', '.pcm']) - cmd = [src_dir + '/ld-decode.py'] + cmd = [src_dir + '/ld-decode'] cmd += ['--ignoreleadout'] if args.pal: cmd += ['--pal'] diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..c78d130f9 --- /dev/null +++ b/setup.py @@ -0,0 +1,37 @@ +#!/usr/bin/python3 + +from distutils.core import setup + +setup( + name='ld-decode', + version='7', + + description='Software defined LaserDisc decoder', + url='https://github.com/happycube/ld-decode', + keywords=['video', 'LaserDisc'], + classifiers=[ + 'Environment :: Console', + 'Environment :: X11 Applications :: Qt', + 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', + 'Programming Language :: C++', + 'Programming Language :: Python :: 3', + 'Topic :: Multimedia :: Video :: Capture', + ], + + packages=['lddecode'], + scripts=[ + 'cx-expander', + 'ld-cut', + 'ld-decode', + 'scripts/ld-compress', + ], + + # These are just the minimal runtime dependencies for the Python scripts -- + # see the documentation for the full list of dependencies. + provides=['lddecode'], + requires=[ + 'numba', + 'numpy', + 'scipy', + ], +)