Skip to content

Commit 265300f

Browse files
committed
Merge pull request #4 from mikrosimage/develop
Develop
2 parents 67475cc + 37e28e3 commit 265300f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2168
-1472
lines changed

app/avMeta/avMeta.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <AvTranscoder/file/InputFile.hpp>
2-
#include <AvTranscoder/mediaProperty/printMediaProperty.hpp>
2+
#include <AvTranscoder/mediaProperty/print.hpp>
33

44
#include <AvTranscoder/progress/NoDisplayProgress.hpp>
55

@@ -16,7 +16,7 @@ int main( int argc, char** argv )
1616
avtranscoder::NoDisplayProgress p;
1717

1818
avtranscoder::InputFile input( argv[1] );
19-
input.analyse( p, avtranscoder::InputFile::eAnalyseLevelFull );
19+
input.analyse( p, avtranscoder::eAnalyseLevelFirstGop );
2020

2121
// a simply metadata display
2222
std::cout << input;

app/avTranscoder/avTranscoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void transcodeVideo( const char* inputfilename, const char* outputFilename )
2828
InputFile input( inputfilename );
2929
input.analyse( p );
3030

31-
input.readStream( input.getProperties().videoStreams.at( 0 ).streamId );
31+
input.readStream( input.getProperties().getVideoProperties().at( 0 ).getStreamId() );
3232

3333
// init video decoders
3434
AvInputVideo inputVideo( input.getStream( 0 ) );

app/avplay/AvReader.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <AvTranscoder/essenceStream/AvInputAudio.hpp>
66
#include <AvTranscoder/essenceStream/AvInputVideo.hpp>
77
#include <AvTranscoder/transform/VideoTransform.hpp>
8-
#include <AvTranscoder/mediaProperty/printMediaProperty.hpp>
8+
#include <AvTranscoder/mediaProperty/print.hpp>
99

1010
#include <AvTranscoder/progress/ConsoleProgress.hpp>
1111

@@ -23,7 +23,7 @@ class AvReader : public Reader
2323
avtranscoder::ConsoleProgress p;
2424

2525
_inputFile.analyse( p );
26-
_videoStream = _inputFile.getProperties().videoStreams.at(0).streamId;
26+
_videoStream = _inputFile.getProperties().getVideoProperties().at(0).getStreamId();
2727

2828
_inputFile.readStream( _videoStream );
2929

@@ -58,17 +58,17 @@ class AvReader : public Reader
5858

5959
size_t getWidth()
6060
{
61-
return _inputFile.getProperties().videoStreams.at(0).width;
61+
return _inputFile.getProperties().getVideoProperties().at(0).getWidth();
6262
};
6363

6464
size_t getHeight()
6565
{
66-
return _inputFile.getProperties().videoStreams.at(0).height;
66+
return _inputFile.getProperties().getVideoProperties().at(0).getHeight();
6767
}
6868

6969
size_t getComponents()
7070
{
71-
return _inputFile.getProperties().videoStreams.at(0).componentsCount;
71+
return _inputFile.getProperties().getVideoProperties().at(0).getComponentsCount();
7272
}
7373

7474
size_t getBitDepth()

app/genericProcessor/genericProcessor.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ int main( int argc, char** argv )
114114
// set verbose of all stream
115115
transcoder.setVerbose( verbose );
116116
transcoder.setProcessMethod( avtranscoder::eProcessMethodLongest );
117-
//transcoder.setOutputFps( 12 );
118117
transcoder.init();
119118

120119
if( verbose )

app/presetChecker/presetChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ int main( int argc, char** argv )
3434
if( profile.find( avtranscoder::constants::avProfileType )->second == avtranscoder::constants::avProfileTypeAudio )
3535
{
3636
avtranscoder::AvOutputAudio outputAudio;
37-
outputAudio.setProfile( profile, outputAudio.getAudioCodec().getFrameDesc() );
37+
outputAudio.setProfile( profile, outputAudio.getAudioCodec().getAudioFrameDesc() );
3838
}
3939
}
4040
catch( ... )

src/AvTranscoder/avTranscoder.i

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
#include <AvTranscoder/codec/AudioCodec.hpp>
2626
#include <AvTranscoder/codec/DataCodec.hpp>
2727

28-
#include <AvTranscoder/mediaProperty/mediaProperty.hpp>
29-
3028
#include <AvTranscoder/codedStream/IOutputStream.hpp>
3129
#include <AvTranscoder/codedStream/AvOutputStream.hpp>
3230

