Stride fix for comm detector
From: Mark Spieth <mspieth@digivation.com.au>
Fixes framing issue with comm detector with some sources where width is not
real width of image data.
---
.../programs/mythcommflag/ClassicCommDetector.cpp | 4 ++--
.../mythcommflag/ClassicSceneChangeDetector.cpp | 8 +++++---
.../mythcommflag/ClassicSceneChangeDetector.h | 1 -
mythtv/programs/mythcommflag/CommDetectorBase.h | 5 +++++
mythtv/programs/mythcommflag/main.cpp | 9 +++++++++
5 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/mythtv/programs/mythcommflag/ClassicCommDetector.cpp b/mythtv/programs/mythcommflag/ClassicCommDetector.cpp
index d3f67c8..9d0d4d7 100644
a
|
b
|
using namespace std; |
25 | 25 | #include "ClassicLogoDetector.h" |
26 | 26 | #include "ClassicSceneChangeDetector.h" |
27 | 27 | |
28 | | enum frameAspects { |
| 28 | typedef enum frameAspects { |
29 | 29 | COMM_ASPECT_NORMAL = 0, |
30 | 30 | COMM_ASPECT_WIDE |
31 | 31 | } FrameAspects; |
32 | 32 | |
33 | | enum frameFormats { |
| 33 | typedef enum frameFormats { |
34 | 34 | COMM_FORMAT_NORMAL = 0, |
35 | 35 | COMM_FORMAT_LETTERBOX, |
36 | 36 | COMM_FORMAT_PILLARBOX, |
diff --git a/mythtv/programs/mythcommflag/ClassicSceneChangeDetector.cpp b/mythtv/programs/mythcommflag/ClassicSceneChangeDetector.cpp
index ca96f93..ab89fd7 100644
a
|
b
|
|
1 | 1 | #include <algorithm> |
2 | 2 | using namespace std; |
3 | 3 | |
| 4 | // MythTV headers |
| 5 | #include "mythframe.h" |
| 6 | |
4 | 7 | #include "ClassicSceneChangeDetector.h" |
5 | 8 | #include "Histogram.h" |
6 | 9 | |
… |
… |
ClassicSceneChangeDetector::ClassicSceneChangeDetector(unsigned int width, |
8 | 11 | unsigned int height, unsigned int commdetectborder_in, |
9 | 12 | unsigned int xspacing_in, unsigned int yspacing_in): |
10 | 13 | SceneChangeDetectorBase(width,height), |
11 | | frameNumber(0), |
12 | 14 | previousFrameWasSceneChange(false), |
13 | 15 | xspacing(xspacing_in), |
14 | 16 | yspacing(yspacing_in), |
… |
… |
void ClassicSceneChangeDetector::deleteLater(void) |
27 | 29 | |
28 | 30 | void ClassicSceneChangeDetector::processFrame(VideoFrame* frame) |
29 | 31 | { |
| 32 | width = frame->pitches[0]; |
30 | 33 | histogram->generateFromImage(frame, width, height, commdetectborder, |
31 | 34 | width-commdetectborder, commdetectborder, |
32 | 35 | height-commdetectborder, xspacing, yspacing); |
… |
… |
void ClassicSceneChangeDetector::processFrame(VideoFrame* frame) |
34 | 37 | |
35 | 38 | bool isSceneChange = (similar < .85 && !previousFrameWasSceneChange); |
36 | 39 | |
37 | | emit(haveNewInformation(frameNumber,isSceneChange,similar)); |
| 40 | emit(haveNewInformation(frame->frameNumber,isSceneChange,similar)); |
38 | 41 | previousFrameWasSceneChange = isSceneChange; |
39 | 42 | |
40 | 43 | std::swap(histogram,previousHistogram); |
41 | | frameNumber++; |
42 | 44 | } |
43 | 45 | |
44 | 46 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ |
diff --git a/mythtv/programs/mythcommflag/ClassicSceneChangeDetector.h b/mythtv/programs/mythcommflag/ClassicSceneChangeDetector.h
index a8fd53b..07e281e 100644
a
|
b
|
class ClassicSceneChangeDetector : public SceneChangeDetectorBase |
21 | 21 | private: |
22 | 22 | Histogram* histogram; |
23 | 23 | Histogram* previousHistogram; |
24 | | unsigned int frameNumber; |
25 | 24 | bool previousFrameWasSceneChange; |
26 | 25 | unsigned int xspacing, yspacing; |
27 | 26 | unsigned int commdetectborder; |
diff --git a/mythtv/programs/mythcommflag/CommDetectorBase.h b/mythtv/programs/mythcommflag/CommDetectorBase.h
index 7fee51b..7faefa1 100644
a
|
b
|
using namespace std; |
11 | 11 | |
12 | 12 | #define MAX_BLANK_FRAMES 180 |
13 | 13 | |
| 14 | #define COMM_DETECT_NG 0x400 |
| 15 | #define COMM_DETECT_AUDIO 0x08 |
| 16 | #define COMM_DETECT_SUBTITLES 0x10 |
| 17 | #define COMM_DETECT_NG_OLD 0x80 |
| 18 | |
14 | 19 | typedef enum commMapValues { |
15 | 20 | MARK_START = 0, |
16 | 21 | MARK_END = 1, |
diff --git a/mythtv/programs/mythcommflag/main.cpp b/mythtv/programs/mythcommflag/main.cpp
index 6db5887..c539f12 100644
a
|
b
|
static int FlagCommercials( uint chanid, const QDateTime &starttime, |
981 | 981 | } |
982 | 982 | |
983 | 983 | |
| 984 | if (pginfo.GetSubtitle().isEmpty()) |
| 985 | LOG(VB_GENERAL, LOG_INFO, |
| 986 | QString("MythTV Commercial Flagger, flagging commercials for: %1") |
| 987 | .arg(pginfo.GetTitle())); |
| 988 | else |
| 989 | LOG(VB_GENERAL, LOG_INFO, |
| 990 | QString("MythTV Commercial Flagger, flagging commercials for: %1 - %2") |
| 991 | .arg(pginfo.GetTitle()) |
| 992 | .arg(pginfo.GetSubtitle())); |
984 | 993 | if (progress) |
985 | 994 | { |
986 | 995 | cerr << "MythTV Commercial Flagger, flagging commercials for:" << endl; |