diff --git a/iina/Base.lproj/PrefCodecViewController.xib b/iina/Base.lproj/PrefCodecViewController.xib
index 9dbe12697c9..abccee0c17e 100644
--- a/iina/Base.lproj/PrefCodecViewController.xib
+++ b/iina/Base.lproj/PrefCodecViewController.xib
@@ -27,11 +27,11 @@
-
+
-
+
@@ -39,7 +39,7 @@
-
+
@@ -47,7 +47,7 @@
-
+
@@ -68,7 +68,7 @@
-
+
@@ -76,7 +76,7 @@
-
+
@@ -97,7 +97,7 @@
-
+
@@ -105,7 +105,7 @@
-
+
@@ -113,7 +113,7 @@
-
+
@@ -131,7 +131,7 @@
-
+
Switch to a matching refresh rate (if there is any) when the player goes fullscreen. This can eliminate stuttering, and, on some external displays, enable frame interpolation.
@@ -150,7 +150,7 @@
-
+
-
-
-
-
-
- Load primaries / trc info from mastering display metadata if available. Unchecking this option effectively disables using Display-P3 colorspace. ( Only for HDR mode )
-
-
-
-
@@ -193,6 +174,7 @@
+
@@ -201,21 +183,15 @@
-
-
-
-
-
-
diff --git a/iina/FFmpegController.h b/iina/FFmpegController.h
index e28c19d4989..72724a24df9 100644
--- a/iina/FFmpegController.h
+++ b/iina/FFmpegController.h
@@ -43,7 +43,4 @@
+ (nullable NSDictionary *)probeVideoInfoForFile:(nonnull NSString *)file;
-// HDR
-+ (nullable NSDictionary *)getColorSpaceMetadataForFile:(nonnull NSString *)file;
-
@end
diff --git a/iina/FFmpegController.m b/iina/FFmpegController.m
index 5da9ad927fd..4821fe04d56 100644
--- a/iina/FFmpegController.m
+++ b/iina/FFmpegController.m
@@ -331,179 +331,6 @@ - (void)saveThumbnail:(AVFrame *)pFrame width
}
}
-// HDR
-// Backward conversion from primaries metadata to color space is taken from here
-// https://github.com/rigaya/NVEnc/issues/51#issuecomment-392572746
-// Also from File__Analyze_Streams.cpp in MediaInfo
-
-struct masteringdisplaycolorvolume_values
-{
- int Code; //ISO code
- double Values[8]; // G, B, R, W pairs (x values then y values)
-};
-static const int MasteringDisplayColorVolume_Values_Size=4;
-static const struct masteringdisplaycolorvolume_values MasteringDisplayColorVolume_Values[] =
-{
- { 1, {15000, 30000, 7500, 3000, 32000, 16500, 15635, 16450}}, // BT.709
- { 9, { 8500, 39850, 6550, 2300, 35400, 14600, 15635, 16450}}, // BT.2020
- {11, {13250, 34500, 7500, 3000, 34000, 16000, 15700, 17550}}, // DCI P3
- {12, {13250 /*green_x*/, 34500 /*green_y*/, 7500 /*blue_x*/, 3000 /*blue_y*/, 34000 /*red_x*/, 16000 /*red_y*/, /* whitepoint_x */ 15635, /* whitepoint_y */ 16450}}, // Display P3
-};
-
-static inline double avr2d(AVRational a) {
- return (double)a.num / (double)a.den;
-}
-
-+ (NSDictionary *)getColorSpaceMetadataForFile:(nonnull NSString *)file
-{
- int ret;
- AVFormatContext *pFormatCtx = NULL;
- AVCodecContext *pCodecCtx = NULL;
- AVFrame *pFrame = NULL;
-
- @try {
- char *cFilename = strdup(file.fileSystemRepresentation);
- ret = avformat_open_input(&pFormatCtx, cFilename, NULL, NULL);
- free(cFilename);
- if (ret < 0) return NULL;
-
- ret = avformat_find_stream_info(pFormatCtx, NULL);
- if (ret < 0) return NULL;
-
- int videoStream = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
- if (videoStream < 0) return NULL;
-
- // Get the codec context for the video stream
- AVStream *pVideoStream = pFormatCtx->streams[videoStream];
-
- NSMutableDictionary *info = [[NSMutableDictionary alloc] init];
-
- switch (pVideoStream->codecpar->color_trc)
- {
- // ITU-R BT.2100 HLG (Hybrid Log-gamma) curve, aka ARIB STD-B67
- case AVCOL_TRC_ARIB_STD_B67: info[@"color-trc"] = @"hlg"; break;
- // ITU-R BT.2100 PQ (Perceptual quantizer) curve, aka SMPTE ST2084
- // assuming that AVCOL_TRC_SMPTEST2084 and AVCOL_TRC_SMPTE2084 have same value
- case AVCOL_TRC_SMPTE2084: info[@"color-trc"] = @"pq"; break;
-
- default: return NULL; // SDR content
- }
-
- AVMasteringDisplayMetadata *metadata = (AVMasteringDisplayMetadata *)av_stream_get_side_data(pVideoStream, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, NULL);
-
- if (!metadata) {
- // Find the decoder for the video stream
- const AVCodec *pCodec = avcodec_find_decoder(pVideoStream->codecpar->codec_id);
- if (!pCodec) return NULL;
-
- // Open codec
- pCodecCtx = avcodec_alloc_context3(pCodec);
- if (!pCodecCtx) return NULL;
-
- ret = avcodec_parameters_to_context(pCodecCtx, pVideoStream->codecpar);
- if (ret < 0) return NULL;
-
- ret = avcodec_open2(pCodecCtx, pCodec, NULL);
- if (ret < 0) return NULL;
-
- AVPacket packet;
- while (av_read_frame(pFormatCtx, &packet) >= 0) {
- if (packet.stream_index != videoStream) continue;
- ret = avcodec_send_packet(pCodecCtx, &packet);
- if (ret < 0) break;
-
- metadata = (AVMasteringDisplayMetadata *)av_packet_get_side_data(&packet, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, NULL);
- if (metadata) break;
-
- pFrame = av_frame_alloc();
- ret = avcodec_receive_frame(pCodecCtx, pFrame);
- if (ret < 0) {
- if (ret == AVERROR(EAGAIN)) continue;
- break;
- }
-
- AVFrameSideData* side_data = av_frame_get_side_data(pFrame, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
-
- if(side_data) metadata = (AVMasteringDisplayMetadata *) side_data->data;
- break;
- }
- }
-
- if (metadata && metadata->has_primaries)
- {
- int code = -1;
- for (int i=0; idisplay_primaries[1][0]) / 0.00002;
- if (gValueValues[0*2+j]-25 || gValue>=values->Values[0*2+j]+25)
- continue;
- double bValue = avr2d(metadata->display_primaries[2][0]) / 0.00002;
- if (bValueValues[1*2+j]-25 || bValue>=values->Values[1*2+j]+25)
- continue;
- double rValue = avr2d(metadata->display_primaries[0][0]) / 0.00002;
- if (rValueValues[2*2+j]-25 || rValue>=values->Values[2*2+j]+25)
- continue;
-
- // +/- 0.00005 (4 digits after comma)
- double wpValue = avr2d(metadata->white_point[0]) / 0.00002;
- if (wpValueValues[3*2+j]-2 || wpValue>=values->Values[3*2+j]+3)
- continue;
-
- code = values->Code;
- break;
- }
-
- switch (code)
- {
- case 9: info[@"primaries"] = @"bt.2020"; break;
- case 11: info[@"primaries"] = @"dci-p3"; break;
- case 12: info[@"primaries"] = @"display-p3"; break;
-
- case 1: // bt709. The source may not be correctly encoded, ignoring...
- default:
- break;
- }
- }
-
- if (!info[@"primaries"]) {
- NSLog(@"HDR: Video source doesn't provide master display metadata");
-
- switch (pVideoStream->codecpar->color_primaries) {
- case AVCOL_PRI_SMPTE432: info[@"primaries"] = @"display-p3"; break;
- case AVCOL_PRI_SMPTE431: info[@"primaries"] = @"dci-p3"; break;
- case AVCOL_PRI_BT2020: default: info[@"primaries"] = @"bt.2020"; break;
- }
- }
-
- if (metadata && metadata->has_luminance)
- {
- double max_luminance = avr2d(metadata->max_luminance);
- info[@"max_luminance"] = [NSNumber numberWithDouble:max_luminance];
- double min_luminance = avr2d(metadata->min_luminance);
- info[@"min_luminance"] = [NSNumber numberWithDouble:min_luminance];
- }
-
- NSLog(@"HDR: primaries=%@ color-trc=%@ max_luminance=%@", info[@"primaries"], info[@"color-trc"], info[@"max_luminance"]);
-
- return info;
- } @finally {
- if (pFrame) {
- av_frame_free(&pFrame);
- }
- if (pCodecCtx) {
- avcodec_free_context(&pCodecCtx);
- }
- if (pFormatCtx) {
- avformat_close_input(&pFormatCtx);
- avformat_free_context(pFormatCtx);
- }
- }
-}
-
+ (NSDictionary *)probeVideoInfoForFile:(nonnull NSString *)file
{
int ret;
diff --git a/iina/Preference.swift b/iina/Preference.swift
index 618b17c9445..685f21aba0f 100644
--- a/iina/Preference.swift
+++ b/iina/Preference.swift
@@ -151,7 +151,6 @@ struct Preference {
static let forceDedicatedGPU = Key("forceDedicatedGPU")
static let matchRefreshRate = Key("matchRefreshRate")
static let loadIccProfile = Key("loadIccProfile")
- static let useMasteringDisplayMetadata = Key("useMasteringDisplayMetadata")
static let audioThreads = Key("audioThreads")
static let audioLanguage = Key("audioLanguage")
@@ -731,7 +730,6 @@ struct Preference {
.forceDedicatedGPU: false,
.matchRefreshRate: false,
.loadIccProfile: true,
- .useMasteringDisplayMetadata: true,
.audioThreads: 0,
.audioLanguage: "",
.maxVolume: 100,
diff --git a/iina/VideoView.swift b/iina/VideoView.swift
index 4d32ee7f791..ff12226f2b8 100644
--- a/iina/VideoView.swift
+++ b/iina/VideoView.swift
@@ -308,22 +308,7 @@ extension VideoView {
return false;
}
- guard var primaries = mpv.getString(MPVProperty.videoParamsPrimaries), var gamma = mpv.getString(MPVProperty.videoParamsGamma) else { return false }
-
- if Preference.bool(for: .useMasteringDisplayMetadata) {
- // 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
- }
- }
- }
- }
+ guard let primaries = mpv.getString(MPVProperty.videoParamsPrimaries), let gamma = mpv.getString(MPVProperty.videoParamsGamma) else { return false }
var name: CFString? = nil;
switch primaries {
diff --git a/iina/zh-Hans.lproj/PrefCodecViewController.strings b/iina/zh-Hans.lproj/PrefCodecViewController.strings
index 802a3864ac6..115a23ea9b8 100644
--- a/iina/zh-Hans.lproj/PrefCodecViewController.strings
+++ b/iina/zh-Hans.lproj/PrefCodecViewController.strings
@@ -57,6 +57,3 @@
/* Class = "NSButtonCell"; title = "Load ICC profile"; ObjectID = "3g4-jW-uJd"; */
"3g4-jW-uJd.title" = "加载ICC色彩特性文件";
-
-/* Class = "NSButtonCell"; title = "Use mastering display metadata"; ObjectID = "bQI-md-h8I"; */
-"bQI-md-h8I.title" = "使用母版显示器元数据";