Skip to content

Commit cda8459

Browse files
author
Clement Champetier
committed
transcoder: manage offset with a float type
Double precision is not needed to express this offset in seconds.
1 parent aad1bbf commit cda8459

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

src/AvTranscoder/transcoder/StreamTranscoder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace avtranscoder
2323
StreamTranscoder::StreamTranscoder(
2424
IInputStream& inputStream,
2525
IOutputFile& outputFile,
26-
const double offset
26+
const float offset
2727
)
2828
: _inputStream( &inputStream )
2929
, _outputStream( NULL )
@@ -109,7 +109,7 @@ StreamTranscoder::StreamTranscoder(
109109
IOutputFile& outputFile,
110110
const ProfileLoader::Profile& profile,
111111
const int subStreamIndex,
112-
const double offset
112+
const float offset
113113
)
114114
: _inputStream( &inputStream )
115115
, _outputStream( NULL )

src/AvTranscoder/transcoder/StreamTranscoder.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ class AvExport StreamTranscoder
2929
* @brief rewrap stream
3030
* @note offset feature when rewrap a stream is not supported
3131
**/
32-
StreamTranscoder( IInputStream& inputStream, IOutputFile& outputFile, const double offset = 0 );
32+
StreamTranscoder( IInputStream& inputStream, IOutputFile& outputFile, const float offset = 0 );
3333

3434
/**
3535
* @brief transcode stream
3636
**/
37-
StreamTranscoder( IInputStream& inputStream, IOutputFile& outputFile, const ProfileLoader::Profile& profile, const int subStreamIndex = -1, const double offset = 0 );
37+
StreamTranscoder( IInputStream& inputStream, IOutputFile& outputFile, const ProfileLoader::Profile& profile, const int subStreamIndex = -1, const float offset = 0 );
3838

3939
/**
4040
* @brief encode from a generated stream
@@ -121,7 +121,7 @@ class AvExport StreamTranscoder
121121

122122
int _subStreamIndex; ///< Index of channel that is processed from the input stream (<0 if no demultiplexing).
123123

124-
double _offset; ///< Offset, in seconds, at the beginning of the StreamTranscoder.
124+
float _offset; ///< Offset, in seconds, at the beginning of the StreamTranscoder.
125125

126126
bool _canSwitchToGenerator; ///< Automatically switch to a generator at the end of the stream
127127
};

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Transcoder::~Transcoder()
3333
}
3434
}
3535

36-
void Transcoder::add( const std::string& filename, const size_t streamIndex, const std::string& profileName, const double offset )
36+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const std::string& profileName, const float offset )
3737
{
3838
// Re-wrap
3939
if( profileName.length() == 0 )
@@ -52,7 +52,7 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
5252
}
5353
}
5454

55-
void Transcoder::add( const std::string& filename, const size_t streamIndex, const std::string& profileName, ICodec& codec, const double offset )
55+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const std::string& profileName, ICodec& codec, const float offset )
5656
{
5757
// Re-wrap
5858
if( profileName.length() == 0 )
@@ -71,7 +71,7 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
7171
}
7272
}
7373

74-
void Transcoder::add( const std::string& filename, const size_t streamIndex, const ProfileLoader::Profile& profile, const double offset )
74+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const ProfileLoader::Profile& profile, const float offset )
7575
{
7676
// Check filename
7777
if( ! filename.length() )
@@ -80,7 +80,7 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
8080
addTranscodeStream( filename, streamIndex, -1, profile, offset );
8181
}
8282

83-
void Transcoder::add( const std::string& filename, const size_t streamIndex, const ProfileLoader::Profile& profile, ICodec& codec, const double offset )
83+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const ProfileLoader::Profile& profile, ICodec& codec, const float offset )
8484
{
8585
// Generator
8686
if( ! filename.length() )
@@ -94,7 +94,7 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
9494
}
9595
}
9696

97-
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName, const double offset )
97+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName, const float offset )
9898
{
9999
// No subStream selected
100100
if( subStreamIndex < 0 )
@@ -124,7 +124,7 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
124124
}
125125
}
126126

127-
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName, ICodec& codec, const double offset )
127+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName, ICodec& codec, const float offset )
128128
{
129129
// No subStream selected
130130
if( subStreamIndex < 0 )
@@ -155,7 +155,7 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
155155
}
156156
}
157157

158-
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, const double offset )
158+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, const float offset )
159159
{
160160
// No subStream selected
161161
if( subStreamIndex < 0 )
@@ -171,7 +171,7 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
171171
addTranscodeStream( filename, streamIndex, subStreamIndex, profile, offset );
172172
}
173173

174-
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, ICodec& codec, const double offset )
174+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, ICodec& codec, const float offset )
175175
{
176176
// No subStream selected
177177
if( subStreamIndex < 0 )
@@ -282,7 +282,7 @@ void Transcoder::setProcessMethod( const EProcessMethod eProcessMethod, const si
282282
_outputDuration = outputDuration;
283283
}
284284

285-
void Transcoder::addRewrapStream( const std::string& filename, const size_t streamIndex, const double offset )
285+
void Transcoder::addRewrapStream( const std::string& filename, const size_t streamIndex, const float offset )
286286
{
287287
LOG_INFO( "Add rewrap stream from file '" << filename << "' / index=" << streamIndex << " / offset=" << offset << "s" )
288288

@@ -292,7 +292,7 @@ void Transcoder::addRewrapStream( const std::string& filename, const size_t stre
292292
_streamTranscoders.push_back( _streamTranscodersAllocated.back() );
293293
}
294294

295-
void Transcoder::addTranscodeStream( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const double offset )
295+
void Transcoder::addTranscodeStream( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const float offset )
296296
{
297297
// Get profile from input file
298298
InputFile inputFile( filename );
@@ -306,7 +306,7 @@ void Transcoder::addTranscodeStream( const std::string& filename, const size_t s
306306
addTranscodeStream( filename, streamIndex, subStreamIndex, profile, offset );
307307
}
308308

309-
void Transcoder::addTranscodeStream( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, const double offset )
309+
void Transcoder::addTranscodeStream( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, const float offset )
310310
{
311311
// Add profile
312312
if( ! _profileLoader.hasProfile( profile ) )
@@ -348,7 +348,7 @@ void Transcoder::addDummyStream( const ProfileLoader::Profile& profile, const IC
348348
_streamTranscoders.push_back( _streamTranscodersAllocated.back() );
349349
}
350350

351-
InputFile* Transcoder::addInputFile( const std::string& filename, const size_t streamIndex, const double offset )
351+
InputFile* Transcoder::addInputFile( const std::string& filename, const size_t streamIndex, const float offset )
352352
{
353353
InputFile* referenceFile = NULL;
354354

@@ -532,7 +532,7 @@ void Transcoder::fillProcessStat( ProcessStat& processStat )
532532
if( encoderContext.coded_frame && ( encoderContext.flags & CODEC_FLAG_PSNR) )
533533
{
534534
videoStat._quality = encoderContext.coded_frame->quality;
535-
videoStat._psnr = VideoStat::psnr(encoderContext.coded_frame->error[0] / (encoderContext.width * encoderContext.height * 255.0 * 255.0));
535+
videoStat._psnr = VideoStat::psnr( encoderContext.coded_frame->error[0] / ( encoderContext.width * encoderContext.height * 255.0 * 255.0 ) );
536536
}
537537
processStat.addVideoStat( streamIndex, videoStat );
538538
break;

src/AvTranscoder/transcoder/Transcoder.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,45 +58,45 @@ class AvExport Transcoder
5858
* If offset is positive, the transcoder will generate black images or silence (depending on the type of stream) before the stream to process.
5959
* If offset is negative, the transcoder will seek in the stream and start process at this specific time.
6060
*/
61-
void add( const std::string& filename, const size_t streamIndex, const std::string& profileName = "", const double offset = 0 );
61+
void add( const std::string& filename, const size_t streamIndex, const std::string& profileName = "", const float offset = 0 );
6262
/*
6363
* @note If filename is empty, add a generated stream.
6464
* @note If filename is empty, profileName can't be empty (no sens to rewrap a generated stream).
6565
*/
66-
void add( const std::string& filename, const size_t streamIndex, const std::string& profileName, ICodec& codec, const double offset = 0 );
66+
void add( const std::string& filename, const size_t streamIndex, const std::string& profileName, ICodec& codec, const float offset = 0 );
6767

