History

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.

Stephen Hutchinson committed 6 years ago

Commit 4c406861 parent 9f1b8081 file · +5 −22Browse files

Unified · Split

libavformat/avisynth.c+5−22
@@ -57,6 +57,7 @@ typedef struct AviSynthLibrary { · 56 unmodified lines
5757 AVSC_DECLARE_FUNC(avs_get_version);
5858 AVSC_DECLARE_FUNC(avs_get_video_info);
5959 AVSC_DECLARE_FUNC(avs_invoke);
60+ AVSC_DECLARE_FUNC(avs_is_color_space);
6061 AVSC_DECLARE_FUNC(avs_release_clip);
6162 AVSC_DECLARE_FUNC(avs_release_value);
6263 AVSC_DECLARE_FUNC(avs_release_video_frame);
@@ -133,6 +134,7 @@ static av_cold int avisynth_load_library(void) · 70 unmodified lines
133134 LOAD_AVS_FUNC(avs_get_version, 0);
134135 LOAD_AVS_FUNC(avs_get_video_info, 0);
135136 LOAD_AVS_FUNC(avs_invoke, 0);
137+ LOAD_AVS_FUNC(avs_is_color_space, 1);
136138 LOAD_AVS_FUNC(avs_release_clip, 0);
137139 LOAD_AVS_FUNC(avs_release_value, 0);
138140 LOAD_AVS_FUNC(avs_release_video_frame, 0);
@@ -628,7 +630,6 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, · 489 unmodified lines
628630 const unsigned char *src_p;
629631 int n, i, plane, rowsize, planeheight, pitch, bits, ret;
630632 const char *error;
631− int avsplus av_unused;
632633
633634 if (avs->curr_frame >= avs->vi->num_frames)
634635 return AVERROR_EOF;
@@ -638,19 +639,6 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, · 3 unmodified lines
638639 if (discard)
639640 return 0;
640641
641−#ifdef _WIN32
642− /* Detect whether we're using AviSynth 2.6 or AviSynth+ by
643− * looking for whether avs_is_planar_rgb exists. */
644− if (GetProcAddress(avs_library.library, "avs_is_planar_rgb") == NULL)
645− avsplus = 0;
646− else
647− avsplus = 1;
648−#else
649− /* AviSynth+ is now the only variant of AviSynth we support
650− * on Linux and macOS. */
651− avsplus = 1;
652−#endif
653−
654642 bits = avs_library.avs_bits_per_pixel(avs->vi);
655643
656644 /* 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, · 30 unmodified lines
687675 planeheight = avs_library.avs_get_height_p(frame, plane);
688676
689677 /* Flip RGB video. */
690− if (avs_is_rgb24(avs->vi) || avs_is_rgb(avs->vi)) {
691− src_p = src_p + (planeheight - 1) * pitch;
692− pitch = -pitch;
693− }
694−
695− /* Flip Planar RGB video */
696− if (avsplus && (avs_library.avs_is_planar_rgb(avs->vi) ||
697− avs_library.avs_is_planar_rgba(avs->vi))) {
678+ if (avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR) ||
679+ avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR48) ||
680+ avs_library.avs_is_color_space(avs->vi, AVS_CS_BGR64)) {
698681 src_p = src_p + (planeheight - 1) * pitch;
699682 pitch = -pitch;
700683 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t