changeset 4:dcc03a32d1bb libavformat

Added support for a realease function to eliminate the context blocks used by each hook.
author philipjsg
date Sat, 30 Nov 2002 17:16:32 +0000
parents 3442cae3ecf9
children 39c4c4336486
files framehook.c framehook.h
diffstat 2 files changed, 30 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/framehook.c	Fri Nov 29 19:19:47 2002 +0000
+++ b/framehook.c	Sat Nov 30 17:16:32 2002 +0000
@@ -21,7 +21,7 @@
 #include "framehook.h"
 #include "avformat.h"
 
-#ifdef HAVE_VHOOK
+#ifdef CONFIG_HAVE_DLFCN
 #include <dlfcn.h>
 #endif
 
@@ -30,6 +30,7 @@
     struct _FrameHookEntry *next;
     FrameHookConfigureFn Configure;
     FrameHookProcessFn Process;
+    FrameHookReleaseFn Release;
     void *ctx;
 } FrameHookEntry;
 
@@ -59,6 +60,7 @@
 
     fhe->Configure = dlsym(loaded, "Configure");
     fhe->Process = dlsym(loaded, "Process");
+    fhe->Release = dlsym(loaded, "Release");    /* Optional */
 
     if (!fhe->Process) {
         fprintf(stderr, "Failed to find Process entrypoint in %s\n", argv[0]);
@@ -100,3 +102,18 @@
         }
     }
 }
+
+void frame_hook_release()
+{
+    FrameHookEntry *fhe;
+    FrameHookEntry *fhenext;
+
+    for (fhe = first_hook; fhe; fhe = fhenext) {
+        fhenext = fhe->next;
+        if (fhe->Release)
+            fhe->Release(fhe->ctx);
+        av_free(fhe);
+    }
+
+    first_hook = NULL;
+}
--- a/framehook.h	Fri Nov 29 19:19:47 2002 +0000
+++ b/framehook.h	Sat Nov 30 17:16:32 2002 +0000
@@ -8,12 +8,22 @@
 #include "avcodec.h"
 
 /* Function must be called 'Configure' */
-typedef int (*FrameHookConfigureFn)(void **ctxp, int argc, char *argv[]);
+typedef int (FrameHookConfigure)(void **ctxp, int argc, char *argv[]);
+typedef FrameHookConfigure *FrameHookConfigureFn;
+extern FrameHookConfigure Configure;
 
 /* Function must be called 'Process' */
-typedef void (*FrameHookProcessFn)(void *ctx, struct AVPicture *pict, enum PixelFormat pix_fmt, int width, int height, INT64 pts);
+typedef void (FrameHookProcess)(void *ctx, struct AVPicture *pict, enum PixelFormat pix_fmt, int width, int height, INT64 pts);
+typedef FrameHookProcess *FrameHookProcessFn;
+extern FrameHookProcess Process;
+
+/* Function must be called 'Release' */
+typedef void (FrameHookRelease)(void *ctx);
+typedef FrameHookRelease *FrameHookReleaseFn;
+extern FrameHookRelease Release;
 
 extern int frame_hook_add(int argc, char *argv[]);
 extern void frame_hook_process(struct AVPicture *pict, enum PixelFormat pix_fmt, int width, int height);
+extern void frame_hook_release();
 
 #endif