* Re: [FFmpeg-devel] [PATCH] mediacodecdec_common: enable refcounting of buffers unconditionally
@ 2022-09-28 8:27 Anton Khirnov
2022-09-28 9:35 ` Matthieu Bouron
0 siblings, 1 reply; 4+ messages in thread
From: Anton Khirnov @ 2022-09-28 8:27 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Matthieu Bouron
Quoting sfan5 (2022-09-18 20:26:48)
> This allows av_mediacodec_release_buffer to be called safely after
> the decoder is closed, this was already the case with delay_flush=1.
> Note that this causes holding onto frames to keep the decoding context
> alive which is generally considered to be the intended behavior
>
>
> (resending as my patch got mangled somehow)
The patch looks like it makes sense, but I have no experience with this
code. CCing the maintainer, will push in a few days if nobody objects.
--
Anton Khirnov
_______________________________________________
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] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] mediacodecdec_common: enable refcounting of buffers unconditionally
2022-09-28 8:27 [FFmpeg-devel] [PATCH] mediacodecdec_common: enable refcounting of buffers unconditionally Anton Khirnov
@ 2022-09-28 9:35 ` Matthieu Bouron
0 siblings, 0 replies; 4+ messages in thread
From: Matthieu Bouron @ 2022-09-28 9:35 UTC (permalink / raw)
To: Anton Khirnov; +Cc: FFmpeg development discussions and patches
On Wed, Sep 28, 2022 at 10:27:49AM +0200, Anton Khirnov wrote:
> Quoting sfan5 (2022-09-18 20:26:48)
> > This allows av_mediacodec_release_buffer to be called safely after
> > the decoder is closed, this was already the case with delay_flush=1.
> > Note that this causes holding onto frames to keep the decoding context
> > alive which is generally considered to be the intended behavior
> >
> >
> > (resending as my patch got mangled somehow)
>
> The patch looks like it makes sense, but I have no experience with this
> code. CCing the maintainer, will push in a few days if nobody objects.
Sorry for the wait, the patch looks good to me.
Thanks,
Matthieu
_______________________________________________
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] 4+ messages in thread
* [FFmpeg-devel] [PATCH] mediacodecdec_common: enable refcounting of buffers unconditionally
@ 2022-09-18 18:26 sfan5
0 siblings, 0 replies; 4+ messages in thread
From: sfan5 @ 2022-09-18 18:26 UTC (permalink / raw)
To: ffmpeg-devel
[-- Attachment #1: Type: text/plain, Size: 317 bytes --]
This allows av_mediacodec_release_buffer to be called safely after
the decoder is closed, this was already the case with delay_flush=1.
Note that this causes holding onto frames to keep the decoding context
alive which is generally considered to be the intended behavior
(resending as my patch got mangled somehow)
[-- Attachment #2: 0001-mediacodecdec_common-enable-refcounting-of-buffers-u.patch --]
[-- Type: text/x-patch, Size: 1879 bytes --]
From c3a5edd940c503cca706b3d92954b8cd5c715e26 Mon Sep 17 00:00:00 2001
From: sfan5 <sfan5@live.de>
Date: Sun, 18 Sep 2022 18:26:43 +0200
Subject: [PATCH] mediacodecdec_common: enable refcounting of buffers
unconditionally
This allows av_mediacodec_release_buffer to be called safely after
the decoder is closed, this was already the case with delay_flush=1.
Note that this causes holding onto frames to keep the decoding context
alive which is generally considered to be the intended behavior.
Signed-off-by: sfan5 <sfan5@live.de>
---
libavcodec/mediacodecdec_common.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c
index 9fa769656c..2a605e7f5b 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -265,8 +265,7 @@ static void mediacodec_buffer_release(void *opaque, uint8_t *data)
ff_AMediaCodec_releaseOutputBuffer(ctx->codec, buffer->index, 0);
}
- if (ctx->delay_flush)
- ff_mediacodec_dec_unref(ctx);
+ ff_mediacodec_dec_unref(ctx);
av_freep(&buffer);
}
@@ -321,8 +320,7 @@ static int mediacodec_wrap_hw_buffer(AVCodecContext *avctx,
buffer->ctx = s;
buffer->serial = atomic_load(&s->serial);
- if (s->delay_flush)
- ff_mediacodec_dec_ref(s);
+ ff_mediacodec_dec_ref(s);
buffer->index = index;
buffer->pts = info->presentationTimeUs;
@@ -872,7 +870,7 @@ int ff_mediacodec_dec_receive(AVCodecContext *avctx, MediaCodecDecContext *s,
*/
int ff_mediacodec_dec_flush(AVCodecContext *avctx, MediaCodecDecContext *s)
{
- if (!s->surface || atomic_load(&s->refcount) == 1) {
+ if (!s->surface || !s->delay_flush || atomic_load(&s->refcount) == 1) {
int ret;
/* No frames (holding a reference to the codec) are retained by the
--
2.37.3
[-- 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] 4+ messages in thread
* [FFmpeg-devel] [PATCH] mediacodecdec_common: enable refcounting of buffers unconditionally
@ 2022-09-18 18:00 sfan5
0 siblings, 0 replies; 4+ messages in thread
From: sfan5 @ 2022-09-18 18:00 UTC (permalink / raw)
To: ffmpeg-devel
This allows av_mediacodec_release_buffer to be called safely after
the decoder is closed, this was already the case with delay_flush=1.
Note that this causes holding onto frames to keep the decoding context
alive which is generally considered to be the intended behavior.
---
libavcodec/mediacodecdec_common.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/libavcodec/mediacodecdec_common.c
b/libavcodec/mediacodecdec_common.c
index 9fa769656c..2a605e7f5b 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -265,8 +265,7 @@ static void mediacodec_buffer_release(void *opaque,
uint8_t *data)
ff_AMediaCodec_releaseOutputBuffer(ctx->codec, buffer->index, 0);
}
- if (ctx->delay_flush)
- ff_mediacodec_dec_unref(ctx);
+ ff_mediacodec_dec_unref(ctx);
av_freep(&buffer);
}
@@ -321,8 +320,7 @@ static int
mediacodec_wrap_hw_buffer(AVCodecContext *avctx,
buffer->ctx = s;
buffer->serial = atomic_load(&s->serial);
- if (s->delay_flush)
- ff_mediacodec_dec_ref(s);
+ ff_mediacodec_dec_ref(s);
buffer->index = index;
buffer->pts = info->presentationTimeUs;
@@ -872,7 +870,7 @@ int ff_mediacodec_dec_receive(AVCodecContext *avctx,
MediaCodecDecContext *s,
*/
int ff_mediacodec_dec_flush(AVCodecContext *avctx,
MediaCodecDecContext *s)
{
- if (!s->surface || atomic_load(&s->refcount) == 1) {
+ if (!s->surface || !s->delay_flush || atomic_load(&s->refcount) == 1) {
int ret;
/* No frames (holding a reference to the codec) are retained
by the
--
2.37.3
_______________________________________________
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] 4+ messages in thread
end of thread, other threads:[~2022-09-28 9:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28 8:27 [FFmpeg-devel] [PATCH] mediacodecdec_common: enable refcounting of buffers unconditionally Anton Khirnov
2022-09-28 9:35 ` Matthieu Bouron
-- strict thread matches above, loose matches on Subject: below --
2022-09-18 18:26 sfan5
2022-09-18 18:00 sfan5
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