1
0
mirror of git://projects.qi-hardware.com/openwrt-packages.git synced 2024-12-22 08:54:37 +02:00

liballegro: add png, jpeg image and ogg/vorbis audio file addons

This commit is contained in:
David Kühling 2012-03-31 01:10:26 +02:00
parent 115dfe5f70
commit 088d3e7b1d
4 changed files with 317 additions and 32 deletions

View File

@ -7,11 +7,11 @@ Subject: [PATCH 2/2] disable-mouse
src/display.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/display.c b/src/display.c
index c2e4d56..dddd9f0 100644
--- a/src/display.c
+++ b/src/display.c
@@ -114,6 +114,10 @@ bard_display *bard_display_open(cst_features *config)
Index: bard-0.7-current/src/display.c
===================================================================
--- bard-0.7-current.orig/src/display.c 2012-03-22 03:13:47.146200911 +0100
+++ bard-0.7-current/src/display.c 2012-03-22 03:14:52.574435005 +0100
@@ -114,6 +114,10 @@
/* unless you move it */
SDL_ShowCursor(SDL_DISABLE);
@ -22,6 +22,3 @@ index c2e4d56..dddd9f0 100644
return display;
}
--
1.7.5.4

View File

@ -72,6 +72,44 @@ $(call Package/liballegro/Default/description)
This package contains various data files that are used by the Allegro library.
endef
define Package/liballegro-png
$(call Package/liballegro/Default)
TITLE+= (PNG image support)
DEPENDS:=+liballegro +zlib +libpng
endef
define Package/liballegro-png/description
$(call Package/liballegro/Default/description)
This package contains the libloadpng addon that allows interfacing allegro
Bitmaps with PNG files. Although the name of the library suggests otherwise
saving to PNG is supported as well as loading PNG files.
endef
# note: jpgalleg contains its own jpeg implementation; libjpeg not needed!
define Package/liballegro-jpeg
$(call Package/liballegro/Default)
TITLE+= (JPEG image support)
DEPENDS:=+liballegro
endef
define Package/liballegro-jpeg/description
$(call Package/liballegro/Default/description)
This package contains the libjpgalleg addon that allows interfacing allegro
Bitmaps with JPEG files. Saving to JPEG files is supported as well as loading.
endef
define Package/liballegro-ogg
$(call Package/liballegro/Default)
TITLE+= (Ogg/Vorbis audio support)
DEPENDS:=+liballegro +libvorbisidec +libogg
endef
define Package/liballegro-ogg/description
$(call Package/liballegro/Default/description)
This package contains the liblogg addon that allows play-back and mixing of
background music from Ogg Vorbis audio files.
endef
define Package/liballegro-demo
$(call Package/liballegro/Default)
TITLE+= (demo)
@ -171,28 +209,31 @@ endif
EXTRA_CFLAGS = -DSETUP_SCREEN_W=320 -DSETUP_SCREEN_H=240 -DSETUP_CFG_FILE=\\\"/etc/allegrorc\\\"
TARGET_LDFLAGS = -L$(STAGING_DIR)/usr/lib -ldl -lrt
CMAKE_OPTIONS = \
-DRT_LIBRARY= \
-DALLEGRO_USE_CONSTRUCTOR_EXITCODE=0 \
-DRT_LIBRARY= \
-DDL_LIBRARY= \
-DWANT_TOOLS=on \
-DWANT_TESTS=on \
-DWANT_MODULES=on \
-DWANT_EXAMPLES=on \
-DWANT_ALLEGROGL=off \
-DWANT_LOADPNG=on \
-DWANT_LOGG=off \
-DWANT_JPGALLEG=off \
-DWANT_X11=off \
-DWANT_LINUX_CONSOLE=on \
-DWANT_LINUX_FBCON=on \
-DWANT_LINUX_VGA=off \
-DWANT_LINUX_SVGALIB=off \
-DWANT_ALSA=on \
-DWANT_OSS=off \
-DWANT_JACK=off \
-DWANT_SGIAUDIO=off
CMAKE_OPTIONS = \
-DRT_LIBRARY= \
-DALLEGRO_USE_CONSTRUCTOR_EXITCODE=0 \
-DRT_LIBRARY= \
-DDL_LIBRARY= \
-DWANT_TOOLS=on \
-DWANT_TESTS=on \
-DWANT_MODULES=on \
-DWANT_EXAMPLES=on \
-DWANT_ALLEGROGL=off \
-DWANT_X11=off \
-DWANT_LINUX_CONSOLE=on \
-DWANT_LINUX_FBCON=on \
-DWANT_LINUX_VGA=off \
-DWANT_LINUX_SVGALIB=off \
-DWANT_ALSA=on \
-DWANT_OSS=off \
-DWANT_JACK=off \
-DWANT_SGIAUDIO=off \
-DWANT_LOADPNG=$(if $(CONFIG_PACKAGE_liballegro-png),on,off) \
-DWANT_JPGALLEG=$(if $(CONFIG_PACKAGE_liballegro-jpeg),on,off) \
-DWANT_LOGG=$(if $(CONFIG_PACKAGE_liballegro-ogg),on,off)
# todo: patch CMakeLists.txt to force addons to be compiled as shared libs?
# -DADDON_LINKAGE=SHARED
MAKE_FLAGS += -j4
@ -219,6 +260,8 @@ define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so* \
$(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.a \
$(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/* \
$(1)/usr/lib/pkgconfig/
# $(SED) 's,-I$$$${includedir},,g' $(1)/usr/lib/pkgconfig/plplotd.pc
@ -226,8 +269,9 @@ define Build/InstallDev
endef
define Package/liballegro/install
$(INSTALL_DIR) $(1)/usr $(1)/etc
$(CP) $(PKG_INSTALL_DIR)/usr/lib $(1)/usr
$(INSTALL_DIR) $(1)/usr/lib $(1)/etc
$(CP) $(PKG_INSTALL_DIR)/usr/lib/liballeg* $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/allegro $(1)/usr/lib/
$(CP) ./files/allegrorc $(1)/etc/
endef
@ -242,6 +286,21 @@ define Package/liballegro-data/install
$(1)/usr/share/allegro/docs/src
endef
define Package/liballegro-png/install
$(INSTALL_DIR) $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libloadpng* $(1)/usr/lib/
endef
define Package/liballegro-jpeg/install
$(INSTALL_DIR) $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libjpgalleg* $(1)/usr/lib/
endef
define Package/liballegro-ogg/install
$(INSTALL_DIR) $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/liblogg* $(1)/usr/lib/
endef
define Package/liballegro-demo/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_DIR) $(1)/usr/share/allegro
@ -274,6 +333,9 @@ endef
$(eval $(call HostBuild))
$(eval $(call BuildPackage,liballegro))
$(eval $(call BuildPackage,liballegro-data))
$(eval $(call BuildPackage,liballegro-png))
$(eval $(call BuildPackage,liballegro-jpeg))
$(eval $(call BuildPackage,liballegro-ogg))
$(eval $(call BuildPackage,liballegro-demo))
$(eval $(call BuildPackage,liballegro-setup))
$(eval $(call BuildPackage,liballegro-examples))

View File

@ -0,0 +1,100 @@
Index: allegro-4.4.2/cmake/FindVorbis.cmake
===================================================================
--- allegro-4.4.2.orig/cmake/FindVorbis.cmake 2012-03-30 23:59:08.149052027 +0200
+++ allegro-4.4.2/cmake/FindVorbis.cmake 2012-03-31 00:02:35.209665654 +0200
@@ -11,10 +11,10 @@
set(VORBIS_FIND_QUIETLY TRUE)
endif(VORBIS_INCLUDE_DIR)
find_path(OGG_INCLUDE_DIR ogg/ogg.h)
- find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
+ find_path(VORBIS_INCLUDE_DIR tremor/ivorbisfile.h)
find_library(OGG_LIBRARY NAMES ogg)
- find_library(VORBIS_LIBRARY NAMES vorbis)
- find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
+ find_library(VORBIS_LIBRARY NAMES vorbisidec)
+ find_library(VORBISFILE_LIBRARY NAMES vorbisidec)
# Handle the QUIETLY and REQUIRED arguments and set VORBIS_FOUND
# to TRUE if all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
Index: allegro-4.4.2/addons/logg/logg.h
===================================================================
--- allegro-4.4.2.orig/addons/logg/logg.h 2012-03-31 00:03:37.965850709 +0200
+++ allegro-4.4.2/addons/logg/logg.h 2012-03-31 00:05:19.486149188 +0200
@@ -6,7 +6,7 @@
#endif
#include <allegro.h>
-#include <vorbis/vorbisfile.h>
+#include <tremor/ivorbisfile.h>
#define OGG_PAGES_TO_BUFFER 2
Index: allegro-4.4.2/addons/logg/logg.c
===================================================================
--- allegro-4.4.2.orig/addons/logg/logg.c 2012-03-30 23:59:16.901078061 +0200
+++ allegro-4.4.2/addons/logg/logg.c 2012-03-31 00:52:21.628986644 +0200
@@ -14,6 +14,20 @@
static int logg_bufsize = 1024*64;
+/* convert samples from signed (tremor) to unsigned (allegro). from and to
+ * are allowed to refer to the same memory. */
+static void logg_from_signed(const char *from, char *to, int nbytes)
+{
+ const unsigned short *src = (const unsigned short*)from;
+ unsigned short *dst = (unsigned short*)to;
+ int i;
+
+ for (i = 0; i < nbytes; i += 2)
+ {
+ *dst++ = *src++ + 0x8000;
+ }
+}
+
SAMPLE* logg_load(const char* filename)
{
OggVorbis_File ovf;
@@ -32,7 +46,7 @@
return 0;
}
- if (ov_open_callbacks(file, &ovf, 0, 0, OV_CALLBACKS_DEFAULT) != 0) {
+ if (ov_open(file, &ovf, 0, 0) != 0) {
strncpy(allegro_error, "ov_open_callbacks failed.", ALLEGRO_ERROR_SIZE);
fclose(file);
free(buf);
@@ -57,9 +71,10 @@
samp->loop_end = samp->len;
samp->data = _al_malloc(sizeof(unsigned short) * samp->len * 2);
+ /* todo: need to convert to unsigned samples */
while ((numRead = ov_read(&ovf, buf, logg_bufsize,
- ENDIANNESS, 2, 0, &bitstream)) != 0) {
- memcpy((unsigned char*)samp->data+offset, buf, numRead);
+ &bitstream)) != 0) {
+ logg_from_signed(buf, (unsigned char*)samp->data+offset, numRead);
offset += numRead;
}
@@ -91,7 +106,7 @@
return 1;
}
- if (ov_open_callbacks(file, &s->ovf, 0, 0, OV_CALLBACKS_DEFAULT) != 0) {
+ if (ov_open(file, &s->ovf, 0, 0) != 0) {
strncpy(allegro_error, "ov_open_callbacks failed.", ALLEGRO_ERROR_SIZE);
fclose(file);
return 1;
@@ -119,9 +134,10 @@
memset(s->buf[page], 0, logg_bufsize);
while (read < logg_bufsize) {
+ /* todo: need to convert to unsigned samples */
int thisRead = ov_read(&s->ovf, s->buf[page]+read,
- logg_bufsize-read,
- ENDIANNESS, 2, 0, &bitstream);
+ logg_bufsize-read, &bitstream);
+ logg_from_signed(s->buf[page]+read,s->buf[page]+read,thisRead);
if (thisRead == 0) {
if (s->loop) {
ov_clear(&s->ovf);

View File

@ -0,0 +1,126 @@
Index: allegro-4.4.2/addons/jpgalleg/examples/ex1.c
===================================================================
--- allegro-4.4.2.orig/addons/jpgalleg/examples/ex1.c 2012-03-31 00:56:40.394446398 +0200
+++ allegro-4.4.2/addons/jpgalleg/examples/ex1.c 2012-03-31 00:56:55.266529285 +0200
@@ -21,7 +21,7 @@
jpgalleg_init();
set_color_depth(32);
- if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) {
+ if (set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 0)) {
set_color_depth(16);
if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) {
set_color_depth(15);
Index: allegro-4.4.2/addons/jpgalleg/examples/ex3.c
===================================================================
--- allegro-4.4.2.orig/addons/jpgalleg/examples/ex3.c 2012-03-31 00:56:40.594447513 +0200
+++ allegro-4.4.2/addons/jpgalleg/examples/ex3.c 2012-03-31 00:57:35.398752424 +0200
@@ -21,7 +21,7 @@
jpgalleg_init();
set_color_depth(32);
- if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) {
+ if (set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 0)) {
set_color_depth(16);
if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) {
set_color_depth(15);
Index: allegro-4.4.2/addons/jpgalleg/examples/ex4.c
===================================================================
--- allegro-4.4.2.orig/addons/jpgalleg/examples/ex4.c 2012-03-31 00:56:40.698448093 +0200
+++ allegro-4.4.2/addons/jpgalleg/examples/ex4.c 2012-03-31 00:57:43.386796746 +0200
@@ -22,7 +22,7 @@
jpgalleg_init();
set_color_depth(32);
- if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) {
+ if (set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 0)) {
set_color_depth(16);
if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) {
set_color_depth(15);
Index: allegro-4.4.2/addons/jpgalleg/examples/ex5.c
===================================================================
--- allegro-4.4.2.orig/addons/jpgalleg/examples/ex5.c 2012-03-31 00:56:40.814448739 +0200
+++ allegro-4.4.2/addons/jpgalleg/examples/ex5.c 2012-03-31 00:57:55.634864647 +0200
@@ -336,7 +336,7 @@
mode = GFX_AUTODETECT_WINDOWED;
set_color_depth(32);
- if (set_gfx_mode(mode, 640, 480, 0, 0)) {
+ if (set_gfx_mode(mode, 320, 240, 0, 0)) {
set_color_depth(16);
if (set_gfx_mode(mode, 640, 480, 0, 0)) {
set_color_depth(15);
Index: allegro-4.4.2/addons/loadpng/examples/exalpha.c
===================================================================
--- allegro-4.4.2.orig/addons/loadpng/examples/exalpha.c 2012-03-31 00:56:25.270361994 +0200
+++ allegro-4.4.2/addons/loadpng/examples/exalpha.c 2012-03-31 00:58:26.647036250 +0200
@@ -29,7 +29,7 @@
int main(int argc, char *argv[])
{
BITMAP *fg;
- int depth = 16;
+ int depth = 32;
const char *file;
allegro_init();
@@ -54,9 +54,9 @@
}
set_color_depth(depth);
- if ((set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) < 0) &&
- (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) < 0)) {
- allegro_message("Unable to set video mode (640x480x%d).\n", depth);
+ if ((set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 240, 0, 0) < 0) &&
+ (set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 0) < 0)) {
+ allegro_message("Unable to set video mode (320x240x%d).\n", depth);
return 1;
}
Index: allegro-4.4.2/addons/loadpng/examples/example.c
===================================================================
--- allegro-4.4.2.orig/addons/loadpng/examples/example.c 2012-03-31 00:56:25.374362575 +0200
+++ allegro-4.4.2/addons/loadpng/examples/example.c 2012-03-31 00:58:42.259122465 +0200
@@ -13,7 +13,7 @@
char *filename;
BITMAP *bmp;
PALETTE pal;
- int depth = 16;
+ int depth = 32;
/* Initialise Allegro. */
allegro_init();
@@ -34,8 +34,8 @@
/* Set a suitable graphics mode. */
set_color_depth(depth);
- if ((set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) < 0) &&
- (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) < 0)) {
+ if ((set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 240, 0, 0) < 0) &&
+ (set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 0) < 0)) {
allegro_message("Error setting video mode (640x480x%d).\n", depth);
return 1;
}
Index: allegro-4.4.2/addons/loadpng/examples/exdata.c
===================================================================
--- allegro-4.4.2.orig/addons/loadpng/examples/exdata.c 2012-03-31 00:56:25.474363134 +0200
+++ allegro-4.4.2/addons/loadpng/examples/exdata.c 2012-03-31 00:59:00.787224634 +0200
@@ -13,7 +13,7 @@
{
BITMAP *bmp;
DATAFILE *data;
- int depth = 16;
+ int depth = 32;
allegro_init();
install_keyboard();
@@ -33,8 +33,8 @@
}
set_color_depth(depth);
- if ((set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) < 0) &&
- (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) < 0)) {
+ if ((set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 240, 0, 0) < 0) &&
+ (set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 0) < 0)) {
allegro_message("Unable to set video mode (640x480x%d).\n", depth);
return 1;
}