1
0
mirror of git://projects.qi-hardware.com/openwrt-packages.git synced 2025-04-21 12:27:27 +03: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

@@ -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;
}