mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-13 19:13:41 +00:00
refactoring
This commit is contained in:
4
Makefile
4
Makefile
@@ -10,6 +10,10 @@ PROG = ustreamer
|
|||||||
all: $(SOURCES) $(PROG)
|
all: $(SOURCES) $(PROG)
|
||||||
|
|
||||||
|
|
||||||
|
regen:
|
||||||
|
tools/make-jpg-h.py src/data/blank.jpg src/data/blank.h BLANK 640 480
|
||||||
|
|
||||||
|
|
||||||
$(PROG): $(OBJECTS)
|
$(PROG): $(OBJECTS)
|
||||||
$(CC) $(LIBS) $(LDFLAGS) $(OBJECTS) -o $@
|
$(CC) $(LIBS) $(LDFLAGS) $(OBJECTS) -o $@
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
|
|
||||||
# =====
|
|
||||||
def main():
|
|
||||||
with open("blank.jpg", "rb") as jpg_file:
|
|
||||||
jpg_data = jpg_file.read()
|
|
||||||
|
|
||||||
rows = [[]]
|
|
||||||
for ch in jpg_data:
|
|
||||||
if len(rows[-1]) > 20:
|
|
||||||
rows.append([])
|
|
||||||
rows[-1].append(hex(ch))
|
|
||||||
|
|
||||||
text = ",\n\t".join(", ".join(row) for row in rows)
|
|
||||||
text = "const unsigned char BLANK_JPG_DATA[] = {\n\t" + text + "\n};"
|
|
||||||
text = "const unsigned long BLANK_JPG_SIZE = %d;\n\n" % (len(jpg_data)) + text
|
|
||||||
text = "const unsigned BLANK_JPG_HEIGHT = 480;\n\n" + text
|
|
||||||
text = "const unsigned BLANK_JPG_WIDTH = 640;\n" + text
|
|
||||||
|
|
||||||
with open("src/blank.h", "w") as h_file:
|
|
||||||
h_file.write(text)
|
|
||||||
|
|
||||||
|
|
||||||
# =====
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
@@ -18,7 +18,7 @@
|
|||||||
#include "stream.h"
|
#include "stream.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
|
||||||
#include "blank.h"
|
#include "data/blank.h"
|
||||||
|
|
||||||
|
|
||||||
#define BOUNDARY "boundarydonotcross"
|
#define BOUNDARY "boundarydonotcross"
|
||||||
|
|||||||
38
tools/make-jpg-h.py
Executable file
38
tools/make-jpg-h.py
Executable file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
# =====
|
||||||
|
def main():
|
||||||
|
assert len(sys.argv) == 6, "%s <src> <dest> <prefix> <width> <height>" % (sys.argv[0])
|
||||||
|
|
||||||
|
src = sys.argv[1]
|
||||||
|
dest = sys.argv[2]
|
||||||
|
prefix = sys.argv[3]
|
||||||
|
width = int(sys.argv[4])
|
||||||
|
height = int(sys.argv[5])
|
||||||
|
|
||||||
|
with open(src, "rb") as jpg_file:
|
||||||
|
jpg_data = jpg_file.read()
|
||||||
|
|
||||||
|
rows = [[]]
|
||||||
|
for ch in jpg_data:
|
||||||
|
if len(rows[-1]) > 20:
|
||||||
|
rows.append([])
|
||||||
|
rows[-1].append(hex(ch))
|
||||||
|
|
||||||
|
text = ",\n\t".join(", ".join(row) for row in rows)
|
||||||
|
text = "const unsigned char %s_JPG_DATA[] = {\n\t%s\n};" % (prefix, text)
|
||||||
|
text = "const unsigned long %s_JPG_SIZE = %d;\n\n" % (prefix, len(jpg_data)) + text
|
||||||
|
text = "const unsigned %s_JPG_HEIGHT = %d;\n\n" % (prefix, height) + text
|
||||||
|
text = "const unsigned %s_JPG_WIDTH = %d;\n" % (prefix, width) + text
|
||||||
|
|
||||||
|
with open(dest, "w") as h_file:
|
||||||
|
h_file.write(text)
|
||||||
|
|
||||||
|
|
||||||
|
# =====
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user