Skip to content

Commit eaf480e

Browse files
author
Clement Champetier
committed
Manage duration as a float
Double type is not constructed the same way in C++ and Java, and does not exist in python. Our bindings of 'C++ double' could create issues, and since a fps with a simple precision is enough, we decided to return fps as float.
1 parent c619856 commit eaf480e

17 files changed

+33
-36
lines changed

src/AvTranscoder/mediaProperty/FileProperties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ double FileProperties::getStartTime() const
157157
return 1.0 * (unsigned int)_avFormatContext->start_time / AV_TIME_BASE;
158158
}
159159

160-
double FileProperties::getDuration() const
160+
float FileProperties::getDuration() const
161161
{
162162
if( ! _avFormatContext )
163163
throw std::runtime_error( "unknown format context" );

src/AvTranscoder/mediaProperty/FileProperties.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class AvExport FileProperties
4444

4545
size_t getProgramsCount() const;
4646
double getStartTime() const;
47-
double getDuration() const; ///< in seconds
47+
float getDuration() const; ///< in seconds
4848
size_t getBitRate() const; ///< total stream bitrate in bit/s, 0 if not available (result of a computation by ffmpeg)
4949
size_t getPacketSize() const;
5050

src/AvTranscoder/mediaProperty/StreamProperties.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ Rational StreamProperties::getTimeBase() const
3737
return timeBase;
3838
}
3939

40-
double StreamProperties::getDuration() const
40+
float StreamProperties::getDuration() const
4141
{
4242
Rational timeBase = getTimeBase();
43-
double duration = ( timeBase.num / (double) timeBase.den ) * _formatContext->streams[_streamIndex]->duration;
44-
return duration;
43+
return ( timeBase.num / (float) timeBase.den ) * _formatContext->streams[_streamIndex]->duration;
4544
}
4645

4746
PropertyVector StreamProperties::getPropertiesAsVector() const

src/AvTranscoder/mediaProperty/StreamProperties.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class AvExport StreamProperties
1818
size_t getStreamIndex() const { return _streamIndex; }
1919
size_t getStreamId() const;
2020
Rational getTimeBase() const;
21-
double getDuration() const; ///< in seconds
21+
float getDuration() const; ///< in seconds
2222
const PropertyVector& getMetadatas() const { return _metadatas; }
2323

2424
#ifndef SWIG

src/AvTranscoder/mediaProperty/VideoProperties.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,8 @@ float VideoProperties::getFps() const
523523
const size_t nbFrames = getNbFrames();
524524
if( nbFrames )
525525
{
526-
double duration = getDuration();
527-
double epsilon = std::numeric_limits<double>::epsilon();
526+
const float duration = getDuration();
527+
const float epsilon = std::numeric_limits<float>::epsilon();
528528
if( duration > epsilon )
529529
return nbFrames / duration;
530530
}

src/AvTranscoder/stat/AudioStat.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ namespace avtranscoder
1212
class AvExport AudioStat
1313
{
1414
public:
15-
AudioStat( const double duration, const size_t nbPackets )
15+
AudioStat( const float duration, const size_t nbPackets )
1616
: _duration( duration )
1717
, _nbPackets( nbPackets )
1818
{}
1919

2020
public:
21-
double _duration;
21+
float _duration;
2222
size_t _nbPackets;
2323
};
2424

src/AvTranscoder/stat/VideoStat.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace avtranscoder
1212
class AvExport VideoStat
1313
{
1414
public:
15-
VideoStat( const double duration, const size_t nbFrames )
15+
VideoStat( const float duration, const size_t nbFrames )
1616
: _duration( duration )
1717
, _nbFrames( nbFrames )
1818
, _quality( 0 )
@@ -23,7 +23,7 @@ class AvExport VideoStat
2323
static double psnr( const double d );
2424

2525
public:
26-
double _duration;
26+
float _duration;
2727
size_t _nbFrames;
2828
size_t _quality; ///< Between 1 (good) and FF_LAMBDA_MAX (bad). 0 if unknown.
2929
double _psnr; ///< 0 if unknown.

src/AvTranscoder/stream/IInputStream.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AvExport IInputStream
2222
virtual bool readNextPacket( CodedData& data ) = 0;
2323

2424
virtual size_t getStreamIndex() const = 0;
25-
virtual double getDuration() const = 0;
25+
virtual float getDuration() const = 0;
2626
virtual AVMediaType getStreamType() const = 0;
2727

2828
//@{

src/AvTranscoder/stream/IOutputStream.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AvExport IOutputStream
2525
virtual ~IOutputStream() {};
2626

2727
virtual size_t getStreamIndex() const = 0;
28-
virtual double getStreamDuration() const = 0;
28+
virtual float getStreamDuration() const = 0;
2929
virtual size_t getNbFrames() const = 0;
3030

3131
virtual EWrappingStatus wrap( const CodedData& data ) = 0;

src/AvTranscoder/stream/InputStream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ AVMediaType InputStream::getStreamType() const
111111
return _inputFile->getFormatContext().getAVStream( _streamIndex ).codec->codec_type;
112112
}
113113

114-
double InputStream::getDuration() const
114+
float InputStream::getDuration() const
115115
{
116116
return _inputFile->getProperties().getStreamPropertiesWithIndex( _streamIndex ).getDuration();
117117
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy