Mercurial > libavformat.hg
annotate framehook.c @ 1116:22a86dfd052d libavformat
Fix typo
| author | lucabe |
|---|---|
| date | Thu, 15 Jun 2006 07:36:57 +0000 |
| parents | edbe5c3717f9 |
| children | 0899bfe4105c |
| 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 | |
|
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
815
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 0 | 18 */ |
| 19 #include <errno.h> | |
| 20 #include "config.h" | |
|
368
08e042299038
(f)printf() is disallowed in libavcodec, compilation will fail now if its used, except that codecs which where added after the printf->av_log change which did ignore av_log() and used prinf are now silent and wont print anything, they should be changed to use av_log, i could do that, but its better if the orginal developer decides which AV_LOG level each message should get
michael
parents:
65
diff
changeset
|
21 #include "avformat.h" |
| 0 | 22 #include "framehook.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) { | |
|
815
5f9e330500d9
printf-> av_log patch by (Benjamin Larsson, banan: student ltu se)
michael
parents:
368
diff
changeset
|
52 av_log(NULL, AV_LOG_ERROR, "%s\n", dlerror()); |
| 0 | 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) { | |
|
815
5f9e330500d9
printf-> av_log patch by (Benjamin Larsson, banan: student ltu se)
michael
parents:
368
diff
changeset
|
66 av_log(NULL, AV_LOG_ERROR, "Failed to find Process entrypoint in %s\n", argv[0]); |
| 0 | 67 return -1; |
| 68 } | |
| 69 | |
| 70 if (!fhe->Configure && argc > 1) { | |
|
815
5f9e330500d9
printf-> av_log patch by (Benjamin Larsson, banan: student ltu se)
michael
parents:
368
diff
changeset
|
71 av_log(NULL, AV_LOG_ERROR, "Failed to find Configure entrypoint in %s\n", argv[0]); |
| 0 | 72 return -1; |
| 73 } | |
| 74 | |
| 75 if (argc > 1 || fhe->Configure) { | |
| 76 if (fhe->Configure(&fhe->ctx, argc, argv)) { | |
|
815
5f9e330500d9
printf-> av_log patch by (Benjamin Larsson, banan: student ltu se)
michael
parents:
368
diff
changeset
|
77 av_log(NULL, AV_LOG_ERROR, "Failed to Configure %s\n", argv[0]); |
| 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 | |
|
815
5f9e330500d9
printf-> av_log patch by (Benjamin Larsson, banan: student ltu se)
michael
parents:
368
diff
changeset
|
89 av_log(NULL, AV_LOG_ERROR, "Video hooking not compiled into this version\n"); |
| 0 | 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 } |
