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