diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-06-05 09:09:31 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-06-05 09:09:31 +0000 |
commit | 9c6324e2165b68654db070e275a69cda0459516d (patch) | |
tree | 049e35f93ad29dd0407c870330f95ec4c493ca41 /src/media | |
parent | 49afe883b07fd22db57f0283ee31f1bb6dd0bbd7 (diff) | |
download | usdx-9c6324e2165b68654db070e275a69cda0459516d.tar.gz usdx-9c6324e2165b68654db070e275a69cda0459516d.tar.xz usdx-9c6324e2165b68654db070e275a69cda0459516d.zip |
compare FFmpeg header and DLL versions and log an error if both do not match
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2442 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r-- | src/media/UMediaCore_FFmpeg.pas | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/media/UMediaCore_FFmpeg.pas b/src/media/UMediaCore_FFmpeg.pas index 2d572ff2..eb136995 100644 --- a/src/media/UMediaCore_FFmpeg.pas +++ b/src/media/UMediaCore_FFmpeg.pas @@ -41,6 +41,7 @@ uses avformat, avutil, avio, + swscale, UMusic, ULog, UPath; @@ -121,9 +122,83 @@ const var Instance: TMediaCore_FFmpeg; +function AV_VERSION_INT(a, b, c: cardinal): cuint; +begin + Result := (a shl 16) or (b shl 8) or c; +end; + +procedure CheckVersions(); +var + libVersion: cuint; + headerVersion: cuint; + + function hexVerToStr(Version: cuint): string; + var + Major, Minor, Release: cardinal; + begin + Major := (Version shr 16) and $FF;; + Minor := (Version shr 8) and $FF; + Release := Version and $FF; + Result := Format('%d.%d.%d', [Major, Minor, Release]); + end; + +begin + libVersion := avcodec_version(); + headerVersion := AV_VERSION_INT( + LIBAVCODEC_VERSION_MAJOR, + LIBAVCODEC_VERSION_MINOR, + LIBAVCODEC_VERSION_RELEASE); + if (libVersion <> headerVersion) then + begin + Log.LogError(Format('%s header (%s) and DLL (%s) versions do not match.', + ['libavcodec', hexVerToStr(headerVersion), hexVerToStr(libVersion)])); + end; + + {$IF LIBAVFORMAT_VERSION >= 52020000} // 52.20.0 + libVersion := avformat_version(); + headerVersion := AV_VERSION_INT( + LIBAVFORMAT_VERSION_MAJOR, + LIBAVFORMAT_VERSION_MINOR, + LIBAVFORMAT_VERSION_RELEASE); + if (libVersion <> headerVersion) then + begin + Log.LogError(Format('%s header (%s) and DLL (%s) versions do not match.', + ['libavformat', hexVerToStr(headerVersion), hexVerToStr(libVersion)])); + end; + {$IFEND} + + {$IF LIBAVUTIL_VERSION >= 49008000} // 49.8.0 + libVersion := avutil_version(); + headerVersion := AV_VERSION_INT( + LIBAVUTIL_VERSION_MAJOR, + LIBAVUTIL_VERSION_MINOR, + LIBAVUTIL_VERSION_RELEASE); + if (libVersion <> headerVersion) then + begin + Log.LogError(Format('%s header (%s) and DLL (%s) versions do not match.', + ['libavutil', hexVerToStr(headerVersion), hexVerToStr(libVersion)])); + end; + {$IFEND} + + {$IF LIBSWSCALE_VERSION >= 000006001} // 0.6.1 + libVersion := swscale_version(); + headerVersion := AV_VERSION_INT( + LIBSWSCALE_VERSION_MAJOR, + LIBSWSCALE_VERSION_MINOR, + LIBSWSCALE_VERSION_RELEASE); + if (libVersion <> headerVersion) then + begin + Log.LogError(Format('%s header (%s) and DLL (%s) versions do not match.', + ['libswscale', hexVerToStr(headerVersion), hexVerToStr(libVersion)])); + end; + {$IFEND} +end; + constructor TMediaCore_FFmpeg.Create(); begin inherited; + + CheckVersions(); av_register_protocol(@UTF8FileProtocol); AVCodecLock := SDL_CreateMutex(); end; |