Mercurial > libavformat.hg
annotate framehook.c @ 111:c1e67f7a0168 libavformat
rgba32 support
author | bellard |
---|---|
date | Sat, 19 Apr 2003 16:23:03 +0000 |
parents | a58a8a53eb46 |
children | 08e042299038 |
rev | line source |
---|---|
0 | 1 /* |
2 * Video processing hooks | |
3 * Copyright (c) 2000, 2001 Fabrice Bellard. | |
4 * | |
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. | |
9 * | |
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. | |
14 * | |
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 | |
18 */ | |
19 #include <errno.h> | |
20 #include "config.h" | |
21 #include "framehook.h" | |
22 #include "avformat.h" | |
23 | |
4
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
24 #ifdef CONFIG_HAVE_DLFCN |
0 | 25 #include <dlfcn.h> |
26 #endif | |
27 | |
28 | |
29 typedef struct _FrameHookEntry { | |
30 struct _FrameHookEntry *next; | |
31 FrameHookConfigureFn Configure; | |
32 FrameHookProcessFn Process; | |
4
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
33 FrameHookReleaseFn Release; |
0 | 34 void *ctx; |
35 } FrameHookEntry; | |
36 | |
37 static FrameHookEntry *first_hook; | |
38 | |
39 /* Returns 0 on OK */ | |
40 int frame_hook_add(int argc, char *argv[]) | |
41 { | |
42 #ifdef HAVE_VHOOK | |
43 void *loaded; | |
44 FrameHookEntry *fhe, **fhep; | |
45 | |
46 if (argc < 1) { | |
47 return ENOENT; | |
48 } | |
49 | |
50 loaded = dlopen(argv[0], RTLD_NOW); | |
51 if (!loaded) { | |
52 fprintf(stderr, "%s\n", dlerror()); | |
53 return -1; | |
54 } | |
55 | |
56 fhe = av_mallocz(sizeof(*fhe)); | |
57 if (!fhe) { | |
58 return errno; | |
59 } | |
60 | |
61 fhe->Configure = dlsym(loaded, "Configure"); | |
62 fhe->Process = dlsym(loaded, "Process"); | |
4
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
63 fhe->Release = dlsym(loaded, "Release"); /* Optional */ |
0 | 64 |
65 if (!fhe->Process) { | |
66 fprintf(stderr, "Failed to find Process entrypoint in %s\n", argv[0]); | |
67 return -1; | |
68 } | |
69 | |
70 if (!fhe->Configure && argc > 1) { | |
71 fprintf(stderr, "Failed to find Configure entrypoint in %s\n", argv[0]); | |
72 return -1; | |
73 } | |
74 | |
75 if (argc > 1 || fhe->Configure) { | |
76 if (fhe->Configure(&fhe->ctx, argc, argv)) { | |
77 fprintf(stderr, "Failed to Configure %s\n", argv[0]); | |
78 return -1; | |
79 } | |
80 } | |
81 | |
82 for (fhep = &first_hook; *fhep; fhep = &((*fhep)->next)) { | |
83 } | |
84 | |
85 *fhep = fhe; | |
86 | |
87 return 0; | |
88 #else | |
89 fprintf(stderr, "Video hooking not compiled into this version\n"); | |
90 return 1; | |
91 #endif | |
92 } | |
93 | |
94 void frame_hook_process(AVPicture *pict, enum PixelFormat pix_fmt, int width, int height) | |
95 { | |
96 if (first_hook) { | |
97 FrameHookEntry *fhe; | |
65 | 98 int64_t pts = av_gettime(); |
0 | 99 |
100 for (fhe = first_hook; fhe; fhe = fhe->next) { | |
101 fhe->Process(fhe->ctx, pict, pix_fmt, width, height, pts); | |
102 } | |
103 } | |
104 } | |
4
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
105 |
64 | 106 void frame_hook_release(void) |
4
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
107 { |
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
108 FrameHookEntry *fhe; |
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
109 FrameHookEntry *fhenext; |
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
110 |
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
111 for (fhe = first_hook; fhe; fhe = fhenext) { |
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
112 fhenext = fhe->next; |
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
113 if (fhe->Release) |
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
114 fhe->Release(fhe->ctx); |
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
115 av_free(fhe); |
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
116 } |
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
117 |
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
118 first_hook = NULL; |
dcc03a32d1bb
Added support for a realease function to eliminate the context blocks used
philipjsg
parents:
0
diff
changeset
|
119 } |