summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrimio <vasi.vilvoiu@gmail.com>2019-01-03 01:48:50 +0200
committerrimio <vasi.vilvoiu@gmail.com>2019-01-03 01:48:50 +0200
commitdf66a60b90200b020c3e32a2a6302971b254bbd0 (patch)
tree0903e8868ed15867e76c33ba99eba8096136f9cf
parent85d1eac288e6f40e326b7d3b240588aac5f88e96 (diff)
Initial
-rw-r--r--CMakeLists.txt59
-rw-r--r--bin/.gitignore2
-rw-r--r--include/.gitignore2
-rw-r--r--lib/.gitignore2
-rw-r--r--src/encoder.c25
-rw-r--r--src/libsstv.template.h60
-rw-r--r--src/sstv.c20
-rw-r--r--src/sstv.h19
-rw-r--r--src/tools/sstv-encode.cpp13
9 files changed, 202 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..1d83269
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,59 @@
+cmake_minimum_required (VERSION 3.8)
+
+project (sstv LANGUAGES C CXX)
+
+# Version
+set (VERSION_MAJOR 1)
+set (VERSION_MINOR 0)
+set (VERSION_PATCH 0)
+
+# Compiler setup
+set(CMAKE_C_STANDARD 99)
+add_compile_options (-Wall -Wextra -pedantic)
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition")
+
+# Options
+option (BUILD_TOOLS "build sstv-encode and sstv-decode tools" ON)
+
+# Directory setup
+set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
+set(INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include")
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib")
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")
+
+# Configuration file
+configure_file (
+ "${SRC_DIR}/libsstv.template.h"
+ "${INCLUDE_DIR}/libsstv.h"
+)
+
+# Source files
+set (LIB_SOURCES
+ "${SRC_DIR}/sstv.c"
+ "${SRC_DIR}/encoder.c"
+)
+
+set (ENCODE_TOOL_SOURCES
+ "${SRC_DIR}/tools/sstv-encode.cpp"
+)
+
+# Dependencies
+find_library (GLOG_LIBRARY glog)
+find_package (gflags REQUIRED)
+find_library (LIQUID_LIBRARY liquid)
+
+# Library (C compiler)
+add_library (${PROJECT_NAME} SHARED ${LIB_SOURCES})
+set_property (TARGET ${PROJECT_NAME} PROPERTY LINKER_LANGUAGE C)
+target_include_directories(${PROJECT_NAME} PUBLIC "${SRC_DIR}" PUBLIC "${INCLUDE_DIR}")
+target_link_libraries (${PROJECT_NAME} liquid)
+
+# Tools (C++ compiler)
+if (BUILD_TOOLS)
+ add_executable (${PROJECT_NAME}-encode ${ENCODE_TOOL_SOURCES})
+ set_property (TARGET ${PROJECT_NAME}-encode PROPERTY LINKER_LANGUAGE CXX)
+ set_property (TARGET ${PROJECT_NAME}-encode PROPERTY CXX_STANDARD 14)
+ target_include_directories(${PROJECT_NAME}-encode PUBLIC "${SRC_DIR}/tools" PUBLIC "${INCLUDE_DIR}")
+ target_link_libraries (${PROJECT_NAME}-encode ${PROJECT_NAME} glog gflags)
+endif (BUILD_TOOLS) \ No newline at end of file
diff --git a/bin/.gitignore b/bin/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/bin/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/include/.gitignore b/include/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/include/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/lib/.gitignore b/lib/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/lib/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/src/encoder.c b/src/encoder.c
new file mode 100644
index 0000000..b45e3b9
--- /dev/null
+++ b/src/encoder.c
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2018 Vasile Vilvoiu (YO7JBP) <vasi.vilvoiu@gmail.com>
+ *
+ * libsstv is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See LICENSE for details.
+ */
+
+#include "sstv.h"
+#include "libsstv.h"
+
+sstv_error_t
+sstv_create_encoder(sstv_mode_t mode, uint8_t *image, size_t sample_rate, void **out_ctx)
+{
+ /* Check input */
+}
+
+sstv_error_t
+sstv_delete_encoder(void *ctx)
+{
+}
+
+sstv_error_t
+sstv_encode(void *ctx, uint8_t *buffer, size_t buffer_size)
+{
+} \ No newline at end of file
diff --git a/src/libsstv.template.h b/src/libsstv.template.h
new file mode 100644
index 0000000..a977ff7
--- /dev/null
+++ b/src/libsstv.template.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2018 Vasile Vilvoiu (YO7JBP) <vasi.vilvoiu@gmail.com>
+ *
+ * libsstv is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See LICENSE for details.
+ */
+
+#ifndef _LIBSSTV_H_
+#define _LIBSSTV_H_
+
+#include <stdint.h>
+#include <stddef.h>
+
+/*
+ * Version
+ */
+#define SSTV_VERSION_MAJOR @VERSION_MAJOR@
+#define SSTV_VERSION_MINOR @VERSION_MINOR@
+#define SSTV_VERSION_PATCH @VERSION_PATCH@
+#define SSTV_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@"
+
+/*
+ * Error codes
+ */
+typedef enum {
+ /* No error */
+ SSTV_OK = 0,
+
+ /* Unknown error - should not happen, fatal */
+ SSTV_UNKNOWN = 1,
+
+ /* Encoder return codes */
+ SSTV_ENCODE_SUCCESSFUL = 1000,
+ SSTV_ENCODE_END = 1001,
+ SSTV_ENCODE_FAIL = 1002,
+} sstv_error_t;
+
+/*
+ * SSTV modes
+ */
+typedef enum {
+ SSTV_MODE_WRAASE_SC_1_8 = 0,
+} sstv_mode_t;
+
+/*
+ * Memory management
+ */
+typedef void* (*sstv_malloc_t)(size_t);
+typedef void (*sstv_free_t)(void *);
+
+/*
+ * Routines
+ */
+extern sstv_error_t sstv_init(sstv_malloc_t alloc_func, sstv_free_t dealloc_func);
+
+extern sstv_error_t sstv_create_encoder(sstv_mode_t mode, uint8_t *image, size_t sample_rate, void **out_ctx);
+extern sstv_error_t sstv_delete_encoder(void *ctx);
+extern sstv_error_t sstv_encode(void *ctx, uint8_t *buffer, size_t buffer_size);
+
+#endif \ No newline at end of file
diff --git a/src/sstv.c b/src/sstv.c
new file mode 100644
index 0000000..a29acd3
--- /dev/null
+++ b/src/sstv.c
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2018 Vasile Vilvoiu (YO7JBP) <vasi.vilvoiu@gmail.com>
+ *
+ * libsstv is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See LICENSE for details.
+ */
+
+#include "libsstv.h"
+
+sstv_malloc_t sstv_malloc_user = NULL;
+sstv_free_t sstv_free_user = NULL;
+
+sstv_error_t
+sstv_init(sstv_malloc_t alloc_func, sstv_free_t dealloc_func)
+{
+ /* Keep user functions for allocation/deallocation */
+ sstv_malloc_user = alloc_func;
+ sstv_free_user = dealloc_func;
+ return SSTV_OK;
+} \ No newline at end of file
diff --git a/src/sstv.h b/src/sstv.h
new file mode 100644
index 0000000..4b0279a
--- /dev/null
+++ b/src/sstv.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2018 Vasile Vilvoiu (YO7JBP) <vasi.vilvoiu@gmail.com>
+ *
+ * libsstv is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See LICENSE for details.
+ */
+
+#ifndef _SSTV_H_
+#define _SSTV_H_
+
+#include "libsstv.h"
+
+/*
+ * Memory management functions
+ */
+extern sstv_malloc_t sstv_malloc_user;
+extern sstv_free_t sstv_free_user;
+
+#endif \ No newline at end of file
diff --git a/src/tools/sstv-encode.cpp b/src/tools/sstv-encode.cpp
new file mode 100644
index 0000000..fe925ed
--- /dev/null
+++ b/src/tools/sstv-encode.cpp
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2018 Vasile Vilvoiu (YO7JBP) <vasi.vilvoiu@gmail.com>
+ *
+ * libsstv is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See LICENSE for details.
+ */
+
+int a = 0;
+
+int main()
+{
+ return 0;
+} \ No newline at end of file