diff options
author | James Almer <jamrial@gmail.com> | 2021-09-03 13:50:32 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2021-09-09 09:31:53 -0300 |
commit | 5e61fce832f7bb5c33103ca09501e195a912fd26 (patch) | |
tree | e4912f15ea298b67e992f79b4663593f11b01afe | |
parent | b5cdf08cae1ae134b7409ec455bf09eb3432ad8e (diff) | |
download | ffmpeg-5e61fce832f7bb5c33103ca09501e195a912fd26.tar.gz |
avcodec/libdav1d: fix compilation after recent libdav1d API changes
They were done in preparation for an upcoming 1.0 release.
Keep supporting previous releases for the time being.
Reviewed-by: BBB
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit e204846ec16c1ab34c7f3a681734cf5190433018)
-rw-r--r-- | libavcodec/libdav1d.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index 3c2a68b7e0..a9c983eaca 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -33,6 +33,9 @@ #include "decode.h" #include "internal.h" +#define FF_DAV1D_VERSION_AT_LEAST(x,y) \ + (DAV1D_API_VERSION_MAJOR > (x) || DAV1D_API_VERSION_MAJOR == (x) && DAV1D_API_VERSION_MINOR >= (y)) + typedef struct Libdav1dContext { AVClass *class; Dav1dContext *c; @@ -145,6 +148,15 @@ static av_cold int libdav1d_init(AVCodecContext *c) if (dav1d->operating_point >= 0) s.operating_point = dav1d->operating_point; +#if FF_DAV1D_VERSION_AT_LEAST(6,0) + if (dav1d->frame_threads || dav1d->tile_threads) + s.n_threads = FFMAX(dav1d->frame_threads, dav1d->tile_threads); + else + s.n_threads = FFMIN(threads, DAV1D_MAX_THREADS); + s.max_frame_delay = (c->flags & AV_CODEC_FLAG_LOW_DELAY) ? 1 : s.n_threads; + av_log(c, AV_LOG_DEBUG, "Using %d threads, %d max_frame_delay\n", + s.n_threads, s.max_frame_delay); +#else s.n_tile_threads = dav1d->tile_threads ? dav1d->tile_threads : FFMIN(floor(sqrt(threads)), DAV1D_MAX_TILE_THREADS); @@ -153,6 +165,7 @@ static av_cold int libdav1d_init(AVCodecContext *c) : FFMIN(ceil(threads / s.n_tile_threads), DAV1D_MAX_FRAME_THREADS); av_log(c, AV_LOG_DEBUG, "Using %d frame threads, %d tile threads\n", s.n_frame_threads, s.n_tile_threads); +#endif res = dav1d_open(&dav1d->c, &s); if (res < 0) @@ -456,6 +469,13 @@ static av_cold int libdav1d_close(AVCodecContext *c) return 0; } +#ifndef DAV1D_MAX_FRAME_THREADS +#define DAV1D_MAX_FRAME_THREADS DAV1D_MAX_THREADS +#endif +#ifndef DAV1D_MAX_TILE_THREADS +#define DAV1D_MAX_TILE_THREADS DAV1D_MAX_THREADS +#endif + #define OFFSET(x) offsetof(Libdav1dContext, x) #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM static const AVOption libdav1d_options[] = { |