diff --git a/mythtv/programs/mythcommflag/ClassicCommDetector.cpp b/mythtv/programs/mythcommflag/ClassicCommDetector.cpp
index 0a7c688..a66ff3e 100644
a
|
b
|
ClassicCommDetector::ClassicCommDetector(SkipType commDetectMethod_in, |
140 | 140 | totalMinBrightness(0), detectBlankFrames(false), |
141 | 141 | detectSceneChanges(false), detectStationLogo(false), |
142 | 142 | logoInfoAvailable(false), logoDetector(0), |
143 | | framePtr(0), frameIsBlank(false), |
| 143 | frameIsBlank(false), |
144 | 144 | sceneHasChanged(false), stationLogoPresent(false), |
145 | 145 | lastFrameWasBlank(false), lastFrameWasSceneChange(false), |
146 | 146 | decoderFoundAspectChanges(false), sceneChangeDetector(0), |
… |
… |
void ClassicCommDetector::Init() |
266 | 266 | frameIsBlank = false; |
267 | 267 | stationLogoPresent = false; |
268 | 268 | |
269 | | framePtr = NULL; |
270 | | |
271 | 269 | logoInfoAvailable = false; |
272 | 270 | |
273 | 271 | ClearAllMaps(); |
… |
… |
void ClassicCommDetector::ProcessFrame(VideoFrame *frame, |
781 | 779 | } |
782 | 780 | |
783 | 781 | curFrameNumber = frame_number; |
784 | | framePtr = frame->buf; |
| 782 | unsigned char* framePtr = frame->buf; |
| 783 | int bytesPerLine = frame->pitches[0]; |
785 | 784 | |
786 | 785 | fInfo.minBrightness = -1; |
787 | 786 | fInfo.maxBrightness = -1; |
… |
… |
void ClassicCommDetector::ProcessFrame(VideoFrame *frame, |
818 | 817 | |
819 | 818 | if (commDetectMethod & COMM_DETECT_SCENE) |
820 | 819 | { |
821 | | sceneChangeDetector->processFrame(framePtr); |
| 820 | sceneChangeDetector->processFrame(frame); |
822 | 821 | } |
823 | 822 | |
824 | 823 | stationLogoPresent = false; |
… |
… |
void ClassicCommDetector::ProcessFrame(VideoFrame *frame, |
829 | 828 | for(int x = commDetectBorder; x < (width - commDetectBorder); |
830 | 829 | x += horizSpacing) |
831 | 830 | { |
832 | | pixel = framePtr[y * width + x]; |
| 831 | pixel = framePtr[y * bytesPerLine + x]; |
833 | 832 | |
834 | 833 | if (commDetectMethod & COMM_DETECT_BLANKS) |
835 | 834 | { |
… |
… |
void ClassicCommDetector::ProcessFrame(VideoFrame *frame, |
948 | 947 | if ((logoInfoAvailable) && (commDetectMethod & COMM_DETECT_LOGO)) |
949 | 948 | { |
950 | 949 | stationLogoPresent = |
951 | | logoDetector->doesThisFrameContainTheFoundLogo(framePtr); |
| 950 | logoDetector->doesThisFrameContainTheFoundLogo(frame); |
952 | 951 | } |
953 | 952 | |
954 | 953 | #if 0 |
diff --git a/mythtv/programs/mythcommflag/ClassicCommDetector.h b/mythtv/programs/mythcommflag/ClassicCommDetector.h
index f9e5c4c..6c25f5d 100644
a
|
b
|
class ClassicCommDetector : public CommDetectorBase |
153 | 153 | bool logoInfoAvailable; |
154 | 154 | LogoDetectorBase* logoDetector; |
155 | 155 | |
156 | | unsigned char *framePtr; |
157 | | |
158 | 156 | frm_dir_map_t blankFrameMap; |
159 | 157 | frm_dir_map_t blankCommMap; |
160 | 158 | frm_dir_map_t blankCommBreakMap; |
diff --git a/mythtv/programs/mythcommflag/ClassicLogoDetector.cpp b/mythtv/programs/mythcommflag/ClassicLogoDetector.cpp
index d909950..3a2326a 100644
a
|
b
|
|
7 | 7 | // MythTV headers |
8 | 8 | #include "mythcorecontext.h" |
9 | 9 | #include "mythplayer.h" |
| 10 | #include "frame.h" |
10 | 11 | |
11 | 12 | // Commercial Flagging headers |
12 | 13 | #include "ClassicLogoDetector.h" |
… |
… |
void ClassicLogoDetector::DumpLogo(bool fromCurrentFrame, |
443 | 444 | * which are partially mods based on Myth's original commercial skip |
444 | 445 | * code written by Chris Pinkham. */ |
445 | 446 | bool ClassicLogoDetector::doesThisFrameContainTheFoundLogo( |
446 | | unsigned char* framePtr) |
| 447 | VideoFrame* frame) |
447 | 448 | { |
448 | 449 | int radius = 2; |
449 | 450 | unsigned int x, y; |
450 | 451 | int pos1, pos2, pos3; |
| 452 | int edgePos; |
451 | 453 | int pixel; |
452 | 454 | int goodEdges = 0; |
453 | 455 | int badEdges = 0; |
454 | 456 | int testEdges = 0; |
455 | 457 | int testNotEdges = 0; |
456 | 458 | |
| 459 | unsigned char* framePtr = frame->buf; |
| 460 | int bytesPerLine = frame->pitches[0]; |
| 461 | |
457 | 462 | for (y = logoMinY; y <= logoMaxY; y++ ) |
458 | 463 | { |
459 | 464 | for (x = logoMinX; x <= logoMaxX; x++ ) |
460 | 465 | { |
461 | | pos1 = y * width + x; |
462 | | pos2 = (y - radius) * width + x; |
463 | | pos3 = (y + radius) * width + x; |
| 466 | pos1 = y * bytesPerLine + x; |
| 467 | edgePos = y * width + x; |
| 468 | pos2 = (y - radius) * bytesPerLine + x; |
| 469 | pos3 = (y + radius) * bytesPerLine + x; |
464 | 470 | |
465 | 471 | pixel = framePtr[pos1]; |
466 | 472 | |
467 | | if (edgeMask[pos1].horiz) |
| 473 | if (edgeMask[edgePos].horiz) |
468 | 474 | { |
469 | 475 | if ((abs(framePtr[pos1 - radius] - pixel) >= logoEdgeDiff) || |
470 | 476 | (abs(framePtr[pos1 + radius] - pixel) >= logoEdgeDiff)) |
… |
… |
bool ClassicLogoDetector::doesThisFrameContainTheFoundLogo( |
479 | 485 | testNotEdges++; |
480 | 486 | } |
481 | 487 | |
482 | | if (edgeMask[pos1].vert) |
| 488 | if (edgeMask[edgePos].vert) |
483 | 489 | { |
484 | 490 | if ((abs(framePtr[pos2] - pixel) >= logoEdgeDiff) || |
485 | 491 | (abs(framePtr[pos3] - pixel) >= logoEdgeDiff)) |
… |
… |
void ClassicLogoDetector::DetectEdges(VideoFrame *frame, EdgeMaskEntry *edges, |
522 | 528 | { |
523 | 529 | int r = 2; |
524 | 530 | unsigned char *buf = frame->buf; |
| 531 | int bytesPerLine = frame->pitches[0]; |
525 | 532 | unsigned char p; |
526 | 533 | unsigned int pos, x, y; |
527 | 534 | |
… |
… |
void ClassicLogoDetector::DetectEdges(VideoFrame *frame, EdgeMaskEntry *edges, |
538 | 545 | continue; |
539 | 546 | |
540 | 547 | pos = y * width + x; |
541 | | p = buf[pos]; |
| 548 | p = buf[y * bytesPerLine + x]; |
542 | 549 | |
543 | | if (( abs(buf[y * width + (x - r)] - p) >= edgeDiff) || |
544 | | ( abs(buf[y * width + (x + r)] - p) >= edgeDiff)) |
| 550 | if (( abs(buf[y * bytesPerLine + (x - r)] - p) >= edgeDiff) || |
| 551 | ( abs(buf[y * bytesPerLine + (x + r)] - p) >= edgeDiff)) |
545 | 552 | { |
546 | 553 | edges[pos].horiz++; |
547 | 554 | edgeCount++; |
548 | 555 | } |
549 | | if (( abs(buf[(y - r) * width + x] - p) >= edgeDiff) || |
550 | | ( abs(buf[(y + r) * width + x] - p) >= edgeDiff)) |
| 556 | if (( abs(buf[(y - r) * bytesPerLine + x] - p) >= edgeDiff) || |
| 557 | ( abs(buf[(y + r) * bytesPerLine + x] - p) >= edgeDiff)) |
551 | 558 | { |
552 | 559 | edges[pos].vert++; |
553 | 560 | edgeCount++; |
554 | 561 | } |
555 | 562 | |
556 | | if (( abs(buf[(y - r) * width + (x - r)] - p) >= edgeDiff) || |
557 | | ( abs(buf[(y + r) * width + (x + r)] - p) >= edgeDiff)) |
| 563 | if (( abs(buf[(y - r) * bytesPerLine + (x - r)] - p) >= edgeDiff) || |
| 564 | ( abs(buf[(y + r) * bytesPerLine + (x + r)] - p) >= edgeDiff)) |
558 | 565 | { |
559 | 566 | edges[pos].ldiag++; |
560 | 567 | edgeCount++; |
561 | 568 | } |
562 | 569 | |
563 | | if (( abs(buf[(y - r) * width + (x + r)] - p) >= edgeDiff) || |
564 | | ( abs(buf[(y + r) * width + (x - r)] - p) >= edgeDiff)) |
| 570 | if (( abs(buf[(y - r) * bytesPerLine + (x + r)] - p) >= edgeDiff) || |
| 571 | ( abs(buf[(y + r) * bytesPerLine + (x - r)] - p) >= edgeDiff)) |
565 | 572 | { |
566 | 573 | edges[pos].rdiag++; |
567 | 574 | edgeCount++; |
diff --git a/mythtv/programs/mythcommflag/ClassicLogoDetector.h b/mythtv/programs/mythcommflag/ClassicLogoDetector.h
index d589df5..b930c98 100644
a
|
b
|
class ClassicLogoDetector : public LogoDetectorBase |
16 | 16 | virtual void deleteLater(void); |
17 | 17 | |
18 | 18 | bool searchForLogo(MythPlayer* player); |
19 | | bool doesThisFrameContainTheFoundLogo(unsigned char* frame); |
| 19 | bool doesThisFrameContainTheFoundLogo(VideoFrame* frame); |
20 | 20 | bool pixelInsideLogo(unsigned int x, unsigned int y); |
21 | 21 | |
22 | 22 | unsigned int getRequiredAvailableBufferForSearch(); |
diff --git a/mythtv/programs/mythcommflag/ClassicSceneChangeDetector.cpp b/mythtv/programs/mythcommflag/ClassicSceneChangeDetector.cpp
index c449353..ca96f93 100644
a
|
b
|
void ClassicSceneChangeDetector::deleteLater(void) |
25 | 25 | SceneChangeDetectorBase::deleteLater(); |
26 | 26 | } |
27 | 27 | |
28 | | void ClassicSceneChangeDetector::processFrame(unsigned char* frame) |
| 28 | void ClassicSceneChangeDetector::processFrame(VideoFrame* frame) |
29 | 29 | { |
30 | 30 | histogram->generateFromImage(frame, width, height, commdetectborder, |
31 | 31 | width-commdetectborder, commdetectborder, |
diff --git a/mythtv/programs/mythcommflag/ClassicSceneChangeDetector.h b/mythtv/programs/mythcommflag/ClassicSceneChangeDetector.h
index f4d2200..a8fd53b 100644
a
|
b
|
class ClassicSceneChangeDetector : public SceneChangeDetectorBase |
13 | 13 | unsigned int yspacing); |
14 | 14 | virtual void deleteLater(void); |
15 | 15 | |
16 | | void processFrame(unsigned char* frame); |
| 16 | void processFrame(VideoFrame* frame); |
17 | 17 | |
18 | 18 | private: |
19 | 19 | ~ClassicSceneChangeDetector() {} |
diff --git a/mythtv/programs/mythcommflag/Histogram.cpp b/mythtv/programs/mythcommflag/Histogram.cpp
index 12d2a9a..90c040d 100644
a
|
b
|
|
3 | 3 | #include <cmath> |
4 | 4 | #include <cstring> |
5 | 5 | |
| 6 | #include "frame.h" |
| 7 | |
6 | 8 | Histogram::Histogram() |
7 | 9 | { |
8 | 10 | memset(data,0,sizeof(data)); |
… |
… |
Histogram::~Histogram() |
15 | 17 | { |
16 | 18 | } |
17 | 19 | |
18 | | void Histogram::generateFromImage(unsigned char* frame, unsigned int frameWidth, |
| 20 | void Histogram::generateFromImage(VideoFrame* frame, unsigned int frameWidth, |
19 | 21 | unsigned int frameHeight, unsigned int minScanX, unsigned int maxScanX, |
20 | 22 | unsigned int minScanY, unsigned int maxScanY, unsigned int XSpacing, |
21 | 23 | unsigned int YSpacing) |
… |
… |
void Histogram::generateFromImage(unsigned char* frame, unsigned int frameWidth, |
29 | 31 | if (maxScanY > frameHeight-1) |
30 | 32 | maxScanY = frameHeight-1; |
31 | 33 | |
| 34 | unsigned char* framePtr = frame->buf; |
| 35 | int bytesPerLine = frame->pitches[0]; |
32 | 36 | for(unsigned int y = minScanY; y < maxScanY; y += YSpacing) |
33 | 37 | for(unsigned int x = minScanX; x < maxScanX; x += XSpacing) |
34 | 38 | { |
35 | | data[frame[y * frameWidth + x]]++; |
| 39 | data[framePtr[y * bytesPerLine + x]]++; |
36 | 40 | numberOfSamples++; |
37 | 41 | } |
38 | 42 | } |
diff --git a/mythtv/programs/mythcommflag/Histogram.h b/mythtv/programs/mythcommflag/Histogram.h
index fbed991..06cd807 100644
a
|
b
|
|
1 | 1 | #ifndef _HISTOGRAM_H_ |
2 | 2 | #define _HISTOGRAM_H_ |
3 | 3 | |
| 4 | typedef struct VideoFrame_ VideoFrame; |
| 5 | |
4 | 6 | class Histogram |
5 | 7 | { |
6 | 8 | public: |
7 | 9 | Histogram(); |
8 | 10 | ~Histogram(); |
9 | 11 | |
10 | | void generateFromImage(unsigned char* frame, unsigned int frameWidth, |
| 12 | void generateFromImage(VideoFrame* frame, unsigned int frameWidth, |
11 | 13 | unsigned int frameHeight, unsigned int minScanX, |
12 | 14 | unsigned int maxScanX, unsigned int minScanY, |
13 | 15 | unsigned int maxScanY, unsigned int XSpacing, |
diff --git a/mythtv/programs/mythcommflag/LogoDetectorBase.h b/mythtv/programs/mythcommflag/LogoDetectorBase.h
index ea3f62f..b28cbcc 100644
a
|
b
|
|
4 | 4 | #include <QObject> |
5 | 5 | |
6 | 6 | class MythPlayer; |
| 7 | typedef struct VideoFrame_ VideoFrame; |
7 | 8 | |
8 | 9 | class LogoDetectorBase : public QObject |
9 | 10 | { |
… |
… |
class LogoDetectorBase : public QObject |
14 | 15 | foundLogo(false), width(w),height(h) {}; |
15 | 16 | |
16 | 17 | virtual bool searchForLogo(MythPlayer* player) = 0; |
17 | | virtual bool doesThisFrameContainTheFoundLogo(unsigned char* frame) = 0; |
| 18 | virtual bool doesThisFrameContainTheFoundLogo(VideoFrame* frame) = 0; |
18 | 19 | virtual bool pixelInsideLogo(unsigned int x, unsigned int y) = 0; |
19 | 20 | virtual unsigned int getRequiredAvailableBufferForSearch() = 0; |
20 | 21 | |
diff --git a/mythtv/programs/mythcommflag/SceneChangeDetectorBase.h b/mythtv/programs/mythcommflag/SceneChangeDetectorBase.h
index 67296d5..9a1b311 100644
a
|
b
|
|
3 | 3 | |
4 | 4 | #include <QObject> |
5 | 5 | |
| 6 | typedef struct VideoFrame_ VideoFrame; |
| 7 | |
6 | 8 | class SceneChangeDetectorBase : public QObject |
7 | 9 | { |
8 | 10 | Q_OBJECT |
… |
… |
class SceneChangeDetectorBase : public QObject |
11 | 13 | SceneChangeDetectorBase(unsigned int w, unsigned int h) : |
12 | 14 | width(w), height(h) {} |
13 | 15 | |
14 | | virtual void processFrame(unsigned char *frame) = 0; |
| 16 | virtual void processFrame(VideoFrame* frame) = 0; |
15 | 17 | |
16 | 18 | signals: |
17 | 19 | void haveNewInformation(unsigned int framenum, bool scenechange, |