[MPlayer-dev-eng] [RFC] the future of libmpeg2
Dominik 'Rathann' Mierzejewski
dominik at rangers.eu.org
Wed Aug 20 01:54:21 CEST 2008
On Monday, 14 July 2008 at 10:51, Diego Biurrun wrote:
> libmpeg2 0.5.0 was just released and it contains all the MPlayer patches
> I sent them. I was going to sync our internal libmpeg2 copy with the
> release, but I'm no longer sure this is really worth it. We now use
> FFmmpeg as default MPEG-1/2 decoder, so we might as well drop the
> internal libmpeg2 copy, possibly adding support for compiling against
> external libmpeg2. Thoughts?
Skeleton patch (compiles, but doesn't work) adding support
for external libmpeg2 attached. Someone familiar with MPlayer internals
please fill the missing parts in each
#ifdef CONFIG_LIBMPEG2_INTERNAL
#else
#endif
block.
Regards,
R.
--
MPlayer http://mplayerhq.hu | Livna http://rpm.livna.org
There should be a science of discontent. People need hard times and
oppression to develop psychic muscles.
-- from "Collected Sayings of Muad'Dib" by the Princess Irulan
-------------- next part --------------
diff -up mplayer-export-2008-08-18/configure.libmpeg2 mplayer-export-2008-08-18/configure
--- mplayer-export-2008-08-18/configure.libmpeg2 2008-08-19 00:52:31.000000000 +0200
+++ mplayer-export-2008-08-18/configure 2008-08-20 01:00:24.000000000 +0200
@@ -321,7 +321,8 @@ Codecs:
--enable-libdca enable libdca support [autodetect]
--disable-mp3lib disable builtin mp3lib [enabled]
--disable-liba52 disable builtin liba52 [enabled]
- --disable-libmpeg2 disable builtin libmpeg2 [autodetect]
+ --enable-libmpeg2-external enable external libmpeg2 [autodetect]
+ --disable-libmpeg2-internal disable builtin libmpeg2 [autodetect]
--disable-musepack disable musepack support [autodetect]
--disable-libamr_nb disable libamr narrowband [autodetect]
--disable-libamr_wb disable libamr wideband [autodetect]
@@ -576,7 +577,8 @@ _theora=auto
_mp3lib=yes
_liba52=yes
_libdca=auto
-_libmpeg2=auto
+_libmpeg2_internal=auto
+_libmpeg2_external=auto
_faad_internal=auto
_faad_external=auto
_faad_fixed=no
@@ -942,8 +944,10 @@ for ac_option do
--disable-liba52) _liba52=no ;;
--enable-libdca) _libdca=yes ;;
--disable-libdca) _libdca=no ;;
- --enable-libmpeg2) _libmpeg2=yes ;;
- --disable-libmpeg2) _libmpeg2=no ;;
+ --enable-libmpeg2-internal) _libmpeg2_internal=yes ;;
+ --disable-libmpeg2-internal) _libmpeg2_internal=no ;;
+ --enable-libmpeg2-external) _libmpeg2_external=yes ;;
+ --disable-libmpeg2-external) _libmpeg2_external=no ;;
--enable-musepack) _musepack=yes ;;
--disable-musepack) _musepack=no ;;
--enable-faad-internal) _faad_internal=yes ;;
@@ -6063,21 +6067,46 @@ else
fi
echores "$_liba52"
-echocheck "internal libmpeg2 support"
-if test "$_libmpeg2" = auto ; then
- _libmpeg2=yes
+echocheck "libmpeg2 support"
+if test "$_libmpeg2_internal" = auto ; then
+ _libmpeg2_internal=yes
if alpha && test cc_vendor=gnu; then
case $cc_version in
2*|3.0*|3.1*) # cannot compile MVI instructions
- _libmpeg2=no
+ _libmpeg2_internal=no
_res_comment="broken gcc"
;;
esac
fi
+elif test "$_libmpeg2_internal" = no && test "$_libmpeg2_external" = auto ; then
+ _libmpeg2_external=no
+ cat > $TMPC << EOF
+#include <inttypes.h>
+#include <mpeg2.h>
+int main(void) { mpeg2dec_t *testHand; testHand = mpeg2_init(); return 0; }
+EOF
+ if $_pkg_config --exists libmpeg2 ; then
+ _libmpeg2cflags=`$_pkg_config --cflags libmpeg2`
+ _libmpeg2libs=`$_pkg_config --libs libmpeg2`
+ cc_check $_libmpeg2cflags $_libmpeg2libs && _libmpeg2_external=yes
+ fi
+fi
+if test "$_libmpeg2_internal" = yes ; then
+ _def_libmpeg2_internal="#define CONFIG_LIBMPEG2_INTERNAL 1"
+ _res_comment="internal"
+ _libmpeg2=yes
+elif test "$_libmpeg2_external" = yes ; then
+ _ld_extra="$_ld_extra $_libmpeg2libs"
+ _inc_extra="$_inc_extra $_libmpeg2cflags"
+ _res_comment="external"
+ _libmpeg2=yes
+else
+ _def_libmpeg2_internal="#undef CONFIG_LIBMPEG2_INTERNAL"
+ _libmpeg2=no
fi
if test "$_libmpeg2" = yes ; then
_def_libmpeg2='#define CONFIG_LIBMPEG2 1'
- _codecmodules="libmpeg2 $_codecmodules"
+ _codecmodules="libmpeg2($_res_comment) $_codecmodules"
else
_def_libmpeg2='#undef CONFIG_LIBMPEG2'
_nocodecmodules="libmpeg2 $_nocodecmodules"
@@ -8354,6 +8383,9 @@ $_def_xvid_lavc
/* Use codec libs included in mplayer CVS / source dist: */
$_def_mp3lib
$_def_liba52
+
+/* enable libmpeg2 support */
+$_def_libmpeg2_internal
$_def_libmpeg2
/* XAnim DLL support */
diff -up mplayer-export-2008-08-18/libmpcodecs/vd_libmpeg2.c.libmpeg2 mplayer-export-2008-08-18/libmpcodecs/vd_libmpeg2.c
--- mplayer-export-2008-08-18/libmpcodecs/vd_libmpeg2.c.libmpeg2 2008-05-01 14:30:29.000000000 +0200
+++ mplayer-export-2008-08-18/libmpcodecs/vd_libmpeg2.c 2008-08-20 01:47:49.000000000 +0200
@@ -22,9 +22,13 @@ LIBVD_EXTERN(libmpeg2)
//#include "libvo/video_out.h" // FIXME!!!
+#ifndef CONFIG_LIBMPEG2_INTERNAL
+#include <mpeg2.h>
+#else
#include "libmpeg2/mpeg2.h"
#include "libmpeg2/attributes.h"
#include "libmpeg2/mpeg2_internal.h"
+#endif
#include "cpudetect.h"
@@ -102,8 +106,10 @@ static int init(sh_video_t *sh){
context->mpeg2dec = mpeg2dec;
sh->context = context;
+#ifdef CONFIG_LIBMPEG2_INTERNAL
mpeg2dec->pending_buffer = 0;
mpeg2dec->pending_length = 0;
+#endif
return 1;
}
@@ -113,9 +119,11 @@ static void uninit(sh_video_t *sh){
int i;
vd_libmpeg2_ctx_t *context = sh->context;
mpeg2dec_t * mpeg2dec = context->mpeg2dec;
+#ifdef CONFIG_LIBMPEG2_INTERNAL
if (mpeg2dec->pending_buffer) free(mpeg2dec->pending_buffer);
mpeg2dec->decoder.convert=NULL;
mpeg2dec->decoder.convert_id=NULL;
+#endif
mpeg2_close (mpeg2dec);
for (i=0; i < 3; i++)
free(context->quant_store[i]);
@@ -131,8 +139,10 @@ static void draw_slice (void * _sh, uint
// printf("draw_slice() y=%d \n",y);
+#ifdef CONFIG_LIBMPEG2_INTERNAL
stride[0]=mpeg2dec->decoder.stride;
stride[1]=stride[2]=mpeg2dec->decoder.uv_stride;
+#endif
mpcodecs_draw_slice(sh, (uint8_t **)src,
stride, info->sequence->picture_width,
@@ -148,9 +158,11 @@ static mp_image_t* decode(sh_video_t *sh
const mpeg2_info_t * info = mpeg2_info (mpeg2dec);
int drop_frame, framedrop=flags&3;
+#ifdef CONFIG_LIBMPEG2_INTERNAL
// MPlayer registers its own draw_slice callback, prevent libmpeg2 from freeing the context
mpeg2dec->decoder.convert=NULL;
mpeg2dec->decoder.convert_id=NULL;
+#endif
if(len<=0) return NULL; // skipped null frame
@@ -161,11 +173,12 @@ static mp_image_t* decode(sh_video_t *sh
((char*)data+len)[3]=0xff;
len+=4;
+#ifdef CONFIG_LIBMPEG2_INTERNAL
if (mpeg2dec->pending_length) {
mpeg2_buffer (mpeg2dec, mpeg2dec->pending_buffer, mpeg2dec->pending_buffer + mpeg2dec->pending_length);
- } else {
+ } else
+#endif
mpeg2_buffer (mpeg2dec, data, (uint8_t *)data+len);
- }
while(1){
int state=mpeg2_parse (mpeg2dec);
@@ -176,14 +189,15 @@ static mp_image_t* decode(sh_video_t *sh
switch(state){
case STATE_BUFFER:
+#ifdef CONFIG_LIBMPEG2_INTERNAL
if (mpeg2dec->pending_length) {
// just finished the pending data, continue with processing of the passed buffer
mpeg2dec->pending_length = 0;
mpeg2_buffer (mpeg2dec, data, (uint8_t *)data+len);
- } else {
+ } else
+#endif
// parsing of the passed buffer finished, return.
return 0;
- }
break;
case STATE_SEQUENCE:
pw = info->sequence->display_width * info->sequence->pixel_width;
@@ -214,7 +228,11 @@ static mp_image_t* decode(sh_video_t *sh
case STATE_PICTURE:
type=info->current_picture->flags&PIC_MASK_CODING_TYPE;
+#ifdef CONFIG_LIBMPEG2_INTERNAL
drop_frame = framedrop && (mpeg2dec->decoder.coding_type == B_TYPE);
+#else
+ drop_frame = framedrop; //FIXME
+#endif
drop_frame |= framedrop>=2; // hard drop
if (drop_frame) {
mpeg2_skip(mpeg2dec, 1);
@@ -249,6 +267,7 @@ static mp_image_t* decode(sh_video_t *sh
if (!(info->current_picture->flags&PIC_FLAG_PROGRESSIVE_FRAME))
mpi_new->fields |= MP_IMGFIELD_INTERLACED;
+#ifdef CONFIG_LIBMPEG2_INTERNAL
#ifdef MPEG12_POSTPROC
mpi_new->qstride=info->sequence->width>>4;
{
@@ -272,6 +291,7 @@ static mp_image_t* decode(sh_video_t *sh
mpeg2dec->decoder.convert=NULL;
mpeg2dec->decoder.convert_id=NULL;
}
+#endif
break;
case STATE_SLICE:
@@ -280,6 +300,7 @@ static mp_image_t* decode(sh_video_t *sh
// decoding done:
if(info->display_fbuf) {
mp_image_t* mpi = info->display_fbuf->id;
+#ifdef CONFIG_LIBMPEG2_INTERNAL
if (mpeg2dec->pending_length == 0) {
mpeg2dec->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start;
mpeg2dec->pending_buffer = realloc(mpeg2dec->pending_buffer, mpeg2dec->pending_length);
@@ -293,6 +314,9 @@ static mp_image_t* decode(sh_video_t *sh
mpeg2dec->pending_length += len;
}
// fprintf(stderr, "pending = %d\n", mpeg2dec->pending_length);
+#else
+// FIXME
+#endif
return mpi;
}
}
diff -up mplayer-export-2008-08-18/Makefile.libmpeg2 mplayer-export-2008-08-18/Makefile
--- mplayer-export-2008-08-18/Makefile.libmpeg2 2008-08-19 00:52:31.000000000 +0200
+++ mplayer-export-2008-08-18/Makefile 2008-08-20 00:43:50.000000000 +0200
@@ -343,8 +343,8 @@ SRCS_COMMON-$(LIBDVDCSS_INTERNAL) +=
libdvdcss/libdvdcss.c \
SRCS_COMMON-$(LIBMAD) += libmpcodecs/ad_libmad.c
-SRCS_COMMON-$(LIBMPEG2) += libmpcodecs/vd_libmpeg2.c \
- libmpeg2/alloc.c \
+SRCS_COMMON-$(LIBMPEG2) += libmpcodecs/vd_libmpeg2.c
+SRCS_COMMON-$(LIBMPEG2_INTERNAL) += libmpeg2/alloc.c \
libmpeg2/cpu_accel.c\
libmpeg2/cpu_state.c \
libmpeg2/decode.c \
@@ -352,16 +352,16 @@ SRCS_COMMON-$(LIBMPEG2) +=
libmpeg2/idct.c \
libmpeg2/motion_comp.c \
libmpeg2/slice.c
-SRCS_COMMON-$(LIBMPEG2)-$(ARCH_ALPHA) += libmpeg2/idct_alpha.c \
+SRCS_COMMON-$(LIBMPEG2_INTERNAL)-$(ARCH_ALPHA) += libmpeg2/idct_alpha.c \
libmpeg2/motion_comp_alpha.c
-SRCS_COMMON-$(LIBMPEG2)-$(ARCH_ARMV4L) += libmpeg2/motion_comp_arm.c \
+SRCS_COMMON-$(LIBMPEG2_INTERNAL)-$(ARCH_ARMV4L) += libmpeg2/motion_comp_arm.c \
libmpeg2/motion_comp_arm_s.S \
libmpeg2/motion_comp_iwmmxt.c
-SRCS_COMMON-$(LIBMPEG2)-$(HAVE_ALTIVEC) += libmpeg2/idct_altivec.c \
+SRCS_COMMON-$(LIBMPEG2_INTERNAL)-$(HAVE_ALTIVEC) += libmpeg2/idct_altivec.c \
libmpeg2/motion_comp_altivec.c
-SRCS_COMMON-$(LIBMPEG2)-$(HAVE_MMX) += libmpeg2/idct_mmx.c \
+SRCS_COMMON-$(LIBMPEG2_INTERNAL)-$(HAVE_MMX) += libmpeg2/idct_mmx.c \
libmpeg2/motion_comp_mmx.c
-SRCS_COMMON-$(LIBMPEG2)-$(HAVE_VIS) += libmpeg2/motion_comp_vis.c
+SRCS_COMMON-$(LIBMPEG2_INTERNAL)-$(HAVE_VIS) += libmpeg2/motion_comp_vis.c
SRCS_COMMON-$(LIBNEMESI) += libmpdemux/demux_nemesi.c \
stream/stream_nemesi.c
SRCS_COMMON-$(LIBNUT) += libmpdemux/demux_nut.c
More information about the MPlayer-dev-eng
mailing list