Skip to content

Commit

Permalink
Add test tool to validate API
Browse files Browse the repository at this point in the history
  • Loading branch information
dheitmueller committed Jan 17, 2017
1 parent efe47ac commit 0e9c813
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src
SUBDIRS = src tools
EXTRA_DIST = doxygen/libklbars.doxyconf doxygen/include

docs:
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ AC_TYPE_UINT8_T
# Checks for library functions.
AC_CHECK_FUNCS([memset strrchr])

AC_CONFIG_FILES([Makefile src/Makefile])
AC_CONFIG_FILES([Makefile src/Makefile tools/Makefile])
AC_OUTPUT

# Add debug support
Expand Down
20 changes: 20 additions & 0 deletions tools/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

AUTOMAKE_OPTIONS = foreign

CFLAGS += -Wall -DVERSION=\"$(VERSION)\" -DPROG="\"$(PACKAGE)\"" -D_FILE_OFFSET_BITS=64 -O3 \
-I$(top_srcdir)/src \
-L$(top_builddir)/src/.libs -lpthread -lklbars

if DEBUG
CFLAGS += -g
endif

CXXFLAGS = $(CFLAGS)

SRC = klbars-test.c

bin_PROGRAMS = klbars_test

klbars_test_SOURCES = $(SRC)

libklbars_noinst_includedir = $(includedir)
35 changes: 35 additions & 0 deletions tools/klbars-test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <libklbars/klbars.h>

int main()
{
struct kl_colorbar_context osd_ctx;
int width=640, height=480;
unsigned char *buf;

/* Use the custom V210 stride required by the Decklink stack */
int rowWidth = ((width + 47) / 48) * 128;
fprintf(stderr, "row stride is %d\n", rowWidth);

buf = malloc(rowWidth * height);
memset(buf, 0, rowWidth * height);
kl_colorbar_init(&osd_ctx, width, height, KL_COLORBAR_10BIT);
kl_colorbar_fill_colorbars(&osd_ctx);
kl_colorbar_finalize(&osd_ctx, buf, rowWidth);

for (int i = 0; i < 32; i++) {
printf("%02x ", buf[i]);
}
printf("\n");

int fd = open("foo.yuv", O_WRONLY | O_TRUNC | O_CREAT, 0644);
write(fd, buf, rowWidth * height);
close(fd);

kl_colorbar_free(&osd_ctx);
return 0;
}

0 comments on commit 0e9c813

Please sign in to comment.