From fff3f0b007e6cda9d9cfcfa57c652e8aaedb8886 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 4 Nov 2015 15:58:16 +0100 Subject: [PATCH 1/6] FormatContext: log info when seek --- src/AvTranscoder/file/FormatContext.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/AvTranscoder/file/FormatContext.cpp b/src/AvTranscoder/file/FormatContext.cpp index 7dd22cbc..9ac0359f 100644 --- a/src/AvTranscoder/file/FormatContext.cpp +++ b/src/AvTranscoder/file/FormatContext.cpp @@ -147,6 +147,7 @@ bool FormatContext::seek( uint64_t position, const int flag ) if( (int)getStartTime() != AV_NOPTS_VALUE ) position += getStartTime(); + LOG_INFO( "Seek in '" << _avFormatContext->filename << "' at " << position << " (in AV_TIME_BASE units)" ) int err = av_seek_frame( _avFormatContext, -1, position, flag ); if( err < 0 ) { From 8eb3abaf9c3f95eaa811a87c88c6000be1440d2c Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 4 Nov 2015 15:59:47 +0100 Subject: [PATCH 2/6] encoders/decoders: do not log empty profile when setup --- src/AvTranscoder/decoder/AudioDecoder.cpp | 5 ++++- src/AvTranscoder/decoder/VideoDecoder.cpp | 5 ++++- src/AvTranscoder/encoder/AudioEncoder.cpp | 5 ++++- src/AvTranscoder/encoder/VideoEncoder.cpp | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/AvTranscoder/decoder/AudioDecoder.cpp b/src/AvTranscoder/decoder/AudioDecoder.cpp index eb9432fe..346ce765 100644 --- a/src/AvTranscoder/decoder/AudioDecoder.cpp +++ b/src/AvTranscoder/decoder/AudioDecoder.cpp @@ -62,7 +62,10 @@ void AudioDecoder::setupDecoder( const ProfileLoader::Profile& profile ) throw std::runtime_error( msg ); } - LOG_INFO( "Setup audio decoder with:\n" << profile ) + if( ! profile.empty() ) + { + LOG_INFO( "Setup audio decoder with:\n" << profile ) + } AudioCodec& codec = _inputStream->getAudioCodec(); diff --git a/src/AvTranscoder/decoder/VideoDecoder.cpp b/src/AvTranscoder/decoder/VideoDecoder.cpp index 08f87271..ae54d737 100644 --- a/src/AvTranscoder/decoder/VideoDecoder.cpp +++ b/src/AvTranscoder/decoder/VideoDecoder.cpp @@ -60,7 +60,10 @@ void VideoDecoder::setupDecoder( const ProfileLoader::Profile& profile ) throw std::runtime_error( msg ); } - LOG_INFO( "Setup video decoder with:\n" << profile ) + if( ! profile.empty() ) + { + LOG_INFO( "Setup video decoder with:\n" << profile ) + } VideoCodec& codec = _inputStream->getVideoCodec(); diff --git a/src/AvTranscoder/encoder/AudioEncoder.cpp b/src/AvTranscoder/encoder/AudioEncoder.cpp index 93e68342..85941c92 100644 --- a/src/AvTranscoder/encoder/AudioEncoder.cpp +++ b/src/AvTranscoder/encoder/AudioEncoder.cpp @@ -37,7 +37,10 @@ AudioEncoder::~AudioEncoder() void AudioEncoder::setupAudioEncoder( const AudioFrameDesc& frameDesc, const ProfileLoader::Profile& profile ) { - LOG_INFO( "Setup audio encoder with:\n" << profile ) + if( ! profile.empty() ) + { + LOG_INFO( "Setup audio encoder with:\n" << profile ) + } // set sampleRate, number of channels, sample format _codec.setAudioParameters( frameDesc ); diff --git a/src/AvTranscoder/encoder/VideoEncoder.cpp b/src/AvTranscoder/encoder/VideoEncoder.cpp index cca0820e..cce274ff 100644 --- a/src/AvTranscoder/encoder/VideoEncoder.cpp +++ b/src/AvTranscoder/encoder/VideoEncoder.cpp @@ -38,7 +38,10 @@ VideoEncoder::~VideoEncoder() void VideoEncoder::setupVideoEncoder( const VideoFrameDesc& frameDesc, const ProfileLoader::Profile& profile ) { - LOG_INFO( "Setup video encoder with:\n" << profile ) + if( ! profile.empty() ) + { + LOG_INFO( "Setup video encoder with:\n" << profile ) + } // set width, height, pixel format, fps _codec.setImageParameters( frameDesc ); From f3a85fb6d8a008e2998663ea1de6535a89bc9857 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 4 Nov 2015 16:00:04 +0100 Subject: [PATCH 3/6] wrap/unwrap: do not log empty profile when setup --- src/AvTranscoder/file/InputFile.cpp | 6 ++++-- src/AvTranscoder/file/OutputFile.cpp | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/AvTranscoder/file/InputFile.cpp b/src/AvTranscoder/file/InputFile.cpp index f780a090..6c945616 100644 --- a/src/AvTranscoder/file/InputFile.cpp +++ b/src/AvTranscoder/file/InputFile.cpp @@ -173,8 +173,10 @@ void InputFile::setupUnwrapping( const ProfileLoader::Profile& profile ) throw std::runtime_error( msg ); } - // set profile - LOG_INFO( "Setup unwrapping with:\n" << profile ) + if( ! profile.empty() ) + { + LOG_INFO( "Setup unwrapping with:\n" << profile ) + } for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it ) { diff --git a/src/AvTranscoder/file/OutputFile.cpp b/src/AvTranscoder/file/OutputFile.cpp index 075889ab..0e99a950 100644 --- a/src/AvTranscoder/file/OutputFile.cpp +++ b/src/AvTranscoder/file/OutputFile.cpp @@ -223,7 +223,10 @@ void OutputFile::setupWrapping( const ProfileLoader::Profile& profile ) throw std::runtime_error( msg ); } - LOG_INFO( "Setup wrapping with:\n" << profile ) + if( ! profile.empty() ) + { + LOG_INFO( "Setup wrapping with:\n" << profile ) + } // check if output format indicated is valid with the filename extension if( ! matchFormat( profile.find( constants::avProfileFormat )->second, getFilename() ) ) From 3264e0d0ae9c794e1d86a4953e11c733d0a1f793 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 4 Nov 2015 16:07:52 +0100 Subject: [PATCH 4/6] IReader: added assert to check not NULL --- src/AvTranscoder/reader/IReader.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/AvTranscoder/reader/IReader.cpp b/src/AvTranscoder/reader/IReader.cpp index 8f938805..a83608b2 100644 --- a/src/AvTranscoder/reader/IReader.cpp +++ b/src/AvTranscoder/reader/IReader.cpp @@ -2,6 +2,8 @@ #include +#include + namespace avtranscoder { @@ -49,6 +51,11 @@ Frame* IReader::readPrevFrame() Frame* IReader::readFrameAt( const size_t frame ) { + assert( _decoder != NULL ); + assert( _transform != NULL ); + assert( _srcFrame != NULL ); + assert( _dstFrame != NULL ); + if( (int)frame != _currentFrame + 1 ) { // seek @@ -65,6 +72,7 @@ Frame* IReader::readFrameAt( const size_t frame ) void IReader::printInfo() { + assert( _streamProperties != NULL ); std::cout << *_streamProperties << std::endl; } From dc2ca7d02f6ed1e00097787de045195c1f4b3db0 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 4 Nov 2015 16:10:15 +0100 Subject: [PATCH 5/6] FormatContext: do not add stream start time before each seek --- src/AvTranscoder/file/FormatContext.cpp | 5 +---- src/AvTranscoder/file/FormatContext.hpp | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/AvTranscoder/file/FormatContext.cpp b/src/AvTranscoder/file/FormatContext.cpp index 9ac0359f..1306347e 100644 --- a/src/AvTranscoder/file/FormatContext.cpp +++ b/src/AvTranscoder/file/FormatContext.cpp @@ -142,11 +142,8 @@ AVStream& FormatContext::addAVStream( const AVCodec& avCodec ) return *stream; } -bool FormatContext::seek( uint64_t position, const int flag ) +bool FormatContext::seek( const uint64_t position, const int flag ) { - if( (int)getStartTime() != AV_NOPTS_VALUE ) - position += getStartTime(); - LOG_INFO( "Seek in '" << _avFormatContext->filename << "' at " << position << " (in AV_TIME_BASE units)" ) int err = av_seek_frame( _avFormatContext, -1, position, flag ); if( err < 0 ) diff --git a/src/AvTranscoder/file/FormatContext.hpp b/src/AvTranscoder/file/FormatContext.hpp index b446d8a9..7c080531 100644 --- a/src/AvTranscoder/file/FormatContext.hpp +++ b/src/AvTranscoder/file/FormatContext.hpp @@ -77,10 +77,10 @@ class AvExport FormatContext * @brief Seek at a specific position * @param position: can be in AV_TIME_BASE units, in frames... depending on the flag value * @param flag: seeking mode (AVSEEK_FLAG_xxx) - * @note before seek, add offset of start time * @return seek status + * @see flushDecoder */ - bool seek( uint64_t position, const int flag ); + bool seek( const uint64_t position, const int flag ); size_t getNbStreams() const { return _avFormatContext->nb_streams; } /// Get duration of the program, in seconds From e9539a7e3255583be546e44cd285580cdfac3d8e Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 4 Nov 2015 16:24:26 +0100 Subject: [PATCH 6/6] Up to v0.5.13 --- src/AvTranscoder/common.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AvTranscoder/common.hpp b/src/AvTranscoder/common.hpp index 010fa163..5f5151d1 100644 --- a/src/AvTranscoder/common.hpp +++ b/src/AvTranscoder/common.hpp @@ -3,7 +3,7 @@ #define AVTRANSCODER_VERSION_MAJOR 0 #define AVTRANSCODER_VERSION_MINOR 5 -#define AVTRANSCODER_VERSION_MICRO 12 +#define AVTRANSCODER_VERSION_MICRO 13 #include