Ticket #8522: commflag_split_blanks.patch
File commflag_split_blanks.patch, 10.2 KB (added by , 14 years ago) |
---|
-
programs/mythfrontend/globalsettings.cpp
559 559 return bc; 560 560 } 561 561 562 static GlobalC heckBox *CommSkipAllBlanks()562 static GlobalComboBox *CommSkipAllBlanks() 563 563 { 564 GlobalC heckBox *bc = new GlobalCheckBox("CommSkipAllBlanks");564 GlobalComboBox *bc = new GlobalComboBox("CommSkipAllBlanks"); 565 565 bc->setLabel(QObject::tr("Skip blank frames after commercials")); 566 bc->setValue(true); 566 bc->addSelection(QObject::tr("Never"), "0"); 567 bc->addSelection(QObject::tr("Always"), "1"); 568 bc->addSelection(QObject::tr("Skip half the blank frames"), "2"); 569 bc->setValue(1); 567 570 bc->setHelpText(QObject::tr("When using Blank Frame Detection and " 568 571 "Auto-Flagging, include blank frames following commercial " 569 572 "breaks as part of the commercial break.")); -
programs/mythcommflag/BlankFrameDetector.h
31 31 { return (index) ? blankMap : breakMap; } 32 32 33 33 /* BlankFrameDetector interface. */ 34 boolgetSkipCommBlanks(void) const { return skipcommblanks; }34 int getSkipCommBlanks(void) const { return skipcommblanks; } 35 35 const FrameAnalyzer::FrameMap *getBlanks(void) const { return &blankMap; } 36 36 int computeForLogoSurplus(const TemplateMatcher *tm); 37 37 int computeForLogoDeficit(const TemplateMatcher *tm); … … 40 40 private: 41 41 HistogramAnalyzer *histogramAnalyzer; 42 42 float fps; 43 boolskipcommblanks; /* skip commercial blanks */43 int skipcommblanks; /* skip commercial blanks */ 44 44 45 45 FrameAnalyzer::FrameMap blankMap; 46 46 FrameAnalyzer::FrameMap breakMap; -
programs/mythcommflag/ClassicCommDetector.h
153 153 bool logoInfoAvailable; 154 154 LogoDetectorBase* logoDetector; 155 155 156 boolskipAllBlanks;156 int skipAllBlanks; 157 157 158 158 unsigned char *framePtr; 159 159 -
programs/mythcommflag/BlankFrameDetector.cpp
204 204 205 205 void 206 206 computeBreakMap(FrameAnalyzer::FrameMap *breakMap, 207 const FrameAnalyzer::FrameMap *blankMap, float fps, boolskipcommblanks,207 const FrameAnalyzer::FrameMap *blankMap, float fps, int skipcommblanks, 208 208 int debugLevel) 209 209 { 210 210 /* … … 345 345 { 346 346 long long iib = iibreak.key(); 347 347 long long iie = iib + *iibreak; 348 FrameAnalyzer::FrameMap::iterator jjbreak = iibreak; 349 ++jjbreak; 350 breakMap->erase(iibreak); 348 351 349 if ( !skipcommblanks)352 if (skipcommblanks == 0 || skipcommblanks == 2) 350 353 { 351 354 /* Trim leading blanks from commercial break. */ 352 FrameAnalyzer::FrameMap::const_iterator iiblank = 353 blankMap->find(iib); 354 FrameAnalyzer::FrameMap::iterator jjbreak = iibreak; 355 ++jjbreak; 356 iib += *iiblank; 357 breakMap->erase(iibreak); 358 breakMap->insert(iib, iie - iib); 359 iibreak = jjbreak; 355 long long addb = *blankMap->find(iib); 356 if (skipcommblanks == 2) 357 addb /= 2; 358 iib += addb; 360 359 } 361 else360 if (skipcommblanks == 1 || skipcommblanks == 2) 362 361 { 363 362 /* Add trailing blanks to commercial break. */ 364 ++iibreak; 365 FrameAnalyzer::FrameMap::const_iterator jjblank = 366 blankMap->find(iie); 367 iie += *jjblank; 368 breakMap->remove(iib); 369 breakMap->insert(iib, iie - iib); 363 long long adde = *blankMap->find(iie); 364 if (skipcommblanks == 2) 365 adde /= 2; 366 iie += adde; 370 367 } 368 breakMap->insert(iib, iie - iib); 369 iibreak = jjbreak; 371 370 } 372 371 } 373 372 … … 379 378 , fps(0.0f) 380 379 , debugLevel(0) 381 380 { 382 skipcommblanks = gCoreContext->GetNumSetting("CommSkipAllBlanks", 1) != 0;381 skipcommblanks = gCoreContext->GetNumSetting("CommSkipAllBlanks", 1); 383 382 384 383 VERBOSE(VB_COMMFLAG, QString("BlankFrameDetector: skipcommblanks=%1") 385 .arg(skipcommblanks ? "true" : "false"));384 .arg(skipcommblanks)); 386 385 387 386 /* 388 387 * debugLevel: -
programs/mythcommflag/TemplateMatcher.cpp
673 673 TemplateMatcher::adjustForBlanks(const BlankFrameDetector *blankFrameDetector, 674 674 long long nframes) 675 675 { 676 const boolskipCommBlanks = blankFrameDetector->getSkipCommBlanks();676 const int skipCommBlanks = blankFrameDetector->getSkipCommBlanks(); 677 677 const FrameAnalyzer::FrameMap *blankMap = blankFrameDetector->getBlanks(); 678 678 679 679 /* … … 778 778 if (jj != blankMap->constEnd()) 779 779 { 780 780 newbrkb = jj.key(); 781 if ( !skipCommBlanks)781 if (skipCommBlanks == 0) 782 782 newbrkb += *jj; 783 else if (skipCommBlanks == 2) 784 newbrkb += *jj / 2; 783 785 } 784 786 785 787 /* … … 796 798 if (kk != blankMap->constEnd()) 797 799 { 798 800 newbrke = kk.key(); 799 if (skipCommBlanks )801 if (skipCommBlanks == 1) 800 802 newbrke += *kk; 803 else if (skipCommBlanks == 2) 804 newbrke += *kk / 2; 801 805 } 802 806 803 807 /* -
programs/mythcommflag/ClassicCommDetector.cpp
170 170 commDetectMaxCommLength = 171 171 gCoreContext->GetNumSetting("CommDetectMaxCommLength", 125); 172 172 173 skipAllBlanks = !!gCoreContext->GetNumSetting("CommSkipAllBlanks", 1);173 skipAllBlanks = gCoreContext->GetNumSetting("CommSkipAllBlanks", 1); 174 174 commDetectBlankCanHaveLogo = 175 175 !!gCoreContext->GetNumSetting("CommDetectBlankCanHaveLogo", 1); 176 176 } … … 1791 1791 { 1792 1792 if (*it == MARK_COMM_START) 1793 1793 { 1794 lastStart = it.key(); 1795 if (skipAllBlanks) 1796 { 1797 while ((lastStart > 0) && 1798 (frameInfo[lastStart - 1].flagMask & COMM_FRAME_BLANK)) 1799 lastStart--; 1800 } 1801 else 1802 { 1803 while ((lastStart < (framesProcessed - (2 * fps))) && 1804 (frameInfo[lastStart + 1].flagMask & COMM_FRAME_BLANK)) 1805 lastStart++; 1806 } 1794 uint64_t lastStartLower = it.key(); 1795 uint64_t lastStartUpper = it.key(); 1796 while ((lastStartLower > 0) && 1797 (frameInfo[lastStartLower - 1].flagMask & COMM_FRAME_BLANK)) 1798 lastStartLower--; 1799 while ((lastStartUpper < (framesProcessed - (2 * fps))) && 1800 (frameInfo[lastStartUpper + 1].flagMask & COMM_FRAME_BLANK)) 1801 lastStartUpper++; 1802 if (skipAllBlanks == 0) 1803 lastStart = lastStartUpper; 1804 else if (skipAllBlanks == 2) 1805 lastStart = (lastStartLower + lastStartUpper) / 2; 1806 else // default is 1 1807 lastStart = lastStartLower; 1807 1808 1808 1809 if (verboseDebugging) 1809 1810 VERBOSE(VB_COMMFLAG, QString("Start Mark: %1 -> %2") … … 1814 1815 } 1815 1816 else 1816 1817 { 1817 lastEnd = it.key(); 1818 if (skipAllBlanks) 1819 { 1820 while ((lastEnd < (framesProcessed - (2 * fps))) && 1821 (frameInfo[lastEnd + 1].flagMask & COMM_FRAME_BLANK)) 1822 lastEnd++; 1823 } 1824 else 1825 { 1826 while ((lastEnd > 0) && 1827 (frameInfo[lastEnd - 1].flagMask & COMM_FRAME_BLANK)) 1828 lastEnd--; 1829 } 1818 uint64_t lastEndLower = it.key(); 1819 uint64_t lastEndUpper = it.key(); 1820 while ((lastEndUpper < (framesProcessed - (2 * fps))) && 1821 (frameInfo[lastEndUpper + 1].flagMask & COMM_FRAME_BLANK)) 1822 lastEndUpper++; 1823 while ((lastEndLower > 0) && 1824 (frameInfo[lastEndLower - 1].flagMask & COMM_FRAME_BLANK)) 1825 lastEndLower--; 1826 if (skipAllBlanks == 0) 1827 lastEnd = lastEndLower; 1828 else if (skipAllBlanks == 2) 1829 lastEnd = (lastEndLower + lastEndUpper) / 2; 1830 else // default is 1 1831 lastEnd = lastEndUpper; 1830 1832 1831 1833 if (verboseDebugging) 1832 1834 VERBOSE(VB_COMMFLAG, QString("End Mark : %1 -> %2") … … 1939 1941 for(; i < (commercials-1); i++) 1940 1942 { 1941 1943 long long r = c_start[i]; 1944 long long adjustment = 0; 1942 1945 1943 1946 if ((r < (30 * fps)) && 1944 1947 (first_comm)) … … 1961 1964 } 1962 1965 1963 1966 if (skipAllBlanks) 1967 { 1964 1968 while((blankFrameMap.contains(r+1)) && 1965 1969 (c_start[i+1] != (r+1))) 1970 { 1966 1971 r++; 1972 adjustment++; 1973 } 1974 } 1967 1975 } 1968 1976 else 1969 1977 { 1970 1978 if (skipAllBlanks) 1971 1979 while(blankFrameMap.contains(r+1)) 1980 { 1972 1981 r++; 1982 adjustment++; 1983 } 1973 1984 } 1974 1985 1986 if (skipAllBlanks == 2) 1987 r -= (adjustment / 2); 1975 1988 blankCommMap[r] = MARK_COMM_END; 1976 1989 first_comm = false; 1977 1990 }