Skip to content

Commit 585a888

Browse files
author
Clement Champetier
committed
Merge branch 'develop' into dev_addReaderClasses
Conflicts: src/AvTranscoder/mediaProperty/print.hpp
2 parents 66e1a5e + 45922a3 commit 585a888

27 files changed

+123
-51
lines changed

.travis.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,22 @@ env:
1515
- DEPENDENCY_INSTALL=${TRAVIS_BUILD_DIR}/install-dependency
1616
- CI_NODE_TOTAL=2
1717
matrix:
18-
- DEPENDENCY_MODE=libav ENABLE_COVERAGE=true
19-
- DEPENDENCY_MODE=libav ENABLE_COVERAGE=false
18+
- DEPENDENCY_MODE=libav ENABLE_COVERAGE=true
19+
- DEPENDENCY_MODE=libav ENABLE_COVERAGE=false
2020
- DEPENDENCY_MODE=ffmpeg ENABLE_COVERAGE=true
2121
- DEPENDENCY_MODE=ffmpeg ENABLE_COVERAGE=false
2222

23+
matrix:
24+
# generate coverage only with gcc
25+
exclude:
26+
- compiler: clang
27+
env: DEPENDENCY_MODE=ffmpeg ENABLE_COVERAGE=true
28+
- compiler: clang
29+
env: DEPENDENCY_MODE=libav ENABLE_COVERAGE=true
30+
allow_failures:
31+
- os: osx
32+
fast_finish: true
33+
2334
# This results in a 2×2×2x2 build matrix.
2435
# Where the variables are: os / compiler / DEPENDENCY_MODE / ENABLE_COVERAGE
2536

@@ -39,18 +50,12 @@ before_script:
3950

4051
script:
4152
# build
42-
- mkdir -p ${AVTRANSCODER_BUILD}
43-
- cd ${AVTRANSCODER_BUILD}
44-
- cmake .. -DCMAKE_INSTALL_PREFIX=${AVTRANSCODER_INSTALL} -DCMAKE_PREFIX_PATH=${DEPENDENCY_INSTALL} -DCMAKE_BUILD_TYPE=Release -DAVTRANSCODER_PYTHON_VERSION_OF_BINDING=2.7 -DAVTRANSCODER_COVERAGE=${ENABLE_COVERAGE}
45-
- make -j${CI_NODE_TOTAL}
46-
- make install
53+
- ./tools/travis.build.sh
4754

4855
# launch tests
49-
- if [ ${DEPENDENCY_MODE} = "ffmpeg" ]; then ./../tools/travis.python.nosetests.sh; fi
56+
- if [ ${DEPENDENCY_MODE} = "ffmpeg" ]; then ./tools/travis.python.nosetests.sh; fi
5057

5158
after_success:
52-
- cd ${TRAVIS_BUILD_DIR}
53-
5459
# generate coverage for coveralls
5560
- if [ ${ENABLE_COVERAGE} ]; then ./tools/travis.gcc.generate.coverage.sh; fi
5661

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ if(MSVC)
2727
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
2828
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
2929
else()
30-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -fPIC -pg -g")
31-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fPIC -O3")
30+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -fPIC -g")
31+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -fPIC -O3")
3232
endif()
3333

3434
# CPP flag to create code coverage report

app/jFileAnalysis/jFileAnalysis.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import org.avtranscoder.NoDisplayProgress;
22
import org.avtranscoder.InputFile;
3+
import org.avtranscoder.avtranscoder;
34

45

56
public class jFileAnalysis {
67
public static void main( String[] args ){
7-
System.loadLibrary("avutil");
8-
System.loadLibrary("swscale");
9-
System.loadLibrary("swresample");
10-
System.loadLibrary("avcodec");
11-
System.loadLibrary("avformat");
12-
System.loadLibrary("avtranscoder");
138
System.loadLibrary("avtranscoder-java");
149

1510
System.out.println( "Start input file analyse");
1611

12+
avtranscoder.preloadCodecsAndFormats();
13+
1714
InputFile inputFile = new InputFile( args[0] );
1815
NoDisplayProgress progress = new NoDisplayProgress();
1916
inputFile.analyse( progress );
2017

18+
// Access the properties you want with
19+
// inputFile.getProperties()
20+
2121
System.out.println( "End input file analyse");
22-
}
22+
}
2323
}
2424

