From b7311120070586579f7aa2feceb1f3ed29aa04e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Sat, 24 Feb 2018 22:23:55 +0100 Subject: [PATCH] added PD modes (#16) --- README.md | 4 ++-- pysstv/color.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 61a6fb0..272d52a 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Command line usage $ python -m pysstv -h usage: __main__.py [-h] - [--mode {MartinM2,MartinM1,Robot24BW,ScottieS2,ScottieS1,Robot8BW,PasokonP3,PasokonP5,PasokonP7}] + [--mode {MartinM1,MartinM2,ScottieS1,ScottieS2,Robot36,PasokonP3,PasokonP5,PasokonP7,PD90,PD120,PD160,PD180,PD240,Robot8BW,Robot24BW}] [--rate RATE] [--bits BITS] [--vox] [--fskid FSKID] [--chan CHAN] image.png output.wav @@ -29,7 +29,7 @@ Command line usage optional arguments: -h, --help show this help message and exit - --mode {MartinM2,MartinM1,Robot24BW,ScottieS2,ScottieS1,Robot8BW,PasokonP3,PasokonP5,PasokonP7} + --mode {MartinM1,MartinM2,ScottieS1,ScottieS2,Robot36,PasokonP3,PasokonP5,PasokonP7,PD90,PD120D160,PD180,PD240,Robot8BW,Robot24BW} image mode (default: Martin M1) --rate RATE sampling rate (default: 48000) --bits BITS bits per sample (default: 16) diff --git a/pysstv/color.py b/pysstv/color.py index fecaf13..ef0d161 100644 --- a/pysstv/color.py +++ b/pysstv/color.py @@ -1,6 +1,6 @@ #!/usr/bin/env python from __future__ import division -from six.moves import range +from six.moves import range, zip from pysstv.sstv import byte_to_freq, FREQ_BLACK, FREQ_WHITE, FREQ_VIS_START from pysstv.grayscale import GrayscaleSSTV from itertools import chain @@ -149,4 +149,52 @@ class PasokonP7(PasokonP3): INTER_CH_GAP = 5 * TIMEUNIT -MODES = (MartinM1, MartinM2, ScottieS1, ScottieS2, Robot36, PasokonP3, PasokonP5, PasokonP7) +class PD90(ColorSSTV): + VIS_CODE = 0x63 + WIDTH = 320 + HEIGHT = 256 + SYNC = 20 + PORCH = 2.08 + PIXEL = 0.532 + + def gen_image_tuples(self): + yuv = self.image.convert('YCbCr').load() + for line in range(0, self.HEIGHT, 2): + for item in self.horizontal_sync(): + yield item + yield FREQ_BLACK, self.PORCH + pixels0 = [yuv[col, line] for col in range(self.WIDTH)] + pixels1 = [yuv[col, line + 1] for col in range(self.WIDTH)] + for p in pixels0: + yield byte_to_freq(p[0]), self.PIXEL + for p0, p1 in zip(pixels0, pixels1): + yield byte_to_freq((p0[2] + p1[2]) / 2), self.PIXEL + for p0, p1 in zip(pixels0, pixels1): + yield byte_to_freq((p0[1] + p1[1]) / 2), self.PIXEL + for p in pixels1: + yield byte_to_freq(p[0]), self.PIXEL + + +class PD120(PD90): + VIS_CODE = 0x5f + WIDTH = 640 + HEIGHT = 496 + PIXEL = 0.19 + +class PD160(PD90): + VIS_CODE = 0x62 + WIDTH = 512 + HEIGHT = 400 + PIXEL = 0.382 + +class PD180(PD120): + VIS_CODE = 0x60 + PIXEL = 0.286 + +class PD240(PD120): + VIS_CODE = 0x61 + PIXEL = 0.382 + + +MODES = (MartinM1, MartinM2, ScottieS1, ScottieS2, Robot36, + PasokonP3, PasokonP5, PasokonP7, PD90, PD120, PD160, PD180, PD240)