From 5217854199e513eb0c63ddac54c6ccfd47621c19 Mon Sep 17 00:00:00 2001 From: Karl Blomster Date: Sat, 26 Sep 2009 23:54:26 +0000 Subject: [PATCH] Update ffms2 to r222. Fixes compilation with ancient ffmpeg's and is a better solution than verm's hack in r3578. Originally committed to SVN as r3580. --- aegisub/libffms/include/ffmscompat.h | 12 ++++++++++++ aegisub/libffms/src/core/haalivideo.cpp | 5 +++++ aegisub/libffms/src/core/lavfvideo.cpp | 9 +++++++-- aegisub/libffms/src/core/matroskavideo.cpp | 9 +++++++-- aegisub/libffms/src/core/videosource.h | 3 +++ 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/aegisub/libffms/include/ffmscompat.h b/aegisub/libffms/include/ffmscompat.h index f85532e52..ba3c2625f 100644 --- a/aegisub/libffms/include/ffmscompat.h +++ b/aegisub/libffms/include/ffmscompat.h @@ -41,6 +41,18 @@ # endif #endif +#ifdef LIBAVCODEC_VERSION_INT +# if (LIBAVCODEC_VERSION_INT) >= (AV_VERSION_INT(52,29,0)) +# define FFMS_HAVE_FFMPEG_COLORSPACE_INFO +# else +# ifdef _MSC_VER +# pragma message("WARNING: Your FFmpeg is too old to support reporting colorspace and luma range information. The corresponding fields of FFMS_VideoProperties will be set to 0. Please update FFmpeg to get rid of this warning.") +# else +# warning "Your FFmpeg is too old to support reporting colorspace and luma range information. The corresponding fields of FFMS_VideoProperties will be set to 0. Please update FFmpeg to get rid of this warning." +# endif +# endif +#endif + #ifndef AV_PKT_FLAG_KEY # define AV_PKT_FLAG_KEY PKT_FLAG_KEY #endif diff --git a/aegisub/libffms/src/core/haalivideo.cpp b/aegisub/libffms/src/core/haalivideo.cpp index a63e8ada8..375ef2eb8 100644 --- a/aegisub/libffms/src/core/haalivideo.cpp +++ b/aegisub/libffms/src/core/haalivideo.cpp @@ -133,8 +133,13 @@ FFHaaliVideo::FFHaaliVideo(const char *SourceFile, int Track, VP.RFFNumerator = CodecContext->time_base.den; VP.NumFrames = Frames.size(); VP.TopFieldFirst = DecodeFrame->top_field_first; +#ifdef FFMS_HAVE_FFMPEG_COLORSPACE_INFO VP.ColorSpace = CodecContext->colorspace; VP.ColorRange = CodecContext->color_range; +#else + VP.ColorSpace = 0; + VP.ColorRange = 0; +#endif VP.FirstTime = ((Frames.front().DTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000; VP.LastTime = ((Frames.back().DTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000; diff --git a/aegisub/libffms/src/core/lavfvideo.cpp b/aegisub/libffms/src/core/lavfvideo.cpp index b1f1cb693..2c78a93ab 100644 --- a/aegisub/libffms/src/core/lavfvideo.cpp +++ b/aegisub/libffms/src/core/lavfvideo.cpp @@ -69,8 +69,13 @@ FFLAVFVideo::FFLAVFVideo(const char *SourceFile, int Track, FFMS_Index *Index, VP.RFFNumerator = CodecContext->time_base.den; VP.NumFrames = Frames.size(); VP.TopFieldFirst = DecodeFrame->top_field_first; -// VP.ColorSpace = CodecContext->colorspace; -// VP.ColorRange = CodecContext->color_range; +#ifdef FFMS_HAVE_FFMPEG_COLORSPACE_INFO + VP.ColorSpace = CodecContext->colorspace; + VP.ColorRange = CodecContext->color_range; +#else + VP.ColorSpace = 0; + VP.ColorRange = 0; +#endif VP.FirstTime = ((Frames.front().DTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000; VP.LastTime = ((Frames.back().DTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000; diff --git a/aegisub/libffms/src/core/matroskavideo.cpp b/aegisub/libffms/src/core/matroskavideo.cpp index fd8e5f6a5..56df418af 100644 --- a/aegisub/libffms/src/core/matroskavideo.cpp +++ b/aegisub/libffms/src/core/matroskavideo.cpp @@ -96,8 +96,13 @@ FFMatroskaVideo::FFMatroskaVideo(const char *SourceFile, int Track, VP.RFFNumerator = CodecContext->time_base.den; VP.NumFrames = Frames.size(); VP.TopFieldFirst = DecodeFrame->top_field_first; -// VP.ColorSpace = CodecContext->colorspace; -// VP.ColorRange = CodecContext->color_range; +#ifdef FFMS_HAVE_FFMPEG_COLORSPACE_INFO + VP.ColorSpace = CodecContext->colorspace; + VP.ColorRange = CodecContext->color_range; +#else + VP.ColorSpace = 0; + VP.ColorRange = 0; +#endif VP.FirstTime = ((Frames.front().DTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000; VP.LastTime = ((Frames.back().DTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000; diff --git a/aegisub/libffms/src/core/videosource.h b/aegisub/libffms/src/core/videosource.h index 417622726..512845d99 100644 --- a/aegisub/libffms/src/core/videosource.h +++ b/aegisub/libffms/src/core/videosource.h @@ -28,6 +28,9 @@ extern "C" { #include } +// must be included after ffmpeg headers +#include "ffmscompat.h" + #include #include "indexing.h" #include "utils.h"