00001
00002
00003
00004
00005 #ifndef _FILTER_H
00006 #define _FILTER_H
00007
00008 #ifdef __cplusplus
00009 extern "C" {
00010 #endif
00011
00012 #include "frame.h"
00013
00014 typedef struct FmtConv_
00015 {
00016 VideoFrameType in;
00017 VideoFrameType out;
00018 } FmtConv;
00019
00020 #define FMT_NULL {FMT_NONE,FMT_NONE}
00021
00022 typedef struct FilterInfo_
00023 {
00024 char *symbol;
00025 char *name;
00026 char *descript;
00027 FmtConv *formats;
00028 char *libname;
00029 } FilterInfo;
00030
00031 typedef struct VideoFilter_
00032 {
00033 int (*filter)(struct VideoFilter_ *, VideoFrame *);
00034 void (*cleanup)(struct VideoFilter_ *);
00035
00036 void *handle;
00037 VideoFrameType inpixfmt;
00038 VideoFrameType outpixfmt;
00039 char *opts;
00040 FilterInfo *info;
00041 } VideoFilter;
00042
00043 #define FILT_NULL {NULL,NULL,NULL,NULL,NULL}
00044
00045 #ifdef TIME_FILTER
00046
00047 #ifndef TF_INTERVAL
00048 #define TF_INTERVAL 300
00049 #endif
00050
00051 #ifdef TF_TYPE_TSC
00052 #include <stdio.h>
00053
00054 #define TF_STRUCT int tf_frames; unsigned long long tf_ticks;
00055 #define TF_INIT(filter) (filter)->tf_frames=0; (filter)->tf_ticks=0;
00056 #define TF_VARS unsigned int t1l,t1h,t2l,t2h;
00057 #define TF_START __asm__ __volatile__ ("rdtsc" :"=a" (t1l), "=d" (t1h));
00058
00059 #ifdef TF_TSC_TICKS
00060 #define TF_END(filter, prefix) \
00061 __asm__ __volatile__ ("rdtsc" :"=a" (t2l), "=d" (t2h)); \
00062 (filter)->tf_ticks += (((unsigned long long)t2h<<32)+t2l)-(((unsigned long long)t1h<<32)+t1l); \
00063 (filter)->tf_frames = ( (filter)->tf_frames + 1 ) % TF_INTERVAL; \
00064 if (!(filter)->tf_frames) \
00065 { \
00066 fprintf(stderr, prefix \
00067 "filter timed at %0.2f frames per second\n", \
00068 TF_INTERVAL / ((double)(filter)->tf_ticks / TF_TSC_TICKS)); \
00069 (filter)->tf_ticks = 0; \
00070 }
00071 #else
00072 #define TF_END(filter, prefix) \
00073 __asm__ __volatile__ ("rdtsc" :"=a" (t2l), "=d" (t2h)); \
00074 (filter)->tf_ticks += (((unsigned long long)t2h<<32)+t2l)-(((unsigned long long)t1h<<32)+t1l); \
00075 (filter)->tf_frames = ( (filter)->tf_frames + 1 ) % TF_INTERVAL; \
00076 if (!(filter)->tf_frames) \
00077 { \
00078 fprintf(stderr, prefix \
00079 "filter timed at %lld ticks per frame\n", \
00080 (filter)->tf_ticks / TF_INTERVAL); \
00081 (filter)->tf_ticks = 0; \
00082 }
00083 #endif
00084 #else
00085 #include <sys/time.h>
00086 #include <stdio.h>
00087 #define TF_STRUCT int tf_frames; double tf_seconds;
00088 #define TF_INIT(filter) (filter)->tf_frames=0; (filter)->tf_seconds=0;
00089 #define TF_VARS struct timeval tf_1, tf_2;
00090 #define TF_START gettimeofday(&tf_1, NULL);
00091 #define TF_END(filter,prefix) \
00092 gettimeofday(&tf_2, NULL); \
00093 (filter)->tf_seconds += (tf_2.tv_sec - tf_1.tv_sec) \
00094 + (tf_2.tv_usec - tf_1.tv_usec) * .000001; \
00095 (filter)->tf_frames = ( (filter)->tf_frames + 1 ) % TF_INTERVAL; \
00096 if (!(filter)->tf_frames) \
00097 { \
00098 fprintf(stderr, prefix \
00099 "filter timed at %0.2f frames per second\n", \
00100 TF_INTERVAL / (filter)->tf_seconds); \
00101 (filter)->tf_seconds = 0; \
00102 }
00103 #endif
00104
00105 #else
00106 #define TF_INIT(filter)
00107 #define TF_STRUCT
00108 #define TF_VARS
00109 #define TF_START
00110 #define TF_END(filter,prefix)
00111 #endif
00112
00113 #ifdef __cplusplus
00114 }
00115 #endif
00116
00117 #endif