Skip to content

Commit 2200f08

Browse files
author
Clement Champetier
committed
VideoProperties: use class initialiser list for Rational
Avoid to call default constructor and set each attributes.
1 parent 86b2d8a commit 2200f08

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/AvTranscoder/mediaProperty/VideoProperties.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,10 @@ Rational VideoProperties::getTimeBase() const
351351
if( ! _codecContext )
352352
throw std::runtime_error( "unknown codec context" );
353353

354-
Rational timeBase;
355-
timeBase.num = _codecContext->time_base.num;
356-
timeBase.den = _codecContext->time_base.den;
354+
Rational timeBase = {
355+
_codecContext->time_base.num,
356+
_codecContext->time_base.den,
357+
};
357358
return timeBase;
358359
}
359360

@@ -362,9 +363,10 @@ Rational VideoProperties::getSar() const
362363
if( ! _codecContext )
363364
throw std::runtime_error( "unknown codec context" );
364365

365-
Rational sar;
366-
sar.num = _codecContext->sample_aspect_ratio.num;
367-
sar.den = _codecContext->sample_aspect_ratio.den;
366+
Rational sar = {
367+
_codecContext->sample_aspect_ratio.num,
368+
_codecContext->sample_aspect_ratio.den,
369+
};
368370
return sar;
369371
}
370372

@@ -379,9 +381,10 @@ Rational VideoProperties::getDar() const
379381
_codecContext->height * getSar().den,
380382
1024 * 1024);
381383

382-
Rational dar;
383-
dar.num = darNum;
384-
dar.den = darDen;
384+
Rational dar = {
385+
darNum,
386+
darDen,
387+
};
385388
return dar;
386389
}
387390

0 commit comments

Comments
 (0)