* [FFmpeg-devel] [PATCH 1/2] avfilter/src_movie: switch to activate()
@ 2022-03-30 17:43 Paul B Mahol
2022-03-30 17:43 ` [FFmpeg-devel] [PATCH 2/2] avfilter/src_movie: add option to set decoding thread type Paul B Mahol
0 siblings, 1 reply; 6+ messages in thread
From: Paul B Mahol @ 2022-03-30 17:43 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
libavfilter/src_movie.c | 76 ++++++++++++++++++++++++-----------------
1 file changed, 45 insertions(+), 31 deletions(-)
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index 711854c23c..78b87cf444 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -46,6 +46,7 @@
#include "audio.h"
#include "avfilter.h"
+#include "filters.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
@@ -55,6 +56,7 @@ typedef struct MovieStream {
AVCodecContext *codec_ctx;
int64_t discontinuity_threshold;
int64_t last_pts;
+ int got_eof;
} MovieStream;
typedef struct MovieContext {
@@ -70,6 +72,7 @@ typedef struct MovieContext {
int64_t discontinuity_threshold;
int64_t ts_offset;
int dec_threads;
+ int got_eagain;
AVFormatContext *format_ctx;
@@ -100,7 +103,6 @@ static const AVOption movie_options[]= {
};
static int movie_config_output_props(AVFilterLink *outlink);
-static int movie_request_frame(AVFilterLink *outlink);
static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec)
{
@@ -314,7 +316,6 @@ static av_cold int movie_common_init(AVFilterContext *ctx)
if (!pad.name)
return AVERROR(ENOMEM);
pad.config_props = movie_config_output_props;
- pad.request_frame = movie_request_frame;
if ((ret = ff_append_outpad_free_name(ctx, &pad)) < 0)
return ret;
if ( movie->st[i].st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
@@ -554,47 +555,60 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
return 0;
}
-static int movie_request_frame(AVFilterLink *outlink)
+static int activate(AVFilterContext *ctx)
{
- AVFilterContext *ctx = outlink->src;
MovieContext *movie = ctx->priv;
- unsigned out_id = FF_OUTLINK_IDX(outlink);
-
- while (1) {
- int got_eagain = 0, got_eof = 0;
- int ret = 0;
+ int ret = 0, x = 0;
- /* check all decoders for available output */
- for (int i = 0; i < ctx->nb_outputs; i++) {
+ /* check all decoders for available output */
+ for (int i = 0; i < ctx->nb_outputs; i++) {
+ if (ff_outlink_frame_wanted(ctx->outputs[i])) {
ret = movie_push_frame(ctx, i);
if (ret == AVERROR(EAGAIN))
- got_eagain++;
+ movie->got_eagain++;
else if (ret == AVERROR_EOF)
- got_eof++;
+ movie->st[i].got_eof++;
else if (ret < 0)
return ret;
- else if (i == out_id)
- return 0;
+ x++;
}
+ }
- if (got_eagain) {
- /* all decoders require more input -> read a new packet */
- ret = movie_decode_packet(ctx);
+ if (movie->got_eagain) {
+ /* all decoders require more input -> read a new packet */
+ movie->got_eagain = 0;
+ ret = movie_decode_packet(ctx);
+ if (ret < 0 && ret != AVERROR(EAGAIN))
+ return ret;
+ ff_filter_set_ready(ctx, 100);
+ return 0;
+ } else {
+ int nb_eofs = 0;
+
+ for (int i = 0; i < ctx->nb_outputs; i++) {
+ if (movie->st[i].got_eof && movie->loop_count == 1)
+ ff_outlink_set_status(ctx->outputs[i], AVERROR_EOF, movie->st[i].last_pts);
+ nb_eofs++;
+ }
+
+ if (nb_eofs != ctx->nb_outputs) {
+ ff_filter_set_ready(ctx, 100);
+ return 0;
+ }
+
+ if (movie->loop_count != 1) {
+ ret = rewind_file(ctx);
if (ret < 0)
return ret;
- } else if (got_eof) {
- /* all decoders flushed */
- if (movie->loop_count != 1) {
- ret = rewind_file(ctx);
- if (ret < 0)
- return ret;
- movie->loop_count -= movie->loop_count > 1;
- av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n");
- continue;
- }
- return AVERROR_EOF;
+ movie->loop_count -= movie->loop_count > 1;
+ av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n");
+ for (int i = 0; i < ctx->nb_outputs; i++)
+ movie->st[i].got_eof = 0;
}
+ return 0;
}
+
+ return FFERROR_NOT_READY;
}
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
@@ -651,7 +665,7 @@ const AVFilter ff_avsrc_movie = {
.init = movie_common_init,
.uninit = movie_uninit,
FILTER_QUERY_FUNC(movie_query_formats),
-
+ .activate = activate,
.inputs = NULL,
.outputs = NULL,
.flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS,
@@ -670,7 +684,7 @@ const AVFilter ff_avsrc_amovie = {
.init = movie_common_init,
.uninit = movie_uninit,
FILTER_QUERY_FUNC(movie_query_formats),
-
+ .activate = activate,
.inputs = NULL,
.outputs = NULL,
.flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS,
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 6+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avfilter/src_movie: add option to set decoding thread type
2022-03-30 17:43 [FFmpeg-devel] [PATCH 1/2] avfilter/src_movie: switch to activate() Paul B Mahol
@ 2022-03-30 17:43 ` Paul B Mahol
0 siblings, 0 replies; 6+ messages in thread
From: Paul B Mahol @ 2022-03-30 17:43 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
doc/filters.texi | 3 +++
libavfilter/src_movie.c | 11 +++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 1d56d24819..af332041e8 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -28790,6 +28790,9 @@ timestamps.
@item dec_threads
Specifies the number of threads for decoding
+@item dec_thread_type
+Specifies the thread type for decoding.
+
@item format_opts
Specify format options for the opened file. Format options can be specified
as a list of @var{key}=@var{value} pairs separated by ':'. The following example
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index 78b87cf444..09d107ee8f 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -72,6 +72,7 @@ typedef struct MovieContext {
int64_t discontinuity_threshold;
int64_t ts_offset;
int dec_threads;
+ int thread_type;
int got_eagain;
AVFormatContext *format_ctx;
@@ -98,6 +99,10 @@ static const AVOption movie_options[]= {
{ "loop", "set loop count", OFFSET(loop_count), AV_OPT_TYPE_INT, {.i64 = 1}, 0, INT_MAX, FLAGS },
{ "discontinuity", "set discontinuity threshold", OFFSET(discontinuity_threshold), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, FLAGS },
{ "dec_threads", "set the number of threads for decoding", OFFSET(dec_threads), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
+ { "dec_thread_type","set the type of threads for decoding", OFFSET(thread_type), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 2, FLAGS, .unit = "thread_type" },
+ { "auto", "auto", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, FLAGS, .unit = "thread_type" },
+ { "frame", "more than one frame at once", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, FLAGS, .unit = "thread_type" },
+ { "slice", "more than one part of single frame at once", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, FLAGS, .unit = "thread_type" },
{ "format_opts", "set format options for the opened file", OFFSET(format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
{ NULL },
};
@@ -158,7 +163,7 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec)
return found;
}
-static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads)
+static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads, int thread_type)
{
const AVCodec *codec;
int ret;
@@ -180,6 +185,8 @@ static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads)
if (!dec_threads)
dec_threads = ff_filter_get_nb_threads(ctx);
st->codec_ctx->thread_count = dec_threads;
+ if (thread_type)
+ st->codec_ctx->thread_type = thread_type;
if ((ret = avcodec_open2(st->codec_ctx, codec, NULL)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Failed to open codec\n");
@@ -324,7 +331,7 @@ static av_cold int movie_common_init(AVFilterContext *ctx)
if (ret < 0)
return ret;
}
- ret = open_stream(ctx, &movie->st[i], movie->dec_threads);
+ ret = open_stream(ctx, &movie->st[i], movie->dec_threads, movie->thread_type);
if (ret < 0)
return ret;
}
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avfilter/src_movie: add option to set decoding thread type
2022-04-05 14:29 ` Andreas Rheinhardt
@ 2022-04-05 15:37 ` Paul B Mahol
0 siblings, 0 replies; 6+ messages in thread
From: Paul B Mahol @ 2022-04-05 15:37 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Tue, Apr 5, 2022 at 4:29 PM Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:
> Paul B Mahol:
> > Signed-off-by: Paul B Mahol <onemda@gmail.com>
> > ---
> > doc/filters.texi | 3 +++
> > libavfilter/src_movie.c | 11 +++++++++--
> > 2 files changed, 12 insertions(+), 2 deletions(-)
> >
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index 636c80dbff..a13977edd8 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -29317,6 +29317,9 @@ timestamps.
> > @item dec_threads
> > Specifies the number of threads for decoding
> >
> > +@item dec_thread_type
> > +Specifies the thread type for decoding.
> > +
> > @item format_opts
> > Specify format options for the opened file. Format options can be
> specified
> > as a list of @var{key}=@var{value} pairs separated by ':'. The
> following example
> > diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
> > index bc7b0d37af..08cba437bf 100644
> > --- a/libavfilter/src_movie.c
> > +++ b/libavfilter/src_movie.c
> > @@ -72,6 +72,7 @@ typedef struct MovieContext {
> > int64_t discontinuity_threshold;
> > int64_t ts_offset;
> > int dec_threads;
> > + int thread_type;
> > int got_eagain;
> > int got_wanted;
> >
> > @@ -99,6 +100,10 @@ static const AVOption movie_options[]= {
> > { "loop", "set loop count", OFFSET(loop_count),
> AV_OPT_TYPE_INT, {.i64 = 1}, 0, INT_MAX, FLAGS },
> > { "discontinuity", "set discontinuity threshold",
> OFFSET(discontinuity_threshold), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0,
> INT64_MAX, FLAGS },
> > { "dec_threads", "set the number of threads for decoding",
> OFFSET(dec_threads), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
> > + { "dec_thread_type","set the type of threads for decoding",
> OFFSET(thread_type), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 2, FLAGS, .unit =
> "thread_type" },
> > + { "auto", "auto", 0,
> AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, FLAGS, .unit = "thread_type" },
> > + { "frame", "more than one frame at once", 0,
> AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, FLAGS, .unit = "thread_type" },
> > + { "slice", "more than one part of single frame at once", 0,
> AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, FLAGS, .unit = "thread_type" },
> > { "format_opts", "set format options for the opened file",
> OFFSET(format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
> > { NULL },
> > };
> > @@ -159,7 +164,7 @@ static AVStream *find_stream(void *log,
> AVFormatContext *avf, const char *spec)
> > return found;
> > }
> >
> > -static int open_stream(AVFilterContext *ctx, MovieStream *st, int
> dec_threads)
> > +static int open_stream(AVFilterContext *ctx, MovieStream *st, int
> dec_threads, int thread_type)
> > {
> > const AVCodec *codec;
> > int ret;
> > @@ -181,6 +186,8 @@ static int open_stream(AVFilterContext *ctx,
> MovieStream *st, int dec_threads)
> > if (!dec_threads)
> > dec_threads = ff_filter_get_nb_threads(ctx);
> > st->codec_ctx->thread_count = dec_threads;
> > + if (thread_type)
> > + st->codec_ctx->thread_type = thread_type;
> >
> > if ((ret = avcodec_open2(st->codec_ctx, codec, NULL)) < 0) {
> > av_log(ctx, AV_LOG_ERROR, "Failed to open codec\n");
> > @@ -325,7 +332,7 @@ static av_cold int movie_common_init(AVFilterContext
> *ctx)
> > if (ret < 0)
> > return ret;
> > }
> > - ret = open_stream(ctx, &movie->st[i], movie->dec_threads);
> > + ret = open_stream(ctx, &movie->st[i], movie->dec_threads,
> movie->thread_type);
> > if (ret < 0)
> > return ret;
> > }
>
> Why do you want to add an option for only this instead of a generic
> AV_OPT_TYPE_DICT option for a dict that will be passed to avcodec_open2()?
>
I think there is conflict if same option name is used.
>
> - Andreas
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avfilter/src_movie: add option to set decoding thread type
2022-04-02 12:06 ` [FFmpeg-devel] [PATCH 2/2] avfilter/src_movie: add option to set decoding thread type Paul B Mahol
@ 2022-04-05 14:29 ` Andreas Rheinhardt
2022-04-05 15:37 ` Paul B Mahol
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Rheinhardt @ 2022-04-05 14:29 UTC (permalink / raw)
To: ffmpeg-devel
Paul B Mahol:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
> doc/filters.texi | 3 +++
> libavfilter/src_movie.c | 11 +++++++++--
> 2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 636c80dbff..a13977edd8 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -29317,6 +29317,9 @@ timestamps.
> @item dec_threads
> Specifies the number of threads for decoding
>
> +@item dec_thread_type
> +Specifies the thread type for decoding.
> +
> @item format_opts
> Specify format options for the opened file. Format options can be specified
> as a list of @var{key}=@var{value} pairs separated by ':'. The following example
> diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
> index bc7b0d37af..08cba437bf 100644
> --- a/libavfilter/src_movie.c
> +++ b/libavfilter/src_movie.c
> @@ -72,6 +72,7 @@ typedef struct MovieContext {
> int64_t discontinuity_threshold;
> int64_t ts_offset;
> int dec_threads;
> + int thread_type;
> int got_eagain;
> int got_wanted;
>
> @@ -99,6 +100,10 @@ static const AVOption movie_options[]= {
> { "loop", "set loop count", OFFSET(loop_count), AV_OPT_TYPE_INT, {.i64 = 1}, 0, INT_MAX, FLAGS },
> { "discontinuity", "set discontinuity threshold", OFFSET(discontinuity_threshold), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, FLAGS },
> { "dec_threads", "set the number of threads for decoding", OFFSET(dec_threads), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
> + { "dec_thread_type","set the type of threads for decoding", OFFSET(thread_type), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 2, FLAGS, .unit = "thread_type" },
> + { "auto", "auto", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, FLAGS, .unit = "thread_type" },
> + { "frame", "more than one frame at once", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, FLAGS, .unit = "thread_type" },
> + { "slice", "more than one part of single frame at once", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, FLAGS, .unit = "thread_type" },
> { "format_opts", "set format options for the opened file", OFFSET(format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
> { NULL },
> };
> @@ -159,7 +164,7 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec)
> return found;
> }
>
> -static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads)
> +static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads, int thread_type)
> {
> const AVCodec *codec;
> int ret;
> @@ -181,6 +186,8 @@ static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads)
> if (!dec_threads)
> dec_threads = ff_filter_get_nb_threads(ctx);
> st->codec_ctx->thread_count = dec_threads;
> + if (thread_type)
> + st->codec_ctx->thread_type = thread_type;
>
> if ((ret = avcodec_open2(st->codec_ctx, codec, NULL)) < 0) {
> av_log(ctx, AV_LOG_ERROR, "Failed to open codec\n");
> @@ -325,7 +332,7 @@ static av_cold int movie_common_init(AVFilterContext *ctx)
> if (ret < 0)
> return ret;
> }
> - ret = open_stream(ctx, &movie->st[i], movie->dec_threads);
> + ret = open_stream(ctx, &movie->st[i], movie->dec_threads, movie->thread_type);
> if (ret < 0)
> return ret;
> }
Why do you want to add an option for only this instead of a generic
AV_OPT_TYPE_DICT option for a dict that will be passed to avcodec_open2()?
- Andreas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 6+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avfilter/src_movie: add option to set decoding thread type
2022-04-02 12:06 [FFmpeg-devel] [PATCH 1/2] avfilter/src_movie: switch to activate() Paul B Mahol
@ 2022-04-02 12:06 ` Paul B Mahol
2022-04-05 14:29 ` Andreas Rheinhardt
0 siblings, 1 reply; 6+ messages in thread
From: Paul B Mahol @ 2022-04-02 12:06 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
doc/filters.texi | 3 +++
libavfilter/src_movie.c | 11 +++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 636c80dbff..a13977edd8 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -29317,6 +29317,9 @@ timestamps.
@item dec_threads
Specifies the number of threads for decoding
+@item dec_thread_type
+Specifies the thread type for decoding.
+
@item format_opts
Specify format options for the opened file. Format options can be specified
as a list of @var{key}=@var{value} pairs separated by ':'. The following example
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index bc7b0d37af..08cba437bf 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -72,6 +72,7 @@ typedef struct MovieContext {
int64_t discontinuity_threshold;
int64_t ts_offset;
int dec_threads;
+ int thread_type;
int got_eagain;
int got_wanted;
@@ -99,6 +100,10 @@ static const AVOption movie_options[]= {
{ "loop", "set loop count", OFFSET(loop_count), AV_OPT_TYPE_INT, {.i64 = 1}, 0, INT_MAX, FLAGS },
{ "discontinuity", "set discontinuity threshold", OFFSET(discontinuity_threshold), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, FLAGS },
{ "dec_threads", "set the number of threads for decoding", OFFSET(dec_threads), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
+ { "dec_thread_type","set the type of threads for decoding", OFFSET(thread_type), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 2, FLAGS, .unit = "thread_type" },
+ { "auto", "auto", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, FLAGS, .unit = "thread_type" },
+ { "frame", "more than one frame at once", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, FLAGS, .unit = "thread_type" },
+ { "slice", "more than one part of single frame at once", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, FLAGS, .unit = "thread_type" },
{ "format_opts", "set format options for the opened file", OFFSET(format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
{ NULL },
};
@@ -159,7 +164,7 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec)
return found;
}
-static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads)
+static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads, int thread_type)
{
const AVCodec *codec;
int ret;
@@ -181,6 +186,8 @@ static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads)
if (!dec_threads)
dec_threads = ff_filter_get_nb_threads(ctx);
st->codec_ctx->thread_count = dec_threads;
+ if (thread_type)
+ st->codec_ctx->thread_type = thread_type;
if ((ret = avcodec_open2(st->codec_ctx, codec, NULL)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Failed to open codec\n");
@@ -325,7 +332,7 @@ static av_cold int movie_common_init(AVFilterContext *ctx)
if (ret < 0)
return ret;
}
- ret = open_stream(ctx, &movie->st[i], movie->dec_threads);
+ ret = open_stream(ctx, &movie->st[i], movie->dec_threads, movie->thread_type);
if (ret < 0)
return ret;
}
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 6+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avfilter/src_movie: add option to set decoding thread type
2022-04-02 10:59 [FFmpeg-devel] [PATCH 1/2] avfilter/src_movie: switch to activate() Paul B Mahol
@ 2022-04-02 10:59 ` Paul B Mahol
0 siblings, 0 replies; 6+ messages in thread
From: Paul B Mahol @ 2022-04-02 10:59 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
doc/filters.texi | 3 +++
libavfilter/src_movie.c | 11 +++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 1d56d24819..af332041e8 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -28790,6 +28790,9 @@ timestamps.
@item dec_threads
Specifies the number of threads for decoding
+@item dec_thread_type
+Specifies the thread type for decoding.
+
@item format_opts
Specify format options for the opened file. Format options can be specified
as a list of @var{key}=@var{value} pairs separated by ':'. The following example
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index 8c7ea5686a..b4592d0390 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -72,6 +72,7 @@ typedef struct MovieContext {
int64_t discontinuity_threshold;
int64_t ts_offset;
int dec_threads;
+ int thread_type;
int got_eagain;
int got_wanted;
@@ -99,6 +100,10 @@ static const AVOption movie_options[]= {
{ "loop", "set loop count", OFFSET(loop_count), AV_OPT_TYPE_INT, {.i64 = 1}, 0, INT_MAX, FLAGS },
{ "discontinuity", "set discontinuity threshold", OFFSET(discontinuity_threshold), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, FLAGS },
{ "dec_threads", "set the number of threads for decoding", OFFSET(dec_threads), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
+ { "dec_thread_type","set the type of threads for decoding", OFFSET(thread_type), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 2, FLAGS, .unit = "thread_type" },
+ { "auto", "auto", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, FLAGS, .unit = "thread_type" },
+ { "frame", "more than one frame at once", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, FLAGS, .unit = "thread_type" },
+ { "slice", "more than one part of single frame at once", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, FLAGS, .unit = "thread_type" },
{ "format_opts", "set format options for the opened file", OFFSET(format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS},
{ NULL },
};
@@ -159,7 +164,7 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec)
return found;
}
-static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads)
+static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads, int thread_type)
{
const AVCodec *codec;
int ret;
@@ -181,6 +186,8 @@ static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads)
if (!dec_threads)
dec_threads = ff_filter_get_nb_threads(ctx);
st->codec_ctx->thread_count = dec_threads;
+ if (thread_type)
+ st->codec_ctx->thread_type = thread_type;
if ((ret = avcodec_open2(st->codec_ctx, codec, NULL)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Failed to open codec\n");
@@ -325,7 +332,7 @@ static av_cold int movie_common_init(AVFilterContext *ctx)
if (ret < 0)
return ret;
}
- ret = open_stream(ctx, &movie->st[i], movie->dec_threads);
+ ret = open_stream(ctx, &movie->st[i], movie->dec_threads, movie->thread_type);
if (ret < 0)
return ret;
}
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-04-05 15:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-30 17:43 [FFmpeg-devel] [PATCH 1/2] avfilter/src_movie: switch to activate() Paul B Mahol
2022-03-30 17:43 ` [FFmpeg-devel] [PATCH 2/2] avfilter/src_movie: add option to set decoding thread type Paul B Mahol
2022-04-02 10:59 [FFmpeg-devel] [PATCH 1/2] avfilter/src_movie: switch to activate() Paul B Mahol
2022-04-02 10:59 ` [FFmpeg-devel] [PATCH 2/2] avfilter/src_movie: add option to set decoding thread type Paul B Mahol
2022-04-02 12:06 [FFmpeg-devel] [PATCH 1/2] avfilter/src_movie: switch to activate() Paul B Mahol
2022-04-02 12:06 ` [FFmpeg-devel] [PATCH 2/2] avfilter/src_movie: add option to set decoding thread type Paul B Mahol
2022-04-05 14:29 ` Andreas Rheinhardt
2022-04-05 15:37 ` Paul B Mahol
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git