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>
This commit is contained in:
Stephen Hutchinson 2013-08-06 20:57:17 -04:00 committed by Michael Niedermayer
parent f277d6bf42
commit 9db353bc47

View File

@ -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;
}