Skip to content

Backward compatibility #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 1, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/AvTranscoder/OptionLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -276,15 +276,21 @@ OptionLoader::OptionArray OptionLoader::loadOptions( void* av_class, int req_fla
return options;
}

std::vector<std::string> OptionLoader::getPixelFormats ( const std::string& videoCodecName ) const
std::vector<std::string> OptionLoader::getPixelFormats( const std::string& videoCodecName ) const
{
std::vector<std::string> pixelFormats;

// all video codec concerned
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;
Expand All @@ -301,7 +307,11 @@ std::vector<std::string> 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 ) );
Expand Down