[FFmpeg-devel] [PATCH 4/5] lavc: add frame multithreading capability (currently intra only)
Michael Niedermayer
michaelni at gmx.at
Sat Jun 23 00:30:54 CEST 2012
On Fri, Jun 15, 2012 at 11:45:46AM +0200, Jean First wrote:
> Hi,
>
> On Thu Jun 14 2012 23:09:08 GMT+0200 (CEST), Michael Niedermayer wrote:
> >Compared to the decoder side, this code is able to change both the
> >delay and the number of threads seamlessly during encoding. Also
> >any idle thread can pick up tasks, the strict round robin in order
> >limit is gone too.
> >
> >Signed-off-by: Michael Niedermayer<michaelni at gmx.at>
> >---
> > libavcodec/Makefile | 6 +-
> > libavcodec/frame_thread_encoder.c | 248 +++++++++++++++++++++++++++++++++++++
> > libavcodec/frame_thread_encoder.h | 26 ++++
> > libavcodec/internal.h | 2 +
> > libavcodec/utils.c | 20 ++-
> > 5 files changed, 297 insertions(+), 5 deletions(-)
> > create mode 100644 libavcodec/frame_thread_encoder.c
> > create mode 100644 libavcodec/frame_thread_encoder.h
> >
> >diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> >index 851fe1d..27fa556 100644
> >--- a/libavcodec/Makefile
> >+++ b/libavcodec/Makefile
> >@@ -755,9 +755,9 @@ OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += remove_extradata_bsf.o
> > OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += movsub_bsf.o
> >
> > # thread libraries
> >-OBJS-$(HAVE_PTHREADS) += pthread.o
> >-OBJS-$(HAVE_W32THREADS) += pthread.o
> >-OBJS-$(HAVE_OS2THREADS) += pthread.o
> >+OBJS-$(HAVE_PTHREADS) += pthread.o frame_thread_encoder.o
> >+OBJS-$(HAVE_W32THREADS) += pthread.o frame_thread_encoder.o
> >+OBJS-$(HAVE_OS2THREADS) += pthread.o frame_thread_encoder.o
> >
> > # inverse.o contains the ff_inverse table definition, which is used by
> > # the FASTDIV macro (from libavutil); since referencing the external
> >diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c
> >new file mode 100644
> >index 0000000..fd2f379
> >--- /dev/null
> >+++ b/libavcodec/frame_thread_encoder.c
> >@@ -0,0 +1,248 @@
> >+/*
> >+ * Copyright (c) 2012 Michael Niedermayer<michaelni at gmx.at>
> >+ *
> >+ * This file is part of FFmpeg.
> >+ *
> >+ * FFmpeg is free software; you can redistribute it and/or
> >+ * modify it under the terms of the GNU Lesser General Public
> >+ * License as published by the Free Software Foundation; either
> >+ * version 2.1 of the License, or (at your option) any later version.
> >+ *
> >+ * FFmpeg is distributed in the hope that it will be useful,
> >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> >+ * Lesser General Public License for more details.
> >+ *
> >+ * You should have received a copy of the GNU Lesser General Public
> >+ * License along with FFmpeg; if not, write to the Free Software
> >+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> >+ */
> >+
> >+#include "frame_thread_encoder.h"
> >+
> >+#include "libavutil/fifo.h"
> >+#include "libavutil/avassert.h"
> >+#include "libavutil/imgutils.h"
> >+#include "avcodec.h"
> >+#include "internal.h"
> >+#include "thread.h"
> >+
> >+#if HAVE_PTHREADS
> >+#include<pthread.h>
> >+#elif HAVE_W32THREADS
> >+#include "w32pthreads.h"
> >+#elif HAVE_OS2THREADS
> >+#include "os2threads.h"
> >+#endif
> >+
> >+#define MAX_THREADS 64
>
> mpegvideo.h already defines MAX_THREADS
> pthread.c defines MAX_AUTO_THREADS
>
> could we unify this somwhow ?
the values dont match
I dont want to reduce the new limit (would be kind of silly)
and:---
/* H264 slice threading seems to be buggy with more than 16 threads,
* limit the number of threads to 16 for automatic detection */
#define MAX_AUTO_THREADS 16
----
sounds like increasing the other limits needs some minor investigation.
i suspect i know where the problem is with the >16 ...
but such unification and value change is better done in a seperate
patch
Thus applied this one
thanks to all for the reviews!
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
You can kill me, but you cannot change the truth.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120623/bc78df2c/attachment.asc>
More information about the ffmpeg-devel
mailing list