1 /**
2 * MltProfile.cpp - MLT Wrapper
3 * Copyright (C) 2008-2020 Meltytech, LLC
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #include "MltProfile.h"
21 #include "MltProperties.h"
22 #include "MltProducer.h"
23
24 using namespace Mlt;
25
Profile()26 Profile::Profile( ) :
27 instance( NULL )
28 {
29 instance = mlt_profile_init( NULL );
30 }
31
Profile(const char * name)32 Profile::Profile( const char* name ) :
33 instance( NULL )
34 {
35 instance = mlt_profile_init( name );
36 }
37
Profile(Properties & properties)38 Profile::Profile( Properties& properties ) :
39 instance( NULL )
40 {
41 instance = mlt_profile_load_properties( properties.get_properties() );
42 }
43
Profile(mlt_profile profile)44 Profile::Profile( mlt_profile profile ) :
45 instance( profile )
46 {
47 }
48
~Profile()49 Profile::~Profile( )
50 {
51 if ( instance )
52 mlt_profile_close( instance );
53 instance = NULL;
54 }
55
is_valid() const56 bool Profile::is_valid() const
57 {
58 return instance != NULL;
59 }
60
get_profile() const61 mlt_profile Profile::get_profile( ) const
62 {
63 return instance;
64 }
65
description() const66 char* Profile::description() const
67 {
68 return instance->description;
69 }
70
frame_rate_num() const71 int Profile::frame_rate_num() const
72 {
73 return instance->frame_rate_num;
74 }
75
frame_rate_den() const76 int Profile::frame_rate_den() const
77 {
78 return instance->frame_rate_den;
79 }
80
fps() const81 double Profile::fps() const
82 {
83 return mlt_profile_fps( instance );
84 }
85
width() const86 int Profile::width() const
87 {
88 return instance->width;
89 }
90
height() const91 int Profile::height() const
92 {
93 return instance->height;
94 }
95
progressive() const96 bool Profile::progressive() const
97 {
98 return instance->progressive;
99 }
100
sample_aspect_num() const101 int Profile::sample_aspect_num() const
102 {
103 return instance->sample_aspect_num;
104 }
105
sample_aspect_den() const106 int Profile::sample_aspect_den() const
107 {
108 return instance->sample_aspect_den;
109 }
110
sar() const111 double Profile::sar() const
112 {
113 return mlt_profile_sar( instance );
114 }
115
display_aspect_num() const116 int Profile::display_aspect_num() const
117 {
118 return instance->display_aspect_num;
119 }
120
display_aspect_den() const121 int Profile::display_aspect_den() const
122 {
123 return instance->display_aspect_den;
124 }
125
dar() const126 double Profile::dar() const
127 {
128 return mlt_profile_dar( instance );
129 }
130
is_explicit() const131 int Profile::is_explicit() const
132 {
133 return instance->is_explicit;
134 }
135
colorspace() const136 int Profile::colorspace() const
137 {
138 return instance->colorspace;
139 }
140
list()141 Properties* Profile::list()
142 {
143 return new Properties( mlt_profile_list() );
144 }
145
from_producer(Producer & producer)146 void Profile::from_producer( Producer &producer )
147 {
148 mlt_profile_from_producer( instance, producer.get_producer() );
149 }
150
set_width(int width)151 void Profile::set_width( int width )
152 {
153 instance->width = width;
154 }
155
set_height(int height)156 void Profile::set_height( int height )
157 {
158 instance->height = height;
159 }
160
set_sample_aspect(int numerator,int denominator)161 void Profile::set_sample_aspect( int numerator, int denominator )
162 {
163 instance->sample_aspect_num = numerator;
164 instance->sample_aspect_den = denominator;
165 }
166
set_display_aspect(int numerator,int denominator)167 void Profile::set_display_aspect(int numerator, int denominator)
168 {
169 instance->display_aspect_num = numerator;
170 instance->display_aspect_den = denominator;
171 }
172
set_progressive(int progressive)173 void Profile::set_progressive( int progressive )
174 {
175 instance->progressive = progressive;
176 }
177
set_colorspace(int colorspace)178 void Profile::set_colorspace( int colorspace )
179 {
180 instance->colorspace = colorspace;
181 }
182
set_frame_rate(int numerator,int denominator)183 void Profile::set_frame_rate( int numerator, int denominator )
184 {
185 instance->frame_rate_num = numerator;
186 instance->frame_rate_den = denominator;
187 }
188
set_explicit(int boolean)189 void Profile::set_explicit( int boolean )
190 {
191 instance->is_explicit = boolean;
192 }
193
scale_width(int width)194 double Profile::scale_width(int width)
195 {
196 return mlt_profile_scale_width(instance, width);
197 }
198
scale_height(int height)199 double Profile::scale_height(int height)
200 {
201 return mlt_profile_scale_height(instance, height);
202 }
203