[mythtv] [PATCH] Fix for commercial flagging using logo detection

Petter Gundersen pettergundersen at gmail.com
Thu Feb 17 08:42:43 UTC 2005


Looks like some code is missing from commercial_skip.cpp, so it is not
possible to flag commercials using logo detection only. The attached
patch should fix this.

The patch also adds some values to the edgeDiffs[] array. I have
experienced needing a value as high as 50 to detect the logo area.


Regards,
Petter
-------------- next part --------------
Index: mythtv/libs/libmythtv/commercial_skip.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/commercial_skip.h,v
retrieving revision 1.20
diff -u -r1.20 commercial_skip.h
--- mythtv/libs/libmythtv/commercial_skip.h	22 Jan 2005 13:46:59 -0000	1.20
+++ mythtv/libs/libmythtv/commercial_skip.h	17 Feb 2005 08:35:52 -0000
@@ -68,6 +68,7 @@
     void GetBlankCommBreakMap(QMap<long long, int> &breaks);
     void GetSceneChangeMap(QMap<long long, int> &scenes,
                            long long start_frame = -1);
+    void GetLogoCommBreakMap(QMap<long long, int> &map);
 
     void BuildMasterCommList(void);
     void BuildAllMethodsCommList(void);
Index: mythtv/libs/libmythtv/commercial_skip.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/commercial_skip.cpp,v
retrieving revision 1.38
diff -u -r1.38 commercial_skip.cpp
--- mythtv/libs/libmythtv/commercial_skip.cpp	4 Feb 2005 17:31:00 -0000	1.38
+++ mythtv/libs/libmythtv/commercial_skip.cpp	17 Feb 2005 08:35:53 -0000
@@ -1576,6 +1576,7 @@
 
 void CommDetect::BuildLogoCommList()
 {
+    GetLogoCommBreakMap(logoCommBreakMap);
     CondenseMarkMap(logoCommBreakMap, (int)(25 * fps), (int)(30 * fps));
     ConvertShowMapToCommMap(logoCommBreakMap);
 
@@ -2114,7 +2115,7 @@
     int maxLoops = 240;
     EdgeMaskEntry *edgeCounts;
     int pos, i, x, y, dx, dy;
-    int edgeDiffs[] = { 5, 7, 10, 0 };
+    int edgeDiffs[] = { 5, 7, 10, 15, 20, 30, 40, 50, 60, 0 };
 
  
     VERBOSE(VB_COMMFLAG, "Searching for Station Logo");
@@ -2462,5 +2463,36 @@
     }
 }
 
+void CommDetect::GetLogoCommBreakMap(QMap<long long, int> &map)
+{
+    VERBOSE(VB_COMMFLAG, "CommDetect::GetLogoCommBreakMap()");
+
+    map.clear();
+
+    int curFrame;
+    bool PrevFrameLogo;
+    bool CurrentFrameLogo;
+    
+    curFrame = 1;    
+    PrevFrameLogo = false;
+    
+    while (curFrame <= framesProcessed)
+    {
+        if (frameInfo[curFrame].flagMask & COMM_FRAME_LOGO_PRESENT)
+            CurrentFrameLogo = true;
+        else
+            CurrentFrameLogo = false;
+
+        if (!PrevFrameLogo && CurrentFrameLogo)
+            map[curFrame] = MARK_START;
+        else if (PrevFrameLogo && !CurrentFrameLogo)
+            map[curFrame] = MARK_END;
+
+        curFrame++;
+        PrevFrameLogo = CurrentFrameLogo;
+    }
+
+}
+
 
 /* vim: set expandtab tabstop=4 shiftwidth=4: */


More information about the mythtv-dev mailing list