On 6/9/20 7:56 PM, Stephen Hutchinson wrote:
avs_is_color_space provides a generic way of checking whether the video is RGB, and has been available since 2.6. This means that GetProcAddress doesn't have to run on every frame. --- Also should probably be applied to the 4.3 branch as well.libavformat/avisynth.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 2c08ace8db..f029a0e842 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -57,6 +57,7 @@ typedef struct AviSynthLibrary { AVSC_DECLARE_FUNC(avs_get_version); AVSC_DECLARE_FUNC(avs_get_video_info); AVSC_DECLARE_FUNC(avs_invoke); + AVSC_DECLARE_FUNC(avs_is_color_space); AVSC_DECLARE_FUNC(avs_release_clip); AVSC_DECLARE_FUNC(avs_release_value); AVSC_DECLARE_FUNC(avs_release_video_frame); @@ -133,6 +134,7 @@ static av_cold int avisynth_load_library(void) 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_is_color_space, 0); LOAD_AVS_FUNC(avs_release_clip, 0); LOAD_AVS_FUNC(avs_release_value, 0); LOAD_AVS_FUNC(avs_release_video_frame, 0); @@ -628,7 +630,6 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, const unsigned char *src_p; int n, i, plane, rowsize, planeheight, pitch, bits, ret; const char *error; - int avsplus av_unused;if (avs->curr_frame >= avs->vi->num_frames)return AVERROR_EOF; @@ -638,19 +639,6 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, if (discard) return 0;-#ifdef _WIN32- /* Detect whether we're using AviSynth 2.6 or AviSynth+ by - * looking for whether avs_is_planar_rgb exists. */ - if (GetProcAddress(avs_library.library, "avs_is_planar_rgb") == NULL) - avsplus = 0; - else - avsplus = 1; -#else - /* AviSynth+ is now the only variant of AviSynth we support - * on Linux and macOS. */ - avsplus = 1; -#endif - bits = avs_library.avs_bits_per_pixel(avs->vi);/* Without the cast to int64_t, calculation overflows at about 9k x 9k@@ -687,14 +675,9 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, planeheight = avs_library.avs_get_height_p(frame, plane);/* Flip RGB video. */- if (avs_is_rgb24(avs->vi) || avs_is_rgb(avs->vi)) { - src_p = src_p + (planeheight - 1) * pitch; - pitch = -pitch; - } - - /* Flip Planar RGB video */ - if (avsplus && (avs_library.avs_is_planar_rgb(avs->vi) || - avs_library.avs_is_planar_rgba(avs->vi))) { + if (avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR) || + avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR48) || + avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR64)) { src_p = src_p + (planeheight - 1) * pitch; pitch = -pitch; }
Ping. _______________________________________________ ffmpeg-devel mailing list [email protected] https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
