Ticket #10793: commdetector.patch
File commdetector.patch, 48.8 KB (added by , 12 years ago) |
---|
-
mythtv/programs/mythcommflag/ClassicCommDetector.cpp
diff --git a/mythtv/programs/mythcommflag/ClassicCommDetector.cpp b/mythtv/programs/mythcommflag/ClassicCommDetector.cpp index 800e83d..bb83323 100644
a b ClassicCommDetector::ClassicCommDetector(SkipType commDetectMethod_in, 134 134 width(0), height(0), 135 135 horizSpacing(0), vertSpacing(0), 136 136 fpm(0.0), blankFramesOnly(false), 137 blankFrameCount(0), currentAspect(0), 137 blankFrameCount(0), 138 currentAspect(0), colMax(NULL), 138 139 totalMinBrightness(0), detectBlankFrames(false), 139 140 detectSceneChanges(false), detectStationLogo(false), 140 141 logoInfoAvailable(false), logoDetector(0), 141 framePtr(0), frameIsBlank(false), 142 sceneHasChanged(false), stationLogoPresent(false), 142 framePtr(0), sceneHasChanged(false), 143 143 lastFrameWasBlank(false), lastFrameWasSceneChange(false), 144 144 decoderFoundAspectChanges(false), sceneChangeDetector(0), 145 145 player(player_in), … … ClassicCommDetector::ClassicCommDetector(SkipType commDetectMethod_in, 152 152 preRoll(0), postRoll(0) 153 153 { 154 154 commDetectBorder = 155 gCoreContext->GetNumSetting("CommDetectBorder", 20);155 gCoreContext->GetNumSetting("CommDetectBorder", 5); 156 156 commDetectBlankFrameMaxDiff = 157 157 gCoreContext->GetNumSetting("CommDetectBlankFrameMaxDiff", 25); 158 158 commDetectDarkBrightness = … … void ClassicCommDetector::Init() 206 206 .arg(width).arg(height) 207 207 .arg(player->GetFrameRate()).arg(commDetectMethod)); 208 208 209 if ((width * height) > 1000000) 210 { 211 horizSpacing = 10; 212 vertSpacing = 10; 213 } 214 else if ((width * height) > 800000) 215 { 216 horizSpacing = 8; 217 vertSpacing = 8; 218 } 219 else if ((width * height) > 400000) 220 { 221 horizSpacing = 6; 222 vertSpacing = 6; 223 } 224 else if ((width * height) > 300000) 225 { 226 horizSpacing = 6; 227 vertSpacing = 4; 228 } 229 else 230 { 231 horizSpacing = 4; 232 vertSpacing = 4; 233 } 209 horizSpacing = 1; 210 vertSpacing = 1; 234 211 235 212 LOG(VB_COMMFLAG, LOG_INFO, 236 213 QString("Using Sample Spacing of %1 horizontal & %2 vertical pixels.") … … void ClassicCommDetector::Init() 245 222 decoderFoundAspectChanges = false; 246 223 247 224 lastSentCommBreakMap.clear(); 225 226 colMax = new unsigned char[width]; 248 227 249 228 // Check if close to 4:3 250 229 if (fabs(((width*1.0)/height) - 1.333333) < 0.1) 251 230 currentAspect = COMM_ASPECT_NORMAL; 252 231 253 232 sceneChangeDetector = new ClassicSceneChangeDetector(width, height, 254 commDetectBorder, horizSpacing, vertSpacing);233 commDetectBorder, fps); 255 234 connect( 256 235 sceneChangeDetector, 257 236 SIGNAL(haveNewInformation(unsigned int,bool,float)), … … void ClassicCommDetector::Init() 259 238 SLOT(sceneChangeDetectorHasNewInformation(unsigned int,bool,float)) 260 239 ); 261 240 262 frameIsBlank = false;263 stationLogoPresent = false;264 265 241 framePtr = NULL; 266 242 267 243 logoInfoAvailable = false; … … void ClassicCommDetector::SetVideoParams(float aspect) 735 711 void ClassicCommDetector::ProcessFrame(VideoFrame *frame, 736 712 long long frame_number) 737 713 { 738 int max = 0;739 int min = 255;740 int avg = 0;741 unsigned char pixel;742 int blankPixelsChecked = 0;743 long long totBrightness = 0;744 unsigned char *rowMax = new unsigned char[height];745 unsigned char *colMax = new unsigned char[width];746 memset(rowMax, 0, sizeof(*rowMax)*height);747 memset(colMax, 0, sizeof(*colMax)*width);748 int topDarkRow = commDetectBorder;749 int bottomDarkRow = height - commDetectBorder - 1;750 int leftDarkCol = commDetectBorder;751 int rightDarkCol = width - commDetectBorder - 1;752 714 FrameInfoEntry fInfo; 753 715 754 if (!frame || !(frame->buf) || frame_number == -1||755 frame ->codec != FMT_YV12)716 if (!frame || !(frame->buf) || !width || !height || 717 frame_number == -1 || frame->codec != FMT_YV12) 756 718 { 757 719 LOG(VB_COMMFLAG, LOG_ERR, "CommDetect: Invalid video frame or codec, " 758 720 "unable to process frame."); 759 delete[] rowMax;760 delete[] colMax;761 return;762 }763 764 if (!width || !height)765 {766 LOG(VB_COMMFLAG, LOG_ERR, "CommDetect: Width or Height is 0, "767 "unable to process frame.");768 delete[] rowMax;769 delete[] colMax;770 721 return; 771 722 } 772 723 … … void ClassicCommDetector::ProcessFrame(VideoFrame *frame, 803 754 804 755 frameInfo[curFrameNumber] = fInfo; 805 756 806 if (commDetectMethod & COMM_DETECT_BLANKS)807 frameIsBlank = false;808 809 757 if (commDetectMethod & COMM_DETECT_SCENE) 810 758 { 811 sceneChangeDetector->processFrame( framePtr);759 sceneChangeDetector->processFrame(curFrameNumber, framePtr); 812 760 } 813 814 stationLogoPresent = false; 815 816 for(int y = commDetectBorder; y < (height - commDetectBorder); 817 y += vertSpacing) 761 762 if (commDetectMethod & COMM_DETECT_BLANKS) 818 763 { 819 for(int x = commDetectBorder; x < (width - commDetectBorder); 820 x += horizSpacing) 764 unsigned char max = 0; 765 unsigned char min = 255; 766 unsigned char avg = 0; 767 long long brightnessSum = 0; 768 769 memset(colMax, 0, sizeof(*colMax)*width); 770 771 unsigned int topLight = height, bottomLight = 0; 772 for(unsigned int y = commDetectBorder; y < (height - commDetectBorder); ++y) 821 773 { 822 pixel = framePtr[y * width + x]; 823 824 if (commDetectMethod & COMM_DETECT_BLANKS) 774 for(unsigned int x = commDetectBorder; x < (width - commDetectBorder); x++) 825 775 { 826 bool checkPixel = false; 827 if (!commDetectBlankCanHaveLogo) 828 checkPixel = true; 829 830 if (!logoInfoAvailable) 831 checkPixel = true; 832 else if (!logoDetector->pixelInsideLogo(x,y)) 833 checkPixel=true; 834 835 if (checkPixel) 836 { 837 blankPixelsChecked++; 838 totBrightness += pixel; 839 840 if (pixel < min) 841 min = pixel; 842 843 if (pixel > max) 844 max = pixel; 845 846 if (pixel > rowMax[y]) 847 rowMax[y] = pixel; 848 849 if (pixel > colMax[x]) 850 colMax[x] = pixel; 851 } 776 unsigned char pixel = framePtr[y * width + x]; 777 778 brightnessSum += pixel; 779 if (max < pixel) 780 max = pixel; 781 if (min > pixel) 782 min = pixel; 783 784 if (colMax[x] < pixel) 785 colMax[x] = pixel; 786 787 if (pixel > commDetectBoxBrightness && 788 (commDetectBlankCanHaveLogo || 789 !logoInfoAvailable || 790 !logoDetector->pixelInsideLogo(x,y))) 791 { 792 if (topLight > y) 793 topLight = y; 794 bottomLight = y; 795 } 852 796 } 853 797 } 854 } 855 856 if (commDetectMethod & COMM_DETECT_BLANKS) 857 { 858 for(int y = commDetectBorder; y < (height - commDetectBorder); 859 y += vertSpacing) 860 { 861 if (rowMax[y] > commDetectBoxBrightness) 862 break; 863 else 864 topDarkRow = y; 865 } 866 867 for(int y = commDetectBorder; y < (height - commDetectBorder); 868 y += vertSpacing) 869 if (rowMax[y] >= commDetectBoxBrightness) 870 bottomDarkRow = y; 871 872 delete[] rowMax; 873 rowMax = 0; 874 875 for(int x = commDetectBorder; x < (width - commDetectBorder); 876 x += horizSpacing) 798 799 unsigned int leftLight = width, rightLight = 0; 800 for(unsigned int x = commDetectBorder; x < (width - commDetectBorder); x ++) 877 801 { 878 802 if (colMax[x] > commDetectBoxBrightness) 879 break; 880 else 881 leftDarkCol = x; 803 { 804 if (leftLight > x) 805 leftLight = x; 806 807 rightLight = x; 808 } 882 809 } 883 884 for(int x = commDetectBorder; x < (width - commDetectBorder); 885 x += horizSpacing) 886 if (colMax[x] >= commDetectBoxBrightness) 887 rightDarkCol = x; 888 889 delete[] colMax; 890 colMax = 0; 891 892 if ((topDarkRow > commDetectBorder) && 893 (topDarkRow < (height * .20)) && 894 (bottomDarkRow < (height - commDetectBorder)) && 895 (bottomDarkRow > (height * .80))) 810 811 if (abs(leftLight - (width - rightLight)) < 5 && 812 leftLight <= width*0.2) 896 813 { 897 814 frameInfo[curFrameNumber].format = COMM_FORMAT_LETTERBOX; 898 815 } 899 else if ((leftDarkCol > commDetectBorder) && 900 (leftDarkCol < (width * .20)) && 901 (rightDarkCol < (width - commDetectBorder)) && 902 (rightDarkCol > (width * .80))) 816 else if(abs(topLight - (height - bottomLight)) < 5 && 817 topLight <= height*0.2) 903 818 { 904 frameInfo[curFrameNumber].format = COMM_FORMAT_ PILLARBOX;819 frameInfo[curFrameNumber].format = COMM_FORMAT_LETTERBOX; 905 820 } 906 821 else 907 822 { 908 823 frameInfo[curFrameNumber].format = COMM_FORMAT_NORMAL; 909 824 } 910 911 avg = totBrightness / blankPixelsChecked;825 826 avg = brightnessSum / (width * height); 912 827 913 828 frameInfo[curFrameNumber].minBrightness = min; 914 829 frameInfo[curFrameNumber].maxBrightness = max; … … void ClassicCommDetector::ProcessFrame(VideoFrame *frame, 916 831 917 832 totalMinBrightness += min; 918 833 commDetectDimAverage = min + 10; 919 920 // Is the frame really dark 921 if (((max - min) <= commDetectBlankFrameMaxDiff) && 922 (max < commDetectDimBrightness)) 923 frameIsBlank = true; 924 925 // Are we non-strict and the frame is blank 926 if ((!aggressiveDetection) && 927 ((max - min) <= commDetectBlankFrameMaxDiff)) 928 frameIsBlank = true; 929 930 // Are we non-strict and the frame is dark 931 // OR the frame is dim and has a low avg brightness 932 if ((!aggressiveDetection) && 933 ((max < commDetectDarkBrightness) || 934 ((max < commDetectDimBrightness) && (avg < commDetectDimAverage)))) 935 frameIsBlank = true; 834 835 bool frameIsBlank; 836 if (aggressiveDetection) 837 { 838 // Is the frame uniform AND dark 839 frameIsBlank = (max - min) <= commDetectBlankFrameMaxDiff && 840 max < commDetectDimBrightness; 841 } 842 else 843 { 844 // Is the frame uniform OR very dark OR dark and low average brightness 845 frameIsBlank = (max - min) <= commDetectBlankFrameMaxDiff || 846 max < commDetectDarkBrightness || 847 (max < commDetectDimBrightness && avg < commDetectDimAverage); 848 } 849 850 if (frameIsBlank) 851 { 852 blankFrameMap[curFrameNumber] = MARK_BLANK_FRAME; 853 flagMask |= COMM_FRAME_BLANK; 854 blankFrameCount++; 855 } 936 856 } 937 857 938 if ( (logoInfoAvailable)&& (commDetectMethod & COMM_DETECT_LOGO))858 if (logoInfoAvailable && (commDetectMethod & COMM_DETECT_LOGO)) 939 859 { 940 stationLogoPresent =941 logoDetector->doesThisFrameContainTheFoundLogo(framePtr);860 if (logoDetector->doesThisFrameContainTheFoundLogo(framePtr)) 861 flagMask |= COMM_FRAME_LOGO_PRESENT; 942 862 } 943 863 944 864 #if 0 … … void ClassicCommDetector::ProcessFrame(VideoFrame *frame, 949 869 } 950 870 #endif 951 871 952 if (frameIsBlank)953 {954 blankFrameMap[curFrameNumber] = MARK_BLANK_FRAME;955 flagMask |= COMM_FRAME_BLANK;956 blankFrameCount++;957 }958 959 if (stationLogoPresent)960 flagMask |= COMM_FRAME_LOGO_PRESENT;961 962 872 //TODO: move this debugging code out of the perframe loop, and do it after 963 873 // we've processed all frames. this is because a scenechangedetector can 964 874 // now use a few frames to determine whether the frame a few frames ago was … … void ClassicCommDetector::ProcessFrame(VideoFrame *frame, 985 895 #endif 986 896 987 897 framesProcessed++; 988 delete[] rowMax;989 delete[] colMax;990 898 } 991 899 992 900 void ClassicCommDetector::ClearAllMaps(void) … … void ClassicCommDetector::UpdateFrameBlock(FrameBlock *fbp, 1140 1048 FrameInfoEntry finfo, 1141 1049 int format, int aspect) 1142 1050 { 1143 int value = 0; 1144 1145 value = finfo.flagMask; 1051 int value = finfo.flagMask; 1146 1052 1147 1053 if (value & COMM_FRAME_LOGO_PRESENT) 1148 1054 fbp->logoCount++; … … void ClassicCommDetector::UpdateFrameBlock(FrameBlock *fbp, 1152 1058 1153 1059 if (value & COMM_FRAME_SCENE_CHANGE) 1154 1060 fbp->scCount++; 1061 1062 if (value & COMM_FRAME_BLANK) 1063 fbp->bfCount++; 1155 1064 1156 1065 if (finfo.format == format) 1157 1066 fbp->formatMatch++; … … void ClassicCommDetector::BuildAllMethodsCommList(void) 1165 1074 { 1166 1075 LOG(VB_COMMFLAG, LOG_INFO, "CommDetect::BuildAllMethodsCommList()"); 1167 1076 1168 FrameBlock *fblock;1169 1077 FrameBlock *fbp; 1170 int value = 0;1171 1078 int curBlock = 0; 1172 1079 int maxBlock = 0; 1173 1080 int lastScore = 0; 1174 1081 int thisScore = 0; 1175 int nextScore = 0;1176 1082 uint64_t curFrame = 0; 1177 1083 int64_t breakStart = 0; 1178 1084 uint64_t lastStart = 0; 1179 1085 uint64_t lastEnd = 0; 1180 1086 int64_t firstLogoFrame = -1; 1181 bool nextFrameIsBlank = false;1182 bool lastFrameWasBlank = false;1183 1087 uint64_t formatFrames = 0; 1184 1088 int format = COMM_FORMAT_NORMAL; 1185 1089 uint64_t aspectFrames = 0; … … void ClassicCommDetector::BuildAllMethodsCommList(void) 1191 1095 1192 1096 commBreakMap.clear(); 1193 1097 1194 fblock = new FrameBlock[blankFrameCount + 2]; 1098 QVector<FrameBlock> fblock; 1099 fblock.reserve(blankFrameCount + 2); 1195 1100 1196 1101 curBlock = 0; 1197 1102 curFrame = 1; 1198 1103 1199 fbp = &fblock[curBlock]; 1104 fblock.resize(1); 1105 fbp = &fblock[0]; 1200 1106 fbp->start = 0; 1201 1107 fbp->bfCount = 0; 1202 1108 fbp->logoCount = 0; … … void ClassicCommDetector::BuildAllMethodsCommList(void) 1245 1151 } 1246 1152 } 1247 1153 } 1248 1154 1249 1155 while (curFrame <= framesProcessed) 1250 1156 { 1251 value = frameInfo[curFrame].flagMask; 1252 1253 if (((curFrame + 1) <= framesProcessed) && 1254 (frameInfo[curFrame + 1].flagMask & COMM_FRAME_BLANK)) 1255 nextFrameIsBlank = true; 1256 else 1257 nextFrameIsBlank = false; 1258 1259 if (value & COMM_FRAME_BLANK) 1157 bool breakBlock = frameInfo[curFrame].flagMask & COMM_FRAME_BLANK; 1158 /*if (!breakBlock && 1159 (frameInfo[curFrame].flagMask & COMM_FRAME_SCENE_CHANGE) && 1160 (frameInfo[curFrame].sceneChangePercent < 50)) 1260 1161 { 1261 fbp->bfCount++; 1262 1263 if (!nextFrameIsBlank || !lastFrameWasBlank) 1162 double length = (curFrame - fbp->start) / fps; 1163 if (abs(length - 5) < 0.10 || 1164 abs(length - 10) < 0.25 || 1165 abs(length - 15) < 0.50 || 1166 abs(length - 20) < 0.50 || 1167 abs(length - 30) < 0.50 || 1168 abs(length - 40) < 0.50 || 1169 abs(length - 45) < 0.75 || 1170 abs(length - 60) < 0.75 || 1171 abs(length - 90) < 1.00 || 1172 abs(length -120) < 1.00) 1264 1173 { 1265 UpdateFrameBlock(fbp, frameInfo[curFrame], format, aspect); 1266 1267 fbp->end = curFrame; 1268 fbp->frames = fbp->end - fbp->start + 1; 1269 fbp->length = fbp->frames / fps; 1270 1271 if ((fbp->scCount) && (fbp->length > 1.05)) 1272 fbp->scRate = fbp->scCount / fbp->length; 1273 1274 curBlock++; 1275 1276 fbp = &fblock[curBlock]; 1277 fbp->bfCount = 1; 1278 fbp->logoCount = 0; 1279 fbp->ratingCount = 0; 1280 fbp->scCount = 0; 1281 fbp->scRate = 0.0; 1282 fbp->score = 0; 1283 fbp->formatMatch = 0; 1284 fbp->aspectMatch = 0; 1285 fbp->start = curFrame; 1174 breakBlock = true; 1175 // Make sure we weren't going to break because of blanks soon anyways 1176 for (unsigned int f = 1; f < fps*2 && curFrame + f < framesProcessed; ++f) 1177 { 1178 if (frameInfo[curFrame+f].flagMask & COMM_FRAME_BLANK) 1179 { 1180 breakBlock = false; 1181 break; 1182 } 1183 } 1286 1184 } 1287 1288 lastFrameWasBlank = true; 1185 }*/ 1186 1187 if (breakBlock) 1188 { 1189 unsigned int bfStart = curFrame, bfEnd = curFrame; 1190 do 1191 { 1192 ++bfEnd; 1193 } 1194 while (bfEnd < framesProcessed && frameInfo[bfEnd].flagMask & COMM_FRAME_BLANK); 1195 1196 unsigned int bfMiddle = curFrame + (bfEnd - bfStart)/2; 1197 1198 do 1199 { 1200 UpdateFrameBlock(fbp, frameInfo[curFrame++], format, aspect); 1201 } 1202 while (curFrame < bfMiddle); 1203 1204 fbp->end = curFrame; 1205 fbp->frames = fbp->end - fbp->start + 1; 1206 fbp->length = fbp->frames / fps; 1207 1208 if (fbp->length < 1.0) 1209 fbp->scRate = fbp->scCount; 1210 else 1211 fbp->scRate = fbp->scCount / fbp->length; // changes per sec 1212 1213 curBlock++; 1214 1215 fblock.resize(curBlock+1); 1216 fbp = &fblock[curBlock]; 1217 fbp->bfCount = 0; 1218 fbp->logoCount = 0; 1219 fbp->ratingCount = 0; 1220 fbp->scCount = 0; 1221 fbp->scRate = 0.0; 1222 fbp->score = 0; 1223 fbp->formatMatch = 0; 1224 fbp->aspectMatch = 0; 1225 1226 fbp->start = curFrame; 1227 for (; curFrame < bfEnd; ++curFrame) 1228 UpdateFrameBlock(fbp, frameInfo[curFrame], format, aspect); 1289 1229 } 1290 1230 else 1291 1231 { 1292 lastFrameWasBlank = false; 1232 UpdateFrameBlock(fbp, frameInfo[curFrame], format, aspect); 1233 if ((frameInfo[curFrame].flagMask & COMM_FRAME_LOGO_PRESENT) && firstLogoFrame == -1) 1234 firstLogoFrame = curFrame; 1235 curFrame++; 1293 1236 } 1294 1295 UpdateFrameBlock(fbp, frameInfo[curFrame], format, aspect);1296 1297 if ((value & COMM_FRAME_LOGO_PRESENT) &&1298 (firstLogoFrame == -1))1299 firstLogoFrame = curFrame;1300 1301 curFrame++;1302 1237 } 1303 1238 1304 1239 fbp->end = curFrame; 1305 1240 fbp->frames = fbp->end - fbp->start + 1; 1306 1241 fbp->length = fbp->frames / fps; 1307 1242 1308 if ((fbp->scCount) && (fbp->length > 1.05)) 1309 fbp->scRate = fbp->scCount / fbp->length; 1310 1243 if (fbp->length < 1.0) 1244 fbp->scRate = fbp->scCount; 1245 else 1246 fbp->scRate = fbp->scCount / fbp->length; // changes per sec 1247 1311 1248 maxBlock = curBlock; 1312 curBlock = 0;1313 lastScore = 0;1314 1249 1315 1250 LOG(VB_COMMFLAG, LOG_INFO, "Initial Block pass"); 1316 1251 LOG(VB_COMMFLAG, LOG_DEBUG, … … void ClassicCommDetector::BuildAllMethodsCommList(void) 1319 1254 LOG(VB_COMMFLAG, LOG_INFO, 1320 1255 "----- ------ ------ ------ ------ ------- " 1321 1256 "--- ------ ------ ------ ----- ------ ------ -----"); 1322 while (curBlock <= maxBlock)1257 for (curBlock = 0; curBlock <= maxBlock; ++curBlock) 1323 1258 { 1324 1259 fbp = &fblock[curBlock]; 1325 1260 … … void ClassicCommDetector::BuildAllMethodsCommList(void) 1332 1267 fbp->scCount, fbp->scRate, fbp->formatMatch, 1333 1268 fbp->aspectMatch, fbp->score); 1334 1269 LOG(VB_COMMFLAG, LOG_DEBUG, msg); 1335 1336 if ( fbp->frames > fps)1270 1271 if ((int)fbp->length > commDetectMaxCommLength) 1337 1272 { 1338 1273 if (verboseDebugging) 1339 1274 LOG(VB_COMMFLAG, LOG_DEBUG, 1340 QString(" FRAMES > %1").arg(fps)); 1341 1342 if (fbp->length > commDetectMaxCommLength) 1343 { 1344 if (verboseDebugging) 1345 LOG(VB_COMMFLAG, LOG_DEBUG, 1346 " length > max comm length, +20"); 1347 fbp->score += 20; 1348 } 1275 " length > max comm length, +10"); 1276 fbp->score += 10; 1277 } 1349 1278 1350 if (fbp->length > commDetectMaxCommBreakLength)1351 1352 1353 1354 1355 1356 1279 if ((int)fbp->length > commDetectMaxCommBreakLength) 1280 { 1281 if (verboseDebugging) 1282 LOG(VB_COMMFLAG, LOG_DEBUG, 1283 " length > max comm break length, +20"); 1284 fbp->score += 20; 1285 } 1357 1286 1358 if ((fbp->length > 4) && 1359 (fbp->logoCount > (fbp->frames * 0.60)) && 1360 (fbp->bfCount < (fbp->frames * 0.10))) 1287 if ((fbp->logoCount > (fbp->frames * 0.20)) && 1288 (fbp->bfCount < (fbp->frames * 0.10))) 1289 { 1290 if (verboseDebugging) 1291 LOG(VB_COMMFLAG, LOG_DEBUG, 1292 " logoCount > frames * 0.20 && " 1293 "bfCount < frames * .10, +10"); 1294 fbp->score += 10; 1295 1296 if (fbp->logoCount > (fbp->frames * 0.50)) 1361 1297 { 1362 1298 if (verboseDebugging) 1363 1299 LOG(VB_COMMFLAG, LOG_DEBUG, 1364 " length > 4 && logoCount > frames * 0.60 && " 1365 "bfCount < frames * .10"); 1366 if (fbp->length > commDetectMaxCommBreakLength) 1367 { 1368 if (verboseDebugging) 1369 LOG(VB_COMMFLAG, LOG_DEBUG, 1370 " length > max comm break length, +20"); 1371 fbp->score += 20; 1372 } 1373 else 1300 " logoCount > frames * 0.50, +10"); 1301 fbp->score += 10; 1302 if (fbp->logoCount > (fbp->frames * 0.75)) 1374 1303 { 1375 1304 if (verboseDebugging) 1376 1305 LOG(VB_COMMFLAG, LOG_DEBUG, 1377 " l ength <= max comm break length, +10");1306 " logoCount > frames * 0.75, +10"); 1378 1307 fbp->score += 10; 1379 1308 } 1380 1309 } 1310 } 1311 else if ((logoInfoAvailable) && 1312 (fbp->logoCount < (fbp->frames * 0.10))) 1313 { 1314 if (verboseDebugging) 1315 LOG(VB_COMMFLAG, LOG_DEBUG, 1316 " logoInfoAvailable && logoCount < frames * .10, " 1317 "-10"); 1318 fbp->score -= 10; 1319 } 1381 1320 1382 if ((logoInfoAvailable) && 1383 (fbp->logoCount < (fbp->frames * 0.50))) 1384 { 1385 if (verboseDebugging) 1386 LOG(VB_COMMFLAG, LOG_DEBUG, 1387 " logoInfoAvailable && logoCount < frames * .50, " 1388 "-10"); 1389 fbp->score -= 10; 1390 } 1321 if (fbp->ratingCount > 5 * fps) 1322 { 1323 if (verboseDebugging) 1324 LOG(VB_COMMFLAG, LOG_DEBUG, 1325 " rating present > 5 seconds, +20"); 1326 fbp->score += 20; 1327 } 1391 1328 1392 if (fbp->ratingCount > (fbp->frames * 0.05)) 1393 { 1394 if (verboseDebugging) 1395 LOG(VB_COMMFLAG, LOG_DEBUG, 1396 " rating symbol present > 5% of time, +20"); 1397 fbp->score += 20; 1398 } 1329 if ((fbp->scRate > 0.5) && 1330 (fbp->logoCount < (fbp->frames * .25))) 1331 { 1332 if (verboseDebugging) 1333 LOG(VB_COMMFLAG, LOG_DEBUG, " scRate > 0.5, -10"); 1334 fbp->score -= 10; 1399 1335 1400 if ((fbp->scRate > 1.0) && 1401 (fbp->logoCount < (fbp->frames * .90))) 1336 if (fbp->scRate > 1.0) 1402 1337 { 1403 1338 if (verboseDebugging) 1404 1339 LOG(VB_COMMFLAG, LOG_DEBUG, " scRate > 1.0, -10"); 1405 1340 fbp->score -= 10; 1406 1407 if (fbp->scRate > 2.0)1408 {1409 if (verboseDebugging)1410 LOG(VB_COMMFLAG, LOG_DEBUG, " scRate > 2.0, -10");1411 fbp->score -= 10;1412 }1413 1341 } 1342 } 1343 else if (fbp->scRate < 0.20) 1344 { 1345 if (verboseDebugging) 1346 LOG(VB_COMMFLAG, LOG_DEBUG, " scRate < 0.20, +10"); 1347 fbp->score += 10; 1348 } 1414 1349 1415 1416 1417 1418 1419 1420 1421 1422 1423 1350 if ((!decoderFoundAspectChanges) && 1351 (fbp->formatMatch < (fbp->frames * .10))) 1352 { 1353 if (verboseDebugging) 1354 LOG(VB_COMMFLAG, LOG_DEBUG, 1355 " < 10% of frames match show letter/pillar-box " 1356 "format, -20"); 1357 fbp->score -= 20; 1358 } 1424 1359 1425 if ((abs((int)(fbp->frames - (15 * fps))) < 5 ) || 1426 (abs((int)(fbp->frames - (30 * fps))) < 6 ) || 1427 (abs((int)(fbp->frames - (60 * fps))) < 8 )) 1428 { 1429 if (verboseDebugging) 1430 LOG(VB_COMMFLAG, LOG_DEBUG, 1431 " block appears to be standard comm length, -10"); 1432 fbp->score -= 10; 1433 } 1360 if (abs(fbp->length - 5) < 0.10 || 1361 abs(fbp->length - 10) < 0.25 || 1362 abs(fbp->length - 15) < 0.50 || 1363 abs(fbp->length - 20) < 0.50 || 1364 abs(fbp->length - 30) < 0.50 || 1365 abs(fbp->length - 40) < 0.50 || 1366 abs(fbp->length - 45) < 0.75 || 1367 abs(fbp->length - 60) < 0.75 || 1368 abs(fbp->length - 90) < 1.00 || 1369 abs(fbp->length -120) < 1.00) 1370 { 1371 if (verboseDebugging) 1372 LOG(VB_COMMFLAG, LOG_DEBUG, 1373 " block appears to be standard comm length, -10"); 1374 fbp->score -= 10; 1434 1375 } 1435 else 1376 1377 if (fbp->length < 30 && fbp->bfCount > (fbp->frames * 0.90)) 1436 1378 { 1437 1379 if (verboseDebugging) 1438 1380 LOG(VB_COMMFLAG, LOG_DEBUG, 1439 QString(" FRAMES <= %1").arg(fps)); 1440 1441 if ((logoInfoAvailable) && 1442 (fbp->start >= firstLogoFrame) && 1443 (fbp->logoCount == 0)) 1444 { 1445 if (verboseDebugging) 1446 LOG(VB_COMMFLAG, LOG_DEBUG, 1447 " logoInfoAvailable && logoCount == 0, -10"); 1448 fbp->score -= 10; 1449 } 1450 1451 if ((!decoderFoundAspectChanges) && 1452 (fbp->formatMatch < (fbp->frames * .10))) 1453 { 1454 if (verboseDebugging) 1455 LOG(VB_COMMFLAG, LOG_DEBUG, 1456 " < 10% of frames match show letter/pillar-box " 1457 "format, -10"); 1458 fbp->score -= 10; 1459 } 1460 1461 if (fbp->ratingCount > (fbp->frames * 0.25)) 1462 { 1463 if (verboseDebugging) 1464 LOG(VB_COMMFLAG, LOG_DEBUG, 1465 " rating symbol present > 25% of time, +10"); 1466 fbp->score += 10; 1467 } 1381 " blength < 30 && " 1382 "bfCount > frames * .9, -10"); 1383 fbp->score -= 10; 1468 1384 } 1469 1385 1470 1386 if ((decoderFoundAspectChanges) && 1471 1387 (fbp->aspectMatch < (fbp->frames * .10))) 1472 1388 { … … void ClassicCommDetector::BuildAllMethodsCommList(void) 1475 1391 " < 10% of frames match show aspect, -20"); 1476 1392 fbp->score -= 20; 1477 1393 } 1478 1479 msg.sprintf(" NOW %3d:%02d %6ld %6ld %6ld %7.2f %3d %6d %6d %6d " 1480 "%5.2f %6d %6d %5d", 1481 (int)(fbp->start / fps) / 60, 1482 (int)((fbp->start / fps )) % 60, 1483 fbp->start, fbp->end, fbp->frames, fbp->length, 1484 fbp->bfCount, fbp->logoCount, fbp->ratingCount, 1485 fbp->scCount, fbp->scRate, fbp->formatMatch, 1486 fbp->aspectMatch, fbp->score); 1487 LOG(VB_COMMFLAG, LOG_DEBUG, msg); 1488 1489 lastScore = fbp->score; 1490 curBlock++; 1491 } 1492 1493 curBlock = 0; 1494 lastScore = 0; 1495 1496 LOG(VB_COMMFLAG, LOG_DEBUG, "============================================"); 1497 LOG(VB_COMMFLAG, LOG_INFO, "Second Block pass"); 1498 LOG(VB_COMMFLAG, LOG_DEBUG, 1499 "Block StTime StFrm EndFrm Frames Secs " 1500 "Bf Lg Cnt RT Cnt SC Cnt SC Rt FmtMch AspMch Score"); 1501 LOG(VB_COMMFLAG, LOG_DEBUG, 1502 "----- ------ ------ ------ ------ ------- " 1503 "--- ------ ------ ------ ----- ------ ------ -----"); 1504 while (curBlock <= maxBlock) 1505 { 1506 fbp = &fblock[curBlock]; 1507 1508 msg.sprintf("%5d %3d:%02d %6ld %6ld %6ld %7.2f %3d %6d %6d %6d " 1509 "%5.2f %6d %6d %5d", 1510 curBlock, (int)(fbp->start / fps) / 60, 1511 (int)((fbp->start / fps )) % 60, 1512 fbp->start, fbp->end, fbp->frames, fbp->length, 1513 fbp->bfCount, fbp->logoCount, fbp->ratingCount, 1514 fbp->scCount, fbp->scRate, fbp->formatMatch, 1515 fbp->aspectMatch, fbp->score); 1516 LOG(VB_COMMFLAG, LOG_DEBUG, msg); 1517 1518 if ((curBlock > 0) && (curBlock < maxBlock)) 1519 { 1520 nextScore = fblock[curBlock + 1].score; 1521 1522 if ((lastScore < 0) && (nextScore < 0) && (fbp->length < 35)) 1523 { 1524 if (verboseDebugging) 1525 LOG(VB_COMMFLAG, LOG_DEBUG, 1526 " lastScore < 0 && nextScore < 0 " 1527 "&& length < 35, setting -10"); 1528 fbp->score -= 10; 1529 } 1530 1531 if ((fbp->bfCount > (fbp->frames * 0.95)) && 1532 (fbp->frames < (2*fps)) && 1533 (lastScore < 0 && nextScore < 0)) 1534 { 1535 if (verboseDebugging) 1536 LOG(VB_COMMFLAG, LOG_DEBUG, 1537 " blanks > frames * 0.95 && frames < 2*fps && " 1538 "lastScore < 0 && nextScore < 0, setting -10"); 1539 fbp->score -= 10; 1540 } 1541 1542 if ((fbp->frames < (120*fps)) && 1543 (lastScore < 0) && 1544 (fbp->score > 0) && 1545 (fbp->score < 20) && 1546 (nextScore < 0)) 1547 { 1548 if (verboseDebugging) 1549 LOG(VB_COMMFLAG, LOG_DEBUG, 1550 " frames < 120 * fps && (-20 < lastScore < 0) && " 1551 "thisScore > 0 && nextScore < 0, setting score = -10"); 1552 fbp->score = -10; 1553 } 1554 1555 if ((fbp->frames < (30*fps)) && 1556 (lastScore > 0) && 1557 (fbp->score < 0) && 1558 (fbp->score > -20) && 1559 (nextScore > 0)) 1560 { 1561 if (verboseDebugging) 1562 LOG(VB_COMMFLAG, LOG_DEBUG, 1563 " frames < 30 * fps && (0 < lastScore < 20) && " 1564 "thisScore < 0 && nextScore > 0, setting score = 10"); 1565 fbp->score = 10; 1566 } 1567 } 1568 1569 if ((fbp->score == 0) && (lastScore > 30)) 1394 1395 if (fbp->score == 0 && fbp->length < 2) 1570 1396 { 1571 int offset = 1; 1572 while(((curBlock + offset) <= maxBlock) && 1573 (fblock[curBlock + offset].frames < (2 * fps)) && 1574 (fblock[curBlock + offset].score == 0)) 1575 offset++; 1576 1577 if ((curBlock + offset) <= maxBlock) 1578 { 1579 offset--; 1580 if (fblock[curBlock + offset + 1].score > 0) 1581 { 1582 for (; offset >= 0; offset--) 1583 { 1584 fblock[curBlock + offset].score += 10; 1585 if (verboseDebugging) 1586 LOG(VB_COMMFLAG, LOG_DEBUG, 1587 QString(" Setting block %1 score +10") 1588 .arg(curBlock+offset)); 1589 } 1590 } 1591 else if (fblock[curBlock + offset + 1].score < 0) 1592 { 1593 for (; offset >= 0; offset--) 1594 { 1595 fblock[curBlock + offset].score -= 10; 1596 if (verboseDebugging) 1597 LOG(VB_COMMFLAG, LOG_DEBUG, 1598 QString(" Setting block %1 score -10") 1599 .arg(curBlock+offset)); 1600 } 1601 } 1602 } 1397 if (verboseDebugging) 1398 LOG(VB_COMMFLAG, LOG_DEBUG, 1399 " length < 2 && score == 0, -10"); 1400 fbp->score = -10; 1603 1401 } 1604 1402 1605 1403 msg.sprintf(" NOW %3d:%02d %6ld %6ld %6ld %7.2f %3d %6d %6d %6d " 1606 1404 "%5.2f %6d %6d %5d", 1607 1405 (int)(fbp->start / fps) / 60, … … void ClassicCommDetector::BuildAllMethodsCommList(void) 1611 1409 fbp->scCount, fbp->scRate, fbp->formatMatch, 1612 1410 fbp->aspectMatch, fbp->score); 1613 1411 LOG(VB_COMMFLAG, LOG_DEBUG, msg); 1614 1412 1615 1413 lastScore = fbp->score; 1616 curBlock++;1617 1414 } 1618 1415 1619 1416 LOG(VB_COMMFLAG, LOG_DEBUG, "============================================"); 1620 1417 LOG(VB_COMMFLAG, LOG_INFO, "FINAL Block stats"); 1621 1418 LOG(VB_COMMFLAG, LOG_DEBUG, … … void ClassicCommDetector::BuildAllMethodsCommList(void) 1624 1421 LOG(VB_COMMFLAG, LOG_DEBUG, 1625 1422 "----- ------ ------ ------ ------ ------- " 1626 1423 "--- ------ ------ ------ ----- ------ ------ -----"); 1627 curBlock = 0; 1628 lastScore = 0; 1424 lastScore = lastStart = lastEnd = 0; 1629 1425 breakStart = -1; 1630 while (curBlock <= maxBlock)1426 for (curBlock = 0; curBlock <= maxBlock; ++curBlock) 1631 1427 { 1632 1428 fbp = &fblock[curBlock]; 1633 1429 thisScore = fbp->score; 1634 1635 if ((breakStart >= 0) && 1636 ((fbp->end - breakStart) > (commDetectMaxCommBreakLength * fps))) 1430 if (thisScore == 0) 1431 thisScore = lastScore; 1432 lastScore = thisScore; 1433 1434 if (thisScore < 0 && breakStart == -1) 1637 1435 { 1638 if (((fbp->start - breakStart) > 1639 (commDetectMinCommBreakLength * fps)) || 1640 (breakStart == 0)) 1436 if (curBlock > 0 && 1437 (fbp->start - lastEnd) < (commDetectMinShowLength * fps)) 1641 1438 { 1439 commBreakMap.remove(lastStart); 1440 commBreakMap.remove(lastEnd); 1441 breakStart = lastStart; 1442 1642 1443 if (verboseDebugging) 1444 { 1643 1445 LOG(VB_COMMFLAG, LOG_DEBUG, 1644 QString("Closing commercial block at start of " 1645 "frame block %1 with length %2, frame " 1646 "block length of %3 frames would put comm " 1647 "block length over max of %4 seconds.") 1648 .arg(curBlock).arg(fbp->start - breakStart) 1649 .arg(fbp->frames) 1650 .arg(commDetectMaxCommBreakLength)); 1651 1652 commBreakMap[breakStart] = MARK_COMM_START; 1653 commBreakMap[fbp->start] = MARK_COMM_END; 1654 lastStart = breakStart; 1655 lastEnd = fbp->start; 1656 breakStart = -1; 1446 QString("ReOpening commercial block at " 1447 "frame %1 because show less than " 1448 "%2 seconds") 1449 .arg(breakStart) 1450 .arg(commDetectMinShowLength)); 1451 } 1657 1452 } 1658 1453 else 1659 1454 { 1455 breakStart = fbp->start; 1456 1660 1457 if (verboseDebugging) 1661 1458 LOG(VB_COMMFLAG, LOG_DEBUG, 1662 QString("Ignoring what appears to be commercial" 1663 " block at frame %1 with length %2, " 1664 "length of %3 frames would put comm " 1665 "block length under min of %4 seconds.") 1666 .arg(breakStart) 1667 .arg(fbp->start - breakStart) 1668 .arg(fbp->frames) 1669 .arg(commDetectMinCommBreakLength)); 1670 breakStart = -1; 1459 QString("Starting new commercial block at " 1460 "frame %1 from start of frame block %2") 1461 .arg(fbp->start).arg(curBlock)); 1671 1462 } 1463 lastStart = breakStart; 1672 1464 } 1673 if (thisScore == 0) 1465 1466 if(breakStart >= 0 && ( 1467 // Break should stop (by score) 1468 thisScore >= 0 || 1469 // Break must stop at end of recording 1470 curBlock == maxBlock || 1471 // Break will be too long 1472 (fbp->end - breakStart) >= commDetectMaxCommBreakLength * fps 1473 )) 1674 1474 { 1675 thisScore = lastScore; 1676 } 1677 else if (thisScore < 0) 1678 { 1679 if ((lastScore > 0) || (curBlock == 0)) 1475 unsigned int endOfBreak = fbp->start; 1476 if (thisScore < 0 && 1477 curBlock == maxBlock && 1478 (fbp->end - breakStart) < commDetectMaxCommBreakLength * fps) 1680 1479 { 1681 if ((fbp->start - lastEnd) < (commDetectMinShowLength * fps)) 1682 { 1683 commBreakMap.remove(lastStart); 1684 commBreakMap.remove(lastEnd); 1685 breakStart = lastStart; 1686 1687 if (verboseDebugging) 1688 { 1689 if (breakStart) 1690 LOG(VB_COMMFLAG, LOG_DEBUG, 1691 QString("ReOpening commercial block at " 1692 "frame %1 because show less than " 1693 "%2 seconds") 1694 .arg(breakStart) 1695 .arg(commDetectMinShowLength)); 1696 else 1697 LOG(VB_COMMFLAG, LOG_DEBUG, 1698 "Opening initial commercial block " 1699 "at start of recording, block 0."); 1700 } 1701 } 1702 else 1703 { 1704 breakStart = fbp->start; 1705 1706 if (verboseDebugging) 1707 LOG(VB_COMMFLAG, LOG_DEBUG, 1708 QString("Starting new commercial block at " 1709 "frame %1 from start of frame block %2") 1710 .arg(fbp->start).arg(curBlock)); 1711 } 1480 // Create what is essentially an open-ended final skip region 1481 // by setting the end point 10 seconds past the end of the 1482 // recording. 1483 endOfBreak = fbp->end + (10 * fps); 1484 1485 if (verboseDebugging) 1486 LOG(VB_COMMFLAG, LOG_DEBUG, 1487 " At end of recording."); 1712 1488 } 1713 else if (curBlock == maxBlock) 1489 1490 if ((endOfBreak - breakStart) >= (commDetectMinCommBreakLength * fps)) 1714 1491 { 1715 if ((fbp->end - breakStart) > 1716 (commDetectMinCommBreakLength * fps)) 1492 if (verboseDebugging) 1717 1493 { 1718 if (fbp->end <= 1719 ((int64_t)framesProcessed - (int64_t)(2 * fps) - 2)) 1494 LOG(VB_COMMFLAG, LOG_DEBUG, 1495 QString("Closing commercial block at " 1496 "frame %1 from frame block %2, length %3") 1497 .arg(endOfBreak).arg(curBlock) 1498 .arg(endOfBreak - breakStart)); 1499 1500 if (thisScore < 0 && 1501 (fbp->end - breakStart) >= commDetectMaxCommBreakLength * fps) 1720 1502 { 1721 if (verboseDebugging)1722 LOG(VB_COMMFLAG, LOG_DEBUG,1723 QString("Closing final commercial block at "1724 "frame %1").arg(fbp->end));1725 1726 commBreakMap[breakStart] = MARK_COMM_START;1727 commBreakMap[fbp->end] = MARK_COMM_END;1728 lastStart = breakStart;1729 lastEnd = fbp->end;1730 breakStart = -1;1731 }1732 }1733 else1734 {1735 if (verboseDebugging)1736 1503 LOG(VB_COMMFLAG, LOG_DEBUG, 1737 QString("Ignoring what appears to be commercial" 1738 " block at frame %1 with length %2, " 1739 "length of %3 frames would put comm " 1740 "block length under min of %4 seconds.") 1741 .arg(breakStart) 1742 .arg(fbp->start - breakStart) 1504 QString(" Frame block length of %1 frames would put comm " 1505 "block length over max of %2 seconds.") 1743 1506 .arg(fbp->frames) 1744 .arg(commDetectM inCommBreakLength));1745 breakStart = -1;1507 .arg(commDetectMaxCommBreakLength)); 1508 } 1746 1509 } 1747 } 1748 } 1749 else if ((thisScore > 0) && 1750 (lastScore < 0) && 1751 (breakStart != -1)) 1752 { 1753 if (((fbp->start - breakStart) > 1754 (commDetectMinCommBreakLength * fps)) || 1755 (breakStart == 0)) 1756 { 1510 1757 1511 commBreakMap[breakStart] = MARK_COMM_START; 1758 commBreakMap[ fbp->start] = MARK_COMM_END;1512 commBreakMap[endOfBreak] = MARK_COMM_END; 1759 1513 lastStart = breakStart; 1760 lastEnd = fbp->start; 1761 1762 if (verboseDebugging) 1763 LOG(VB_COMMFLAG, LOG_DEBUG, 1764 QString("Closing commercial block at frame %1") 1765 .arg(fbp->start)); 1514 lastEnd = endOfBreak; 1766 1515 } 1767 1516 else 1768 1517 { 1769 1518 if (verboseDebugging) 1770 1519 LOG(VB_COMMFLAG, LOG_DEBUG, 1771 QString("Ignoring what appears to be commercial " 1772 "block at frame %1 with length %2, " 1773 "length of %3 frames would put comm block " 1774 "length under min of %4 seconds.") 1520 QString("Ignoring what appears to be commercial" 1521 " block at frame %1 with length %2, " 1522 "block length would be under min of %3 seconds.") 1775 1523 .arg(breakStart) 1776 .arg(fbp->start - breakStart) 1777 .arg(fbp->frames) 1524 .arg(endOfBreak - breakStart) 1778 1525 .arg(commDetectMinCommBreakLength)); 1779 1526 } 1780 1527 breakStart = -1; 1781 1528 } 1782 1529 1783 1530 msg.sprintf("%5d %3d:%02d %6ld %6ld %6ld %7.2f %3d %6d %6d %6d " 1784 1531 "%5.2f %6d %6d %5d", 1785 1532 curBlock, (int)(fbp->start / fps) / 60, … … void ClassicCommDetector::BuildAllMethodsCommList(void) 1789 1536 fbp->scCount, fbp->scRate, fbp->formatMatch, 1790 1537 fbp->aspectMatch, thisScore); 1791 1538 LOG(VB_COMMFLAG, LOG_DEBUG, msg); 1792 1793 lastScore = thisScore;1794 curBlock++;1795 }1796 1797 if ((breakStart != -1) &&1798 (breakStart <= ((int64_t)framesProcessed - (int64_t)(2 * fps) - 2)))1799 {1800 if (verboseDebugging)1801 LOG(VB_COMMFLAG, LOG_DEBUG,1802 QString("Closing final commercial block started at "1803 "block %1 and going to end of program. length "1804 "is %2 frames")1805 .arg(curBlock)1806 .arg((framesProcessed - breakStart - 1)));1807 1808 commBreakMap[breakStart] = MARK_COMM_START;1809 // Create what is essentially an open-ended final skip region1810 // by setting the end point 10 seconds past the end of the1811 // recording.1812 commBreakMap[framesProcessed + (10 * fps)] = MARK_COMM_END;1813 1539 } 1814 1540 1815 1541 // include/exclude blanks from comm breaks … … void ClassicCommDetector::BuildAllMethodsCommList(void) 1821 1547 "Adjusting start/end marks according to blanks."); 1822 1548 for (it = tmpCommMap.begin(); it != tmpCommMap.end(); ++it) 1823 1549 { 1824 if (*it == MARK_COMM_START) 1825 { 1826 uint64_t lastStartLower = it.key(); 1827 uint64_t lastStartUpper = it.key(); 1828 while ((lastStartLower > 0) && 1829 (frameInfo[lastStartLower - 1].flagMask & COMM_FRAME_BLANK)) 1830 lastStartLower--; 1831 while ((lastStartUpper < (framesProcessed - (2 * fps))) && 1832 (frameInfo[lastStartUpper + 1].flagMask & COMM_FRAME_BLANK)) 1833 lastStartUpper++; 1834 uint64_t adj = (lastStartUpper - lastStartLower) / 2; 1835 if (adj > MAX_BLANK_FRAMES) 1836 adj = MAX_BLANK_FRAMES; 1837 lastStart = lastStartLower + adj; 1838 1839 if (verboseDebugging) 1840 LOG(VB_COMMFLAG, LOG_DEBUG, QString("Start Mark: %1 -> %2") 1841 .arg(it.key()).arg(lastStart)); 1842 1843 commBreakMap[lastStart] = MARK_COMM_START; 1844 } 1845 else 1846 { 1847 uint64_t lastEndLower = it.key(); 1848 uint64_t lastEndUpper = it.key(); 1849 while ((lastEndUpper < (framesProcessed - (2 * fps))) && 1850 (frameInfo[lastEndUpper + 1].flagMask & COMM_FRAME_BLANK)) 1851 lastEndUpper++; 1852 while ((lastEndLower > 0) && 1853 (frameInfo[lastEndLower - 1].flagMask & COMM_FRAME_BLANK)) 1854 lastEndLower--; 1855 uint64_t adj = (lastEndUpper - lastEndLower) / 2; 1856 if (adj > MAX_BLANK_FRAMES) 1857 adj = MAX_BLANK_FRAMES; 1858 lastEnd = lastEndUpper - adj; 1859 1860 if (verboseDebugging) 1861 LOG(VB_COMMFLAG, LOG_DEBUG, QString("End Mark : %1 -> %2") 1862 .arg(it.key()).arg(lastEnd)); 1863 1864 commBreakMap[lastEnd] = MARK_COMM_END; 1865 } 1550 uint64_t blankStart, blankEnd; 1551 blankStart = blankEnd = it.key(); 1552 1553 while (blankStart > 0 && frameInfo[blankStart].flagMask & COMM_FRAME_BLANK) 1554 --blankStart; 1555 while (blankEnd < framesProcessed && frameInfo[blankEnd].flagMask & COMM_FRAME_BLANK) 1556 ++blankEnd; 1557 1558 uint64_t split = blankStart + (blankEnd - blankStart) / 2; 1559 1560 commBreakMap[split] = *it; 1561 1562 if (verboseDebugging) 1563 LOG(VB_COMMFLAG, LOG_DEBUG, QString("Adjusted Mark %1: %2 -> %3") 1564 .arg(*it).arg(it.key()).arg(split)); 1866 1565 } 1867 1868 delete [] fblock;1869 1566 } 1870 1567 1871 1568 -
mythtv/programs/mythcommflag/ClassicCommDetector.h
diff --git a/mythtv/programs/mythcommflag/ClassicCommDetector.h b/mythtv/programs/mythcommflag/ClassicCommDetector.h index f9e5c4c..f397fec 100644
a b class ClassicCommDetector : public CommDetectorBase 142 142 bool blankFramesOnly; 143 143 int blankFrameCount; 144 144 int currentAspect; 145 145 unsigned char *colMax; 146 146 147 147 int totalMinBrightness; 148 148