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

Andreas Hess jaska at gmx.net
Sun Jun 15 09:29:04 CEST 2003


On Fri, Jun 13, 2003 at 02:14:38AM +0200, Diego Biurrun wrote:
> Hmm, I do not like that wording very much (and careful is spelt with
> only one "l" BTW).  What about this: [...]

Here are the updated patches.
-------------- 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	14 Jun 2003 10:08:51 -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
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.726
diff -u -r1.726 configure
--- configure	13 Jun 2003 01:25:08 -0000	1.726
+++ configure	14 Jun 2003 10:09:00 -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
+  _mencoder=no
+  if test "$_dxr3" = auto ; then _dxr3=no ; fi
+  if test "$_fame" = auto ; then _fame=no ; fi
+  if test "$_zr" = auto ; then _zr=no ; fi
+  _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,14 @@
 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 have disabled support for all encoders. Make sure you know what
+you are doing, this might break compilation and proper functioning.
 
 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	14 Jun 2003 10:09:14 -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	14 Jun 2003 10:09:16 -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	14 Jun 2003 10:09:16 -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"
-------------- next part --------------
Index: libavcodec/ffv1.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/ffv1.c,v
retrieving revision 1.3
diff -u -r1.3 ffv1.c
--- libavcodec/ffv1.c	13 Jun 2003 21:31:28 -0000	1.3
+++ libavcodec/ffv1.c	14 Jun 2003 10:08:38 -0000
@@ -209,6 +209,7 @@
 /**
  * put 
  */
+#ifdef CONFIG_ENCODERS
 static inline void put_symbol(CABACContext *c, uint8_t *state, int v, int is_signed){
     int i;
 
@@ -230,6 +231,7 @@
         put_cabac(c, state+0, 1);
     }
 }
+#endif //CONFIG_ENCODERS
 
 static inline int get_symbol(CABACContext *c, uint8_t *state, int is_signed){
     int i;
@@ -287,6 +289,7 @@
     state->count= count;
 }
 
+#ifdef CONFIG_ENCODERS
 static inline void put_vlc_symbol(PutBitContext *pb, VlcState * const state, int v){
     int i, k, code;
 //printf("final: %d ", v);
@@ -312,6 +315,7 @@
 
     update_vlc_state(state, v);
 }
+#endif //CONFIG_ENCODERS
 
 static inline int get_vlc_symbol(GetBitContext *gb, VlcState * const state){
     int k, i, v, ret;
@@ -345,6 +349,7 @@
 
 
 
+#ifdef CONFIG_ENCODERS
 static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index){
     PlaneContext * const p= &s->plane[plane_index];
     CABACContext * const c= &s->c;
@@ -457,6 +462,7 @@
     for(i=0; i<5; i++)
         write_quant_table(c, f->quant_table[i]);
 }
+#endif //CONFIG_ENCODERS
 
 static int common_init(AVCodecContext *avctx){
     FFV1Context *s = avctx->priv_data;
@@ -475,6 +481,7 @@
     return 0;
 }
 
+#ifdef CONFIG_ENCODERS
 static int encode_init(AVCodecContext *avctx)
 {
     FFV1Context *s = avctx->priv_data;
@@ -535,6 +542,7 @@
     
     return 0;
 }
+#endif //CONFIG_ENCODERS
 
 
 static void clear_state(FFV1Context *f){
@@ -560,6 +568,7 @@
     }
 }
 
+#ifdef CONFIG_ENCODERS
 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
     FFV1Context *f = avctx->priv_data;
     CABACContext * const c= &f->c;
@@ -636,6 +645,7 @@
 
     return 0;
 }
+#endif //CONFIG_ENCODERS
 
 static void decode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index){
     PlaneContext * const p= &s->plane[plane_index];
@@ -905,6 +915,7 @@
     NULL
 };
 
+#ifdef CONFIG_ENCODERS
 AVCodec ffv1_encoder = {
     "ffv1",
     CODEC_TYPE_VIDEO,
@@ -914,3 +925,4 @@
     encode_frame,
     encode_end,
 };
+#endif //CONFIG_ENCODERS
Index: libavcodec/h264.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/h264.c,v
retrieving revision 1.16
diff -u -r1.16 h264.c
--- libavcodec/h264.c	24 May 2003 18:48:29 -0000	1.16
+++ libavcodec/h264.c	14 Jun 2003 10:08:47 -0000

     return dst;
 }
 
+#ifdef CONFIG_ENCODERS
 /**
  * @param src the data which should be escaped
  * @param dst the target buffer, dst+1 == src is allowed as a special case
@@ -1072,6 +1073,7 @@
     length= (-get_bit_count(pb))&7;
     if(length) put_bits(pb, length, 0);
 }
+#endif //CONFIG_ENCODERS
 
 /**
  * identifies the exact end of the bitstream
Index: libavcodec/mjpeg.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/mjpeg.c,v
retrieving revision 1.61
diff -u -r1.61 mjpeg.c
--- libavcodec/mjpeg.c	23 May 2003 16:04:24 -0000	1.61
+++ libavcodec/mjpeg.c	14 Jun 2003 10:08:50 -0000
@@ -241,6 +241,7 @@
     }
 }
 
+#ifdef CONFIG_ENCODERS
 int mjpeg_init(MpegEncContext *s)
 {
     MJpegContext *m;
@@ -631,6 +632,7 @@
         encode_block(s, block[i], i);
     }
 }
+#endif //CONFIG_ENCODER
 
 /******************************************/
 /* decoding */
