]> git.seodisparate.com - EN605.617.81.FA21_StephenSeo_DitheringProject/commitdiff
Apply fixes based on FFmpeg 5.0
authorStephen Seo <seo.disparate@gmail.com>
Fri, 18 Feb 2022 06:24:31 +0000 (15:24 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Fri, 18 Feb 2022 06:24:31 +0000 (15:24 +0900)
See README.md for more details

CMakeLists.txt
README.md
src/video.cc

index dd75a64884f1cf35c1739eef2696cf8dbb39cffa..6939390c6686489964b44ae272a15c328c26645a 100644 (file)
@@ -30,27 +30,6 @@ find_package(PkgConfig REQUIRED)
 pkg_check_modules(FFMPEG_LIBAVCODEC REQUIRED
     libavcodec libavformat libavutil libswscale)
 
-if(${FFMPEG_LIBAVCODEC_libavcodec_VERSION} VERSION_GREATER "58.134.100"
-        OR
-    ${FFMPEG_LIBAVCODEC_libavformat_VERSION} VERSION_GREATER "58.76.100"
-        OR
-    ${FFMPEG_LIBAVCODEC_libavutil_VERSION} VERSION_GREATER "56.70.100"
-        OR
-    ${FFMPEG_LIBAVCODEC_libswscale_VERSION} VERSION_GREATER "5.9.100")
-    message(FATAL_ERROR "FFmpeg version is newer than expected, please use FFmpeg version 4.4")
-# The following may be necessary when moving to FFmpeg 5.0
-#elseif(${FFMPEG_LIBAVCODEC_libavcodec_VERSION} VERSION_LESS_EQUAL "58.91.100"
-#        OR
-#    ${FFMPEG_LIBAVCODEC_libavformat_VERSION} VERSION_LESS_EQUAL "58.45.100"
-#        OR
-#    ${FFMPEG_LIBAVCODEC_libavutil_VERSION} VERSION_LESS_EQUAL "56.51.100"
-#        OR
-#    ${FFMPEG_LIBAVCODEC_libswscale_VERSION} VERSION_LESS_EQUAL "5.7.100")
-#    message(FATAL_ERROR "FFmpeg version is older than expected, please use FFmpeg version 4.4")
-else()
-    message("FFmpeg version is OK")
-endif()
-
 target_include_directories(DitheringProject PUBLIC
   ${OpenCL_INCLUDE_DIRS}
   ${PNG_INCLUDE_DIRS}
index f455cef778702cabdf63c990b26042b65a0736d9..4a0165c1515f0c3482e41bcf789fdeb22d7693c1 100644 (file)
--- a/README.md
+++ b/README.md
@@ -2,14 +2,19 @@
 
 ## Note about Maintenance and Versions
 
-The project at tag `1.0.0` refers to the state of the project upon completion
+~~The project at tag `1.0.0` refers to the state of the project upon completion
 of the course. Newer versions are meant to be maintenance releases; fixes that
 keep the project working. As of 2022-01-18, there may be (after now) a version
 `1.1.0` or `1.0.1` due to keeping up to date with the FFmpeg dependency as a new
 major version of FFmpeg was released (version `5.0`).
 
 To be clear, version `1.0.0` of this project is expected to work with FFmpeg
-version `4.4`.
+version `4.4`.~~
+
+Fixes were applied for FFmpeg version 5. A macro is used to change incompatible
+code based on what version of FFmpeg is specified in the headers, so external
+checking of version is not necessary. Thus, the latest version of this repo
+should work with both FFmpeg 5.0 and 4.4.
 
 ## Background
 
index 200edfc7f7a7c35b92fe3959205e68417079bca4..146c5c065e4b0a382048758c28817f6d53f43256 100644 (file)
@@ -74,7 +74,11 @@ bool Video::DitherVideo(const std::string &output_filename, Image *blue_noise,
   }
 
   // Get "best" video stream
+#if LIBAVFORMAT_VERSION_MAJOR >= 59
+  const AVCodec *dec_codec = nullptr;
+#else
   AVCodec *dec_codec = nullptr;
+#endif
   return_value = av_find_best_stream(
       avf_dec_context, AVMediaType::AVMEDIA_TYPE_VIDEO, -1, -1, &dec_codec, 0);
   if (return_value < 0) {
@@ -193,7 +197,11 @@ bool Video::DitherVideo(const std::string &output_filename, Image *blue_noise,
 
   // set output video codec (h264)
   AVCodecContext *enc_codec_context = nullptr;
+#if LIBAVCODEC_VERSION_MAJOR >= 59
+  const AVCodec *enc_codec = nullptr;
+#else
   AVCodec *enc_codec = nullptr;
+#endif
 
   // get H264 codec
   if (!output_as_pngs) {