History

vd_lavc: add "auto" choice for vd-lavc-dr

--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).

sfan5 committed 3 years ago

Commit c7ea0cd1 parent f8c17f54 files · +19 −6Browse files

Unified · Split

4 files
  1. DOCS/interface-changes.rst +1 −0
  2. DOCS/man/options.rst +6 −2
  3. video/decode/vd_lavc.c +7 −4
  4. video/out/vo.h +5 −0
DOCS/interface-changes.rst+1−0
@@ -45,6 +45,7 @@ Interface changes · 44 unmodified lines
45 watch-later. It is still written by default but you may45 watch-later. It is still written by default but you may
46 need to explictly add `start` depending on how you have46 need to explictly add `start` depending on how you have
47 `--watch-later-options` configured.47 `--watch-later-options` configured.
48 - add `--vd-lavc-dr=auto` and make it the default
48 --- mpv 0.35.0 ---49 --- mpv 0.35.0 ---
49 - add the `--vo=gpu-next` video output driver, as well as the options50 - add the `--vo=gpu-next` video output driver, as well as the options
50 `--allow-delayed-peak-detect`, `--builtin-scalers`,51 `--allow-delayed-peak-detect`, `--builtin-scalers`,
DOCS/man/options.rst+6−2
@@ -1700,8 +1700,8 @@ Video · 1699 unmodified lines
1700 support this, then it will be treated as ``cpu``, regardless of the setting.1700 support this, then it will be treated as ``cpu``, regardless of the setting.
1701 Currently, only ``gpu-next`` supports film grain application.1701 Currently, only ``gpu-next`` supports film grain application.
1702 1702
1703``--vd-lavc-dr=<yes|no>``1703``--vd-lavc-dr=<auto|yes|no>``
1704 Enable direct rendering (default: yes). If this is set to ``yes``, the1704 Enable direct rendering (default: auto). If this is set to ``yes``, the
1705 video will be decoded directly to GPU video memory (or staging buffers).1705 video will be decoded directly to GPU video memory (or staging buffers).
1706 This can speed up video upload, and may help with large resolutions or1706 This can speed up video upload, and may help with large resolutions or
1707 slow hardware. This works only with the following VOs:1707 slow hardware. This works only with the following VOs:
@@ -1709,6 +1709,10 @@ Video · 1 unmodified line
1709 - ``gpu``: requires at least OpenGL 4.4 or Vulkan.1709 - ``gpu``: requires at least OpenGL 4.4 or Vulkan.
1710 - ``libmpv``: The libmpv render API has optional support.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 Using video filters of any kind that write to the image data (or output1716 Using video filters of any kind that write to the image data (or output
1713 newly allocated frames) will silently disable the DR code path.1717 newly allocated frames) will silently disable the DR code path.
1714 1718
video/decode/vd_lavc.c+7−4
@@ -120,7 +120,8 @@ const struct m_sub_options vd_lavc_conf = { · 119 unmodified lines
120 {"vd-lavc-software-fallback", OPT_CHOICE(software_fallback,120 {"vd-lavc-software-fallback", OPT_CHOICE(software_fallback,
121 {"no", INT_MAX}, {"yes", 1}), M_RANGE(1, INT_MAX)},121 {"no", INT_MAX}, {"yes", 1}), M_RANGE(1, INT_MAX)},
122 {"vd-lavc-o", OPT_KEYVALUELIST(avopts)},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 {"hwdec", OPT_STRING(hwdec_api),125 {"hwdec", OPT_STRING(hwdec_api),
125 .help = hwdec_opt_help,126 .help = hwdec_opt_help,
126 .flags = M_OPT_OPTIONAL_PARAM | UPDATE_HWDEC},127 .flags = M_OPT_OPTIONAL_PARAM | UPDATE_HWDEC},
@@ -139,7 +140,7 @@ const struct m_sub_options vd_lavc_conf = { · 12 unmodified lines
139 .skip_idct = AVDISCARD_DEFAULT,140 .skip_idct = AVDISCARD_DEFAULT,
140 .skip_frame = AVDISCARD_DEFAULT,141 .skip_frame = AVDISCARD_DEFAULT,
141 .framedrop = AVDISCARD_NONREF,142 .framedrop = AVDISCARD_NONREF,
142 .dr = 1,143 .dr = -1,
143 .hwdec_api = "no",144 .hwdec_api = "no",
144 .hwdec_codecs = "h264,vc1,hevc,vp8,vp9,av1,prores",145 .hwdec_codecs = "h264,vc1,hevc,vp8,vp9,av1,prores",
145 // Maximum number of surfaces the player wants to buffer. This number146 // 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 struct mp_image *img = mp_image_pool_get_no_alloc(p->dr_pool, imgfmt, w, h);986 struct mp_image *img = mp_image_pool_get_no_alloc(p->dr_pool, imgfmt, w, h);
986 if (!img) {987 if (!img) {
987 MP_DBG(p, "Allocating new DR image...\n");988 bool host_cached = p->opts->dr == -1; // auto
988 img = vo_get_image(p->vo, imgfmt, w, h, stride_align, 0);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 if (!img) {992 if (!img) {
990 MP_DBG(p, "...failed..\n");993 MP_DBG(p, "...failed..\n");
991 goto fallback;994 goto fallback;
video/out/vo.h+5−0
@@ -194,6 +194,11 @@ enum { · 193 unmodified lines
194 VO_CAP_FILM_GRAIN = 1 << 3,194 VO_CAP_FILM_GRAIN = 1 << 3,
195};195};
196 196
197enum {
198 // Require DR buffers to be host-cached (i.e. fast readback)
199 VO_DR_FLAG_HOST_CACHED = 1 << 0,
200};
201
197#define VO_MAX_REQ_FRAMES 10202#define VO_MAX_REQ_FRAMES 10
198 203
199struct vo;204struct vo;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t