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 */
0005 
0006 #pragma once
0007 
0008 #include "profileinfo.hpp"
0009 #include <QDomElement>
0010 #include <QString>
0011 #include <memory>
0012 
0013 #include <mlt++/MltProfile.h>
0014 
0015 /** @class ProfileModel
0016     @brief This is a wrapper around Mlt::Profile to be used by the rest of kdenlive.
0017     It has implicit conversion to Mlt::Profile so you can use it directly in calls to Mlt backend.
0018   */
0019 class ProfileModel : public ProfileInfo
0020 {
0021 
0022 public:
0023     ProfileModel() = delete;
0024 
0025     /** @brief Constructs a profile using the path to the profile description
0026      */
0027     ProfileModel(const QString &path);
0028     ~ProfileModel() override = default;
0029 
0030     bool is_valid() const override;
0031     QString description() const override;
0032     int frame_rate_num() const override;
0033     int frame_rate_den() const override;
0034     double fps() const override;
0035     int width() const override;
0036     int height() const override;
0037     bool progressive() const override;
0038     bool bottom_field_first() const override;
0039     int sample_aspect_num() const override;
0040     int sample_aspect_den() const override;
0041     double sar() const override;
0042     int display_aspect_num() const override;
0043     int display_aspect_den() const override;
0044     double dar() const override;
0045     int is_explicit() const;
0046     void set_explicit(int b);
0047     int colorspace() const override;
0048     mlt_profile get_profile() const;
0049     QString path() const override;
0050 
0051     void adjustDimensions() override{};
0052 
0053     /** @brief get underlying profile. Use with caution*/
0054     Mlt::Profile &profile() { return *m_profile.get(); };
0055 
0056 protected:
0057     QString m_path;
0058     bool m_invalid;
0059     QString m_description;
0060     bool m_bottom_field_first;
0061 
0062     std::unique_ptr<Mlt::Profile> m_profile;
0063 };
0064 
0065 /** @class ProfileParam
0066     @brief This class serves to describe the parameters of a profile
0067  */
0068 class ProfileParam : public ProfileInfo
0069 {
0070 public:
0071     ProfileParam() = delete;
0072 
0073     ProfileParam(QDomElement element);
0074     ProfileParam(ProfileInfo *p);
0075     ProfileParam(Mlt::Profile *p);
0076     ProfileParam(ProfileParam *p);
0077 
0078     QString path() const override;
0079     QString description() const override;
0080     int frame_rate_num() const override;
0081     int frame_rate_den() const override;
0082     int width() const override;
0083     int height() const override;
0084     bool progressive() const override;
0085     bool bottom_field_first() const override;
0086     int sample_aspect_num() const override;
0087     int sample_aspect_den() const override;
0088     int display_aspect_num() const override;
0089     int display_aspect_den() const override;
0090     int colorspace() const override;
0091     double fps() const override;
0092     double sar() const override;
0093     double dar() const override;
0094 
0095     // A profile's width should always be a multiple of 8
0096     void adjustDimensions() override;
0097     bool is_valid() const override;
0098 
0099     QString m_path;
0100     QString m_description;
0101     int m_frame_rate_num;
0102     int m_frame_rate_den;
0103     int m_width;
0104     int m_height;
0105     bool m_progressive;
0106     bool m_bottom_field_first;
0107     int m_sample_aspect_num;
0108     int m_sample_aspect_den;
0109     int m_display_aspect_num;
0110     int m_display_aspect_den;
0111     int m_colorspace;
0112     double m_fps;
0113     double m_sar;
0114     double m_dar;
0115 };