[MPlayer-dev-eng] [PATCH] multi-threaded lavc
Loren Merritt
lorenm at u.washington.edu
Tue Jul 6 00:51:28 CEST 2004
Patch allows use of libavcodec's multi-threaded encoding.
The results are not bitwise identical to a single-threaded encode, but
I don't see any difference in quality, either PSNR or by eye.
I'm not sure of the configure stuff - I don't have a computer without
pthreads.
--Loren Merritt
-------------- next part --------------
--- configure.bak Mon Jul 5 02:42:28 2004
+++ configure Mon Jul 5 15:31:15 2004
@@ -2496,8 +2496,12 @@
fi
if test "$_ld_pthread" != '' ; then
echores "yes (using $_ld_pthread)"
+ _pthreads='yes'
+ _def_pthreads='#define HAVE_PTHREADS 1'
else
echores "no"
+ _pthreads=''
+ _def_pthreads='#undef HAVE_PTHREADS'
fi
@@ -6134,6 +6138,7 @@
WIN32_LIB = $_ld_win32libs
STATIC_LIB = $_ld_static
ENCA_LIB = $_ld_enca
+HAVE_PTHREADS = $_pthreads
X11_INC = $_inc_x11
X11DIR = $_ld_x11
@@ -6478,6 +6483,9 @@
/* Define this if your system has glob */
$_def_glob
+/* Define this if your system has pthreads */
+$_def_pthreads
+
/* LIRC (remote control, see www.lirc.org) support: */
$_def_lirc
--- libmpcodecs/ve_lavc.c.bak 2004-06-07 10:31:50.000000000 -0700
+++ libmpcodecs/ve_lavc.c 2004-07-05 14:46:56.000000000 -0700
@@ -150,6 +150,7 @@
static int lavc_param_alt= 0;
static int lavc_param_ilme= 0;
static int lavc_param_nssew= 8;
+static int lavc_param_threads= 1;
char *lavc_param_acodec = "mp2";
@@ -292,6 +293,7 @@
{"top", &lavc_param_top, CONF_TYPE_INT, CONF_RANGE, -1, 1, NULL},
{"qns", &lavc_param_qns, CONF_TYPE_INT, CONF_RANGE, 0, 1000000, NULL},
{"nssew", &lavc_param_nssew, CONF_TYPE_INT, CONF_RANGE, 0, 1000000, NULL},
+ {"threads", &lavc_param_threads, CONF_TYPE_INT, CONF_RANGE, 1, 8, NULL},
{NULL, NULL, 0, 0, 0, 0, NULL}
};
#endif
@@ -661,6 +663,11 @@
#endif
vf->priv->pic->quality = (int)(FF_QP2LAMBDA * lavc_param_vqscale + 0.5);
}
+
+#if LIBAVCODEC_BUILD >= 4716
+ if(lavc_param_threads > 1)
+ avcodec_thread_init(lavc_venc_context, lavc_param_threads);
+#endif
if (avcodec_open(lavc_venc_context, vf->priv->codec) != 0) {
mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CantOpenCodec);
More information about the MPlayer-dev-eng
mailing list