* [FFmpeg-devel] [PATCH] avfilter/src_movie: switch to activate()
@ 2023-05-15 21:13 Paul B Mahol
2023-05-16 23:38 ` Michael Niedermayer
0 siblings, 1 reply; 2+ messages in thread
From: Paul B Mahol @ 2023-05-15 21:13 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1: Type: text/plain, Size: 10 bytes --]
Attached.
[-- Attachment #2: 0001-avfilter-src_movie-switch-to-activate.patch --]
[-- Type: text/x-patch, Size: 5692 bytes --]
From a5bfd2e0856a02989ce7f1d2a4f3b9f45c77189f Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Sat, 2 Apr 2022 14:06:22 +0200
Subject: [PATCH 1/3] avfilter/src_movie: switch to activate()
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
libavfilter/src_movie.c | 91 +++++++++++++++++++++++++----------------
1 file changed, 56 insertions(+), 35 deletions(-)
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index 5937613d13..a7d7c188e6 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 &&
@@ -551,50 +552,70 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
if (ret < 0)
return ret;
- return 0;
+ return 1;
}
-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);
+ int ret = 0;
- while (1) {
- int got_eagain = 0, got_eof = 0;
- int ret = 0;
+ /* check all decoders for available output */
+ for (int i = 0; i < ctx->nb_outputs; i++) {
+ if (movie->st[i].got_eof)
+ continue;
- /* 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++;
- else if (ret == AVERROR_EOF)
- got_eof++;
- else if (ret < 0)
- return ret;
- else if (i == out_id)
- return 0;
+ if (ret == AVERROR(EAGAIN))
+ movie->got_eagain++;
+ else if (ret == AVERROR_EOF)
+ movie->st[i].got_eof = 1;
+ else if (ret < 0)
+ return ret;
+ else if (ret == 1)
+ return 0;
+ }
+
+ 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) {
+ if (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 (got_eagain) {
- /* all decoders require more input -> read a new packet */
- ret = movie_decode_packet(ctx);
+ 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;
+ ff_filter_set_ready(ctx, 100);
}
+ return 0;
}
+
+ return FFERROR_NOT_READY;
}
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
@@ -651,7 +672,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 +691,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.39.1
[-- Attachment #3: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/src_movie: switch to activate()
2023-05-15 21:13 [FFmpeg-devel] [PATCH] avfilter/src_movie: switch to activate() Paul B Mahol
@ 2023-05-16 23:38 ` Michael Niedermayer
0 siblings, 0 replies; 2+ messages in thread
From: Michael Niedermayer @ 2023-05-16 23:38 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 1469 bytes --]
On Mon, May 15, 2023 at 11:13:10PM +0200, Paul B Mahol wrote:
> Attached.
> src_movie.c | 91 ++++++++++++++++++++++++++++++++++++------------------------
> 1 file changed, 56 insertions(+), 35 deletions(-)
> 2fe86f393e8afc2e055458cf8c505e0fb4e20931 0001-avfilter-src_movie-switch-to-activate.patch
> From a5bfd2e0856a02989ce7f1d2a4f3b9f45c77189f Mon Sep 17 00:00:00 2001
> From: Paul B Mahol <onemda@gmail.com>
> Date: Sat, 2 Apr 2022 14:06:22 +0200
> Subject: [PATCH 1/3] avfilter/src_movie: switch to activate()
>
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
> libavfilter/src_movie.c | 91 +++++++++++++++++++++++++----------------
> 1 file changed, 56 insertions(+), 35 deletions(-)
Causes infinite loop in
./ffmpeg -f lavfi -i "amovie=fate-suite/wavpack/num_channels/eva_2.22_6.1_16bit-partial.wv,asplit=3[out1][a][b]; [a]showwaves=s=340x240,pad=iw:ih*2[waves]; [b]showspectrum=s=340x240[spectrum]; [waves][spectrum] overlay=0:h [out0]" -t 0.1 -qscale 2 -bitexact file-waves.avi
ive also seen memory corruption with some other patches from today on top using
the same command above. but only bisected the first issue, i can bisect
teh others too if it helps ?
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 2+ messages in thread
end of thread, other threads:[~2023-05-16 23:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-15 21:13 [FFmpeg-devel] [PATCH] avfilter/src_movie: switch to activate() Paul B Mahol
2023-05-16 23:38 ` Michael Niedermayer
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