6868
/**
6969
* @brief Add a stream and set a custom profile
7070
* @note Profile will be updated, be sure to pass unique profile name.
7171
*/
72-
void add( const std::string& filename, const size_t streamIndex, const ProfileLoader::Profile& profile, const double offset = 0 );
72+
void add( const std::string& filename, const size_t streamIndex, const ProfileLoader::Profile& profile, const float offset = 0 );
7373
/*
7474
* @note If filename is empty, add a generated stream.
7575
*/
76-
void add( const std::string& filename, const size_t streamIndex, const ProfileLoader::Profile& profile, ICodec& codec, const double offset = 0 );
76+
void add( const std::string& filename, const size_t streamIndex, const ProfileLoader::Profile& profile, ICodec& codec, const float offset = 0 );
7777

7878
/**
7979
* @brief Add a stream and set a profile
8080
* @note If profileName is empty, rewrap.
8181
* @note If subStreamIndex is negative, no substream is selected it's the stream.
8282
*/
83-
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName = "", const double offset = 0 );
83+
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName = "", const float offset = 0 );
8484
/**
8585
* @note If filename is empty, add a generated stream.
8686
* @note If filename is empty, profileName can't be empty (no sens to rewrap a generated stream).
8787
*/
88-
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName, ICodec& codec, const double offset = 0 );
88+
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName, ICodec& codec, const float offset = 0 );
8989

9090
/**
9191
* @brief Add a stream and set a custom profile
9292
* @note Profile will be updated, be sure to pass unique profile name.
9393
* @note If subStreamIndex is negative, no substream is selected it's the stream.
9494
*/
95-
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, const double offset = 0 );
95+
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, const float offset = 0 );
9696
/**
9797
* @note If filename is empty, add a generated stream.
9898
*/
99-
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, ICodec& codec, const double offset = 0 );
99+
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, ICodec& codec, const float offset = 0 );
100100

101101
/**
102102
* @brief Add the stream
@@ -152,14 +152,14 @@ class AvExport Transcoder
152152
void setProcessMethod( const EProcessMethod eProcessMethod, const size_t indexBasedStream = 0, const double outputDuration = 0 );
153153

154154
private:
155-
void addRewrapStream( const std::string& filename, const size_t streamIndex, const double offset );
155+
void addRewrapStream( const std::string& filename, const size_t streamIndex, const float offset );
156156

157-
void addTranscodeStream( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const double offset );
158-
void addTranscodeStream( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, const double offset = 0 );
157+
void addTranscodeStream( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const float offset );
158+
void addTranscodeStream( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, const float offset = 0 );
159159

160160
void addDummyStream( const ProfileLoader::Profile& profile, const ICodec& codec );
161161

162-
InputFile* addInputFile( const std::string& filename, const size_t streamIndex, const double offset );
162+
InputFile* addInputFile( const std::string& filename, const size_t streamIndex, const float offset );
163163

164164
ProfileLoader::Profile getProfileFromFile( InputFile& inputFile, const size_t streamIndex ); ///< The function analyses the inputFile
165165

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