[MPlayer-dev-eng] [PATCH#2] make the mplayer binary several 100k smaller
Andreas Hess
jaska at gmx.net
Thu Jun 12 14:25:27 CEST 2003
On Sat, Jun 07, 2003 at 12:24:06PM +0200, Arpi wrote:
> > Well we could do #if defined (HAVE_MENCODER) || defined (HAVE_DXR3) ||
>
> not ok, as there are filters like -vf lavc, which dont depend on any
> optional vo driver.
>
> but some --disable-all-encoders option could do the job.
> so embedded system makers could use it.
The attached patch implements --disable-all-encoders. It also removes the
checks for mp1e, because it's no longer needed.
The second patch includes the necessary changes to libavcodec.
The third patch is just a small update to support the latest version of
the 3ivx codec.
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="#define CONFIG_ENCODERS 1"
+else
+ _def_config_encoders="#undef CONFIG_ENCODERS"
+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_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"
-------------- next part --------------
Index: libavcodec/ffv1.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/ffv1.c,v
retrieving revision 1.2
diff -u -r1.2 ffv1.c
--- libavcodec/ffv1.c 9 Jun 2003 23:55:16 -0000 1.2
+++ libavcodec/ffv1.c 12 Jun 2003 11:58:47 -0000
@@ -216,6 +216,8 @@
}
#endif
+#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;
@@ -289,6 +291,8 @@
}
}
+#endif //CONFIG_ENCODERS
+
static int common_init(AVCodecContext *avctx){
FFV1Context *s = avctx->priv_data;
int width, height;
@@ -306,6 +310,7 @@
return 0;
}
+#ifdef CONFIG_ENCODERS
static int encode_init(AVCodecContext *avctx)
{
FFV1Context *s = avctx->priv_data;
@@ -350,7 +355,7 @@
return 0;
}
-
+#endif //CONFIG_ENCODERS
static void clear_state(FFV1Context *f){
int i, j;
@@ -368,6 +373,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;
@@ -433,6 +439,8 @@
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];
CABACContext * const c= &s->c;
@@ -642,6 +650,7 @@
NULL
};
+#ifdef CONFIG_ENCODERS
AVCodec ffv1_encoder = {
"ffv1",
CODEC_TYPE_VIDEO,
@@ -651,3 +660,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 12 Jun 2003 11:59:01 -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 12 Jun 2003 11:59:05 -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 12 Jun 2003 11:59:13 -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 12 Jun 2003 11:59:14 -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,
-------------- next part --------------
Index: etc/codecs.conf
===================================================================
RCS file: /cvsroot/mplayer/main/etc/codecs.conf,v
retrieving revision 1.282
diff -u -r1.282 codecs.conf
--- etc/codecs.conf 9 Jun 2003 02:30:40 -0000 1.282
+++ etc/codecs.conf 12 Jun 2003 11:58:54 -0000
@@ -1093,7 +1093,7 @@
status working
fourcc 3IV1
driver qtvideo
- dll "3ivx Delta 3.5.qtx"
+ dll "3ivxD4_404.qtx"
out YUY2
videocodec qth263
More information about the MPlayer-dev-eng
mailing list