]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/avisynth.c
lavf/mov.c: Avoid OOB in mov_read_udta_string()
[ffmpeg] / libavformat / avisynth.c
index 1fe8e083be552f2d3efcce6821d0982f6a5ae3d7..514cb99f49a767d548ee0505ba8ce1ee4c48ab42 100644 (file)
@@ -29,7 +29,7 @@
 
 /* Platform-specific directives for AviSynth vs AvxSynth. */
 #ifdef _WIN32
-  #include <windows.h>
+  #include "compat/w32dlfcn.h"
   #undef EXTERN_C
   #include "compat/avisynth/avisynth_c.h"
   #define AVISYNTH_LIB "avisynth"
   #include "compat/avisynth/avxsynth_c.h"
   #define AVISYNTH_NAME "libavxsynth"
   #define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF
-
-  #define LoadLibrary(x) dlopen(x, RTLD_NOW | RTLD_LOCAL)
-  #define GetProcAddress dlsym
-  #define FreeLibrary dlclose
 #endif
 
 typedef struct AviSynthLibrary {
@@ -118,13 +114,13 @@ static av_cold void avisynth_atexit_handler(void);
 
 static av_cold int avisynth_load_library(void)
 {
-    avs_library.library = LoadLibrary(AVISYNTH_LIB);
+    avs_library.library = dlopen(AVISYNTH_LIB, RTLD_NOW | RTLD_LOCAL);
     if (!avs_library.library)
         return AVERROR_UNKNOWN;
 
 #define LOAD_AVS_FUNC(name, continue_on_fail)                          \
         avs_library.name =                                             \
-            (void *)GetProcAddress(avs_library.library, #name);        \
+            (void *)dlsym(avs_library.library, #name);                 \
         if (!continue_on_fail && !avs_library.name)                    \
             goto fail;
 
@@ -157,7 +153,7 @@ static av_cold int avisynth_load_library(void)
     return 0;
 
 fail:
-    FreeLibrary(avs_library.library);
+    dlclose(avs_library.library);
     return AVERROR_UNKNOWN;
 }
 
@@ -225,7 +221,7 @@ static av_cold void avisynth_atexit_handler(void)
         avisynth_context_destroy(avs);
         avs = next;
     }
-    FreeLibrary(avs_library.library);
+    dlclose(avs_library.library);
 
     avs_atexit_called = 1;
 }
@@ -690,8 +686,10 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt,
 #ifdef USING_AVISYNTH
         /* Flip Planar RGB video. */
         if (avsplus && (avs_library.avs_is_planar_rgb(avs->vi) ||
-                        avs_library.avs_is_planar_rgba(avs->vi)))
+                        avs_library.avs_is_planar_rgba(avs->vi))) {
+            src_p = src_p + (planeheight - 1) * pitch;
             pitch = -pitch;
+        }
 #endif
 
         avs_library.avs_bit_blt(avs->env, dst_p, rowsize, src_p, pitch,