summaryrefslogtreecommitdiff
path: root/libavformat/avisynth.c
diff options
context:
space:
mode:
authorStephen Hutchinson <qyot27@gmail.com>2013-08-06 20:57:17 -0400
committerMichael Niedermayer <michaelni@gmx.at>2013-08-07 10:38:48 +0200
commit9db353bc4727d2a184778c110cf4ea0b9d1616cb (patch)
tree2b165ff72c84d6adfdb3c9888df8ab99507c8b74 /libavformat/avisynth.c
parentf277d6bf42329d481f58b6147f6dc4130f198ba5 (diff)
avisynth: Exit gracefully when trying to serve video from v2.5.8.
'Fixes' ticket #2526 insofar as it stops 2.5.8 from crashing and tells the user to upgrade to 2.6 if they want to make video input work. A real solution to #2526 would be to get video input from 2.5.8 to work right. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/avisynth.c')
-rw-r--r--libavformat/avisynth.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index 03f1688cbe..8a480ede21 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -69,6 +69,7 @@ typedef struct {
AVSC_DECLARE_FUNC(avs_get_audio);
AVSC_DECLARE_FUNC(avs_get_error);
AVSC_DECLARE_FUNC(avs_get_frame);
+ AVSC_DECLARE_FUNC(avs_get_version);
AVSC_DECLARE_FUNC(avs_get_video_info);
AVSC_DECLARE_FUNC(avs_invoke);
AVSC_DECLARE_FUNC(avs_release_clip);
@@ -134,6 +135,7 @@ static av_cold int avisynth_load_library(void) {
LOAD_AVS_FUNC(avs_get_audio, 0);
LOAD_AVS_FUNC(avs_get_error, 1); // New to AviSynth 2.6
LOAD_AVS_FUNC(avs_get_frame, 0);
+ LOAD_AVS_FUNC(avs_get_version, 0);
LOAD_AVS_FUNC(avs_get_video_info, 0);
LOAD_AVS_FUNC(avs_invoke, 0);
LOAD_AVS_FUNC(avs_release_clip, 0);
@@ -479,7 +481,26 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, int dis
pitch = -pitch;
}
+ // An issue with avs_bit_blt on 2.5.8 prevents video from working correctly.
+ // This problem doesn't exist for 2.6 and AvxSynth, so enable the workaround
+ // for 2.5.8 only. This only displays the warning and exits if the script has
+ // video. 2.5.8's internal interface version is 3, so avs_get_version allows
+ // it to work only in the circumstance that the interface is 5 or higher (4 is
+ // unused). There's a strong chance that AvxSynth, having been based on 2.5.8,
+ // would also be identified as interface version 3, but since AvxSynth doesn't
+ // suffer from this problem, special-case it.
+#ifdef _WIN32
+ if (avs_library->avs_get_version(avs->clip) > 3) {
avs_library->avs_bit_blt(avs->env, dst_p, rowsize, src_p, pitch, rowsize, planeheight);
+ } else {
+ av_log(s, AV_LOG_ERROR, "Video input from AviSynth 2.5.8 is not supported. Please upgrade to 2.6.\n");
+ avs->error = 1;
+ av_freep(&pkt->data);
+ return AVERROR_UNKNOWN;
+ }
+#else
+ avs_library->avs_bit_blt(avs->env, dst_p, rowsize, src_p, pitch, rowsize, planeheight);
+#endif
dst_p += rowsize * planeheight;
}