MythTV  master
FrameAnalyzer.h
Go to the documentation of this file.
1 /*
2  * FrameAnalyzer
3  *
4  * Provide a generic interface for plugging in video frame analysis algorithms.
5  */
6 
7 #ifndef __FRAMEANALYZER_H__
8 #define __FRAMEANALYZER_H__
9 
10 /* Base class for commercial flagging video frame analyzers. */
11 
12 #include <climits>
13 
14 #include <QMap>
15 
16 /*
17  * At least FreeBSD doesn't define LONG_LONG_MAX, but it does define
18  * __LONG_LONG_MAX__. Who knows what other systems do the same?
19  */
20 #ifndef LONG_LONG_MAX
21 #define LONG_LONG_MAX __LONG_LONG_MAX__
22 #endif
23 
24 typedef struct VideoFrame_ VideoFrame;
25 class MythPlayer;
26 
28 {
29 public:
30  virtual ~FrameAnalyzer(void) = default;
31 
32  virtual const char *name(void) const = 0;
33 
34  /* Analyze a video frame. */
36  ANALYZE_OK, /* Analysis OK */
37  ANALYZE_ERROR, /* Recoverable error */
38  ANALYZE_FINISHED, /* Analysis complete, don't need more frames. */
39  ANALYZE_FATAL, /* Don't use this analyzer anymore. */
40  };
41 
42 
43  /* 0-based frameno => nframes */
44  typedef QMap<long long, long long> FrameMap;
45 
47  MythPlayer *player, long long nframes) {
48  (void)player;
49  (void)nframes;
50  return ANALYZE_OK;
51  };
52 
53  /*
54  * Populate *pNextFrame with the next frame number desired by this
55  * analyzer.
56  */
57  static const long long ANYFRAME = LLONG_MAX;
58  static const long long NEXTFRAME = -1;
59  virtual enum analyzeFrameResult analyzeFrame(const VideoFrame *frame,
60  long long frameno, long long *pNextFrame /* [out] */) = 0;
61 
62  virtual int finished(long long nframes, bool final) {
63  (void)nframes;
64  (void)final;
65  return 0;
66  }
67  virtual int reportTime(void) const { return 0; }
68 
69  virtual FrameMap GetMap(unsigned int) const = 0;
70 };
71 
72 namespace frameAnalyzer {
73 
74 bool rrccinrect(int rr, int cc, int rrow, int rcol, int rwidth, int rheight);
75 
77  float fps, const char *comment);
78 
80  float fps, const char *comment);
81 
82 long long frameAnalyzerMapSum(const FrameAnalyzer::FrameMap *frameMap);
83 
84 bool removeShortBreaks(FrameAnalyzer::FrameMap *breakMap, float fps,
85  int minbreaklen, bool verbose);
86 
87 bool removeShortSegments(FrameAnalyzer::FrameMap *breakMap, long long nframes,
88  float fps, int minseglen, bool verbose);
89 
90 FrameAnalyzer::FrameMap::const_iterator frameMapSearchForwards(
91  const FrameAnalyzer::FrameMap *frameMap, long long mark,
92  long long markend);
93 
94 FrameAnalyzer::FrameMap::const_iterator frameMapSearchBackwards(
95  const FrameAnalyzer::FrameMap *frameMap, long long markbegin,
96  long long mark);
97 
98 }; /* namespace */
99 
100 #endif /* !__FRAMEANALYZER_H__ */
101 
102 /* vim: set expandtab tabstop=4 shiftwidth=4: */
bool removeShortBreaks(FrameAnalyzer::FrameMap *breakMap, float fps, int minbreaklen, bool verbose)
bool rrccinrect(int rr, int cc, int rrow, int rcol, int rwidth, int rheight)
virtual int reportTime(void) const
Definition: FrameAnalyzer.h:67
static const long long ANYFRAME
Definition: FrameAnalyzer.h:57
Definition: cc.h:13
virtual const char * name(void) const =0
static const long long NEXTFRAME
Definition: FrameAnalyzer.h:58
Definition: lang.c:20
bool removeShortSegments(FrameAnalyzer::FrameMap *breakMap, long long nframes, float fps, int minseglen, bool verbose)
FrameAnalyzer::FrameMap::const_iterator frameMapSearchBackwards(const FrameAnalyzer::FrameMap *frameMap, long long markbegin, long long mark)
virtual ~FrameAnalyzer(void)=default
virtual enum analyzeFrameResult analyzeFrame(const VideoFrame *frame, long long frameno, long long *pNextFrame)=0
virtual FrameMap GetMap(unsigned int) const =0
QMap< int, FrameList * > FrameMap
Definition: mpeg2fix.h:115
void frameAnalyzerReportMap(const FrameAnalyzer::FrameMap *frameMap, float fps, const char *comment)
long long frameAnalyzerMapSum(const FrameAnalyzer::FrameMap *frameMap)
FrameAnalyzer::FrameMap::const_iterator frameMapSearchForwards(const FrameAnalyzer::FrameMap *frameMap, long long mark, long long markend)
virtual int finished(long long nframes, bool final)
Definition: FrameAnalyzer.h:62
QMap< long long, long long > FrameMap
Definition: FrameAnalyzer.h:44
virtual enum analyzeFrameResult MythPlayerInited(MythPlayer *player, long long nframes)
Definition: FrameAnalyzer.h:46
void frameAnalyzerReportMapms(const FrameAnalyzer::FrameMap *frameMap, float fps, const char *comment)