Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Commit

Permalink
Use FFMPEG to check for mastering display metadata, for enabling Disp…
Browse files Browse the repository at this point in the history
…lay-P3 primaries

Ref: mpv-player/mpv#9620
  • Loading branch information
CarterLi committed Jan 21, 2022
1 parent e69c1e0 commit 53a0cd7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion iina/VideoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,20 @@ extension VideoView {
return false;
}

guard let primaries = mpv.getString(MPVProperty.videoParamsPrimaries), let gamma = mpv.getString(MPVProperty.videoParamsGamma) else { return false }
guard var primaries = mpv.getString(MPVProperty.videoParamsPrimaries), var gamma = mpv.getString(MPVProperty.videoParamsGamma) else { return false }

// Because MPV won't check for mastering display metadata, we have to check it ourselves
// TODO: Supports multi-track video source. Maps MPV `player.info.vid` to FFMPEG `streamIndex`
if primaries == "bt.2020" && !player.info.isNetworkResource && player.info.videoTracks.count == 1 {
if let path = mpv.getString(MPVProperty.path), let colorspaceData = FFmpegController.getColorSpaceMetadata(forFile: path) {
if let _primaries = colorspaceData["primaries"] as? String {
primaries = _primaries
}
if let _gamma = colorspaceData["color-trc"] as? String {
gamma = _gamma
}
}
}

var name: CFString? = nil;
switch primaries {
Expand Down

0 comments on commit 53a0cd7

Please sign in to comment.