Skip to content

Commit 912a3b7

Browse files
author
Clement Champetier
committed
Merge branch 'develop' into dev_newAppAvConcat
2 parents 83ddac1 + 2f911ea commit 912a3b7

34 files changed

+1298
-1020
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ Note: for continuous integration, we launch tests with media files contained in
4848
###### Build openSUSE
4949
comming soon
5050

51+
52+
53+
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/avTranscoder/avtranscoder/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
54+

appveyor.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
os:
2+
- Windows Server 2012 R2
3+
4+
platform:
5+
- x86
6+
# - x64
7+
8+
matrix:
9+
fast_finish: true
10+
11+
init:
12+
- call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %platform%
13+
14+
before_build:
15+
- choco install -y swig
16+
- tools/appveyor.win.install.deps.bat
17+
18+
build_script:
19+
- tools/appveyor.build.bat
20+
21+
before_test:
22+
- set PATH=C:\Python27\scripts;%PATH%
23+
- pip install nose
24+
25+
test_script:
26+
- cd ..
27+
- tools/appveyor.python.nosetests.bat
28+
29+
on_failure:
30+
- type "C:\projects\avtranscoder\build\CMakeFiles\CMakeOutput.log"
31+
32+
#on_success:
33+
# - create archives
34+
35+
#artifacts:
36+
# - path: C:\ProgramData\ffmpeg-2.2.11
37+
# name: ffmpeg
38+
# type: zip
39+
40+
# - path: C:\projects\avtranscoder\build
41+
# name: avtranscoder
42+
# type: zip
43+
44+
#deploy:
45+
# - provider: GitHub
46+
# artifact: ffmpeg,avtranscoder
47+
# auth_token:
48+
# secure: <your encrypted token>
49+
# on:
50+
# branch: master
51+
# appveyor_repo_tag: true

cmake/AvTranscoderMacros.cmake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ file(GLOB_RECURSE AVTRANSCODER_SRC_FILES "AvTranscoder/*.cpp" "AvTranscoder/*.hp
1010
# AVTRANSCODER_VERSION
1111
file(STRINGS "${AVTRANSCODER_SRC_PATH}/AvTranscoder/common.hpp" _avtranscoder_VERSION_HPP_CONTENTS REGEX "#define AVTRANSCODER_VERSION_")
1212
foreach(v MAJOR MINOR MICRO)
13-
if("${_avtranscoder_VERSION_HPP_CONTENTS}" MATCHES "#define AVTRANSCODER_VERSION_${v} ([0-9]+)")
14-
set(AVTRANSCODER_VERSION_${v} "${CMAKE_MATCH_1}")
15-
else()
16-
set(AVTRANSCODER_RETRIEVE_VERSION_FAILED 1)
17-
endif()
13+
if("${_avtranscoder_VERSION_HPP_CONTENTS}" MATCHES "#define AVTRANSCODER_VERSION_${v} ([0-9]+)")
14+
set(AVTRANSCODER_VERSION_${v} "${CMAKE_MATCH_1}")
15+
else()
16+
set(AVTRANSCODER_RETRIEVE_VERSION_FAILED 1)
17+
endif()
1818
endforeach()
1919
unset(_avtranscoder_VERSION_HPP_CONTENTS)
2020

2121
set(AVTRANSCODER_VERSION "${AVTRANSCODER_VERSION_MAJOR}.${AVTRANSCODER_VERSION_MINOR}.${AVTRANSCODER_VERSION_MICRO}")
2222

2323
if(AVTRANSCODER_RETRIEVE_VERSION_FAILED)
24-
message(SEND_ERROR "Failed to retrieve AvTranscoder version: ${AVTRANSCODER_VERSION}")
24+
message(SEND_ERROR "Failed to retrieve AvTranscoder version: ${AVTRANSCODER_VERSION}")
2525
endif()

cmake/FindFFmpeg.cmake

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ macro(manage_components)
100100
set(FFMPEG_INCLUDE_DIR ${${COMPONENT}_INCLUDE_DIR})
101101
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${COMPONENT}_LIBRARIES})
102102
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${COMPONENT}_DEFINITIONS})
103-
else()
104-
set(${COMPONENT}_FOUND FALSE)
103+
else()
104+
message(STATUS "Skip ${COMPONENT} component because it was found elsewhere ('${${COMPONENT}_INCLUDE_DIR}' instead of '${FFMPEG_INCLUDE_DIR}').")
105+
set(${COMPONENT}_FOUND FALSE)
105106
endif()
106107
else()
107108
if(FFmpeg_FIND_REQUIRED)
@@ -121,12 +122,12 @@ endmacro()
121122

