2 * Video processing hooks
3 * Copyright (c) 2000, 2001 Fabrice Bellard.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "framehook.h"
24 #ifdef CONFIG_HAVE_DLFCN
29 typedef struct _FrameHookEntry {
30 struct _FrameHookEntry *next;
31 FrameHookConfigureFn Configure;
32 FrameHookProcessFn Process;
33 FrameHookReleaseFn Release;
37 static FrameHookEntry *first_hook;
40 int frame_hook_add(int argc, char *argv[])
44 FrameHookEntry *fhe, **fhep;
50 loaded = dlopen(argv[0], RTLD_NOW);
52 fprintf(stderr, "%s\n", dlerror());
56 fhe = av_mallocz(sizeof(*fhe));
61 fhe->Configure = dlsym(loaded, "Configure");
62 fhe->Process = dlsym(loaded, "Process");
63 fhe->Release = dlsym(loaded, "Release"); /* Optional */
66 fprintf(stderr, "Failed to find Process entrypoint in %s\n", argv[0]);
70 if (!fhe->Configure && argc > 1) {
71 fprintf(stderr, "Failed to find Configure entrypoint in %s\n", argv[0]);
75 if (argc > 1 || fhe->Configure) {
76 if (fhe->Configure(&fhe->ctx, argc, argv)) {
77 fprintf(stderr, "Failed to Configure %s\n", argv[0]);
82 for (fhep = &first_hook; *fhep; fhep = &((*fhep)->next)) {
89 fprintf(stderr, "Video hooking not compiled into this version\n");
94 void frame_hook_process(AVPicture *pict, enum PixelFormat pix_fmt, int width, int height)
98 int64_t pts = av_gettime();
100 for (fhe = first_hook; fhe; fhe = fhe->next) {
101 fhe->Process(fhe->ctx, pict, pix_fmt, width, height, pts);
106 void frame_hook_release(void)
109 FrameHookEntry *fhenext;
111 for (fhe = first_hook; fhe; fhe = fhenext) {
114 fhe->Release(fhe->ctx);