* [FFmpeg-devel] [PATCH] avcodec/libdav1d: export decoder frame delay
@ 2023-05-11 16:04 James Almer
2023-05-11 19:22 ` Derek Buitenhuis
2023-05-12 11:36 ` Ronald S. Bultje
0 siblings, 2 replies; 3+ messages in thread
From: James Almer @ 2023-05-11 16:04 UTC (permalink / raw)
To: ffmpeg-devel
As this is a AV_CODEC_CAP_OTHER_THREADS decoder, threading is handled by the
underlying library. In this case, the frame delay is calculated by libdav1d
based on the values from avctx->thread_count and the private max_frame_delay
option.
Make said max_frame_delay option an exported one, and store the final delay
used by libdav1d here, for the caller to query if needed.
Signed-off-by: James Almer <jamrial@gmail.com>
---
doc/decoders.texi | 3 ++-
libavcodec/libdav1d.c | 16 +++++++++++++++-
libavcodec/version.h | 2 +-
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/doc/decoders.texi b/doc/decoders.texi
index 09b8314dd2..0130b35603 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -86,7 +86,8 @@ global option @code{threads} instead.
@item max_frame_delay
Set max amount of frames the decoder may buffer internally. The default value is 0
-(autodetect).
+(autodetect). The decoder will afterwards export the final calculated frame delay here
+when using libdav1d >= 1.1.0.
@item filmgrain
Apply film grain to the decoded video if present in the bitstream. Defaults to the
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index af072da681..de06a2c09e 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -278,6 +278,14 @@ static av_cold int libdav1d_init(AVCodecContext *c)
if (res < 0)
return AVERROR(ENOMEM);
+#if FF_DAV1D_VERSION_AT_LEAST(6,7)
+ res = dav1d_get_frame_delay(&s);
+ if (res < 0) // Should not happen
+ return AVERROR_EXTERNAL;
+
+ dav1d->max_frame_delay = res;
+#endif
+
return 0;
}
@@ -648,10 +656,16 @@ static av_cold int libdav1d_close(AVCodecContext *c)
#define OFFSET(x) offsetof(Libdav1dContext, x)
#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
+#if FF_DAV1D_VERSION_AT_LEAST(6,7)
+#define X AV_OPT_FLAG_EXPORT
+#else
+#define X 0
+#endif
+
static const AVOption libdav1d_options[] = {
{ "tilethreads", "Tile threads", OFFSET(tile_threads), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_TILE_THREADS, VD | AV_OPT_FLAG_DEPRECATED },
{ "framethreads", "Frame threads", OFFSET(frame_threads), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_FRAME_THREADS, VD | AV_OPT_FLAG_DEPRECATED },
- { "max_frame_delay", "Max frame delay", OFFSET(max_frame_delay), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_FRAME_DELAY, VD },
+ { "max_frame_delay", "Max frame delay", OFFSET(max_frame_delay), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_FRAME_DELAY, VD|X },
{ "filmgrain", "Apply Film Grain", OFFSET(apply_grain), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VD | AV_OPT_FLAG_DEPRECATED },
{ "oppoint", "Select an operating point of the scalable bitstream", OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 31, VD },
{ "alllayers", "Output all spatial layers", OFFSET(all_layers), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 8b53586be1..6d4d7ca018 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
#include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 11
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
--
2.40.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] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/libdav1d: export decoder frame delay
2023-05-11 16:04 [FFmpeg-devel] [PATCH] avcodec/libdav1d: export decoder frame delay James Almer
@ 2023-05-11 19:22 ` Derek Buitenhuis
2023-05-12 11:36 ` Ronald S. Bultje
1 sibling, 0 replies; 3+ messages in thread
From: Derek Buitenhuis @ 2023-05-11 19:22 UTC (permalink / raw)
To: ffmpeg-devel
On 5/11/2023 5:04 PM, James Almer wrote:
> As this is a AV_CODEC_CAP_OTHER_THREADS decoder, threading is handled by the
> underlying library. In this case, the frame delay is calculated by libdav1d
> based on the values from avctx->thread_count and the private max_frame_delay
> option.
> Make said max_frame_delay option an exported one, and store the final delay
> used by libdav1d here, for the caller to query if needed.
>
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
I can confirm this works as expected.
- Derek
_______________________________________________
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] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/libdav1d: export decoder frame delay
2023-05-11 16:04 [FFmpeg-devel] [PATCH] avcodec/libdav1d: export decoder frame delay James Almer
2023-05-11 19:22 ` Derek Buitenhuis
@ 2023-05-12 11:36 ` Ronald S. Bultje
1 sibling, 0 replies; 3+ messages in thread
From: Ronald S. Bultje @ 2023-05-12 11:36 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Hi,
On Thu, May 11, 2023 at 12:04 PM James Almer <jamrial@gmail.com> wrote:
> As this is a AV_CODEC_CAP_OTHER_THREADS decoder, threading is handled by
> the
> underlying library. In this case, the frame delay is calculated by libdav1d
> based on the values from avctx->thread_count and the private
> max_frame_delay
> option.
> Make said max_frame_delay option an exported one, and store the final delay
> used by libdav1d here, for the caller to query if needed.
>
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> doc/decoders.texi | 3 ++-
> libavcodec/libdav1d.c | 16 +++++++++++++++-
> libavcodec/version.h | 2 +-
> 3 files changed, 18 insertions(+), 3 deletions(-)
>
LGTM.
Ronald
_______________________________________________
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] 3+ messages in thread
end of thread, other threads:[~2023-05-12 11:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-11 16:04 [FFmpeg-devel] [PATCH] avcodec/libdav1d: export decoder frame delay James Almer
2023-05-11 19:22 ` Derek Buitenhuis
2023-05-12 11:36 ` Ronald S. Bultje
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