[FFmpeg-devel] [PATCH v5] vvcdec: add thread executor

Nuo Mi nuomi2021 at gmail.com
Tue Aug 29 16:07:10 EEST 2023


On Tue, Aug 29, 2023 at 1:06 AM Michael Niedermayer <michael at niedermayer.cc>
wrote:

> On Tue, Aug 22, 2023 at 09:32:28PM +0800, Nuo Mi wrote:
> > The executor design pattern was inroduced by java
>
> inTroduced
>
>
> > <
> https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/util/concurrent/Executor.html
> >
> > it also adapted by python
> > <https://docs.python.org/3/library/concurrent.futures.html>
> > Compared to handcrafted thread pool management, it greatly simplifies
> the thread code.
> > ---
> >  doc/APIchanges       |   3 +
> >  libavutil/Makefile   |   2 +
> >  libavutil/executor.c | 201 +++++++++++++++++++++++++++++++++++++++++++
> >  libavutil/executor.h |  67 +++++++++++++++
> >  libavutil/version.h  |   2 +-
> >  5 files changed, 274 insertions(+), 1 deletion(-)
> >  create mode 100644 libavutil/executor.c
> >  create mode 100644 libavutil/executor.h
> >
> > diff --git a/doc/APIchanges b/doc/APIchanges
> > index ad1efe708d..06822f22da 100644
> > --- a/doc/APIchanges
> > +++ b/doc/APIchanges
> > @@ -2,6 +2,9 @@ The last version increases of all libraries were on
> 2023-02-09
> >
> >  API changes, most recent first:
> >
> > +2023-08-22 - xxxxxxxxxx - lavu 58.18.100 - executor.h
> > +  Add AVExecutor API
> > +
> >  2023-08-18 - xxxxxxxxxx - lavu 58.17.100 - channel_layout.h
> >    All AV_CHANNEL_LAYOUT_* macros are now compatible with C++ 17 and
> older.
> >
> > diff --git a/libavutil/Makefile b/libavutil/Makefile
> > index 7828c94dc5..4711f8cde8 100644
> > --- a/libavutil/Makefile
> > +++ b/libavutil/Makefile
> > @@ -31,6 +31,7 @@ HEADERS = adler32.h
>                  \
> >            encryption_info.h
>  \
> >            error.h
>  \
> >            eval.h
> \
> > +          executor.h
> \
> >            fifo.h
> \
> >            file.h
> \
> >            frame.h
>  \
> > @@ -127,6 +128,7 @@ OBJS = adler32.o
>                     \
> >         encryption_info.o
> \
> >         error.o
> \
> >         eval.o
>  \
> > +       executor.o
>  \
> >         fifo.o
>  \
> >         file.o
>  \
> >         file_open.o
> \
> > diff --git a/libavutil/executor.c b/libavutil/executor.c
> > new file mode 100644
> > index 0000000000..38adaef811
> > --- /dev/null
> > +++ b/libavutil/executor.c
> > @@ -0,0 +1,201 @@
> > +/*
> > + * Copyright (C) 2023 Nuo Mi
> > + *
> > + * 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 "internal.h"
> > +#include "mem.h"
> > +#include "thread.h"
> > +
> > +#include "executor.h"
> > +
> > +#if !HAVE_THREADS
> > +
> > +#define executor_thread_t    char
> > +
> > +#define executor_thread_create(t, a, s, ar)      0
> > +#define executor_thread_join(t, r)               do {} while(0)
> > +
> > +#else
> > +
>
> > +#define executor_thread_t    pthread_t
>
> I think *_t is reserved by POSIX
>
fixed by v6.
thank you

>
>
> should be ok otherwise
>
> thx
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Everything should be made as simple as possible, but not simpler.
> -- Albert Einstein
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-devel mailing list