VirtualBox

source: vbox/trunk/src/libs/ffmpeg-20060710/libavformat/framehook.c@ 10184

最後變更 在這個檔案從10184是 5776,由 vboxsync 提交於 17 年 前

ffmpeg: exported to OSE

檔案大小: 3.0 KB
 
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19#include <errno.h>
20#include "config.h"
21#include "avformat.h"
22#include "framehook.h"
23
24#ifdef CONFIG_HAVE_DLFCN
25#include <dlfcn.h>
26#endif
27
28
29typedef struct _FrameHookEntry {
30 struct _FrameHookEntry *next;
31 FrameHookConfigureFn Configure;
32 FrameHookProcessFn Process;
33 FrameHookReleaseFn Release;
34 void *ctx;
35} FrameHookEntry;
36
37static FrameHookEntry *first_hook;
38
39/* Returns 0 on OK */
40int 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 av_log(NULL, AV_LOG_ERROR, "%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");
63 fhe->Release = dlsym(loaded, "Release"); /* Optional */
64
65 if (!fhe->Process) {
66 av_log(NULL, AV_LOG_ERROR, "Failed to find Process entrypoint in %s\n", argv[0]);
67 return -1;
68 }
69
70 if (!fhe->Configure && argc > 1) {
71 av_log(NULL, AV_LOG_ERROR, "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 av_log(NULL, AV_LOG_ERROR, "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 av_log(NULL, AV_LOG_ERROR, "Video hooking not compiled into this version\n");
90 return 1;
91#endif
92}
93
94void frame_hook_process(AVPicture *pict, enum PixelFormat pix_fmt, int width, int height)
95{
96 if (first_hook) {
97 FrameHookEntry *fhe;
98 int64_t pts = av_gettime();
99
100 for (fhe = first_hook; fhe; fhe = fhe->next) {
101 fhe->Process(fhe->ctx, pict, pix_fmt, width, height, pts);
102 }
103 }
104}
105
106void frame_hook_release(void)
107{
108 FrameHookEntry *fhe;
109 FrameHookEntry *fhenext;
110
111 for (fhe = first_hook; fhe; fhe = fhenext) {
112 fhenext = fhe->next;
113 if (fhe->Release)
114 fhe->Release(fhe->ctx);
115 av_free(fhe);
116 }
117
118 first_hook = NULL;
119}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette