summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author11rcombs <rodger.combs@gmail.com>2013-12-31 11:49:30 -0600
committer11rcombs <rodger.combs@gmail.com>2014-01-25 13:56:06 -0600
commit449ae478ab4263a11766ee7f9e224e4fe8588d69 (patch)
tree298a427ab946148b413700d31d5bb8479c81e137
parentc55e335fc5dd1d877e1863a38fb48e9dd2072af6 (diff)
downloadlibass-449ae478ab4263a11766ee7f9e224e4fe8588d69.tar.bz2
libass-449ae478ab4263a11766ee7f9e224e4fe8588d69.tar.xz
Added profile program and corresponding configure options
-rw-r--r--Makefile.am6
-rw-r--r--configure.ac6
-rw-r--r--profile/Makefile.am7
-rw-r--r--profile/profile.c99
4 files changed, 116 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 5a17a08..4cd26e6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,5 +9,9 @@ if HAVE_LIBPNG
test = test
endif
-SUBDIRS = libass $(test)
+if ENABLE_PROFILE
+ profile = profile
+endif
+
+SUBDIRS = libass $(test) $(profile)
diff --git a/configure.ac b/configure.ac
index a05cf8f..11c1f79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,6 +36,8 @@ AC_CHECK_LIB([m], [fabs])
# Check for libraries via pkg-config
AC_ARG_ENABLE([test], AS_HELP_STRING([--enable-test],
[enable test program (requires libpng) @<:@default=no@:>@]))
+AC_ARG_ENABLE([profile], AS_HELP_STRING([--enable-profile],
+ [enable profiling program @<:@default=no@:>@]))
AC_ARG_ENABLE([enca], AS_HELP_STRING([--disable-enca],
[disable enca (charset autodetect) support @<:@default=check@:>@]))
AC_ARG_ENABLE([fontconfig], AS_HELP_STRING([--disable-fontconfig],
@@ -92,6 +94,8 @@ fi
AM_CONDITIONAL([HAVE_LIBPNG], [test x$libpng = xtrue])
+AM_CONDITIONAL([ENABLE_PROFILE], [test x$enable_profile = xyes])
+
# add libraries/packages to pkg-config for static linking
pkg_libs="-lm"
pkg_requires="freetype2 >= 9.10.3"
@@ -114,5 +118,5 @@ AC_SUBST([PKG_REQUIRES_PRIVATE], [$(test x$enable_shared = xno || echo ${pkg_req
# Setup output beautifier.
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
-AC_CONFIG_FILES([Makefile libass/Makefile test/Makefile libass.pc])
+AC_CONFIG_FILES([Makefile libass/Makefile test/Makefile profile/Makefile libass.pc])
AC_OUTPUT
diff --git a/profile/Makefile.am b/profile/Makefile.am
new file mode 100644
index 0000000..598c96b
--- /dev/null
+++ b/profile/Makefile.am
@@ -0,0 +1,7 @@
+AM_CFLAGS = -Wall
+
+noinst_PROGRAMS = profile
+profile_SOURCES = profile.c
+profile_CPPFLAGS = -I../libass
+profile_LDADD = ../libass/.libs/libass.a
+profile_LDFLAGS = $(AM_LDFLAGS) -static
diff --git a/profile/profile.c b/profile/profile.c
new file mode 100644
index 0000000..749c331
--- /dev/null
+++ b/profile/profile.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
+ * Copyright (C) 2009 Grigori Goronzy <greg@geekmind.org>
+ * Copyright (C) 2013 Rodger Combs <rcombs@rcombs.me>
+ *
+ * This file is part of libass.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <ass.h>
+
+typedef struct image_s {
+ int width, height, stride;
+ unsigned char *buffer; // RGB24
+} image_t;
+
+ASS_Library *ass_library;
+ASS_Renderer *ass_renderer;
+
+void msg_callback(int level, const char *fmt, va_list va, void *data)
+{
+ if (level > 6)
+ return;
+ printf("libass: ");
+ vprintf(fmt, va);
+ printf("\n");
+}
+
+static void init(int frame_w, int frame_h)
+{
+ ass_library = ass_library_init();
+ if (!ass_library) {
+ printf("ass_library_init failed!\n");
+ exit(1);
+ }
+
+ ass_set_message_cb(ass_library, msg_callback, NULL);
+
+ ass_renderer = ass_renderer_init(ass_library);
+ if (!ass_renderer) {
+ printf("ass_renderer_init failed!\n");
+ exit(1);
+ }
+
+ ass_set_frame_size(ass_renderer, frame_w, frame_h);
+ ass_set_fonts(ass_renderer, NULL, "Sans", 1, NULL, 1);
+}
+
+int main(int argc, char *argv[])
+{
+ const int frame_w = 1280;
+ const int frame_h = 720;
+
+ if (argc < 5) {
+ printf("usage: %s <subtitle file> <start time> <fps> <time to render>\n", argv[0]);
+ exit(1);
+ }
+ char *subfile = argv[1];
+ double tm = strtod(argv[2], 0);
+ double fps = strtod(argv[3], 0);
+ double time = strtod(argv[4], 0);
+
+ if(fps == 0){
+ printf("fps cannot equal 0\n");
+ exit(1);
+ }
+
+ init(frame_w, frame_h);
+ ASS_Track *track = ass_read_file(ass_library, subfile, NULL);
+ if (!track) {
+ printf("track init failed!\n");
+ exit(1);
+ }
+
+ while(tm < time){
+ ass_render_frame(ass_renderer, track, (int) (tm * 1000), NULL);
+ tm += 1 / fps;
+ }
+
+ ass_free_track(track);
+ ass_renderer_done(ass_renderer);
+ ass_library_done(ass_library);
+
+ return 0;
+}