Skip to content

Commit 7102412

Browse files
set common member variables, removing many m_*
1 parent a771f86 commit 7102412

24 files changed

+370
-367
lines changed

src/AvTranscoder/AudioTransform.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,28 @@ namespace avtranscoder
2020
{
2121

2222
AudioTransform::AudioTransform()
23-
: m_audioConvertContext( NULL )
24-
, m_isInit ( false )
23+
: _audioConvertContext( NULL )
24+
, _isInit ( false )
2525
{
2626
}
2727

2828
bool AudioTransform::init( const AudioFrame& src, const AudioFrame& dst )
2929
{
30-
m_audioConvertContext = swr_alloc();
30+
_audioConvertContext = swr_alloc();
3131

32-
if( !m_audioConvertContext )
32+
if( !_audioConvertContext )
3333
{
3434
throw std::runtime_error( "unable to create audio convert context" );
3535
}
3636

37-
swr_alloc_set_opts( m_audioConvertContext,
37+
swr_alloc_set_opts( _audioConvertContext,
3838
av_get_default_channel_layout( dst.desc().getChannels() ), dst.desc().getSampleFormat(), av_get_default_channel_layout( dst.desc().getSampleRate() ),
3939
av_get_default_channel_layout( src.desc().getChannels() ), src.desc().getSampleFormat(), av_get_default_channel_layout( src.desc().getSampleRate() ),
4040
0, NULL);
4141

42-
if( swr_init( m_audioConvertContext ) < 0 )
42+
if( swr_init( _audioConvertContext ) < 0 )
4343
{
44-
swr_free( &m_audioConvertContext );
44+
swr_free( &_audioConvertContext );
4545
throw std::runtime_error( "unable to open audio convert context" );
4646
}
4747

@@ -50,10 +50,10 @@ bool AudioTransform::init( const AudioFrame& src, const AudioFrame& dst )
5050

5151
void AudioTransform::convert( const AudioFrame& src, AudioFrame& dst )
5252
{
53-
if( ! m_isInit )
53+
if( ! _isInit )
5454
{
55-
m_isInit = init( src, dst );
56-
m_isInit = true;
55+
_isInit = init( src, dst );
56+
_isInit = true;
5757
}
5858

5959
if( dst.getSize() != src.getSize() )
@@ -62,7 +62,7 @@ void AudioTransform::convert( const AudioFrame& src, AudioFrame& dst )
6262
const unsigned char* srcData = src.getPtr();
6363
unsigned char* dstData = dst.getPtr();
6464

65-
swr_convert( m_audioConvertContext, &dstData, dst.getSize(), &srcData, src.getSize() );
65+
swr_convert( _audioConvertContext, &dstData, dst.getSize(), &srcData, src.getSize() );
6666

6767
dst.setNbSamples( src.getNbSamples() );
6868
}

src/AvTranscoder/AudioTransform.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class AvExport AudioTransform
2020
private:
2121
bool init( const AudioFrame& src, const AudioFrame& dst );
2222

23-
SwrContext* m_audioConvertContext;
23+
SwrContext* _audioConvertContext;
2424

25-
bool m_isInit;
25+
bool _isInit;
2626
};
2727

2828
}

src/AvTranscoder/AvInputStream.cpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ namespace avtranscoder
2222

2323
AvInputStream::AvInputStream( )
2424
: InputStream( )
25-
, m_inputFile( NULL )
26-
, m_packetDuration( 0 )
27-
, m_streamIndex( 0 )
28-
, m_bufferized( false )
25+
, _inputFile( NULL )
26+
, _packetDuration( 0 )
27+
, _streamIndex( 0 )
28+
, _bufferized( false )
2929
{
3030
}
3131

3232
AvInputStream::AvInputStream( InputFile& inputFile, const size_t streamIndex )
3333
: InputStream( )
34-
, m_inputFile( &inputFile )
35-
, m_packetDuration( 0 )
36-
, m_streamIndex( streamIndex )
37-
, m_bufferized( false )
34+
, _inputFile( &inputFile )
35+
, _packetDuration( 0 )
36+
, _streamIndex( streamIndex )
37+
, _bufferized( false )
3838
{
39-
if( m_inputFile->getFormatContext().streams[m_streamIndex]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
40-
m_inputFile->getFormatContext().streams[m_streamIndex]->codec->block_align = 5760;
39+
if( _inputFile->getFormatContext().streams[_streamIndex]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
40+
_inputFile->getFormatContext().streams[_streamIndex]->codec->block_align = 5760;
4141
}
4242

4343
AvInputStream::~AvInputStream( )
@@ -46,37 +46,37 @@ AvInputStream::~AvInputStream( )
4646

4747
bool AvInputStream::readNextPacket( DataStream& data )
4848
{
49-
if( ! m_bufferized )
49+
if( ! _bufferized )
5050
throw std::runtime_error( "Can't read packet on non-bufferized input stream." );
5151

52-
if( m_streamCache.empty() )
53-
m_inputFile->readNextPacket( m_streamIndex );
52+
if( _streamCache.empty() )
53+
_inputFile->readNextPacket( _streamIndex );
5454

55-
if( m_streamCache.empty() )
55+
if( _streamCache.empty() )
5656
return false;
5757

58-
m_streamCache.front().getBuffer().swap( data.getBuffer() );
58+
_streamCache.front().getBuffer().swap( data.getBuffer() );
5959

60-
m_streamCache.erase( m_streamCache.begin() );
60+
_streamCache.erase( _streamCache.begin() );
6161

6262
return true;
6363
}
6464

6565
void AvInputStream::addPacket( AVPacket& packet )
6666
{
67-
//std::cout << "add packet for stream " << m_streamIndex << std::endl;
67+
//std::cout << "add packet for stream " << _streamIndex << std::endl;
6868
DataStream data;
69-
m_streamCache.push_back( data );
70-
m_packetDuration = packet.duration;
69+
_streamCache.push_back( data );
70+
_packetDuration = packet.duration;
7171

72-
if( ! m_bufferized )
72+
if( ! _bufferized )
7373
return;
7474

7575
// is it possible to remove this copy ?
7676
// using : av_packet_unref ?
77-
m_streamCache.back().getBuffer().resize( packet.size );
77+
_streamCache.back().getBuffer().resize( packet.size );
7878
if( packet.size != 0 )
79-
memcpy( m_streamCache.back().getPtr(), packet.data, packet.size );
79+
memcpy( _streamCache.back().getPtr(), packet.data, packet.size );
8080

8181
// std::vector<unsigned char> tmpData( 0,0 );
8282
// &tmpData[0] = packet.data;
@@ -86,19 +86,19 @@ void AvInputStream::addPacket( AVPacket& packet )
8686
// packet.data = NULL;
8787
// packet.size = 0;
8888

89-
// std::cout << this << " buffer size " << m_streamCache.size() << std::endl;
89+
// std::cout << this << " buffer size " << _streamCache.size() << std::endl;
9090
}
9191

9292
VideoDesc AvInputStream::getVideoDesc() const
9393
{
94-
assert( m_streamIndex <= m_inputFile->getFormatContext().nb_streams );
94+
assert( _streamIndex <= _inputFile->getFormatContext().nb_streams );
9595

96-
if( m_inputFile->getFormatContext().streams[m_streamIndex]->codec->codec_type != AVMEDIA_TYPE_VIDEO )
96+
if( _inputFile->getFormatContext().streams[_streamIndex]->codec->codec_type != AVMEDIA_TYPE_VIDEO )
9797
{
9898
throw std::runtime_error( "unable to get video descriptor on non-video stream" );
9999
}
100100

101-
AVCodecContext* codecContext = m_inputFile->getFormatContext().streams[m_streamIndex]->codec;
101+
AVCodecContext* codecContext = _inputFile->getFormatContext().streams[_streamIndex]->codec;
102102

103103
VideoDesc desc( codecContext->codec_id );
104104

@@ -110,14 +110,14 @@ VideoDesc AvInputStream::getVideoDesc() const
110110

111111
AudioDesc AvInputStream::getAudioDesc() const
112112
{
113-
assert( m_streamIndex <= m_inputFile->getFormatContext().nb_streams );
113+
assert( _streamIndex <= _inputFile->getFormatContext().nb_streams );
114114

115-
if( m_inputFile->getFormatContext().streams[m_streamIndex]->codec->codec_type != AVMEDIA_TYPE_AUDIO )
115+
if( _inputFile->getFormatContext().streams[_streamIndex]->codec->codec_type != AVMEDIA_TYPE_AUDIO )
116116
{
117117
throw std::runtime_error( "unable to get audio descriptor on non-audio stream" );
118118
}
119119

120-
AVCodecContext* codecContext = m_inputFile->getFormatContext().streams[m_streamIndex]->codec;
120+
AVCodecContext* codecContext = _inputFile->getFormatContext().streams[_streamIndex]->codec;
121121

122122
AudioDesc desc( codecContext->codec_id );
123123

@@ -128,22 +128,22 @@ AudioDesc AvInputStream::getAudioDesc() const
128128

129129
AVMediaType AvInputStream::getStreamType() const
130130
{
131-
return m_inputFile->getStreamType( m_streamIndex );
131+
return _inputFile->getStreamType( _streamIndex );
132132
}
133133

134134
double AvInputStream::getDuration() const
135135
{
136-
return 1.0 * m_inputFile->getFormatContext().duration / AV_TIME_BASE;
136+
return 1.0 * _inputFile->getFormatContext().duration / AV_TIME_BASE;
137137
}
138138

139139
double AvInputStream::getPacketDuration() const
140140
{
141-
return m_packetDuration * av_q2d( m_inputFile->getFormatContext().streams[m_streamIndex]->time_base );
141+
return _packetDuration * av_q2d( _inputFile->getFormatContext().streams[_streamIndex]->time_base );
142142
}
143143

144144
void AvInputStream::clearBuffering()
145145
{
146-
m_streamCache.clear();
146+
_streamCache.clear();
147147
}
148148

149149
}

src/AvTranscoder/AvInputStream.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ class AvExport AvInputStream : public InputStream
1818

1919
AvInputStream( const AvInputStream& inputStream )
2020
: InputStream( )
21-
, m_inputFile( inputStream.m_inputFile )
22-
, m_streamIndex( inputStream.m_streamIndex )
23-
, m_bufferized( inputStream.m_bufferized )
21+
, _inputFile( inputStream._inputFile )
22+
, _streamIndex( inputStream._streamIndex )
23+
, _bufferized( inputStream._bufferized )
2424
{
2525
}
2626

27-
size_t getStreamIndex() const { return m_streamIndex; }
27+
size_t getStreamIndex() const { return _streamIndex; }
2828

2929
bool readNextPacket( DataStream& data );
3030

@@ -39,20 +39,20 @@ class AvExport AvInputStream : public InputStream
3939

4040
void addPacket( AVPacket& packet );
4141

42-
void setBufferred( const bool bufferized ){ m_bufferized = bufferized; };
42+
void setBufferred( const bool bufferized ){ _bufferized = bufferized; };
4343

4444
void clearBuffering();
4545

4646
private:
47-
InputFile* m_inputFile;
48-
std::vector<DataStream> m_streamCache;
47+
InputFile* _inputFile;
48+
std::vector<DataStream> _streamCache;
4949

50-
VideoDesc m_videoDesc;
51-
AudioDesc m_audioDesc;
50+
VideoDesc _videoDesc;
51+
AudioDesc _audioDesc;
5252

53-
int m_packetDuration;
54-
size_t m_streamIndex;
55-
bool m_bufferized;
53+
int _packetDuration;
54+
size_t _streamIndex;
55+
bool _bufferized;
5656
};
5757

5858
}

src/AvTranscoder/ColorTransform.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ namespace avtranscoder
2323
{
2424

2525
ColorTransform::ColorTransform()
26-
: m_imageConvertContext( NULL )
27-
, srcData ( (uint8_t)MAX_SWS_PLANE, NULL )
28-
, dstData ( (uint8_t)MAX_SWS_PLANE, NULL )
29-
, srcLineSize ( MAX_SWS_PLANE, 0 )
30-
, dstLineSize ( MAX_SWS_PLANE, 0 )
31-
, srcOffsets ( MAX_SWS_PLANE, 0 )
32-
, dstOffsets ( MAX_SWS_PLANE, 0 )
33-
, m_isInit ( false )
26+
: _imageConvertContext( NULL )
27+
, _srcData ( (uint8_t)MAX_SWS_PLANE, NULL )
28+
, _dstData ( (uint8_t)MAX_SWS_PLANE, NULL )
29+
, _srcLineSize ( MAX_SWS_PLANE, 0 )
30+
, _dstLineSize ( MAX_SWS_PLANE, 0 )
31+
, _srcOffsets ( MAX_SWS_PLANE, 0 )
32+
, _dstOffsets ( MAX_SWS_PLANE, 0 )
33+
, _isInit ( false )
3434
{
3535
}
3636

@@ -41,36 +41,36 @@ bool ColorTransform::init( const Image& src, const Image& dst )
4141
assert( src.desc().getWidth() == dst.desc().getWidth() );
4242
assert( src.desc().getHeight() == dst.desc().getHeight() );
4343

44-
m_imageConvertContext = sws_getContext(
44+
_imageConvertContext = sws_getContext(
4545
src.desc().getWidth(), src.desc().getHeight(), src.desc().getPixelDesc().findPixel(),
4646
dst.desc().getWidth(), dst.desc().getHeight(), dst.desc().getPixelDesc().findPixel(),
4747
SWS_POINT, NULL, NULL, NULL);
4848

49-
if( !m_imageConvertContext )
49+
if( ! _imageConvertContext )
5050
{
5151
throw std::runtime_error( "unable to create color convert context" );
5252
}
5353

54-
av_image_fill_linesizes( &srcLineSize[0], src.desc().getPixelDesc().findPixel(), src.desc().getWidth() );
55-
av_image_fill_linesizes( &dstLineSize[0], dst.desc().getPixelDesc().findPixel(), dst.desc().getWidth() );
54+
av_image_fill_linesizes( &_srcLineSize[0], src.desc().getPixelDesc().findPixel(), src.desc().getWidth() );
55+
av_image_fill_linesizes( &_dstLineSize[0], dst.desc().getPixelDesc().findPixel(), dst.desc().getWidth() );
5656

5757
size_t cumulSrcOffset = 0;
5858
size_t cumulDstOffset = 0;
5959

6060
for( size_t plane = 0; plane < MAX_SWS_PLANE; ++plane )
6161
{
6262
#ifdef FFALIGN
63-
srcLineSize.at( plane ) = FFALIGN( srcLineSize.at( plane ), 16 );
64-
dstLineSize.at( plane ) = FFALIGN( dstLineSize.at( plane ), 16 );
63+
_srcLineSize.at( plane ) = FFALIGN( _srcLineSize.at( plane ), 16 );
64+
_dstLineSize.at( plane ) = FFALIGN( _dstLineSize.at( plane ), 16 );
6565
#else
66-
srcLineSize.at( plane ) = srcLineSize.at( plane );
67-
dstLineSize.at( plane ) = dstLineSize.at( plane );
66+
_srcLineSize.at( plane ) = _srcLineSize.at( plane );
67+
_dstLineSize.at( plane ) = _dstLineSize.at( plane );
6868
#endif
69-
srcOffsets.at( plane ) = cumulSrcOffset;
70-
dstOffsets.at( plane ) = cumulDstOffset;
69+
_srcOffsets.at( plane ) = cumulSrcOffset;
70+
_dstOffsets.at( plane ) = cumulDstOffset;
7171

72-
cumulSrcOffset += srcLineSize.at( plane ) * src.desc().getHeight();
73-
cumulDstOffset += dstLineSize.at( plane ) * dst.desc().getHeight();
72+
cumulSrcOffset += _srcLineSize.at( plane ) * src.desc().getHeight();
73+
cumulDstOffset += _dstLineSize.at( plane ) * dst.desc().getHeight();
7474
}
7575

7676
return true;
@@ -85,23 +85,23 @@ void ColorTransform::convert( const Image& src, Image& dst )
8585
assert( src.desc().getPixelDesc().getComponents() != 0 );
8686
assert( src.desc().getPixelDesc().getComponents() == dst.desc().getPixelDesc().getComponents() );
8787

88-
if( ! m_isInit )
89-
m_isInit = init( src, dst );
88+
if( ! _isInit )
89+
_isInit = init( src, dst );
9090

9191
for( size_t plane = 0; plane < MAX_SWS_PLANE; ++plane )
9292
{
93-
srcData.at( plane ) = (uint8_t*)const_cast< unsigned char* >( src.getPtr() + srcOffsets.at( plane ) );
94-
dstData.at( plane ) = (uint8_t*)dst.getPtr() + dstOffsets.at( plane );
93+
_srcData.at( plane ) = (uint8_t*)const_cast< unsigned char* >( src.getPtr() + _srcOffsets.at( plane ) );
94+
_dstData.at( plane ) = (uint8_t*)dst.getPtr() + _dstOffsets.at( plane );
9595
}
9696

97-
if( !m_imageConvertContext )
97+
if( !_imageConvertContext )
9898
{
9999
throw std::runtime_error( "unknown color convert context" );
100100
}
101101

102-
int ret = sws_scale( m_imageConvertContext,
103-
&srcData[0], &srcLineSize[0], 0, src.desc().getHeight(),
104-
&dstData[0], &dstLineSize[0] );
102+
int ret = sws_scale( _imageConvertContext,
103+
&_srcData[0], &_srcLineSize[0], 0, src.desc().getHeight(),
104+
&_dstData[0], &_dstLineSize[0] );
105105

106106
if( ret != (int) src.desc().getHeight() )
107107
throw std::runtime_error( "error in color converter" );

src/AvTranscoder/ColorTransform.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ class AvExport ColorTransform
2222
private:
2323
bool init( const Image& src, const Image& dst );
2424

25-
SwsContext* m_imageConvertContext;
25+
SwsContext* _imageConvertContext;
2626

27-
std::vector<uint8_t *> srcData;
28-
std::vector<uint8_t *> dstData;
29-
std::vector<int> srcLineSize;
30-
std::vector<int> dstLineSize;
31-
std::vector<size_t> srcOffsets;
32-
std::vector<size_t> dstOffsets;
27+
std::vector<uint8_t *> _srcData;
28+
std::vector<uint8_t *> _dstData;
29+
std::vector<int> _srcLineSize;
30+
std::vector<int> _dstLineSize;
31+
std::vector<size_t> _srcOffsets;
32+
std::vector<size_t> _dstOffsets;
3333

34-
bool m_isInit;
34+
bool _isInit;
3535
};
3636

3737
}

0 commit comments

Comments
 (0)