MythTV  master
filter.h
Go to the documentation of this file.
1 /*
2  * filter.h
3  */
4 
5 #ifndef _FILTER_H
6 #define _FILTER_H
7 
8 #include "mythframe.h"
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 typedef struct FmtConv_
15 {
18 } FmtConv;
19 
20 #define FMT_NULL {FMT_NONE,FMT_NONE}
21 
22 typedef struct VideoFilter_ VideoFilter;
23 
24 typedef VideoFilter*(*init_filter)(int, int, const int *, const int *, const char *, int);
25 
26 typedef struct FilterInfo_
27 {
29  char *name;
30  char *descript;
32  char *libname;
33 } FilterInfo;
34 
36 {
37  int (*filter)(struct VideoFilter_ *, VideoFrame *, int);
38  void (*cleanup)(struct VideoFilter_ *);
39 
40  void *handle; /* Library handle */
43  char *opts;
45 };
46 
47 #define FILT_NULL {NULL,NULL,NULL,NULL,NULL}
48 
49 #ifdef TIME_FILTER
50 
51 #ifndef TF_INTERVAL
52 #define TF_INTERVAL 300
53 #endif /* TF_INTERVAL */
54 
55 #ifdef TF_TYPE_TSC
56 #include <cstdio>
57 
58 #define TF_STRUCT int tf_frames; unsigned long long tf_ticks;
59 #define TF_INIT(filter) (filter)->tf_frames=0; (filter)->tf_ticks=0;
60 #define TF_VARS unsigned int t1l,t1h,t2l,t2h;
61 #define TF_START __asm__ __volatile__ ("rdtsc" :"=a" (t1l), "=d" (t1h));
62 
63 #ifdef TF_TSC_TICKS
64 #define TF_END(filter, prefix) \
65  __asm__ __volatile__ ("rdtsc" :"=a" (t2l), "=d" (t2h)); \
66  (filter)->tf_ticks += (((unsigned long long)t2h<<32)+t2l)-(((unsigned long long)t1h<<32)+t1l); \
67  (filter)->tf_frames = ( (filter)->tf_frames + 1 ) % TF_INTERVAL; \
68  if (!(filter)->tf_frames) \
69  { \
70  fprintf(stderr, prefix \
71  "filter timed at %0.2f frames per second\n", \
72  TF_INTERVAL / ((double)(filter)->tf_ticks / TF_TSC_TICKS)); \
73  (filter)->tf_ticks = 0; \
74  }
75 #else /* TF_TSC_TICKS */
76 #define TF_END(filter, prefix) \
77  __asm__ __volatile__ ("rdtsc" :"=a" (t2l), "=d" (t2h)); \
78  (filter)->tf_ticks += (((unsigned long long)t2h<<32)+t2l)-(((unsigned long long)t1h<<32)+t1l); \
79  (filter)->tf_frames = ( (filter)->tf_frames + 1 ) % TF_INTERVAL; \
80  if (!(filter)->tf_frames) \
81  { \
82  fprintf(stderr, prefix \
83  "filter timed at %lld ticks per frame\n", \
84  (filter)->tf_ticks / TF_INTERVAL); \
85  (filter)->tf_ticks = 0; \
86  }
87 #endif /* TF_TSC_TICKS */
88 #else /* TF_TYPE_TSC */
89 #include <sys/time.h>
90 #include <cstdio>
91 #define TF_STRUCT int tf_frames; double tf_seconds;
92 #define TF_INIT(filter) (filter)->tf_frames=0; (filter)->tf_seconds=0;
93 #define TF_VARS struct timeval tf_1, tf_2;
94 #define TF_START gettimeofday(&tf_1, NULL);
95 #define TF_END(filter,prefix) \
96  gettimeofday(&tf_2, NULL); \
97  (filter)->tf_seconds += (tf_2.tv_sec - tf_1.tv_sec) \
98  + (tf_2.tv_usec - tf_1.tv_usec) * .000001; \
99  (filter)->tf_frames = ( (filter)->tf_frames + 1 ) % TF_INTERVAL; \
100  if (!(filter)->tf_frames) \
101  { \
102  fprintf(stderr, prefix \
103  "filter timed at %0.2f frames per second\n", \
104  TF_INTERVAL / (filter)->tf_seconds); \
105  (filter)->tf_seconds = 0; \
106  }
107 #endif /* TF_TYPE_TSC */
108 
109 #else /* TIME_FILTER */
110 #define TF_INIT(filter)
111 #define TF_STRUCT
112 #define TF_VARS
113 #define TF_START
114 #define TF_END(filter,prefix)
115 #endif /* TIME_FILTER */
116 
117 #ifdef __cplusplus
118 }
119 #endif
120 
121 #endif /* #ifndef _FILTER_H */
int(* filter)(struct VideoFilter_ *, VideoFrame *, int)
Definition: filter.h:37
init_filter filter_init
Definition: filter.h:28
struct FilterInfo_ FilterInfo
VideoFilter *(* init_filter)(int, int, const int *, const int *, const char *, int)
Definition: filter.h:24
void(* cleanup)(struct VideoFilter_ *)
Definition: filter.h:38
char * libname
Definition: filter.h:32
enum FrameType_ VideoFrameType
char * name
Definition: filter.h:29
struct FmtConv_ FmtConv
VideoFrameType inpixfmt
Definition: filter.h:41
FmtConv * formats
Definition: filter.h:31
char * descript
Definition: filter.h:30
VideoFrameType in
Definition: filter.h:16
VideoFrameType outpixfmt
Definition: filter.h:42
FilterInfo * info
Definition: filter.h:44
VideoFrameType out
Definition: filter.h:17
char * opts
Definition: filter.h:43
void * handle
Definition: filter.h:40