From 5d38b3b52d98627f03d04fa33d7df2923bea2014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Wed, 20 Apr 2016 14:04:57 +0200 Subject: [PATCH] codegen: avoid defining test image in multiple places --- pysstv/examples/codegen.py | 5 +++-- pysstv/examples/codeman.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pysstv/examples/codegen.py b/pysstv/examples/codegen.py index 2eb7985..feeb37f 100644 --- a/pysstv/examples/codegen.py +++ b/pysstv/examples/codegen.py @@ -113,6 +113,7 @@ def test(): from datetime import datetime import struct exe = './codegen-test-executable' + img_file = '320x256rgb.png' if not path.exists('stb_image.h'): from urllib import urlretrieve urlretrieve('https://raw.githubusercontent.com/nothings/stb/master/stb_image.h', 'stb_image.h') @@ -127,10 +128,10 @@ def test(): gen_elapsed = datetime.now() - start print ' - gengcc took', gen_elapsed start = datetime.now() - gen = check_output([exe]) + gen = check_output([exe, img_file]) native_elapsed = datetime.now() - start print ' - native took', native_elapsed - img = Image.open("320x256rgb.png") + img = Image.open(img_file) sstv = sstv_class(img, 44100, 16) start = datetime.now() try: diff --git a/pysstv/examples/codeman.c b/pysstv/examples/codeman.c index fce6b05..11ac0c0 100644 --- a/pysstv/examples/codeman.c +++ b/pysstv/examples/codeman.c @@ -5,9 +5,9 @@ #include "stb_image.h" #include "codegen.c" -int main() { +int main(int argc, char **argv) { int x, y, n; - unsigned char *img = stbi_load("320x256rgb.png", &x, &y, &n, 0); + unsigned char *img = stbi_load(argv[1], &x, &y, &n, 0); float freqs[FREQ_COUNT], msecs[FREQ_COUNT];