From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] avcodec/libdav1d: export decoder frame delay Date: Thu, 11 May 2023 13:04:45 -0300 Message-ID: <20230511160445.2214-1-jamrial@gmail.com> (raw) 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".
next reply other threads:[~2023-05-11 16:04 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-11 16:04 James Almer [this message] 2023-05-11 19:22 ` Derek Buitenhuis 2023-05-12 11:36 ` Ronald S. Bultje
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230511160445.2214-1-jamrial@gmail.com \ --to=jamrial@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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