@@ -40,28 +38,22 @@
4038
#include <AvTranscoder/essenceStream/IInputEssence.hpp>
4139
#include <AvTranscoder/essenceStream/AvInputAudio.hpp>
4240
#include <AvTranscoder/essenceStream/AvInputVideo.hpp>
43-
44-
#include <AvTranscoder/file/InputFile.hpp>
45-
#include <AvTranscoder/file/OutputFile.hpp>
41+
#include <AvTranscoder/essenceStream/GeneratorVideo.hpp>
42+
#include <AvTranscoder/essenceStream/GeneratorAudio.hpp>
4643

4744
#include <AvTranscoder/transcoder/StreamTranscoder.hpp>
4845
#include <AvTranscoder/transcoder/Transcoder.hpp>
4946
%}
5047

51-
namespace std {
48+
namespace std {
5249
%template(IntPair) pair< size_t, size_t >;
53-
%template(VideoVector) vector< avtranscoder::VideoProperties >;
54-
%template(AudioVector) vector< avtranscoder::AudioProperties >;
55-
%template(MetadataPair) pair< string, string >;
56-
%template(MetadatasVector) vector< pair< string, string > >;
57-
%template(GopPair) pair< char, bool >;
58-
%template(GopVector) vector< pair< char, bool > >;
59-
%template(ChannelVector) vector< avtranscoder::Channel >;
6050
%template(ProfileMap) map< string, string >;
6151
%template(ProfilesVector) vector< map< string, string > >;
52+
%template(DataBuffer) std::vector< unsigned char >;
6253
}
6354

6455
%include "AvTranscoder/progress/progress.i"
56+
%include "AvTranscoder/mediaProperty/mediaProperty.i"
6557

6658
%include <AvTranscoder/ProfileLoader.hpp>
6759

@@ -75,8 +67,6 @@ namespace std {
7567
%include <AvTranscoder/codec/AudioCodec.hpp>
7668
%include <AvTranscoder/codec/DataCodec.hpp>
7769

78-
%include <AvTranscoder/mediaProperty/mediaProperty.hpp>
79-
8070
%include <AvTranscoder/codedStream/IOutputStream.hpp>
8171
%include <AvTranscoder/codedStream/AvOutputStream.hpp>
8272

@@ -90,9 +80,10 @@ namespace std {
9080
%include <AvTranscoder/essenceStream/IInputEssence.hpp>
9181
%include <AvTranscoder/essenceStream/AvInputAudio.hpp>
9282
%include <AvTranscoder/essenceStream/AvInputVideo.hpp>
83+
%include <AvTranscoder/essenceStream/GeneratorVideo.hpp>
84+
%include <AvTranscoder/essenceStream/GeneratorAudio.hpp>
9385

94-
%include <AvTranscoder/file/InputFile.hpp>
95-
%include <AvTranscoder/file/OutputFile.hpp>
86+
%include "AvTranscoder/file/file.i"
9687

9788
%include <AvTranscoder/transcoder/StreamTranscoder.hpp>
9889
%include <AvTranscoder/transcoder/Transcoder.hpp>

src/AvTranscoder/codec/AudioCodec.cpp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ AudioCodec::AudioCodec( const ICodec& codec )
2020
{
2121
}
2222

23-
AudioFrameDesc AudioCodec::getFrameDesc() const
23+
AudioFrameDesc AudioCodec::getAudioFrameDesc() const
2424
{
2525
assert( _codecContext != NULL );
2626
AudioFrameDesc audioFrameDesc;
@@ -33,24 +33,6 @@ AudioFrameDesc AudioCodec::getFrameDesc() const
3333
return audioFrameDesc;
3434
}
3535

36-
const size_t AudioCodec::getSampleRate() const
37-
{
38-
assert( _codecContext != NULL );
39-
return _codecContext->sample_rate;
40-
}
41-
42-
const size_t AudioCodec::getChannels() const
43-
{
44-
assert( _codecContext != NULL );
45-
return _codecContext->channels;
46-
}
47-
48-
const AVSampleFormat AudioCodec::getAVSampleFormat() const
49-
{
50-
assert( _codecContext != NULL );
51-
return _codecContext->sample_fmt;
52-
}
53-
5436
void AudioCodec::setAudioParameters( const AudioFrameDesc& audioFrameDesc )
5537
{
5638
setAudioParameters( audioFrameDesc.getSampleRate(), audioFrameDesc.getChannels(), audioFrameDesc.getAVSampleFormat() );

src/AvTranscoder/codec/AudioCodec.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ class AvExport AudioCodec : public ICodec
1414
AudioCodec( const ECodecType type, const AVCodecID codecId );
1515
AudioCodec( const ICodec& codec );
1616

17-
AudioFrameDesc getFrameDesc() const;
18-
const size_t getSampleRate() const;
19-
const size_t getChannels() const;
20-
const AVSampleFormat getAVSampleFormat() const;
21-
17+
AudioFrameDesc getAudioFrameDesc() const;
18+
2219
void setAudioParameters( const AudioFrameDesc& audioFrameDesc );
2320
void setAudioParameters( const size_t sampleRate, const size_t channels, const AVSampleFormat sampleFormat );
2421
};

src/AvTranscoder/codec/VideoCodec.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ VideoCodec::VideoCodec( const ICodec& codec )
2323
VideoFrameDesc VideoCodec::getVideoFrameDesc() const
2424
{
2525
assert( _codecContext != NULL );
26-
VideoFrameDesc VideoFrameDesc;
26+
27+
VideoFrameDesc videoFrameDesc;
28+
videoFrameDesc.setWidth ( _codecContext->width );
29+
videoFrameDesc.setHeight( _codecContext->height );
30+
videoFrameDesc.setDar( _codecContext->width, _codecContext->height );
31+
2732
Pixel pixel( _codecContext->pix_fmt );
33+
videoFrameDesc.setPixel( pixel );
2834

29-
VideoFrameDesc.setWidth ( _codecContext->width );
30-
VideoFrameDesc.setHeight( _codecContext->height );
31-
VideoFrameDesc.setPixel ( pixel );
32-
VideoFrameDesc.setDar ( _codecContext->height, _codecContext->width );
33-
return VideoFrameDesc;
35+
return videoFrameDesc;
3436
}
3537

3638
std::pair< size_t, size_t > VideoCodec::getTimeBase() const

src/AvTranscoder/codedStream/AvInputStream.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ AvInputStream::AvInputStream( InputFile& inputFile, const size_t streamIndex )
1717
: IInputStream( )
1818
, _inputFile( &inputFile )
1919
, _codec( NULL )
20-
, _packetDuration( 0 )
2120
, _streamIndex( streamIndex )
2221
, _bufferized( false )
2322
{
@@ -98,7 +97,6 @@ void AvInputStream::addPacket( AVPacket& packet )
9897
//std::cout << "add packet for stream " << _streamIndex << std::endl;
9998
CodedData data;
10099
_streamCache.push_back( data );
101-
_packetDuration = packet.duration;
102100

103101
if( ! _bufferized )
104102
return;
@@ -166,11 +164,6 @@ double AvInputStream::getDuration() const
166164
return 1.0 * _inputFile->getFormatContext().duration / AV_TIME_BASE;
167165
}
168166

169-
double AvInputStream::getPacketDuration() const
170-
{
171-
return _packetDuration * av_q2d( _inputFile->getFormatContext().streams[_streamIndex]->time_base );
172-
}
173-
174167
void AvInputStream::clearBuffering()
175168
{
176169
_streamCache.clear();

src/AvTranscoder/codedStream/AvInputStream.hpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class AvExport AvInputStream : public IInputStream
3030
AVMediaType getStreamType() const;
3131

3232
double getDuration() const;
33-
double getPacketDuration() const;
3433

3534
void addPacket( AVPacket& packet );
3635

@@ -43,14 +42,13 @@ class AvExport AvInputStream : public IInputStream
4342
AVStream* getAVStream() const;
4443

4544
private:
46-
InputFile* _inputFile;
47-
std::vector<CodedData> _streamCache;
48-
45+
InputFile* _inputFile; ///< Has link (no ownership)
4946
ICodec* _codec; ///< Has ownership
5047

51-
int _packetDuration;
52-
size_t _streamIndex;
53-
bool _bufferized;
48+
std::vector<CodedData> _streamCache;
49+
50+
size_t _streamIndex; ///< Index of the stream in the input file
51+
bool _bufferized; ///< If the stream is bufferized
5452
};
5553

5654
}

src/AvTranscoder/codedStream/AvOutputStream.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class AvExport AvOutputStream : public IOutputStream
1818
IOutputStream::EWrappingStatus wrap( const CodedData& data );
1919

2020
private:
21-
OutputFile* _outputFile;
21+
OutputFile* _outputFile; ///< Has link (no ownership)
2222

23-
size_t _streamIndex;
23+
size_t _streamIndex; ///< Index of the stream in the output file
2424
};
2525

2626
}

