--vd-lavc-dr defaulted to "yes", which caused issues on certain hardware. Instead of disabling it, add a new "auto" value and make it the default. The "auto" choice will enable DR only when we can request host-cached buffers (as signalled by the new VO_DR_FLAG_HOST_CACHED).
Unified · Split
| @@ -45,6 +45,7 @@ Interface changes · 44 unmodified lines | ||
| 45 | 45 | watch-later. It is still written by default but you may |
| 46 | 46 | need to explictly add `start` depending on how you have |
| 47 | 47 | `--watch-later-options` configured. |
| 48 | + - add `--vd-lavc-dr=auto` and make it the default | |
| 48 | 49 | --- mpv 0.35.0 --- |
| 49 | 50 | - add the `--vo=gpu-next` video output driver, as well as the options |
| 50 | 51 | `--allow-delayed-peak-detect`, `--builtin-scalers`, |
| @@ -1700,8 +1700,8 @@ Video · 1699 unmodified lines | ||
| 1700 | 1700 | support this, then it will be treated as ``cpu``, regardless of the setting. |
| 1701 | 1701 | Currently, only ``gpu-next`` supports film grain application. |
| 1702 | 1702 | |
| 1703 | −``--vd-lavc-dr=<yes|no>`` | |
| 1704 | − Enable direct rendering (default: yes). If this is set to ``yes``, the | |
| 1703 | +``--vd-lavc-dr=<auto|yes|no>`` | |
| 1704 | + Enable direct rendering (default: auto). If this is set to ``yes``, the | |
| 1705 | 1705 | video will be decoded directly to GPU video memory (or staging buffers). |
| 1706 | 1706 | This can speed up video upload, and may help with large resolutions or |
| 1707 | 1707 | slow hardware. This works only with the following VOs: |
| @@ -1709,6 +1709,10 @@ Video · 1 unmodified line | ||
| 1709 | 1709 | - ``gpu``: requires at least OpenGL 4.4 or Vulkan. |
| 1710 | 1710 | - ``libmpv``: The libmpv render API has optional support. |
| 1711 | 1711 | |
| 1712 | + The ``auto`` option will try to guess whether DR can improve performance | |
| 1713 | + on your particular hardware. Currently this enables it on AMD or NVIDIA | |
| 1714 | + if using OpenGL or unconditionally if using Vulkan. | |
| 1715 | + | |
| 1712 | 1716 | Using video filters of any kind that write to the image data (or output |
| 1713 | 1717 | newly allocated frames) will silently disable the DR code path. |
| 1714 | 1718 | |
| @@ -120,7 +120,8 @@ const struct m_sub_options vd_lavc_conf = { · 119 unmodified lines | ||
| 120 | 120 | {"vd-lavc-software-fallback", OPT_CHOICE(software_fallback, |
| 121 | 121 | {"no", INT_MAX}, {"yes", 1}), M_RANGE(1, INT_MAX)}, |
| 122 | 122 | {"vd-lavc-o", OPT_KEYVALUELIST(avopts)}, |
| 123 | − {"vd-lavc-dr", OPT_FLAG(dr)}, | |
| 123 | + {"vd-lavc-dr", OPT_CHOICE(dr, | |
| 124 | + {"auto", -1}, {"no", 0}, {"yes", 1})}, | |
| 124 | 125 | {"hwdec", OPT_STRING(hwdec_api), |
| 125 | 126 | .help = hwdec_opt_help, |
| 126 | 127 | .flags = M_OPT_OPTIONAL_PARAM | UPDATE_HWDEC}, |
| @@ -139,7 +140,7 @@ const struct m_sub_options vd_lavc_conf = { · 12 unmodified lines | ||
| 139 | 140 | .skip_idct = AVDISCARD_DEFAULT, |
| 140 | 141 | .skip_frame = AVDISCARD_DEFAULT, |
| 141 | 142 | .framedrop = AVDISCARD_NONREF, |
| 142 | − .dr = 1, | |
| 143 | + .dr = -1, | |
| 143 | 144 | .hwdec_api = "no", |
| 144 | 145 | .hwdec_codecs = "h264,vc1,hevc,vp8,vp9,av1,prores", |
| 145 | 146 | // Maximum number of surfaces the player wants to buffer. This number |
| @@ -984,8 +985,10 @@ static int get_buffer2_direct(AVCodecContext *avctx, AVFrame *pic, int flags) · 838 unmodified lines | ||
| 984 | 985 | |
| 985 | 986 | struct mp_image *img = mp_image_pool_get_no_alloc(p->dr_pool, imgfmt, w, h); |
| 986 | 987 | if (!img) { |
| 987 | − MP_DBG(p, "Allocating new DR image...\n"); | |
| 988 | − img = vo_get_image(p->vo, imgfmt, w, h, stride_align, 0); | |
| 988 | + bool host_cached = p->opts->dr == -1; // auto | |
| 989 | + int dr_flags = host_cached ? VO_DR_FLAG_HOST_CACHED : 0; | |
| 990 | + MP_DBG(p, "Allocating new%s DR image...\n", host_cached ? " (host-cached)" : ""); | |
| 991 | + img = vo_get_image(p->vo, imgfmt, w, h, stride_align, dr_flags); | |
| 989 | 992 | if (!img) { |
| 990 | 993 | MP_DBG(p, "...failed..\n"); |
| 991 | 994 | goto fallback; |
| @@ -194,6 +194,11 @@ enum { · 193 unmodified lines | ||
| 194 | 194 | VO_CAP_FILM_GRAIN = 1 << 3, |
| 195 | 195 | }; |
| 196 | 196 | |
| 197 | +enum { | |
| 198 | + // Require DR buffers to be host-cached (i.e. fast readback) | |
| 199 | + VO_DR_FLAG_HOST_CACHED = 1 << 0, | |
| 200 | +}; | |
| 201 | + | |
| 197 | 202 | #define VO_MAX_REQ_FRAMES 10 |
| 198 | 203 | |
| 199 | 204 | struct vo; |