From: 11rcombs Date: Tue, 31 Dec 2013 17:49:30 +0000 (-0600) Subject: Added profile program and corresponding configure options X-Git-Tag: 0.11.0~31 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=449ae478ab4263a11766ee7f9e224e4fe8588d69;p=libass Added profile program and corresponding configure options --- 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 + * Copyright (C) 2009 Grigori Goronzy + * Copyright (C) 2013 Rodger Combs + * + * 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 +#include +#include +#include + +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