annotate framehook.c @ 438:b3fdae08c556 libavformat

libavformat/mov.c fails with gcc 2.95.3 patch by ("Steven M. Schultz" <sms at 2BSD dot COM>)
author michael
date Mon, 12 Apr 2004 17:40:31 +0000
parents 08e042299038
children 5f9e330500d9
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 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
9 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
13 * Lesser General Public License for more details.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
14 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
18 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
19 #include <errno.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
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
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
22 #include "framehook.h"
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
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
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
25 #include <dlfcn.h>
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
26 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
27
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
28
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
29 typedef struct _FrameHookEntry {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
30 struct _FrameHookEntry *next;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
31 FrameHookConfigureFn Configure;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
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
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
34 void *ctx;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
35 } FrameHookEntry;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
36
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
37 static FrameHookEntry *first_hook;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
38
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
39 /* Returns 0 on OK */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
40 int frame_hook_add(int argc, char *argv[])
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
41 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
42 #ifdef HAVE_VHOOK
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
43 void *loaded;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
44 FrameHookEntry *fhe, **fhep;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
45
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
46 if (argc < 1) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
47 return ENOENT;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
48 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
49
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
50 loaded = dlopen(argv[0], RTLD_NOW);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
51 if (!loaded) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
52 fprintf(stderr, "%s\n", dlerror());
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
53 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
54 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
55
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
56 fhe = av_mallocz(sizeof(*fhe));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
57 if (!fhe) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
58 return errno;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
59 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
60
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
61 fhe->Configure = dlsym(loaded, "Configure");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
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
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
64
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
65 if (!fhe->Process) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
66 fprintf(stderr, "Failed to find Process entrypoint in %s\n", argv[0]);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
67 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
68 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
69
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
70 if (!fhe->Configure && argc > 1) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
71 fprintf(stderr, "Failed to find Configure entrypoint in %s\n", argv[0]);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
72 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
73 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
74
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
75 if (argc > 1 || fhe->Configure) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
76 if (fhe->Configure(&fhe->ctx, argc, argv)) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
77 fprintf(stderr, "Failed to Configure %s\n", argv[0]);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
78 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
79 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
80 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
81
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
82 for (fhep = &first_hook; *fhep; fhep = &((*fhep)->next)) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
83 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
84
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
85 *fhep = fhe;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
86
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
87 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
88 #else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
89 fprintf(stderr, "Video hooking not compiled into this version\n");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
90 return 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
91 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
92 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
93
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
94 void frame_hook_process(AVPicture *pict, enum PixelFormat pix_fmt, int width, int height)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
95 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
96 if (first_hook) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
97 FrameHookEntry *fhe;
65
a58a8a53eb46 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 64
diff changeset
98 int64_t pts = av_gettime();
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
99
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
100 for (fhe = first_hook; fhe; fhe = fhe->next) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
101 fhe->Process(fhe->ctx, pict, pix_fmt, width, height, pts);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
102 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
103 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
104 }
4
dcc03a32d1bb Added support for a realease function to eliminate the context blocks used
philipjsg
parents: 0
diff changeset
105
64
b0e0eb595e29 * static,const,compiler warning cleanup
kabi
parents: 4
diff changeset
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 }