2
* Video processing hooks
3
* Copyright (c) 2000, 2001 Fabrice Bellard.
5
* This file is part of FFmpeg.
7
* FFmpeg is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
12
* FFmpeg is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with FFmpeg; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
#include "framehook.h"
31
typedef struct FrameHookEntry {
32
struct FrameHookEntry *next;
33
FrameHookConfigureFn Configure;
34
FrameHookProcessFn Process;
35
FrameHookReleaseFn Release;
39
static FrameHookEntry *first_hook;
42
int frame_hook_add(int argc, char *argv[])
46
FrameHookEntry *fhe, **fhep;
52
loaded = dlopen(argv[0], RTLD_NOW);
54
av_log(NULL, AV_LOG_ERROR, "%s\n", dlerror());
58
fhe = av_mallocz(sizeof(*fhe));
60
return AVERROR(ENOMEM);
63
fhe->Configure = dlsym(loaded, "Configure");
64
fhe->Process = dlsym(loaded, "Process");
65
fhe->Release = dlsym(loaded, "Release"); /* Optional */
68
av_log(NULL, AV_LOG_ERROR, "Failed to find Process entrypoint in %s\n", argv[0]);
69
return AVERROR(ENOENT);
72
if (!fhe->Configure && argc > 1) {
73
av_log(NULL, AV_LOG_ERROR, "Failed to find Configure entrypoint in %s\n", argv[0]);
74
return AVERROR(ENOENT);
77
if (argc > 1 || fhe->Configure) {
78
if (fhe->Configure(&fhe->ctx, argc, argv)) {
79
av_log(NULL, AV_LOG_ERROR, "Failed to Configure %s\n", argv[0]);
80
return AVERROR(EINVAL);
84
for (fhep = &first_hook; *fhep; fhep = &((*fhep)->next)) {
91
av_log(NULL, AV_LOG_ERROR, "Video hooking not compiled into this version\n");
96
void frame_hook_process(AVPicture *pict, enum PixelFormat pix_fmt, int width, int height, int64_t pts)
101
for (fhe = first_hook; fhe; fhe = fhe->next) {
102
fhe->Process(fhe->ctx, pict, pix_fmt, width, height, pts);
107
void frame_hook_release(void)
110
FrameHookEntry *fhenext;
112
for (fhe = first_hook; fhe; fhe = fhenext) {
115
fhe->Release(fhe->ctx);