Index: libavcodec/mpeg12.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/mpeg12.c,v
retrieving revision 1.113
diff -u -r1.113 mpeg12.c
--- libavcodec/mpeg12.c	30 May 2003 00:02:25 -0000	1.113
+++ libavcodec/mpeg12.c	14 Jun 2003 10:08:55 -0000
@@ -48,11 +48,13 @@
 #define MB_BTYPE_VLC_BITS 6
 #define TEX_VLC_BITS 9
 
+#ifdef CONFIG_ENCODERS
 static void mpeg1_encode_block(MpegEncContext *s, 
                          DCTELEM *block, 
                          int component);
 static void mpeg1_encode_motion(MpegEncContext *s, int val, int f_or_b_code);    // RAL: f_code parameter added
 static void mpeg1_skip_picture(MpegEncContext *s, int pict_num);
+#endif //CONFIG_ENCODERS
 static inline int mpeg1_decode_block_inter(MpegEncContext *s, 
                               DCTELEM *block, 
                               int n);
@@ -114,6 +116,7 @@
     }
 }
 
+#ifdef CONFIG_ENCODERS
 static void init_uni_ac_vlc(RLTable *rl, uint32_t *uni_ac_vlc_bits, uint8_t *uni_ac_vlc_len){
     int i;
 
@@ -309,6 +312,7 @@
     put_bits(&s->pb, 1, 1); 
     put_bits(&s->pb, 1, 1); 
 }
+#endif //CONFIG_ENCODERS
 
 static void common_init(MpegEncContext *s)
 {
@@ -324,6 +328,8 @@
     put_bits(&s->pb, 1, 0); /* slice extra information */
 }
 
+#endif //CONFIG_ENCODERS
+
 void ff_mpeg1_clean_buffers(MpegEncContext *s){
     s->last_dc[0] = 1 << (7 + s->intra_dc_precision);
     s->last_dc[1] = s->last_dc[0];
@@ -331,6 +337,7 @@
     memset(s->last_mv, 0, sizeof(s->last_mv));
 }
 
+#ifdef CONFIG_ENCODERS
 void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
 {
     mpeg1_encode_sequence_header(s);
Index: libavcodec/mpeg12data.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/mpeg12data.h,v
retrieving revision 1.17
diff -u -r1.17 mpeg12data.h
--- libavcodec/mpeg12data.h	11 Apr 2003 21:15:17 -0000	1.17
+++ libavcodec/mpeg12data.h	14 Jun 2003 10:08:56 -0000
@@ -63,8 +63,10 @@
 };
 
 /* simple include everything table for dc, first byte is bits number next 3 are code*/
+#ifdef CONFIG_ENCODERS
 static uint32_t mpeg1_lum_dc_uni[512];
 static uint32_t mpeg1_chr_dc_uni[512];
+#endif //CONFIG_ENCODERS
 
 static const uint16_t mpeg1_vlc[113][2] = {
  { 0x3, 2 }, { 0x4, 4 }, { 0x5, 5 }, { 0x6, 7 },
@@ -166,8 +168,10 @@
  25, 26, 27, 28, 29, 30, 31,
 };
 
+#ifdef CONFIG_ENCODERS
 static uint8_t mpeg1_index_run[2][64];
 static int8_t mpeg1_max_level[2][64];
+#endif //CONFIG_ENCODERS
 
 static RLTable rl_mpeg1 = {
     111,
Index: libavcodec/msmpeg4.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/msmpeg4.c,v
retrieving revision 1.71
diff -u -r1.71 msmpeg4.c
--- libavcodec/msmpeg4.c	19 May 2003 13:30:58 -0000	1.71
+++ libavcodec/msmpeg4.c	14 Jun 2003 10:09:00 -0000
@@ -86,7 +86,9 @@
 
 #include "msmpeg4data.h"
 
+#ifdef CONFIG_ENCODERS
 static uint8_t rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2];
+#endif //CONFIG_ENCODERS
 
 #ifdef STATS
 
Index: libavcodec/wmv2.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/wmv2.c,v
retrieving revision 1.16
diff -u -r1.16 wmv2.c
--- libavcodec/wmv2.c	19 May 2003 13:30:58 -0000	1.16
+++ libavcodec/wmv2.c	14 Jun 2003 10:09:02 -0000
@@ -59,6 +59,7 @@
     ff_init_scantable(s->dsp.idct_permutation, &w->abt_scantable[1], wmv2_scantableB);
 }
 
+#ifdef CONFIG_ENCODERS
 static int encode_ext_header(Wmv2Context *w){
     MpegEncContext * const s= &w->s;
     PutBitContext pb;
@@ -84,7 +85,6 @@
     return 0;
 }
 
-#ifdef CONFIG_ENCODERS
 static int wmv2_encode_init(AVCodecContext *avctx){
     Wmv2Context * const w= avctx->priv_data;
     


More information about the MPlayer-dev-eng mailing list