File indexing completed on 2024-04-21 04:51:53
0001 /* 0002 SPDX-FileCopyrightText: 2017 Nicolas Carion 0003 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 This file is part of Kdenlive. See www.kdenlive.org. 0005 */ 0006 0007 #include "profileinfo.hpp" 0008 #include <KLocalizedString> 0009 #include <mlt++/MltProfile.h> 0010 0011 bool ProfileInfo::operator==(const ProfileInfo &other) const 0012 { 0013 if (!description().isEmpty() && other.description() == description()) { 0014 return true; 0015 } 0016 int fps = frame_rate_num() * 100 / frame_rate_den(); 0017 int sar = sample_aspect_num() * 100 / sample_aspect_den(); 0018 int dar = display_aspect_num() * 100 / display_aspect_den(); 0019 return other.frame_rate_num() * 100 / other.frame_rate_den() == fps && other.width() == width() && other.height() == height() && 0020 other.progressive() == progressive() && (progressive() ? true : other.bottom_field_first() == bottom_field_first()) && 0021 other.sample_aspect_num() * 100 / other.sample_aspect_den() == sar && other.display_aspect_num() * 100 / other.display_aspect_den() == dar && 0022 other.colorspace() == colorspace(); 0023 } 0024 0025 bool ProfileInfo::isCompatible(std::unique_ptr<ProfileInfo> &other) const 0026 { 0027 return frame_rate_num() * 100 / frame_rate_den() == other->frame_rate_num() * 100 / other->frame_rate_den(); 0028 } 0029 0030 bool ProfileInfo::isCompatible(Mlt::Profile *other) const 0031 { 0032 return frame_rate_num() * 100 / frame_rate_den() == other->frame_rate_num() * 100 / other->frame_rate_den(); 0033 } 0034 0035 QString ProfileInfo::colorspaceDescription() const 0036 { 0037 // TODO: should the descriptions be translated? 0038 switch (colorspace()) { 0039 case 601: 0040 return QStringLiteral("ITU-R 601"); 0041 case 709: 0042 return QStringLiteral("ITU-R 709"); 0043 case 240: 0044 return QStringLiteral("SMPTE240M"); 0045 default: 0046 return i18n("Unknown"); 0047 } 0048 } 0049 0050 const QString ProfileInfo::descriptiveString() const 0051 { 0052 QString data = description(); 0053 if (!data.isEmpty()) { 0054 data.append(QLatin1Char(' ')); 0055 } 0056 QString fps_str; 0057 if (frame_rate_num() % frame_rate_den() == 0) { 0058 fps_str = QString::number(frame_rate_num() / frame_rate_den()); 0059 } else { 0060 fps_str = QString::number(double(frame_rate_num()) / frame_rate_den(), 'f', 2); 0061 } 0062 data.append(QStringLiteral("(%1x%2, %3fps)").arg(width()).arg(height()).arg(fps_str)); 0063 return data; 0064 } 0065 0066 const QString ProfileInfo::dialogDescriptiveString() const 0067 { 0068 QString text; 0069 if (frame_rate_num() % frame_rate_den() == 0) { 0070 text = QString::number(frame_rate_num() / frame_rate_den()); 0071 } else { 0072 text = QString::number(frame_rate_num() / frame_rate_den(), 'f', 2); 0073 } 0074 text.append(i18nc("frames per second", "fps")); 0075 if (!progressive()) { 0076 text.append(i18n(" interlaced")); 0077 } 0078 return text; 0079 }