Merge branch 'master' into devel

This commit is contained in:
Joao Carreira
2022-03-07 00:17:00 +00:00
3 changed files with 18 additions and 13 deletions
+2
View File
@@ -1,6 +1,8 @@
# Created by https://www.gitignore.io/api/c++,clion,linux
# Edit at https://www.gitignore.io/?templates=c++,clion,linux
deps/**
templates/**
### C++ ###
# Prerequisites
*.d
+15 -13
View File
@@ -35,6 +35,10 @@
#define FF_USER_CODEC_PARAM
#endif
#if( LIBAVCODEC_VERSION_MAJOR >= 59 && LIBAVFORMAT_VERSION_MAJOR >= 59 )
#define FF_API_LAVF_AVCTX
#endif
std::vector<CalypStreamFormat> StreamHandlerLibav::supportedReadFormats()
{
INI_REGIST_CALYP_SUPPORTED_FMT;
@@ -123,7 +127,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
#else
int codecId = m_cStream->codec->codec_id;
#endif
AVCodec* dec = avcodec_find_decoder( AVCodecID( codecId ) );
auto* dec = avcodec_find_decoder( AVCodecID( codecId ) );
if( !dec )
{
std::cout << "Failed to find video coded" << std::endl;
@@ -150,7 +154,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
if( avcodec_open2( m_cCodedCtx, dec, NULL ) < 0 )
{
std::cout << "Failed to open video coded" << std::endl;
std::cout << "Failed to open video codec" << std::endl;
return false;
}
@@ -200,9 +204,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
m_iPixelFormat = ClpPixelFormats::Invalid;
m_bNative = false;
auto found_fmt = std::find_if( g_CalypPixFmtDescriptorsMap.begin(), g_CalypPixFmtDescriptorsMap.end(),
[auxPixFmt]( const auto& fmt ) {
return fmt.second.ffmpegPelFormat == auxPixFmt;
} );
[auxPixFmt]( const auto& fmt ) { return fmt.second.ffmpegPelFormat == auxPixFmt; } );
if( found_fmt != g_CalypPixFmtDescriptorsMap.end() )
{
m_bNative = true;
@@ -272,8 +274,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
AVPixelFormat newAvFmt = AVPixelFormat( g_CalypPixFmtDescriptorsMap.at( m_iPixelFormat ).ffmpegPelFormat );
/* create scaling context */
m_ScalerCtx = sws_getContext( m_uiWidth, m_uiHeight, AVPixelFormat( m_ffPixFmt ),
m_uiWidth, m_uiHeight, newAvFmt,
m_ScalerCtx = sws_getContext( m_uiWidth, m_uiHeight, AVPixelFormat( m_ffPixFmt ), m_uiWidth, m_uiHeight, newAvFmt,
SWS_BILINEAR, NULL, NULL, NULL );
m_cConvertedFrame = av_frame_alloc();
@@ -283,8 +284,9 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
return false;
}
if( av_image_alloc( m_cConvertedFrame->data, m_cConvertedFrame->linesize,
m_uiWidth, m_uiHeight, newAvFmt, 16 ) < 0 )
auto alloc_error =
av_image_alloc( m_cConvertedFrame->data, m_cConvertedFrame->linesize, m_uiWidth, m_uiHeight, newAvFmt, 16 );
if( alloc_error < 0 )
{
closeHandler();
return false;
@@ -415,13 +417,13 @@ bool StreamHandlerLibav::read( CalypFrame& pcFrame )
AVFrame* decFrame = m_cFrame;
if( !m_bNative )
{
sws_scale( m_ScalerCtx, (const uint8_t* const*)decFrame->data, decFrame->linesize, 0,
decFrame->height, (uint8_t* const*)m_cConvertedFrame->data, m_cConvertedFrame->linesize );
sws_scale( m_ScalerCtx, (const uint8_t* const*)decFrame->data, decFrame->linesize, 0, decFrame->height,
(uint8_t* const*)m_cConvertedFrame->data, m_cConvertedFrame->linesize );
decFrame = m_cConvertedFrame;
}
av_image_copy_to_buffer( m_pStreamBuffer.data(), m_uiFrameBufferSize, decFrame->data,
decFrame->linesize, AVPixelFormat( m_ffPixFmt ), m_uiWidth, m_uiHeight, 1 );
av_image_copy_to_buffer( m_pStreamBuffer.data(), m_uiFrameBufferSize, decFrame->data, decFrame->linesize,
AVPixelFormat( m_ffPixFmt ), m_uiWidth, m_uiHeight, 1 );
pcFrame.frameFromBuffer( m_pStreamBuffer, m_iEndianness );
m_uiCurrFrameFileIdx++;
+1
View File
@@ -40,6 +40,7 @@
#endif
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
#include <libavutil/imgutils.h>