martes, 24 de marzo de 2009

Adornicos

Hoy ponemos un favicon
que no es sino una miniatura de mi avatar:
Sólo queda ahora poner el favicon en su sitio (que salga junto al enlace en "Favoritos") y plantar el avatar como imagen en la cabecera.

lunes, 23 de marzo de 2009

gd-2.0.36

Como parte de nuestra búsqueda de la brevedad y la bondad, vamos a aligerar un poco a libGD.

El paquete oficial de Cygwin tiene como dependencias a:
cygwin libXpm4 libfontconfig1 libjpeg62 libpng12

El problema es que libXpm4 tiene como dependencias al megapaquetón libX11_6, sólo para usar las funciones que manejan los bitmaps XPM, así que se puede sustituir por libXpm-noX.

Quitar libfontconfig1, es fácil: al compilar el fuente de libGD, tenemos una opción durante la configuración.

libiconv sólo se usa para convertir de una oscura codificación de japonés a Unicode. Así que fuera, mejor usar Unicode directamente para los (ejem, escasos) textos en japonés que yo maneje.

Otro ahorro es quitar la tipografía de tamaño fijo.

Así que vamos poco a poco editando los fuentes e intentando compilarlos, y cuando ya ya funciona, guardamos los cambios en un parche:

diff -u Makefile.am.org Makefile.am > ../patches/libgd.trim.1.diff
diff -u configure.ac.org configure.ac >> ../patches/libgd.trim.1.diff
diff -u config/gdlib-config.in.org config/gdlib-config.in >> ../patches/libgd.trim.1.diff
diff -u gdft.c.org gdft.c >> ../patches/libgd.trim.1.diff
diff -u gddemo.c.org gddemo.c >> ../patches/libgd.trim.1.diff


El parche es una chapucilla: lo elegante sería un parche por cambio, y enviarlos a libGD.

El parche es éste:

--- Makefile.am.org 2007-11-27 09:30:34.000000000 +0100
+++ Makefile.am 2009-03-19 11:30:01.260819300 +0100
@@ -13,17 +13,19 @@

EXTRA_DIST = README-JPEG.TXT README.TXT configure.pl bdftogd demoin.png err.out index.html install-item makefile.sample readme.jpn entities.html entities.tcl

-include_HEADERS = gd.h gdfx.h gd_io.h gdcache.h gdfontg.h gdfontl.h gdfontmb.h gdfonts.h gdfontt.h entities.h
+include_FIXFONTS = gdfontg.h gdfontl.h gdfontmb.h gdfonts.h gdfontt.h
+
+include_HEADERS = gd.h gdfx.h gd_io.h gdcache.h entities.h

lib_LTLIBRARIES = libgd.la

-libgd_la_SOURCES = gd.c gdfx.c gd_security.c gd_gd.c gd_gd2.c gd_io.c gd_io_dp.c gd_gif_in.c gd_gif_out.c gd_io_file.c gd_io_ss.c gd_jpeg.c gd_png.c gd_ss.c gd_topal.c gd_wbmp.c gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c gdft.c gdhelpers.c gdhelpers.h gdkanji.c gdtables.c gdxpm.c jisx0208.h wbmp.c wbmp.h
+libgd_la_FIXFONTSOURCES = gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c

-libgd_la_LDFLAGS = -version-info 2:0:0 $(XTRA_LDFLAGS)
+libgd_la_SOURCES = gd.c gdfx.c gd_security.c gd_gd.c gd_gd2.c gd_io.c gd_io_dp.c gd_gif_in.c gd_gif_out.c gd_io_file.c gd_io_ss.c gd_jpeg.c gd_png.c gd_ss.c gd_topal.c gd_wbmp.c gdcache.c gdft.c gdhelpers.c gdhelpers.h gdtables.c gdxpm.c jisx0208.h wbmp.c wbmp.h

-libgd_la_LIBADD = $(LTLIBICONV)
+libgd_la_LDFLAGS = -version-info 2:0:0 $(XTRA_LDFLAGS)

-LDADD = ./libgd.la $(LIBICONV)
+LDADD = ./libgd.la

dist-zip: distdir
zip -qr $(distdir).zip $(distdir)
--- configure.ac.org 2009-03-17 16:42:29.526062500 +0100
+++ configure.ac 2009-03-18 16:44:50.994075200 +0100
@@ -61,19 +61,6 @@
AC_HEADER_STDC
AC_CHECK_HEADERS([errno.h limits.h stddef.h stdlib.h string.h unistd.h])

