summaryrefslogtreecommitdiff
path: root/libav
diff options
context:
space:
mode:
authorPhilip Gladstone <philipjsg@users.sourceforge.net>2002-11-20 03:00:27 +0000
committerPhilip Gladstone <philipjsg@users.sourceforge.net>2002-11-20 03:00:27 +0000
commit3b2cbbed21b53bb6e83828d3157c2ba88b6db5e5 (patch)
tree089624915513d01e4c308c09326046f24511662b /libav
parente752dc90c27437aaf70f988c2cd0622c9da37f3b (diff)
Initial versions of code to all per-frame video processing in ffmpeg.
Originally committed as revision 1244 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libav')
-rw-r--r--libav/framehook.c102
-rw-r--r--libav/framehook.h19
-rw-r--r--libav/framehook.obin0 -> 30188 bytes
3 files changed, 121 insertions, 0 deletions
diff --git a/libav/framehook.c b/libav/framehook.c
new file mode 100644
index 0000000000..03ee32e188
--- /dev/null
+++ b/libav/framehook.c
@@ -0,0 +1,102 @@
+/*
+ * Video processing hooks
+ * Copyright (c) 2000, 2001 Fabrice Bellard.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <errno.h>
+#include "config.h"
+#include "framehook.h"
+#include "avformat.h"
+
+#ifdef HAVE_VHOOK
+#include <dlfcn.h>
+#endif
+
+
+typedef struct _FrameHookEntry {
+ struct _FrameHookEntry *next;
+ FrameHookConfigureFn Configure;
+ FrameHookProcessFn Process;
+ void *ctx;
+} FrameHookEntry;
+
+static FrameHookEntry *first_hook;
+
+/* Returns 0 on OK */
+int frame_hook_add(int argc, char *argv[])
+{
+#ifdef HAVE_VHOOK
+ void *loaded;
+ FrameHookEntry *fhe, **fhep;
+
+ if (argc < 1) {
+ return ENOENT;
+ }
+
+ loaded = dlopen(argv[0], RTLD_NOW);
+ if (!loaded) {
+ fprintf(stderr, "%s\n", dlerror());
+ return -1;
+ }
+
+ fhe = av_mallocz(sizeof(*fhe));
+ if (!fhe) {
+ return errno;
+ }
+
+ fhe->Configure = dlsym(loaded, "Configure");
+ fhe->Process = dlsym(loaded, "Process");
+
+ if (!fhe->Process) {
+ fprintf(stderr, "Failed to find Process entrypoint in %s\n", argv[0]);
+ return -1;
+ }
+
+ if (!fhe->Configure && argc > 1) {
+ fprintf(stderr, "Failed to find Configure entrypoint in %s\n", argv[0]);
+ return -1;
+ }
+
+ if (argc > 1 || fhe->Configure) {
+ if (fhe->Configure(&fhe->ctx, argc, argv)) {
+ fprintf(stderr, "Failed to Configure %s\n", argv[0]);
+ return -1;
+ }
+ }
+
+ for (fhep = &first_hook; *fhep; fhep = &((*fhep)->next)) {
+ }
+
+ *fhep = fhe;
+
+ return 0;
+#else
+ fprintf(stderr, "Video hooking not compiled into this version\n");
+ return 1;
+#endif
+}
+
+void frame_hook_process(AVPicture *pict, enum PixelFormat pix_fmt, int width, int height)
+{
+ if (first_hook) {
+ FrameHookEntry *fhe;
+ INT64 pts = av_gettime();
+
+ for (fhe = first_hook; fhe; fhe = fhe->next) {
+ fhe->Process(fhe->ctx, pict, pix_fmt, width, height, pts);
+ }
+ }
+}
diff --git a/libav/framehook.h b/libav/framehook.h
new file mode 100644
index 0000000000..eb1a51f7e4
--- /dev/null
+++ b/libav/framehook.h
@@ -0,0 +1,19 @@
+#ifndef _FRAMEHOOK_H
+#define _FRAMEHOOK_H
+
+/*
+ * Prototypes for interface to .so that implement a video processing hook
+ */
+
+#include "avcodec.h"
+
+/* Function must be called 'Configure' */
+typedef int (*FrameHookConfigureFn)(void **ctxp, int argc, char *argv[]);
+
+/* Function must be called 'Process' */
+typedef void (*FrameHookProcessFn)(void *ctx, struct AVPicture *pict, enum PixelFormat pix_fmt, int width, int height, INT64 pts);
+
+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);
+
+#endif
diff --git a/libav/framehook.o b/libav/framehook.o
new file mode 100644
index 0000000000..9e412c7776
--- /dev/null
+++ b/libav/framehook.o
Binary files differ