2525
// How to use

app/pyThumbnail/pythumbnail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
formatProfile[ av.avProfileType ] = av.avProfileTypeFormat
7676
formatProfile[ av.avProfileFormat ] = "mjpeg"
7777
outputFile = av.OutputFile( args.outputFileName )
78-
outputFile.setProfile( formatProfile )
78+
outputFile.setupWrapping( formatProfile )
7979

8080
# create input stream
8181
videoStreamIndex = inputFile.getProperties().getVideoProperties()[0].getStreamIndex()

src/AvTranscoder/decoder/AudioDecoder.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ namespace avtranscoder
1818
{
1919

2020
AudioDecoder::AudioDecoder( InputStream& inputStream )
21-
: _inputStream ( &inputStream )
22-
, _frame ( NULL )
21+
: _inputStream( &inputStream )
22+
, _frame( NULL )
23+
, _isSetup(false)
2324
{
2425
#if LIBAVCODEC_VERSION_MAJOR > 54
2526
_frame = av_frame_alloc();
@@ -84,6 +85,7 @@ void AudioDecoder::setupDecoder( const ProfileLoader::Profile& profile )
8485

8586
// open decoder
8687
_inputStream->getAudioCodec().openCodec();
88+
_isSetup = true;
8789
}
8890

8991
bool AudioDecoder::decodeNextFrame( Frame& frameBuffer )
@@ -155,6 +157,9 @@ bool AudioDecoder::decodeNextFrame( Frame& frameBuffer, const size_t subStreamIn
155157

156158
bool AudioDecoder::decodeNextFrame()
157159
{
160+
if(!_isSetup)
161+
setupDecoder();
162+
158163
int got_frame = 0;
159164
while( ! got_frame )
160165
{

src/AvTranscoder/decoder/AudioDecoder.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class AvExport AudioDecoder : public IDecoder
2929
private:
3030
InputStream* _inputStream; ///< Stream from which we read next frames (no ownership, has link)
3131
AVFrame* _frame; ///< Libav object to store decoded data (has ownership)
32+
33+
bool _isSetup;
3234
};
3335

3436
}

src/AvTranscoder/decoder/AudioGenerator.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ class AvExport AudioGenerator : public IDecoder
1616

1717
~AudioGenerator();
1818

19-
void setupDecoder( const ProfileLoader::Profile& profile = ProfileLoader::Profile() ) {}
20-
2119
bool decodeNextFrame( Frame& frameBuffer );
2220
bool decodeNextFrame( Frame& frameBuffer, const size_t subStreamIndex );
2321

src/AvTranscoder/decoder/IDecoder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class AvExport IDecoder
1818
* @param profile: set decoder parameters from the given profile
1919
* @note Open the decoder.
2020
*/
21-
virtual void setupDecoder( const ProfileLoader::Profile& profile = ProfileLoader::Profile() ) = 0;
21+
virtual void setupDecoder( const ProfileLoader::Profile& profile = ProfileLoader::Profile() ) {}
2222

2323
/**
2424
* @brief Decode next frame

src/AvTranscoder/decoder/VideoDecoder.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ namespace avtranscoder
1717
{
1818

1919
VideoDecoder::VideoDecoder( InputStream& inputStream )
20-
: _inputStream ( &inputStream )
21-
, _frame ( NULL )
20+
: _inputStream( &inputStream )
21+
, _frame( NULL )
22+
, _isSetup(false)
2223
{
2324
#if LIBAVCODEC_VERSION_MAJOR > 54
2425
_frame = av_frame_alloc();
@@ -82,6 +83,7 @@ void VideoDecoder::setupDecoder( const ProfileLoader::Profile& profile )
8283

8384
// open decoder
8485
_inputStream->getVideoCodec().openCodec();
86+
_isSetup = true;
8587
}
8688

8789
bool VideoDecoder::decodeNextFrame( Frame& frameBuffer )
@@ -109,6 +111,9 @@ bool VideoDecoder::decodeNextFrame( Frame& frameBuffer, const size_t subStreamIn
109111

110112
bool VideoDecoder::decodeNextFrame()
111113
{
114+
if(!_isSetup)
115+
setupDecoder();
116+
112117
int got_frame = 0;
113118
while( ! got_frame )
114119
{

src/AvTranscoder/decoder/VideoDecoder.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class AvExport VideoDecoder : public IDecoder
2929
private:
3030
InputStream* _inputStream; ///< Stream from which we read next frames (no ownership, has link)
3131
AVFrame* _frame; ///< Libav object to store decoded data (has ownership)
32+
33+
bool _isSetup;
3234
};
3335

3436
}

src/AvTranscoder/decoder/VideoGenerator.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ class AvExport VideoGenerator : public IDecoder
1616

1717
~VideoGenerator();
1818

19-
void setupDecoder( const ProfileLoader::Profile& profile = ProfileLoader::Profile() ) {}
20-
2119
bool decodeNextFrame( Frame& frameBuffer );
2220
bool decodeNextFrame( Frame& frameBuffer, const size_t subStreamIndex );
2321

src/AvTranscoder/file/InputFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ double InputFile::getFps()
160160
return fps;
161161
}
162162

163-
void InputFile::setProfile( const ProfileLoader::Profile& profile )
163+
void InputFile::setupUnwrapping( const ProfileLoader::Profile& profile )
164164
{
165165
LOG_DEBUG( "Set profile of input file with:\n" << profile )
166166

src/AvTranscoder/file/InputFile.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class AvExport InputFile
100100
* @brief Set the format of the input file
101101
* @param profile: the profile of the input format
102102
*/
103-
virtual void setProfile( const ProfileLoader::Profile& profile );
103+
virtual void setupUnwrapping( const ProfileLoader::Profile& profile );
104104

105105
public:
106106
/**

src/AvTranscoder/file/OutputFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void OutputFile::addMetadata( const std::string& key, const std::string& value )
181181
_formatContext.addMetaData( key, value );
182182
}
183183

184-
void OutputFile::setProfile( const ProfileLoader::Profile& profile )
184+
void OutputFile::setupWrapping( const ProfileLoader::Profile& profile )
185185
{
186186
LOG_DEBUG( "Set profile of output file with:\n" << profile )
187187

src/AvTranscoder/file/OutputFile.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class AvExport OutputFile : public IOutputFile
7777
* @brief Set the format of the output file
7878
* @param profile: the profile of the output format
7979
*/
80-
void setProfile( const ProfileLoader::Profile& profile );
80+
void setupWrapping( const ProfileLoader::Profile& profile );
8181

8282
private:
8383
FormatContext _formatContext;

src/AvTranscoder/mediaProperty/FileProperties.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,16 @@ const avtranscoder::StreamProperties& FileProperties::getStreamPropertiesWithInd
189189
throw std::runtime_error( os.str() );
190190
}
191191

192+
const std::vector< avtranscoder::StreamProperties* > FileProperties::getStreamProperties() const
193+
{
194+
std::vector< avtranscoder::StreamProperties* > streams;
195+
for( std::map< size_t, StreamProperties* >::const_iterator it = _streams.begin(); it != _streams.end(); ++it )
196+
{
197+
streams.push_back( it->second );
198+
}
199+
return streams;
200+
}
201+
192202
size_t FileProperties::getNbStreams() const
193203
{
194204
if( ! _avFormatContext )

src/AvTranscoder/mediaProperty/FileProperties.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@ class AvExport FileProperties
6868

6969
//@{
7070
// @brief Get the list of properties for a given type (video, audio...)
71+
const std::vector< avtranscoder::StreamProperties* > getStreamProperties() const;
7172
const std::vector< avtranscoder::VideoProperties >& getVideoProperties() const { return _videoStreams; }
7273
const std::vector< avtranscoder::AudioProperties >& getAudioProperties() const { return _audioStreams; }
7374
const std::vector< avtranscoder::DataProperties >& getDataProperties() const { return _dataStreams; }
7475
const std::vector< avtranscoder::SubtitleProperties >& getSubtitleProperties() const { return _subtitleStreams; }
7576
const std::vector< avtranscoder::AttachementProperties >& getAttachementProperties() const { return _attachementStreams; }
76-
const std::vector< avtranscoder::UnknownProperties >& getUnknownPropertiesProperties() const { return _unknownStreams; }
77+
const std::vector< avtranscoder::UnknownProperties >& getUnknownProperties() const { return _unknownStreams; }
7778
//@}
7879

7980
#ifndef SWIG

src/AvTranscoder/mediaProperty/VideoProperties.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,10 @@ size_t VideoProperties::getNbFrames() const
452452
{
453453
if( ! _formatContext )
454454
throw std::runtime_error( "unknown format context" );
455-
return _formatContext->streams[_streamIndex]->nb_frames;
455+
size_t nbFrames = _formatContext->streams[_streamIndex]->nb_frames;
456+
if( nbFrames == 0 )
457+
nbFrames = getFps() * getDuration();
458+
return nbFrames;
456459
}
457460

458461
size_t VideoProperties::getTicksPerFrame() const
@@ -513,16 +516,6 @@ int VideoProperties::getLevel() const
513516

514517
float VideoProperties::getFps() const
515518
{
516-
const size_t nbFrames = getNbFrames();
517-
if( nbFrames )
518-
{
519-
const float duration = getDuration();
520-
const float epsilon = std::numeric_limits<float>::epsilon();
521-
if( duration > epsilon )
522-
return nbFrames / duration;
523-
}
524-
525-
// if nbFrames of stream is unknwon
526519
Rational timeBase = getTimeBase();
527520
float fps = timeBase.den / (double) timeBase.num;
528521
if( std::isinf( fps ) )

src/AvTranscoder/mediaProperty/print.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ std::ostream& operator<<( std::ostream& flux, const InputFile& input )
156156
// unknown streams
157157
for( size_t unknownStreamIndex = 0; unknownStreamIndex < input.getProperties().getNbUnknownStreams(); ++unknownStreamIndex )
158158
{
159-
flux << input.getProperties().getUnknownPropertiesProperties().at( unknownStreamIndex );
159+
flux << input.getProperties().getUnknownProperties().at( unknownStreamIndex );
160160
}
161161

162162
return flux;

src/AvTranscoder/mediaProperty/print.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
#include <AvTranscoder/file/InputFile.hpp>
55

6-
#include <iostream>
7-
86
namespace avtranscoder
97
{
108

src/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ if(SWIG_FOUND)
132132
include_directories(${JAVA_INCLUDE_PATH})
133133
include_directories(${JNI_INCLUDE_DIRS})
134134

135+
# Update compilation flags
136+
if(NOT MSVC)
137+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-strict-aliasing")
138+
endif()
139+
135140
# Swig flags
136141
set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -package org.avtranscoder)
137142

tools/travis.build.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Print commands and their arguments as they are executed.
4+
set -x
5+
6+
# Create directory of build
7+
mkdir -p ${AVTRANSCODER_BUILD}
8+
cd ${AVTRANSCODER_BUILD}
9+
10+
# Customize environment
11+
if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
12+
# Ask cmake to search in all dependencies we've installed manually
13+
export CMAKE_PREFIX_PATH=${DEPENDENCY_INSTALL}
14+
elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then
15+
# Ask cmake to search in all homebrew packages
16+
export CMAKE_PREFIX_PATH=$(echo /usr/local/Cellar/*/* | sed 's/ /;/g')
17+
fi
18+
19+
# Build avTranscoder
20+
cmake .. -DCMAKE_INSTALL_PREFIX=${AVTRANSCODER_INSTALL} -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH -DCMAKE_BUILD_TYPE=Release -DAVTRANSCODER_PYTHON_VERSION_OF_BINDING=2.7 -DAVTRANSCODER_COVERAGE=${ENABLE_COVERAGE}
21+
make -j${CI_NODE_TOTAL}
22+
make install

tools/travis.gcc.generate.coverage.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#!/bin/bash
2+
3+
# Print commands and their arguments as they are executed.
4+
set -x
5+
16
# capture coverage info
27
lcov --capture --directory ${AVTRANSCODER_BUILD} --output-file coverage.info
38

tools/travis.gcc.install.coverage.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#!/bin/bash
2+
3+
# Print commands and their arguments as they are executed.
4+
set -x
5+
16
# install latest LCOV (1.9 was failing for me)
27
wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz
38
tar xf lcov_1.11.orig.tar.gz

tools/travis.linux.install.deps.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#!/bin/bash
2+
3+
# Print commands and their arguments as they are executed.
4+
set -x
5+
26
lsb_release -a
37

48
sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse"

0 commit comments

Comments
 (0)