diff options
author | Stephen Hutchinson <qyot27@gmail.com> | 2020-04-07 19:47:43 -0400 |
---|---|---|
committer | Stephen Hutchinson <qyot27@gmail.com> | 2021-03-11 14:21:30 -0500 |
commit | 4c40686ee25f2aae29a121fe9e52c5db41007b36 (patch) | |
tree | 60cf1d499b68d269a03ed9204a5cd95ce3376428 | |
parent | 9f1b808bded79b005874c1bb0e526e000d3ae8b2 (diff) | |
download | ffmpeg-4c40686ee25f2aae29a121fe9e52c5db41007b36.tar.gz |
avisynth: more intelligent RGB flipping
avs_is_color_space provides a generic way of checking whether the
video is RGB, and has been available through AVSC_API since 2.6.
This means that GetProcAddress doesn't have to run on every frame.
Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
-rw-r--r-- | libavformat/avisynth.c | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 2c08ace8db..5756aea0b6 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, 1); 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; } |