src/AvTranscoder/codedStream/IInputStream.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class IInputStream
2626
virtual AVMediaType getStreamType() const = 0;
2727

2828
virtual double getDuration() const = 0;
29-
virtual double getPacketDuration() const = 0;
3029

3130
virtual void setBufferred( const bool bufferized ) = 0;
3231

src/AvTranscoder/essenceStream/AvInputAudio.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ namespace avtranscoder
2020
AvInputAudio::AvInputAudio( AvInputStream& inputStream )
2121
: IInputEssence()
2222
, _inputStream ( &inputStream )
23-
, _codec( eCodecTypeDecoder, inputStream.getAudioCodec().getCodecId() )
23+
, _codec( &inputStream.getAudioCodec() )
2424
, _frame ( NULL )
25-
, _selectedStream( -1 )
25+
, _selectedStream( inputStream.getStreamIndex() )
2626
{
2727
}
2828

@@ -46,10 +46,10 @@ AvInputAudio::~AvInputAudio()
4646

4747
void AvInputAudio::setup()
4848
{
49-
AVCodecContext* avCodecContext = _codec.getAVCodecContext();
50-
AVCodec* avCodec = _codec.getAVCodec();
49+
AVCodecContext* avCodecContext = _codec->getAVCodecContext();
50+
AVCodec* avCodec = _codec->getAVCodec();
5151

52-
avCodecContext->channels = _inputStream->getAudioCodec().getChannels();
52+
avCodecContext->channels = _inputStream->getAudioCodec().getAudioFrameDesc().getChannels();
5353

5454
int ret = avcodec_open2( avCodecContext, avCodec, NULL );
5555

@@ -82,10 +82,10 @@ void AvInputAudio::setup()
8282

8383
bool AvInputAudio::readNextFrame( Frame& frameBuffer )
8484
{
85-
if( ! getNextFrame() )
85+
if( ! decodeNextFrame() )
8686
return false;
8787

88-
AVCodecContext* avCodecContext = _codec.getAVCodecContext();
88+
AVCodecContext* avCodecContext = _codec->getAVCodecContext();
8989

9090
size_t decodedSize = av_samples_get_buffer_size(
9191
NULL, avCodecContext->channels,
@@ -116,14 +116,14 @@ bool AvInputAudio::readNextFrame( Frame& frameBuffer )
116116

117117
bool AvInputAudio::readNextFrame( Frame& frameBuffer, const size_t subStreamIndex )
118118
{
119-
if( ! getNextFrame() )
119+
if( ! decodeNextFrame() )
120120
return false;
121121

122122
const int output_nbChannels = 1;
123123
const int output_align = 1;
124-
size_t decodedSize = av_samples_get_buffer_size(NULL, output_nbChannels, _frame->nb_samples, _codec.getAVCodecContext()->sample_fmt, output_align);
124+
size_t decodedSize = av_samples_get_buffer_size(NULL, output_nbChannels, _frame->nb_samples, _codec->getAVCodecContext()->sample_fmt, output_align);
125125

126-
size_t nbSubStreams = _codec.getAVCodecContext()->channels;
126+
size_t nbSubStreams = _codec->getAVCodecContext()->channels;
127127
size_t bytePerSample = av_get_bytes_per_sample( (AVSampleFormat)_frame->format );
128128

129129
if( subStreamIndex > nbSubStreams - 1 )
@@ -156,7 +156,7 @@ bool AvInputAudio::readNextFrame( Frame& frameBuffer, const size_t subStreamInde
156156
return true;
157157
}
158158

159-
bool AvInputAudio::getNextFrame()
159+
bool AvInputAudio::decodeNextFrame()
160160
{
161161
int got_frame = 0;
162162
while( ! got_frame )
@@ -172,7 +172,7 @@ bool AvInputAudio::getNextFrame()
172172
packet.data = data.getPtr();
173173
packet.size = data.getSize();
174174

175-
int ret = avcodec_decode_audio4( _codec.getAVCodecContext(), _frame, &got_frame, &packet );
175+
int ret = avcodec_decode_audio4( _codec->getAVCodecContext(), _frame, &got_frame, &packet );
176176

177177
if( ret < 0 )
178178
{

src/AvTranscoder/essenceStream/AvInputAudio.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ class AvExport AvInputAudio : public IInputEssence
2323
bool readNextFrame( Frame& frameBuffer, const size_t subStreamIndex );
2424

2525
private:
26-
bool getNextFrame();
26+
bool decodeNextFrame();
2727

28-
AvInputStream* _inputStream;
29-
AudioCodec _codec;
30-
AVFrame* _frame;
28+
AvInputStream* _inputStream; ///< Stream from which we read next frames
29+
const AudioCodec* _codec; ///< Audio decoder. Has link (no ownership)
30+
AVFrame* _frame; ///< Libav object to store decoded data
3131

32-
int _selectedStream;
32+
int _selectedStream; ///< Index of the selected stream in the input file
3333
};
3434

3535
}

0 commit comments

Comments
 (0)