-AM_ICONV
-# if test -n "$LIBICONV" ; then
-# LIBS="$LIBS $LIBICONV"
-# fi
-
-AC_CHECK_HEADERS(iconv.h,
- [AC_MSG_CHECKING(whether iconv.h defines iconv_t)
- AC_EGREP_HEADER([typedef.*iconv_t],iconv.h,
- [AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_ICONV_T_DEF, 1,
- [Define if defines iconv_t.])],
- AC_MSG_RESULT(no))])
-
# Checks for typedefs, structures, and compiler characteristics.
#AC_C_CONST
#AC_TYPE_SIZE_T
@@ -524,10 +511,9 @@

if test "$withval" != no; then
AC_CHECK_LIB(Xpm,XpmReadFileToXpmImage,
- [LIBS="-lXpm -lX11 $LIBS"
+ [LIBS="-lXpm $LIBS"
FEATURES="GD_XPM $FEATURES"
- AC_DEFINE(HAVE_LIBXPM, 1, [ Define if you have the Xpm library. ])],,
- [-lX11])
+ AC_DEFINE(HAVE_LIBXPM, 1, [ Define if you have the Xpm library. ])])
else
ac_cv_lib_Xpm_XpmReadFileToXpmImage=no
fi
--- config/gdlib-config.in.org 2009-03-19 16:12:36.221283200 +0100
+++ config/gdlib-config.in 2009-03-19 16:12:06.709311200 +0100
@@ -71,7 +71,7 @@
echo @LDFLAGS@
;;
--libs)
- echo @LIBS@ @LIBICONV@
+ echo @LIBS@
;;
--cflags|--includes)
echo -I@includedir@
@@ -84,7 +84,7 @@
echo "includedir: $includedir"
echo "cflags: -I@includedir@"
echo "ldflags: @LDFLAGS@"
- echo "libs: @LIBS@ @LIBICONV@"
+ echo "libs: @LIBS@"
echo "libdir: $libdir"
echo "features: @FEATURES@"
;;
--- gdft.c.org 2009-03-20 10:08:09.643623800 +0100
+++ gdft.c 2009-03-20 10:07:19.824264500 +0100
@@ -1081,26 +1081,7 @@
return "No character set found";
}

-#ifndef JISX0208
- if (encoding == gdFTEX_Shift_JIS)
- {
-#endif
- if ((tmpstr = (char *) gdMalloc (BUFSIZ)))
- {
- any2eucjp (tmpstr, string, BUFSIZ);
- next = tmpstr;
- }
- else
- {
next = string;
- }
-#ifndef JISX0208
- }
- else
- {
- next = string;
- }
-#endif

#if 0
fprintf(stderr,"dpi=%d,%d metric_res=%d ptsize=%g\n",hdpi,vdpi,METRIC_RES,ptsize);
--- gddemo.c.org 2009-03-20 10:36:35.767539000 +0100
+++ gddemo.c 2009-03-20 10:38:27.198319800 +0100
@@ -38,7 +38,9 @@
int i;

/* gd fonts for font test */
+#ifdef CONFIG_FIXFONT
gdFontPtr fonts[5];
+#endif
int y;

/* Create output image, in true color. */
@@ -136,6 +138,7 @@
/* Draw the styled, brushed line */
gdImageLine (im_out, 0, 255, 255, 0, gdStyledBrushed);
}
+#ifdef CONFIG_FIXFONT
/* Text (non-truetype; see gdtestft for a freetype demo) */
fonts[0] = gdFontGetTiny ();
fonts[1] = gdFontGetSmall ();
@@ -156,6 +159,7 @@
(unsigned char *) "hi", red);
y += fonts[i]->h;
}
+#endif
/* Random antialiased lines; coordinates all over the image,
but the output will respect a small clipping rectangle */
gdImageSetClip (im_out, 0, gdImageSY (im_out) - 100,


Los comandos para configurar y compilar quedan así:
LC_ALL=C autoreconf -i
CC=gcc-4 TMPDIR=/tmp CFLAGS="-march=core2 -DXPM_NO_X" ./configure --x-includes=/usr/include/noX --x-libraries=/usr/lib/noX --with-xpm --without-x --without-fontconfig
LC_ALL=C TMPDIR=/tmp make

martes, 17 de marzo de 2009

x264-20090315

Toca compilar x264 para Cygwin.

Cogemos el x264 de hoy, y, como cuando detecta a Cygwin lo que hace es una compilación cruzada para MinGW, le aplicamos un parche:

patch < x264.cygwin.diff

El contenido de x264.cygwin.diff es:

diff --git a/configure b/configure
index eb51091..31da92e 100755
--- a/configure
+++ b/configure
@@ -212,11 +212,8 @@ case $host_os in
LDFLAGS="$LDFLAGS -lm"
;;
cygwin*)
- SYS="MINGW"
- CFLAGS="$CFLAGS -mno-cygwin"
- LDFLAGS="$LDFLAGS -mno-cygwin"
+ SYS="CYGWIN"
EXE=".exe"
- DEVNULL="NUL"
;;
mingw*)
SYS="MINGW"
@@ -241,6 +238,8 @@ case $host_cpu in
ASFLAGS="-O2"
if [ "$SYS" = MACOSX ]; then
ASFLAGS="$ASFLAGS -f macho -DPREFIX"
+ elif [ "$SYS" = CYGWIN ]; then
+ ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
elif [ "$SYS" = MINGW ]; then
ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
else
@@ -368,6 +367,8 @@ fi
if [ "$avis_input" = "auto" ] ; then
if [ $SYS = MINGW ]; then
avis_input="yes"
+ elif [ "$SYS" = CYGWIN ]; then
+ avis_input="yes"
else
avis_input="no";
fi
@@ -440,6 +441,10 @@ if [ "$shared" = "yes" ]; then
echo "SONAME=libx264-$API.dll" >> config.mak
echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
echo 'SOFLAGS=-Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
+ elif [ "$SYS" = CYGWIN ]; then
+ echo "SONAME=libx264-$API.dll" >> config.mak
+ echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
+ echo 'SOFLAGS=-Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
elif [ "$SYS" = "MACOSX" ]; then
echo "SOSUFFIX=dylib" >> config.mak
echo "SONAME=libx264.$API.dylib" >> config.mak


