[FFmpeg-devel] [PATCH 4/5] lavc: add frame multithreading capability (currently intra only)

Jean First jeanfirst at gmail.com
Fri Jun 15 11:45:46 CEST 2012


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 ?

Jean


More information about the ffmpeg-devel mailing list