annotate framehook.c @ 3369:026b8ba58408 libavformat

cosmetics, remove useless cases and braces
author bcoudurier
date Tue, 27 May 2008 02:55:34 +0000
parents ffb5d8bb96b3
children 97a01cb166f5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
2 * Video processing hooks
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
3 * Copyright (c) 2000, 2001 Fabrice Bellard.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
4 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 896
diff changeset
5 * This file is part of FFmpeg.
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 896
diff changeset
6 *
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 896
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 896
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
11 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 896
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
15 * Lesser General Public License for more details.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
16 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 896
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
896
edbe5c3717f9 Update licensing information: The FSF changed postal address.
diego
parents: 815
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
20 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
21 #include <errno.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
22 #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
23 #include "avformat.h"
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
24 #include "framehook.h"
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
25
1510
d68525fe36da rename HAVE_DLFCN to HAVE_DLFCN_H
mru
parents: 1493
diff changeset
26 #ifdef HAVE_DLFCN_H
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
27 #include <dlfcn.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
28 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
29
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
30
2903
ffb5d8bb96b3 Rename two structures, identifiers starting with _[A-Z] are reserved.
diego
parents: 1960
diff changeset
31 typedef struct FrameHookEntry {
ffb5d8bb96b3 Rename two structures, identifiers starting with _[A-Z] are reserved.
diego
parents: 1960
diff changeset
32 struct FrameHookEntry *next;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
33 FrameHookConfigureFn Configure;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
34 FrameHookProcessFn Process;
4
dcc03a32d1bb Added support for a realease function to eliminate the context blocks used
philipjsg
parents: 0
diff changeset
35 FrameHookReleaseFn Release;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
36 void *ctx;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
37 } FrameHookEntry;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
38
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
39 static FrameHookEntry *first_hook;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
40
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
41 /* Returns 0 on OK */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
42 int frame_hook_add(int argc, char *argv[])
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
43 {
1470
88994beb6054 rename HAVE_VHOOK/BUILD_VHOOK to CONFIG_VHOOK
mru
parents: 1358
diff changeset
44 #ifdef CONFIG_VHOOK
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
45 void *loaded;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
46 FrameHookEntry *fhe, **fhep;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
47
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
48 if (argc < 1) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
49 return ENOENT;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
50 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
51
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
52 loaded = dlopen(argv[0], RTLD_NOW);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
53 if (!loaded) {
815
5f9e330500d9 printf-> av_log patch by (Benjamin Larsson, banan: student ltu se)
michael
parents: 368
diff changeset
54 av_log(NULL, AV_LOG_ERROR, "%s\n", dlerror());
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
55 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
56 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
57
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
58 fhe = av_mallocz(sizeof(*fhe));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
59 if (!fhe) {
1787
eb16c64144ee This fixes error handling for BeOS, removing the need for some ifdefs.
mmu_man
parents: 1742
diff changeset
60 return AVERROR(ENOMEM);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
61 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
62
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
63 fhe->Configure = dlsym(loaded, "Configure");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
64 fhe->Process = dlsym(loaded, "Process");
4
dcc03a32d1bb Added support for a realease function to eliminate the context blocks used
philipjsg
parents: 0
diff changeset
65 fhe->Release = dlsym(loaded, "Release"); /* Optional */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
66
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
67 if (!fhe->Process) {
815
5f9e330500d9 printf-> av_log patch by (Benjamin Larsson, banan: student ltu se)
michael
parents: 368
diff changeset
68 av_log(NULL, AV_LOG_ERROR, "Failed to find Process entrypoint in %s\n", argv[0]);
1787
eb16c64144ee This fixes error handling for BeOS, removing the need for some ifdefs.
mmu_man
parents: 1742
diff changeset
69 return AVERROR(ENOENT);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
70 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
71
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
72 if (!fhe->Configure && argc > 1) {
815
5f9e330500d9 printf-> av_log patch by (Benjamin Larsson, banan: student ltu se)
michael
parents: 368
diff changeset
73 av_log(NULL, AV_LOG_ERROR, "Failed to find Configure entrypoint in %s\n", argv[0]);
1787
eb16c64144ee This fixes error handling for BeOS, removing the need for some ifdefs.
mmu_man
parents: 1742
diff changeset
74 return AVERROR(ENOENT);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
75 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
76
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
77 if (argc > 1 || fhe->Configure) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
78 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
79 av_log(NULL, AV_LOG_ERROR, "Failed to Configure %s\n", argv[0]);
1787
eb16c64144ee This fixes error handling for BeOS, removing the need for some ifdefs.
mmu_man
parents: 1742
diff changeset
80 return AVERROR(EINVAL);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
81 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
82 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
83
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
84 for (fhep = &first_hook; *fhep; fhep = &((*fhep)->next)) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
85 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
86
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
87 *fhep = fhe;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
88
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
89 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
90 #else
815
5f9e330500d9 printf-> av_log patch by (Benjamin Larsson, banan: student ltu se)
michael
parents: 368
diff changeset
91 av_log(NULL, AV_LOG_ERROR, "Video hooking not compiled into this version\n");
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
92 return 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
93 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
94 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
95
1960
c0289552590f Change the vhook code to send real timestamps to the filters instead of the
diego
parents: 1787
diff changeset
96 void frame_hook_process(AVPicture *pict, enum PixelFormat pix_fmt, int width, int height, int64_t pts)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
97 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
98 if (first_hook) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
99 FrameHookEntry *fhe;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
100
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
101 for (fhe = first_hook; fhe; fhe = fhe->next) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
102 fhe->Process(fhe->ctx, pict, pix_fmt, width, height, pts);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
103 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
104 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
105 }
4
dcc03a32d1bb Added support for a realease function to eliminate the context blocks used
philipjsg
parents: 0
diff changeset
106
64
b0e0eb595e29 * static,const,compiler warning cleanup
kabi
parents: 4
diff changeset
107 void frame_hook_release(void)
4
dcc03a32d1bb Added support for a realease function to eliminate the context blocks used
philipjsg
parents: 0
diff changeset
108 {
dcc03a32d1bb Added support for a realease function to eliminate the context blocks used
philipjsg
parents: 0
diff changeset
109 FrameHookEntry *fhe;
dcc03a32d1bb Added support for a realease function to eliminate the context blocks used
philipjsg
parents: 0
diff changeset
110 FrameHookEntry *fhenext;
dcc03a32d1bb Added support for a realease function to eliminate the context blocks used
philipjsg
parents: 0
diff changeset
111
dcc03a32d1bb Added support for a realease function to eliminate the context blocks used
philipjsg
parents: 0
diff changeset
112 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
113 fhenext = fhe->next;
dcc03a32d1bb Added support for a realease function to eliminate the context blocks used
philipjsg
parents: 0
diff changeset
114 if (fhe->Release)
dcc03a32d1bb Added support for a realease function to eliminate the context blocks used
philipjsg
parents: 0
diff changeset
115 fhe->Release(fhe->ctx);
dcc03a32d1bb Added support for a realease function to eliminate the context blocks used
philipjsg
parents: 0
diff changeset
116 av_free(fhe);
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
dcc03a32d1bb Added support for a realease function to eliminate the context blocks used
philipjsg
parents: 0
diff changeset
119 first_hook = NULL;
dcc03a32d1bb Added support for a realease function to eliminate the context blocks used
philipjsg
parents: 0
diff changeset
120 }