122123
# Check FFmpeg version
123124
if(DEFINED FFmpeg_FIND_VERSION)
124-
check_ffmpeg_version()
125+
check_ffmpeg_version()
125126
endif()
126127

127128
# Get basic components if no one is indicated
128129
if(NOT FFmpeg_FIND_COMPONENTS)
129-
set(FFmpeg_FIND_COMPONENTS avcodec avformat avutil)
130+
set(FFmpeg_FIND_COMPONENTS avcodec avformat avutil)
130131
endif()
131132

132133
# Check each component

src/AvTranscoder/common.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#define _AV_TRANSCODER_COMMON_HPP_
33

44
#define AVTRANSCODER_VERSION_MAJOR 0
5-
#define AVTRANSCODER_VERSION_MINOR 5
6-
#define AVTRANSCODER_VERSION_MICRO 12
5+
#define AVTRANSCODER_VERSION_MINOR 6
6+
#define AVTRANSCODER_VERSION_MICRO 0
77

88
#include <AvTranscoder/system.hpp>
99

src/AvTranscoder/decoder/AudioDecoder.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ void AudioDecoder::setupDecoder( const ProfileLoader::Profile& profile )
6262
throw std::runtime_error( msg );
6363
}
6464

65-
LOG_INFO( "Setup audio decoder with:\n" << profile )
65+
if( ! profile.empty() )
66+
{
67+
LOG_INFO( "Setup audio decoder with:\n" << profile )
68+
}
6669

6770
AudioCodec& codec = _inputStream->getAudioCodec();
6871

src/AvTranscoder/decoder/VideoDecoder.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ void VideoDecoder::setupDecoder( const ProfileLoader::Profile& profile )
6060
throw std::runtime_error( msg );
6161
}
6262

63-
LOG_INFO( "Setup video decoder with:\n" << profile )
63+
if( ! profile.empty() )
64+
{
65+
LOG_INFO( "Setup video decoder with:\n" << profile )
66+
}
6467

6568
VideoCodec& codec = _inputStream->getVideoCodec();
6669

src/AvTranscoder/encoder/AudioEncoder.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ AudioEncoder::~AudioEncoder()
3737

3838
void AudioEncoder::setupAudioEncoder( const AudioFrameDesc& frameDesc, const ProfileLoader::Profile& profile )
3939
{
40-
LOG_INFO( "Setup audio encoder with:\n" << profile )
40+
if( ! profile.empty() )
41+
{
42+
LOG_INFO( "Setup audio encoder with:\n" << profile )
43+
}
4144

4245
// set sampleRate, number of channels, sample format
4346
_codec.setAudioParameters( frameDesc );

src/AvTranscoder/encoder/VideoEncoder.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ VideoEncoder::~VideoEncoder()
3838

3939
void VideoEncoder::setupVideoEncoder( const VideoFrameDesc& frameDesc, const ProfileLoader::Profile& profile )
4040
{
41-
LOG_INFO( "Setup video encoder with:\n" << profile )
41+
if( ! profile.empty() )
42+
{
43+
LOG_INFO( "Setup video encoder with:\n" << profile )
44+
}
4245

4346
// set width, height, pixel format, fps
4447
_codec.setImageParameters( frameDesc );

src/AvTranscoder/file/FormatContext.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,9 @@ AVStream& FormatContext::addAVStream( const AVCodec& avCodec )
142142
return *stream;
143143
}
144144

145-
bool FormatContext::seek( uint64_t position, const int flag )
145+
bool FormatContext::seek( const uint64_t position, const int flag )
146146
{
147-
if( (int)getStartTime() != AV_NOPTS_VALUE )
148-
position += getStartTime();
149-
147+
LOG_INFO( "Seek in '" << _avFormatContext->filename << "' at " << position << " (in AV_TIME_BASE units)" )
150148
int err = av_seek_frame( _avFormatContext, -1, position, flag );
151149
if( err < 0 )
152150
{
@@ -193,12 +191,12 @@ void FormatContext::setOutputFormat( const std::string& filename, const std::str
193191
msg += filename;
194192
if( ! shortName.empty() )
195193
{
196-
msg += ", ";
194+
msg += ", formatName = ";
197195
msg += shortName;
198196
}
199197
if( ! mimeType.empty() )
200198
{
201-
msg += ", ";
199+
msg += ", mimeType = ";
202200
msg += mimeType;
203201
}
204202
throw std::ios_base::failure( msg );

src/AvTranscoder/file/FormatContext.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ class AvExport FormatContext
7777
* @brief Seek at a specific position
7878
* @param position: can be in AV_TIME_BASE units, in frames... depending on the flag value
7979
* @param flag: seeking mode (AVSEEK_FLAG_xxx)
80-
* @note before seek, add offset of start time
8180
* @return seek status
81+
* @see flushDecoder
8282
*/
83-
bool seek( uint64_t position, const int flag );
83+
bool seek( const uint64_t position, const int flag );
8484

8585
size_t getNbStreams() const { return _avFormatContext->nb_streams; }
8686
/// Get duration of the program, in seconds

src/AvTranscoder/file/InputFile.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,10 @@ void InputFile::setupUnwrapping( const ProfileLoader::Profile& profile )
173173
throw std::runtime_error( msg );
174174
}
175175

176-
// set profile
177-
LOG_INFO( "Setup unwrapping with:\n" << profile )
176+
if( ! profile.empty() )
177+
{
178+
LOG_INFO( "Setup unwrapping with:\n" << profile )
179+
}
178180

179181
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
180182
{

src/AvTranscoder/file/OutputFile.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
namespace avtranscoder
1212
{
1313

14-
OutputFile::OutputFile( const std::string& filename )
14+
OutputFile::OutputFile( const std::string& filename, const std::string& formatName, const std::string& mimeType )
1515
: _formatContext( AV_OPT_FLAG_ENCODING_PARAM )
1616
, _outputStreams()
1717
, _frameCount()
1818
, _previousProcessedStreamDuration( 0.0 )
1919
, _profile()
2020
{
2121
_formatContext.setFilename( filename );
22-
_formatContext.setOutputFormat( filename );
22+
_formatContext.setOutputFormat( filename, formatName, mimeType );
2323
}
2424

2525
OutputFile::~OutputFile()
@@ -223,7 +223,10 @@ void OutputFile::setupWrapping( const ProfileLoader::Profile& profile )
223223
throw std::runtime_error( msg );
224224
}
225225

226-
LOG_INFO( "Setup wrapping with:\n" << profile )
226+
if( ! profile.empty() )
227+
{
228+
LOG_INFO( "Setup wrapping with:\n" << profile )
229+
}
227230

228231
// check if output format indicated is valid with the filename extension
229232
if( ! matchFormat( profile.find( constants::avProfileFormat )->second, getFilename() ) )

src/AvTranscoder/file/OutputFile.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ class AvExport OutputFile : public IOutputFile
2222

2323
public:
2424
/**
25-
* @brief Open an output media file
25+
* @brief Create an output media file.
2626
* @param filename resource to access
27+
* @param formatName should matches with the names of the registered formats
28+
* @param mimeType should matches with the MIME type of the registered formats
29+
* @note The caller should indicate formatName and/or mimeType if the filename has no extension.
30+
* @note The ressource is allocated when beginWrap.
31+
* @see beginWrap
2732
**/
28-
OutputFile( const std::string& filename = "" );
33+
OutputFile( const std::string& filename, const std::string& formatName = "", const std::string& mimeType = "" );
2934

3035
~OutputFile();
3136

src/AvTranscoder/mediaProperty/PixelProperties.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ size_t PixelProperties::getBitsPerPixel() const
5656
return av_get_bits_per_pixel( _pixelDesc );
5757
}
5858

59+
size_t PixelProperties::getMaxNbBitsInChannels() const
60+
{
61+
if( ! _pixelDesc )
62+
throw std::runtime_error( "unable to find pixel description." );
63+
64+
size_t maxNbBitsInChannels = 0;
65+
for( unsigned int channelIndex = 0; channelIndex < _pixelDesc->nb_components; ++channelIndex )
66+
{
67+
const size_t nbBits = _pixelDesc->comp[channelIndex].depth_minus1 + 1;
68+
if( nbBits > maxNbBitsInChannels )
69+
maxNbBitsInChannels = nbBits;
70+
}
71+
return maxNbBitsInChannels;
72+
}
73+
5974
size_t PixelProperties::getNbComponents() const
6075
{
6176
if( ! _pixelDesc )
@@ -230,6 +245,7 @@ PropertyVector PixelProperties::getPropertiesAsVector() const
230245
addProperty( data, "pixelName", &PixelProperties::getPixelName );
231246
addProperty( data, "pixelFormatName", &PixelProperties::getPixelFormatName );
232247
addProperty( data, "bitDepth", &PixelProperties::getBitsPerPixel );
248+
addProperty( data, "maxNbBitsInChannels", &PixelProperties::getMaxNbBitsInChannels );
233249
addProperty( data, "nbComponents", &PixelProperties::getNbComponents );
234250
addProperty( data, "chromaWidth", &PixelProperties::getChromaWidth );
235251
addProperty( data, "chromaHeight", &PixelProperties::getChromaHeight );

src/AvTranscoder/mediaProperty/PixelProperties.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class AvExport PixelProperties
5555
std::string getPixelName() const;
5656
std::string getPixelFormatName() const;
5757

58-
size_t getBitsPerPixel() const;
58+
size_t getBitsPerPixel() const; ///< padding bits are not counted
59+
size_t getMaxNbBitsInChannels() const;
5960
size_t getNbComponents() const;
6061
size_t getChromaWidth() const;
6162
size_t getChromaHeight() const;

src/AvTranscoder/reader/IReader.cpp

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

33
#include <AvTranscoder/mediaProperty/print.hpp>
44

5+
#include <cassert>
6+
57
namespace avtranscoder
68
{
79

@@ -49,6 +51,11 @@ Frame* IReader::readPrevFrame()
4951

5052
Frame* IReader::readFrameAt( const size_t frame )
5153
{
54+
assert( _decoder != NULL );
55+
assert( _transform != NULL );
56+
assert( _srcFrame != NULL );
57+
assert( _dstFrame != NULL );
58+
5259
if( (int)frame != _currentFrame + 1 )
5360
{
5461
// seek
@@ -65,6 +72,7 @@ Frame* IReader::readFrameAt( const size_t frame )
6572

6673
void IReader::printInfo()
6774
{
75+
assert( _streamProperties != NULL );
6876
std::cout << *_streamProperties << std::endl;
6977
}
7078

src/CMakeLists.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ message(STATUS "AvTranscoder version is ${AVTRANSCODER_VERSION}")
99
find_package(FFmpeg COMPONENTS avcodec avformat avutil swscale swresample avresample)
1010
if(swresample_FOUND)
1111
add_definitions(-DAVTRANSCODER_FFMPEG_DEPENDENCY)
12-
message(STATUS "Build avTranscoder with dependency to ffmpeg.")
12+
message(STATUS "Build avTranscoder with dependency to ffmpeg.")
1313
elseif(avresample_FOUND)
1414
add_definitions(-DAVTRANSCODER_LIBAV_DEPENDENCY)
1515
message(STATUS "Build avTranscoder with dependency to libav.")
1616
else()
17-
message(SEND_ERROR "Can't define if you depend on ffmpeg or libav.")
17+
message(SEND_ERROR "Can't define if you depend on ffmpeg or libav.")
1818
endif()
1919

2020
# Include AvTranscoder and FFmpeg
@@ -38,8 +38,7 @@ set_target_properties(avtranscoder-shared PROPERTIES SOVERSION ${AVTRANSCODER_VE
3838
set_target_properties(avtranscoder-shared PROPERTIES VERSION ${AVTRANSCODER_VERSION})
3939
set_target_properties(avtranscoder-shared PROPERTIES INSTALL_RPATH_USE_LINK_PATH 1)
4040
target_link_libraries(avtranscoder-shared ${FFMPEG_LIBRARIES})
41-
target_include_directories(avtranscoder-shared PUBLIC
42-
${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
41+
target_include_directories(avtranscoder-shared PUBLIC ${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
4342

4443

4544
### Install AvTranscoder libs and include
@@ -120,12 +119,12 @@ if(SWIG_FOUND)
120119
else()
121120
message("PYTHON not found, will not build python binding.")
122121
endif()
123-
endif()
122+
endif()
124123

125124
### JAVA BINDING
126-
if(AVTRANSCODER_DISABLE_JAVA_BINDING)
125+
if(AVTRANSCODER_DISABLE_JAVA_BINDING)
127126
message("JAVA binding disabled, will not build java binding.")
128-
else()
127+
else()
129128
find_package(Java)
130129
find_package(JNI)
131130
if(JAVA_FOUND AND JNI_FOUND)

0 commit comments

Comments
 (0)