git: 3efc49fffd5a - main - multimedia/mythtv: unbreak with dav1d 1.0.0

From: Jan Beich <jbeich_at_FreeBSD.org>
Date: Sun, 20 Feb 2022 18:31:13 UTC
The branch main has been updated by jbeich:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3efc49fffd5ace5b83292d1037b4f3fc03164815

commit 3efc49fffd5ace5b83292d1037b4f3fc03164815
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2022-02-20 16:56:13 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2022-02-20 18:30:48 +0000

    multimedia/mythtv: unbreak with dav1d 1.0.0
    
    libavcodec/libdav1d.c:135:7: error: no member named 'n_tile_threads' in 'struct Dav1dSettings'
        s.n_tile_threads = dav1d->tile_threads
        ~ ^
    libavcodec/libdav1d.c:138:7: error: no member named 'n_frame_threads' in 'struct Dav1dSettings'
        s.n_frame_threads = dav1d->frame_threads
        ~ ^
---
 multimedia/mythtv/files/patch-dav1d-1.0 | 111 ++++++++++++++++++++++++++++++++
 1 file changed, 111 insertions(+)

diff --git a/multimedia/mythtv/files/patch-dav1d-1.0 b/multimedia/mythtv/files/patch-dav1d-1.0
new file mode 100644
index 000000000000..272eb84994a9
--- /dev/null
+++ b/multimedia/mythtv/files/patch-dav1d-1.0
@@ -0,0 +1,111 @@
+https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/5e61fce832f7
+
+libavcodec/libdav1d.c:137:7: error: no member named 'n_tile_threads' in 'struct Dav1dSettings'
+    s.n_tile_threads = dav1d->tile_threads
+    ~ ^
+libavcodec/libdav1d.c:139:52: error: use of undeclared identifier 'DAV1D_MAX_TILE_THREADS'
+                     : FFMIN(floor(sqrt(threads)), DAV1D_MAX_TILE_THREADS);
+                                                   ^
+libavcodec/libdav1d.c:139:52: error: use of undeclared identifier 'DAV1D_MAX_TILE_THREADS'
+libavcodec/libdav1d.c:140:7: error: no member named 'n_frame_threads' in 'struct Dav1dSettings'
+    s.n_frame_threads = dav1d->frame_threads
+    ~ ^
+libavcodec/libdav1d.c:142:48: error: no member named 'n_tile_threads' in 'struct Dav1dSettings'
+                      : FFMIN(ceil(threads / s.n_tile_threads), DAV1D_MAX_FRAME_THREADS);
+                                             ~ ^
+./libavutil/common.h:96:22: note: expanded from macro 'FFMIN'
+#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
+                     ^
+libavcodec/libdav1d.c:142:65: error: use of undeclared identifier 'DAV1D_MAX_FRAME_THREADS'; did you mean 'DAV1D_OBU_FRAME_HDR'?
+                      : FFMIN(ceil(threads / s.n_tile_threads), DAV1D_MAX_FRAME_THREADS);
+                                                                ^~~~~~~~~~~~~~~~~~~~~~~
+                                                                DAV1D_OBU_FRAME_HDR
+./libavutil/common.h:96:28: note: expanded from macro 'FFMIN'
+#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
+                           ^
+/usr/local/include/dav1d/headers.h:48:5: note: 'DAV1D_OBU_FRAME_HDR' declared here
+    DAV1D_OBU_FRAME_HDR = 3,
+    ^
+libavcodec/libdav1d.c:142:65: error: use of undeclared identifier 'DAV1D_MAX_FRAME_THREADS'; did you mean 'DAV1D_OBU_FRAME_HDR'?
+                      : FFMIN(ceil(threads / s.n_tile_threads), DAV1D_MAX_FRAME_THREADS);
+                                                                ^~~~~~~~~~~~~~~~~~~~~~~
+                                                                DAV1D_OBU_FRAME_HDR
+./libavutil/common.h:96:34: note: expanded from macro 'FFMIN'
+#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
+                                 ^
+/usr/local/include/dav1d/headers.h:48:5: note: 'DAV1D_OBU_FRAME_HDR' declared here
+    DAV1D_OBU_FRAME_HDR = 3,
+    ^
+libavcodec/libdav1d.c:142:48: error: no member named 'n_tile_threads' in 'struct Dav1dSettings'
+                      : FFMIN(ceil(threads / s.n_tile_threads), DAV1D_MAX_FRAME_THREADS);
+                                             ~ ^
+./libavutil/common.h:96:40: note: expanded from macro 'FFMIN'
+#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
+                                       ^
+libavcodec/libdav1d.c:144:14: error: no member named 'n_frame_threads' in 'struct Dav1dSettings'
+           s.n_frame_threads, s.n_tile_threads);
+           ~ ^
+libavcodec/libdav1d.c:144:33: error: no member named 'n_tile_threads' in 'struct Dav1dSettings'
+           s.n_frame_threads, s.n_tile_threads);
+                              ~ ^
+libavcodec/libdav1d.c:378:94: error: use of undeclared identifier 'DAV1D_MAX_TILE_THREADS'
+    { "tilethreads", "Tile threads", OFFSET(tile_threads), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_TILE_THREADS, VD },
+                                                                                             ^
+libavcodec/libdav1d.c:379:97: error: use of undeclared identifier 'DAV1D_MAX_FRAME_THREADS'; did you mean 'DAV1D_OBU_FRAME_HDR'?
+    { "framethreads", "Frame threads", OFFSET(frame_threads), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_FRAME_THREADS, VD },
+                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~
+                                                                                                DAV1D_OBU_FRAME_HDR
+/usr/local/include/dav1d/headers.h:48:5: note: 'DAV1D_OBU_FRAME_HDR' declared here
+    DAV1D_OBU_FRAME_HDR = 3,
+    ^
+
+--- external/FFmpeg/libavcodec/libdav1d.c.orig	2020-03-23 14:32:28 UTC
++++ external/FFmpeg/libavcodec/libdav1d.c
+@@ -30,6 +30,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;
+@@ -132,6 +135,15 @@ static av_cold int libdav1d_init(AVCodecContext *c)
+     s.allocator.release_picture_callback = libdav1d_picture_release;
+     s.apply_grain = dav1d->apply_grain;
+ 
++#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);
+@@ -140,6 +152,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)
+@@ -335,6 +348,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