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 VideoFilter_ VideoFilter;
00023
00024 typedef VideoFilter*(*init_filter)(int, int, int *, int *, char *, int);
00025
00026 typedef struct FilterInfo_
00027 {
00028 init_filter filter_init;
00029 char *name;
00030 char *descript;
00031 FmtConv *formats;
00032 char *libname;
00033 } FilterInfo;
00034
00035 typedef struct ConstFilterInfo_
00036 {
00037 const init_filter filter_init;
00038 const char *name;
00039 const char *descript;
00040 const FmtConv *formats;
00041 const char *libname;
00042 } ConstFilterInfo;
00043
00044 struct VideoFilter_
00045 {
00046 int (*filter)(struct VideoFilter_ *, VideoFrame *, int);
00047 void (*cleanup)(struct VideoFilter_ *);
00048
00049 void *handle;
00050 VideoFrameType inpixfmt;
00051 VideoFrameType outpixfmt;
00052 char *opts;
00053 FilterInfo *info;
00054 };
00055
00056 #define FILT_NULL {NULL,NULL,NULL,NULL,NULL}
00057
00058 #ifdef TIME_FILTER
00059
00060 #ifndef TF_INTERVAL
00061 #define TF_INTERVAL 300
00062 #endif
00063
00064 #ifdef TF_TYPE_TSC
00065 #include <stdio.h>
00066
00067 #define TF_STRUCT int tf_frames; unsigned long long tf_ticks;
00068 #define TF_INIT(filter) (filter)->tf_frames=0; (filter)->tf_ticks=0;
00069 #define TF_VARS unsigned int t1l,t1h,t2l,t2h;
00070 #define TF_START __asm__ __volatile__ ("rdtsc" :"=a" (t1l), "=d" (t1h));
00071
00072 #ifdef TF_TSC_TICKS
00073 #define TF_END(filter, prefix) \
00074 __asm__ __volatile__ ("rdtsc" :"=a" (t2l), "=d" (t2h)); \
00075 (filter)->tf_ticks += (((unsigned long long)t2h<<32)+t2l)-(((unsigned long long)t1h<<32)+t1l); \
00076 (filter)->tf_frames = ( (filter)->tf_frames + 1 ) % TF_INTERVAL; \
00077 if (!(filter)->tf_frames) \
00078 { \
00079 fprintf(stderr, prefix \
00080 "filter timed at %0.2f frames per second\n", \
00081 TF_INTERVAL / ((double)(filter)->tf_ticks / TF_TSC_TICKS)); \
00082 (filter)->tf_ticks = 0; \
00083 }
00084 #else
00085 #define TF_END(filter, prefix) \
00086 __asm__ __volatile__ ("rdtsc" :"=a" (t2l), "=d" (t2h)); \
00087 (filter)->tf_ticks += (((unsigned long long)t2h<<32)+t2l)-(((unsigned long long)t1h<<32)+t1l); \
00088 (filter)->tf_frames = ( (filter)->tf_frames + 1 ) % TF_INTERVAL; \
00089 if (!(filter)->tf_frames) \
00090 { \
00091 fprintf(stderr, prefix \
00092 "filter timed at %lld ticks per frame\n", \
00093 (filter)->tf_ticks / TF_INTERVAL); \
00094 (filter)->tf_ticks = 0; \
00095 }
00096 #endif
00097 #else
00098 #include <sys/time.h>
00099 #include <stdio.h>
00100 #define TF_STRUCT int tf_frames; double tf_seconds;
00101 #define TF_INIT(filter) (filter)->tf_frames=0; (filter)->tf_seconds=0;
00102 #define TF_VARS struct timeval tf_1, tf_2;
00103 #define TF_START gettimeofday(&tf_1, NULL);
00104 #define TF_END(filter,prefix) \
00105 gettimeofday(&tf_2, NULL); \
00106 (filter)->tf_seconds += (tf_2.tv_sec - tf_1.tv_sec) \
00107 + (tf_2.tv_usec - tf_1.tv_usec) * .000001; \
00108 (filter)->tf_frames = ( (filter)->tf_frames + 1 ) % TF_INTERVAL; \
00109 if (!(filter)->tf_frames) \
00110 { \
00111 fprintf(stderr, prefix \
00112 "filter timed at %0.2f frames per second\n", \
00113 TF_INTERVAL / (filter)->tf_seconds); \
00114 (filter)->tf_seconds = 0; \
00115 }
00116 #endif
00117
00118 #else
00119 #define TF_INIT(filter)
00120 #define TF_STRUCT
00121 #define TF_VARS
00122 #define TF_START
00123 #define TF_END(filter,prefix)
00124 #endif
00125
00126 #ifdef __cplusplus
00127 }
00128 #endif
00129
00130 #endif