From c67aef532e6e3b6afee3c1411f5b82cd8d476f81 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Mon, 30 Jun 2014 17:30:43 +0200 Subject: [PATCH 1/2] OptionLoader: getPixelFormats, manage backward compatibility --- src/AvTranscoder/OptionLoader.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/AvTranscoder/OptionLoader.cpp b/src/AvTranscoder/OptionLoader.cpp index 53630c91..e64b5f71 100644 --- a/src/AvTranscoder/OptionLoader.cpp +++ b/src/AvTranscoder/OptionLoader.cpp @@ -284,7 +284,13 @@ std::vector OptionLoader::getPixelFormats ( const std::string& vide if( videoCodecName == "" ) { const AVPixFmtDescriptor* pixFmtDesc = NULL; + +#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT( 51, 44, 0 ) + for( int pix_fmt = 0; pix_fmt < PIX_FMT_NB; ++pix_fmt ) + pixFmtDesc = &av_pix_fmt_descriptors[pix_fmt]; +#else while( ( pixFmtDesc = av_pix_fmt_desc_next( pixFmtDesc ) ) != NULL ) +#endif { if( ! pixFmtDesc->name ) continue; @@ -301,7 +307,11 @@ std::vector OptionLoader::getPixelFormats ( const std::string& vide size_t pix_fmt = 0; while( videoCodec->pix_fmts[pix_fmt] != -1 ) { +#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT( 51, 44, 0 ) + const AVPixFmtDescriptor* pix_desc = &av_pix_fmt_descriptors[ videoCodec->pix_fmts[pix_fmt] ]; +#else const AVPixFmtDescriptor* pix_desc = av_pix_fmt_desc_get( videoCodec->pix_fmts[pix_fmt] ); +#endif if( ! pix_desc->name ) continue; pixelFormats.push_back( std::string( pix_desc->name ) ); From 7d0e27ddec1062fc8b65026f1ec52a67a80bed1f Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Mon, 30 Jun 2014 17:33:13 +0200 Subject: [PATCH 2/2] OptionLoader: refactoring * Backward compatibility: always the old version in first. * getPixelFormats: no spaces between the name of the function and its list of parameters. --- src/AvTranscoder/OptionLoader.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/AvTranscoder/OptionLoader.cpp b/src/AvTranscoder/OptionLoader.cpp index e64b5f71..00867a01 100644 --- a/src/AvTranscoder/OptionLoader.cpp +++ b/src/AvTranscoder/OptionLoader.cpp @@ -65,11 +65,11 @@ OptionLoader::OptionLoader() AVCodec* c = NULL; while( ( c = av_codec_next( c ) ) != NULL ) { -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 53, 34, 0 ) - if( ! c->encode2 ) +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 53, 34, 0 ) + if( ! c->encode ) continue; #else - if( ! c->encode ) + if( ! c->encode2 ) continue; #endif switch( c->type ) @@ -153,10 +153,10 @@ OptionLoader::OptionMap OptionLoader::loadVideoCodecOptions() // iterate on codecs while( _codec ) { -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 53, 34, 0 ) - if( _codec->encode2 ) -#else +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 53, 34, 0 ) if( _codec->encode ) +#else + if( _codec->encode2 ) #endif { // add only video codec @@ -189,10 +189,10 @@ OptionLoader::OptionMap OptionLoader::loadAudioCodecOptions() // iterate on codecs while( _codec ) { -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 53, 34, 0 ) - if( _codec->encode2 ) -#else +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 53, 34, 0 ) if( _codec->encode ) +#else + if( _codec->encode2 ) #endif { // add only audio codec @@ -276,7 +276,7 @@ OptionLoader::OptionArray OptionLoader::loadOptions( void* av_class, int req_fla return options; } -std::vector OptionLoader::getPixelFormats ( const std::string& videoCodecName ) const +std::vector OptionLoader::getPixelFormats( const std::string& videoCodecName ) const { std::vector pixelFormats;