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

Andreas Hess jaska at gmx.net
Sat Jun 7 00:10:39 CEST 2003


Hi,

while looking at the configure I saw that the libavcodec encoders
are always build wether we need them or not. So if mplayer is build
without mencoder, there is no need for the encoding support in
libavcodec.
Only problem is, to get this to work there are some changes to
libavcodec needed (some missing #ifdef's). I'm not subscribed to
the ffmpeg-devel list, so maybe someone from this list, who has
ffmpeg cvs access can apply the second patch (the first patch is
the small change to the configure).


Andreas
-------------- next part --------------
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.719
diff -u -r1.719 configure
--- configure	30 May 2003 18:23:52 -0000	1.719
+++ configure	30 May 2003 21:39:28 -0000
@@ -5599,8 +5599,10 @@
 
 /* Use libavcodec's decoders */
 #define CONFIG_DECODERS 1
-/* Use libavcodec's encoders */
+/* Use libavcodec's encoders (if we need them) */
+#ifdef HAVE_MENCODER
 #define CONFIG_ENCODERS 1
+#endif
 
 /* Use codec libs included in mplayer CVS / source dist: */
 #define USE_MP3LIB
-------------- next part --------------
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	30 May 2003 21:06:15 -0000
@@ -1000,6 +1000,8 @@
     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 +1074,8 @@
     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	30 May 2003 21:06:18 -0000
@@ -241,6 +241,8 @@
     }
 }
 
+#ifdef CONFIG_ENCODERS
+
 int mjpeg_init(MpegEncContext *s)
 {
     MJpegContext *m;
@@ -631,6 +633,8 @@
         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	30 May 2003 21:06:23 -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,8 @@
     }
 }
 
+#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;
 
@@ -310,6 +314,8 @@
     put_bits(&s->pb, 1, 1); 
 }
 
+#endif //CONFIG_ENCODERS
+
 static void common_init(MpegEncContext *s)
 {
     s->y_dc_scale_table=
@@ -324,12 +330,16 @@
     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];
     s->last_dc[2] = s->last_dc[0];
     memset(s->last_mv, 0, sizeof(s->last_mv));
 }
+
+#ifdef CONFIG_ENCODERS
 
 void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
 {
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	30 May 2003 21:06:24 -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,


More information about the MPlayer-dev-eng mailing list