Esta es mi configuración:
CC=gcc-4 ./configure --disable-mp4-output --extra-cflags=-march=core2

Le damos caña y casca:

Found no assembler
Minimum version is yasm-0.6.1
If you really want to compile without asm, configure with --disable-asm.

Vaya, requiere yasm y no lo tengo instalado en mi Cygwin 1.7. Bueno pero lo tengo para Cygwin 1.5, bajado de Cygwin Ports, y se supone que hay compatibilidad hacia delante.

En mi Cygwin 1.5, cygcheck -l yasm me dice lo que tengo que copiar, y cygcheck /usr/bin/yasm.exe me dice las dependencias (las DLLs que también habrá que copiar si no existen ya).

Así que ejecuto en mi Cygwin 1.7:

cd /bin && cp -p /cygdrive/c/cygwin/bin/yasm.exe .
cd /usr/include && cp -pri /cygdrive/c/cygwin/usr/include/libyasm .


Y ahora ya funciona:

$ CC=gcc-4 ./configure --disable-mp4-output --extra-cflags=-march=core2
./version.sh: line 2: git: command not found
Platform: X86
System: CYGWIN
asm: yes
avis input: yes
mp4 output: no
pthread: yes
debug: no
gprof: no
PIC: no
shared: no
visualize: no
You can run 'make' or 'make fprofiled' now.


Bueno hay un errorcillo, pero git sólo se usa para poner la versión.

Así que make && make install y ya tenemos libx264 disponible.

lunes, 16 de marzo de 2009

ffmpeg-17998

Los chicos de Cygwin han sacado la versión 4.3.2-2 de gcc. Vamos a probarla con el ffmpeg de hoy.

Aprovechando que gcc 4.3.x permite optimizar para Core2, uso esta configuración:

./configure --cc=gcc-4 --enable-shared --disable-static --cpu=core2 --enable-gpl --enable-avfilter --enable-avfilter-lavf --enable-pthreads --enable-avisynth --enable-bzlib --enable-zlib --build-suffix=-SVN

Decimos make y, vaya, hombre, salen errores:

libavformat/rtsp.o: In function `__ntohl':
/usr/include/asm/byteorder.h:40: multiple definition of `___ntohl'
libavformat/os_support.o:/usr/include/asm/byteorder.h:40: first defined here


¿De dónde viene esto? Pues hay tres motivos encadenados:

  1. FFmpeg le pasa -std=c99 al compilador
  2. La versión 4.3.x de gcc cambia la semántica del comando inline en modo C99
  3. Los "includes" de las funciones C de Cygwin no cumplen la norma C99.


¿Qué soluciones hay?

  1. La fácil, quitamos el trozo que casca, o sea añadimos --disable-network a nuestra configuración.
  2. La complicada, avisar en la lista de correo de Cygwin que habría que soportar C99 en los "includes".


Es lunes, así que vamos a usar la opción 1.

Ahora funciona la cosa, pero otra tarea pendiente es enviar un parche a ffmpeg-devel para no tener que hacer esta chapucilla con las compilaciones que crean bibliotecas compartidas.

miércoles, 4 de marzo de 2009

El mejor conversor de multimedia

Claro, es FFmpeg, y casi todo lo demás está basado en él.

El resto no son tan versátiles, sino que se limitan a manejar un formato o dos como mucho: