[MPlayer-dev-eng] [PATCH#2] make the mplayer binary several 100k smaller

Andreas Hess jaska at gmx.net
Thu Jun 12 16:34:46 CEST 2003


On Thu, Jun 12, 2003 at 03:30:55PM +0200, Arpi wrote:
> Hi,
> 
> > Index: libmpcodecs/vf_lavc.c
> > ===================================================================
> > RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_lavc.c,v
> > retrieving revision 1.12
> > diff -u -r1.12 vf_lavc.c
> > --- libmpcodecs/vf_lavc.c	15 Mar 2003 18:01:02 -0000	1.12
> > +++ libmpcodecs/vf_lavc.c	12 Jun 2003 11:59:01 -0000
> > @@ -7,7 +7,7 @@
> >  #include "../mp_msg.h"
> >  #include "../help_mp.h"
> >  
> > -#ifdef USE_LIBAVCODEC
> > +#if defined(USE_LIBAVCODEC) && defined(CONFIG_ENCODERS)
> >  
> 
> did you test your patch???
> if you #ifdef this, you have to #ifdef the reference in vf.c too

Sorry, I've tested it with the wrong version with the swaped #define
and #undef, and it worked, because it build the encoders, when it
shouldn't.
Attached a patch that fixes my 10l in vf.c.


Andreas
-------------- next part --------------
Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.267
diff -u -r1.267 Makefile
--- Makefile	1 Jun 2003 13:39:49 -0000	1.267
+++ Makefile	12 Jun 2003 11:58:25 -0000
@@ -33,7 +33,7 @@
 OBJS_MENCODER = $(SRCS_MENCODER:.c=.o)
 OBJS_MPLAYER = $(SRCS_MPLAYER:.c=.o)
 
-VO_LIBS = $(AA_LIB) $(X_LIB) $(SDL_LIB) $(GGI_LIB) $(MP1E_LIB) $(MLIB_LIB) $(SVGA_LIB) $(DIRECTFB_LIB) 
+VO_LIBS = $(AA_LIB) $(X_LIB) $(SDL_LIB) $(GGI_LIB) $(MLIB_LIB) $(SVGA_LIB) $(DIRECTFB_LIB) 
 AO_LIBS = $(ARTS_LIB) $(ESD_LIB) $(NAS_LIB) $(SGIAUDIO_LIB)
 CODEC_LIBS = $(AV_LIB) $(FAME_LIB) $(MAD_LIB) $(VORBIS_LIB) $(THEORA_LIB) $(FAAD_LIB) $(LIBLZO_LIB) $(DECORE_LIB) $(XVID_LIB) $(PNG_LIB) $(Z_LIB) $(JPEG_LIB) $(ALSA_LIB) $(XMMS_LIB) $(MATROSKA_LIB) 
 COMMON_LIBS = libmpcodecs/libmpcodecs.a mp3lib/libMP3.a liba52/liba52.a libmpeg2/libmpeg2.a $(W32_LIB) $(DS_LIB) libaf/libaf.a libmpdemux/libmpdemux.a input/libinput.a postproc/libswscale.a osdep/libosdep.a $(CSS_LIB) $(CODEC_LIBS) $(FREETYPE_LIB) $(TERMCAP_LIB) $(CDPARANOIA_LIB) $(MPLAYER_NETWORK_LIB) $(WIN32_LIB) $(GIF_LIB) $(MACOSX_FRAMEWORKS) $(SMBSUPPORT_LIB) $(FRIBIDI_LIB)
@@ -80,7 +80,7 @@
 ALL_PRG += $(PRG_FIBMAP)
 endif
 
-COMMON_DEPS = $(W32_DEP) $(DS_DEP) $(MP1E_DEP) $(AV_DEP) libmpdemux/libmpdemux.a libmpcodecs/libmpcodecs.a libao2/libao2.a liba52/liba52.a mp3lib/libMP3.a libmpeg2/libmpeg2.a osdep/libosdep.a postproc/libswscale.a input/libinput.a libvo/libvo.a libaf/libaf.a
+COMMON_DEPS = $(W32_DEP) $(DS_DEP) $(AV_DEP) libmpdemux/libmpdemux.a libmpcodecs/libmpcodecs.a libao2/libao2.a liba52/liba52.a mp3lib/libMP3.a libmpeg2/libmpeg2.a osdep/libosdep.a postproc/libswscale.a input/libinput.a libvo/libvo.a libaf/libaf.a
 
 ifeq ($(VIDIX),yes)
 COMMON_DEPS += libdha/libdha.so vidix/libvidix.a
@@ -241,7 +241,7 @@
 $(MENCODER_DEP): version.h
 
 $(PRG_CFG): version.h codec-cfg.c codec-cfg.h
-	$(CC) $(CFLAGS) -g codec-cfg.c mp_msg.c -o $(PRG_CFG) -DCODECS2HTML $(EXTRA_LIB) $(I18NLIBS)
+	$(CC) $(CFLAGS) codec-cfg.c mp_msg.c -o $(PRG_CFG) -DCODECS2HTML $(EXTRA_LIB) $(I18NLIBS)
 
 install: $(ALL_PRG)
 ifeq ($(VIDIX),yes)
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.725
diff -u -r1.725 configure
--- configure	11 Jun 2003 16:47:39 -0000	1.725
+++ configure	12 Jun 2003 11:58:39 -0000
@@ -270,6 +270,7 @@
   --disable-sighandler   disable sighandler for crashes [enable]
   --enable-i18n          _experimental_ gnu gettext() support [autodetect]
   --enable-dynamic-plugins  Enable support for dynamic a/v plugins [disable]
+  --disable-all-encoders    disable all encoder functions [enable]
 
 Hazardous options a.k.a. "DO NOT REPORT ANY BUGS!"
   --disable-gcc-checking   disable gcc version checking [enable]
@@ -998,7 +999,6 @@
 _libavcodec=auto
 _libavcodecso=auto 
 _fame=auto
-_mp1e=no
 _mencoder=yes
 _x11=auto
 _dga=auto	# 1 2 no auto
@@ -1100,6 +1100,7 @@
 _fribidiconfig='fribidi-config'
 _inet6=auto
 _gethostbyname2=auto
+_all_encoders=yes
 for ac_option do
   case "$ac_option" in
   # Skip 1st pass
@@ -1168,8 +1169,6 @@
   --disable-iconv)	_iconv=no	;;
   --enable-rtc)	        _rtc=yes	;;
   --disable-rtc)	_rtc=no	        ;;
-  --enable-mp1e)	_mp1e=yes	;;
-  --disable-mp1e)	_mp1e=no	;;
   --enable-libdv)	_libdv=yes	;;
   --disable-libdv)	_libdv=no	;;
   --enable-ossaudio)	_ossaudio=yes	;;
@@ -1408,6 +1407,9 @@
   --enable-dshow) _win32=yes _dshow=yes ;;
   --disable-dshow) _dshow=no ;;
 
+  --enable-all-encoders) _all_encoders=yes ;;
+  --disable-all-encoders) _all_encoders=no ;;
+
   --with-x11incdir=*)
     _inc_x11=-I`echo $ac_option | cut -d '=' -f 2 | sed 's,:, -I,g'`
     ;;
@@ -2494,6 +2496,15 @@
 fi
 echores "$_smbsupport"
 
+if test "$_all_encoders" = no ; then
+  _dxr3=no
+  _fame=no
+  _mencoder=no
+  _zr=no
+  _def_config_encoders="#undef CONFIG_ENCODERS"
+else
+  _def_config_encoders="#define CONFIG_ENCODERS 1"
+fi
 
 #########
 # VIDEO #
@@ -3423,32 +3434,9 @@
 else
   _def_dxr3='#undef HAVE_DXR3'
   _novomodules="dxr3 $_novomodules"
-  if test "$_mp1e" = auto ; then
-    # we don't need mp1e
-    _mp1e=no
-  fi
 fi
 echores "$_dxr3"
 
-echocheck "libmp1e"
-if test "$_mmx" = no ; then
-  # mp1e REQUIRES mmx!
-  _mp1e=no
-fi
-if test "$_mp1e" != no ; then
-  _mp1e=yes
-  _def_mp1e='#define USE_MP1E'
-  _ld_mp1e='libmp1e/libmp1e.a'
-  _dep_mp1e='libmp1e/libmp1e.a'
-else
-  _mp1e=no
-  _def_mp1e='#undef USE_MP1E'
-  _ld_mp1e=""
-  _dep_mp1e=''
-fi
-echores "$_mp1e"
-
-
 echocheck "libfame"
 if test "$_fame" = auto ; then
   _fame=no
@@ -5350,8 +5338,6 @@
 AV_LIB = $_ld_libavcodec
 FAME = $_fame
 FAME_LIB = $_ld_fame
-MP1E_DEP = $_dep_mp1e
-MP1E_LIB = $_ld_mp1e
 ARCH_LIB =  $_ld_arch $_ld_iconv
 XVID = $_xvid
 XVID_LIB = $_ld_xvid
@@ -5491,9 +5477,6 @@
    Note: for mencoder */
 $_def_mp3lame
 
-/* Define libmp1e for realtime mpeg encoding (for DXR3 and DVB cards) */
-$_def_mp1e
-
 /* Define this to enable avg. byte/sec-based AVI sync method by default:
    (use -bps or -nobps commandline option for run-time method selection)
    -bps gives better sync for vbr mp3 audio, it is now default */
@@ -5632,8 +5615,8 @@
 
 /* Use libavcodec's decoders */
 #define CONFIG_DECODERS 1
-/* Use libavcodec's encoders */
-#define CONFIG_ENCODERS 1
+/* Use libavcodec's encoders (if we need them) */
+$_def_config_encoders
 
 /* Use codec libs included in mplayer CVS / source dist: */
 #define USE_MP3LIB
@@ -6056,6 +6039,15 @@
 cat <<EOF
 You've disabled VIDIX. Although it would be better to PORT it instead.
 Have a look at the documentation for supported cards!
+
+EOF
+fi
+
+if test "$_all_encoders" = no ; then
+cat <<EOF
+You've disabled support for all encoders, be carefull and be sure you
+know what you do. This might break something or doesn't even compile
+(e. g. libavcodec).
 
 EOF
 fi
Index: libmpcodecs/Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/Makefile,v
retrieving revision 1.98
diff -u -r1.98 Makefile
--- libmpcodecs/Makefile	8 Jun 2003 20:27:25 -0000	1.98
+++ libmpcodecs/Makefile	12 Jun 2003 11:59:00 -0000
@@ -46,7 +46,11 @@
 .c.o:
 	$(CC) -c $(CFLAGS) -o $@ $<
 
+ifeq ($(MENCODER),yes)
 all:    $(LIBNAME) $(LIBNAME2)
+else
+all:    $(LIBNAME)
+endif
 
 $(LIBNAME):     $(OBJS)
 	$(AR) r $(LIBNAME) $(OBJS)
Index: libmpcodecs/vf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf.c,v
retrieving revision 1.84
diff -u -r1.84 vf.c
--- libmpcodecs/vf.c    2 Jun 2003 00:17:36 -0000       1.84
+++ libmpcodecs/vf.c    12 Jun 2003 14:27:22 -0000
@@ -95,7 +95,9 @@
     &vf_info_mirror,
     &vf_info_palette,
 #ifdef USE_LIBAVCODEC
+#ifdef CONFIG_ENCODERS
     &vf_info_lavc,
+#endif
     &vf_info_lavcdeint,
 #endif
     &vf_info_dvbscale,
Index: libmpcodecs/vf_lavc.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_lavc.c,v
retrieving revision 1.12
diff -u -r1.12 vf_lavc.c
--- libmpcodecs/vf_lavc.c	15 Mar 2003 18:01:02 -0000	1.12
+++ libmpcodecs/vf_lavc.c	12 Jun 2003 11:59:01 -0000
@@ -7,7 +7,7 @@
 #include "../mp_msg.h"
 #include "../help_mp.h"
 
-#ifdef USE_LIBAVCODEC
+#if defined(USE_LIBAVCODEC) && defined(CONFIG_ENCODERS)
 
 #include "img_format.h"
 #include "mp_image.h"


More information about the MPlayer-dev-eng mailing list