Skip to content

Draft: Send content frame rate surface hints#18038

Draft
k2naveen wants to merge 1 commit into
mpv-player:masterfrom
k2naveen:test-content-refresh-rate
Draft

Draft: Send content frame rate surface hints#18038
k2naveen wants to merge 1 commit into
mpv-player:masterfrom
k2naveen:test-content-refresh-rate

Conversation

@k2naveen
Copy link
Copy Markdown

Mpv player detects content fps via demux/decoder metadata, rationalized with FFmpeg av_d2q() and calls set_frame_rate(num, den) to sends the content frame rate (a rational frame rate numerator / denominator) using a new wp-content-frame-rate-v1 protocol to the compositor.

A new Wayland protocol, wp_content_frame_rate_v1 is floated here https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/518

Mutter implementation can be found here https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/5091

@k2naveen k2naveen force-pushed the test-content-refresh-rate branch from 6db2d13 to ad37b44 Compare May 30, 2026 14:11
@Dudemanguy Dudemanguy marked this pull request as draft May 30, 2026 14:14
Copy link
Copy Markdown
Member

@Dudemanguy Dudemanguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously still a draft but just some small things.

Comment thread video/out/meson.build
@@ -1,3 +1,5 @@
fs = import('fs')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to use this module.

Comment on lines +3827 to +3828
uint32_t den = wl->current_content_frame_rate_den ?
wl->current_content_frame_rate_den : 1;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it better to just initialize the value as 0/1 so you wouldn't need this check?

Comment thread video/out/vo.h
Comment on lines +146 to +149
struct voctrl_content_frame_rate {
uint32_t numerator;
uint32_t denominator;
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this you could just use a uint32_t array.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to use double as in all other code. This needs to be converted only in wayland_common.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure either way is fine with me.

Comment thread player/misc.c
};

if (track && track->vo_c && !track->image) {
double fps = track->vo_c->filter->container_fps;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use estimated fps, if available? Container value is often invalid.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this rate should be what mpv is actually presenting at so estimated-vf-fps is the right value to use here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course it's different in display-resync mode, but as I understand we prefer content framerate as target and on top of that display-resync would work.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I guess I'm not sure if reporting 23.976 in display-sync mode would confuse the compositor or not with this protocol. The content rate is that 23.976 number but we're technically drawing every vblank in that mode.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I think, it should mostly be used for frame rate adaptation on compositor side, so that it should presentation limit us, but I have not read it at all, so there is that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants