summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--audio.cpp2
-rw-r--r--global.h8
-rw-r--r--markad-standalone.cpp42
-rw-r--r--markad-standalone.h1
-rw-r--r--marks.cpp9
-rw-r--r--marks.h12
-rw-r--r--video.cpp41
-rw-r--r--video.h2
8 files changed, 87 insertions, 30 deletions
diff --git a/audio.cpp b/audio.cpp
index f391b33..bd35ddc 100644
--- a/audio.cpp
+++ b/audio.cpp
@@ -154,7 +154,6 @@ MarkAdMark *cMarkAdAudio::Process(int LastIFrame)
char *buf=NULL;
if (asprintf(&buf,"audio channel silence detecion (%i)",lastiframe)!=-1)
{
- isyslog(buf);
AddMark(MT_SILENCECHANGE,lastiframe,buf);
free(buf);
}
@@ -167,7 +166,6 @@ MarkAdMark *cMarkAdAudio::Process(int LastIFrame)
if (asprintf(&buf,"audio channel change from %i to %i (%i)", channels,
macontext->Audio.Info.Channels,lastiframe)!=-1)
{
- isyslog(buf);
if (macontext->Audio.Info.Channels>2)
{
AddMark(MT_CHANNELSTART,lastiframe,buf);
diff --git a/global.h b/global.h
index 537df9f..1034ded 100644
--- a/global.h
+++ b/global.h
@@ -23,16 +23,24 @@ typedef unsigned char uchar;
#define MA_BI_TYPE 7
#define MT_COMMON 0x10
+
#define MT_ASPECTCHANGE 0x20
+
#define MT_CHANNELCHANGE 0x30
#define MT_CHANNELSTART 0x30
#define MT_CHANNELSTOP 0x31
+
+#define MT_LOGOCHANGE 0x40
#define MT_LOGOSTART 0x40
#define MT_LOGOSTOP 0x41
+
#define MT_BORDERCHANGE 0x50
#define MT_BORDERSTART 0x50
#define MT_BORDERSTOP 0x51
+
#define MT_SILENCECHANGE 0x60
+
+#define MT_MOVED 0xE0
#define MT_ALL 0xFF
typedef struct MarkAdMark
diff --git a/markad-standalone.cpp b/markad-standalone.cpp
index a36565c..e4f4b3c 100644
--- a/markad-standalone.cpp
+++ b/markad-standalone.cpp
@@ -91,6 +91,39 @@ void cMarkAdStandalone::AddMark(MarkAdMark *Mark)
if (!Mark) return;
if (!Mark->Type) return;
+ if (Mark->Type==MT_LOGOSTART)
+ {
+ // check if last mark is an aspectratio change
+ clMark *prev=marks.GetLast();
+ if ((prev) && (prev->type==MT_ASPECTCHANGE))
+ {
+ if ((Mark->Position-prev->position)<20)
+ {
+ if (Mark->Comment) isyslog(Mark->Comment);
+ isyslog("aspectratio change in low distance, moving mark (%i->%i)",Mark->Position,prev->position);
+ marks.Add(MT_MOVED,prev->position,Mark->Comment);
+ return;
+ }
+ }
+ }
+
+ if (((Mark->Type & 0xF0)==MT_LOGOCHANGE) && (macontext.Video.Info.FramesPerSecond>0))
+ {
+ // check if the distance to the last mark is large enough!
+ clMark *prev=marks.GetLast();
+ if ((prev) && ((prev->type & 0xF0)==MT_LOGOCHANGE))
+ {
+ int MINMARKDIFF=(int) (macontext.Video.Info.FramesPerSecond*60*2);
+ if ((Mark->Position-prev->position)<MINMARKDIFF)
+ {
+ if (Mark->Comment) isyslog(Mark->Comment);
+ isyslog("logo distance too short, deleting (%i,%i)",prev->position,Mark->Position);
+ marks.Del(prev);
+ return;
+ }
+ }
+ }
+
if (((Mark->Type & 0xF0)==MT_BORDERCHANGE) && (Mark->Position>25000) &&
(!macontext.Video.Options.IgnoreLogoDetection))
{
@@ -140,11 +173,13 @@ void cMarkAdStandalone::AddMark(MarkAdMark *Mark)
// Aspect- / Channelchange wins over Logo/Border
if (((old->type & 0xF0)!=MT_ASPECTCHANGE) && ((old->type & 0xF0)!=MT_CHANNELCHANGE))
{
+ if (Mark->Comment) isyslog(Mark->Comment);
marks.Add(Mark->Type,Mark->Position,Mark->Comment);
}
}
else
{
+ if (Mark->Comment) isyslog(Mark->Comment);
marks.Add(Mark->Type,Mark->Position,Mark->Comment);
}
}
@@ -307,7 +342,8 @@ bool cMarkAdStandalone::ProcessFile(const char *Directory, int Number)
framecnt++;
if (macontext.Video.Info.Pict_Type==MA_I_TYPE)
{
- lastiframe=framecnt-1;
+ lastiframe=iframe;
+ iframe=framecnt-1;
}
}
@@ -315,7 +351,7 @@ bool cMarkAdStandalone::ProcessFile(const char *Directory, int Number)
if ((decoder) && (bDecodeVideo)) dRes=decoder->DecodeVideo(&macontext,pkt,pktlen);
if (dRes)
{
- if ((framecnt-lastiframe)<=3)
+ if ((framecnt-iframe)<=3)
{
mark=video->Process(lastiframe);
AddMark(mark);
@@ -453,7 +489,6 @@ void cMarkAdStandalone::Process(const char *Directory)
{
tempmark.Comment=buf;
AddMark(&tempmark);
- isyslog(buf);
free(buf);
}
}
@@ -1041,6 +1076,7 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, bool BackupMarks, in
framecnt=0;
lastiframe=0;
+ iframe=0;
}
cMarkAdStandalone::~cMarkAdStandalone()
diff --git a/markad-standalone.h b/markad-standalone.h
index a5a62a4..01f381a 100644
--- a/markad-standalone.h
+++ b/markad-standalone.h
@@ -162,6 +162,7 @@ unsigned Descriptor_Length:
bool isTS;
int MaxFiles;
int lastiframe;
+ int iframe;
int framecnt;
bool abort;
int waittime;
diff --git a/marks.cpp b/marks.cpp
index e8fb449..543ed0d 100644
--- a/marks.cpp
+++ b/marks.cpp
@@ -128,7 +128,8 @@ clMark *clMarks::GetPrev(int Position, int Type)
}
mark=mark->Next();
}
- return mark->Prev();
+ if (mark) return mark->Prev();
+ return last;
}
clMark *clMarks::GetNext(int Position, int Type)
@@ -160,6 +161,7 @@ clMark *clMarks::Add(int Type, int Position,const char *Comment)
free(newmark->comment);
newmark->comment=strdup(Comment);
}
+ newmark->type=Type;
return newmark;
}
@@ -169,7 +171,7 @@ clMark *clMarks::Add(int Type, int Position,const char *Comment)
if (!first)
{
//first element
- first=newmark;
+ first=last=newmark;
count++;
return newmark;
}
@@ -185,6 +187,7 @@ clMark *clMarks::Add(int Type, int Position,const char *Comment)
// add as last element
newmark->Set(mark,NULL);
mark->SetNext(newmark);
+ last=newmark;
break;
}
else
@@ -210,7 +213,7 @@ clMark *clMarks::Add(int Type, int Position,const char *Comment)
{
if ((Position>mark->position) && (Position<mark->Next()->position))
{
- // add after mark
+ // add between two marks
newmark->Set(mark,mark->Next());
mark->SetNext(newmark);
break;
diff --git a/marks.h b/marks.h
index cc71760..611f6b7 100644
--- a/marks.h
+++ b/marks.h
@@ -75,7 +75,7 @@ uint16_t number:
};
char filename[1024];
- clMark *first;
+ clMark *first,*last;
char *IndexToHMSF(int Index, double FramesPerSecond);
int count;
int savedcount;
@@ -83,7 +83,7 @@ public:
clMarks()
{
strcpy(filename,"marks");
- first=NULL;
+ first=last=NULL;
savedcount=0;
count=0;
}
@@ -103,6 +103,14 @@ public:
clMark *Get(int Position);
clMark *GetPrev(int Position,int Type=0xFF);
clMark *GetNext(int Position,int Type=0xFF);
+ clMark *GetFirst()
+ {
+ return first;
+ }
+ clMark *GetLast()
+ {
+ return last;
+ }
bool Backup(const char *Directory, bool isTS);
bool Save(const char *Directory, double FrameRate, bool isTS);
bool CheckIndex(const char *Directory, bool isTS, bool *IndexError);
diff --git a/video.cpp b/video.cpp
index 6b607d1..f32faa9 100644
--- a/video.cpp
+++ b/video.cpp
@@ -202,7 +202,7 @@ int cMarkAdLogo::Detect(int lastiframe, int *logoiframe)
#endif
int ret=NOCHANGE;
- if (SUMA<100)
+ if ((SUMA<100) || ((area.status==LOGO) && (SUMA<180)))
{
int SUM;
@@ -296,6 +296,7 @@ int cMarkAdLogo::Detect(int lastiframe, int *logoiframe)
}
else
{
+ area.lastiframe=lastiframe;
area.counter=0;
}
}
@@ -312,7 +313,6 @@ int cMarkAdLogo::Detect(int lastiframe, int *logoiframe)
}
else
{
- if (!area.counter) area.lastiframe=lastiframe;
area.counter++;
}
}
@@ -327,10 +327,12 @@ int cMarkAdLogo::Detect(int lastiframe, int *logoiframe)
area.counter=0;
}
- //printf("%5i %3i %4i %4i %i %i %i\n",lastiframe,SUMA,area.rpixel,area.mpixel,
- // (area.rpixel>=(area.mpixel*LOGO_VMARK)),(area.rpixel<(area.mpixel*LOGO_IMARK)),
- // area.counter );
- //Save(lastiframe,area.sobel); // TODO: JUST FOR DEBUGGING!
+#if 0
+ printf("%5i %3i %4i %4i %i %i %i\n",lastiframe,SUMA,area.rpixel,area.mpixel,
+ (area.rpixel>=(area.mpixel*LOGO_VMARK)),(area.rpixel<(area.mpixel*LOGO_IMARK)),
+ area.counter );
+ Save(lastiframe,area.sobel); // TODO: JUST FOR DEBUGGING!
+#endif
}
else
{
@@ -428,8 +430,6 @@ int cMarkAdBlackBordersHoriz::Process(int LastIFrame, int *BorderIFrame)
if (xz<macontext->Video.Info.Width)
{
val+=macontext->Video.Data.Plane[0][x];
- macontext->Video.Data.Plane[0][x]=255;
-
cnt++;
}
xz++;
@@ -450,8 +450,6 @@ int cMarkAdBlackBordersHoriz::Process(int LastIFrame, int *BorderIFrame)
if (xz<macontext->Video.Info.Width)
{
val+=macontext->Video.Data.Plane[0][x];
- macontext->Video.Data.Plane[0][x]=255;
-
cnt++;
}
xz++;
@@ -469,18 +467,28 @@ int cMarkAdBlackBordersHoriz::Process(int LastIFrame, int *BorderIFrame)
}
else
{
- if (LastIFrame>(borderiframe+macontext->Video.Info.FramesPerSecond*60))
+#define MINSECS 60
+ switch (borderstatus)
{
- if (borderstatus==UNINITIALIZED)
+ case UNINITIALIZED:
+ if (LastIFrame>(borderiframe+macontext->Video.Info.FramesPerSecond*MINSECS))
{
borderstatus=BORDER;
}
- if (borderstatus==NOBORDER)
+ break;
+
+ case NOBORDER:
+ if (LastIFrame>(borderiframe+macontext->Video.Info.FramesPerSecond*MINSECS))
{
*BorderIFrame=borderiframe;
borderstatus=BORDER;
return 1; // detected start of black border
}
+ break;
+
+ case BORDER:
+ borderiframe=LastIFrame;
+ break;
}
}
}
@@ -490,7 +498,7 @@ int cMarkAdBlackBordersHoriz::Process(int LastIFrame, int *BorderIFrame)
{
if (borderstatus==BORDER)
{
- *BorderIFrame=LastIFrame;
+ *BorderIFrame=borderiframe;
borderstatus=NOBORDER;
borderiframe=-1;
return -1; // detected stop of black border
@@ -589,7 +597,6 @@ MarkAdMark *cMarkAdVideo::Process(int LastIFrame)
{
if (asprintf(&buf,"detected logo start (%i)",logoiframe)!=-1)
{
- isyslog(buf);
AddMark(MT_LOGOSTART,logoiframe,buf);
free(buf);
}
@@ -598,7 +605,6 @@ MarkAdMark *cMarkAdVideo::Process(int LastIFrame)
{
if (asprintf(&buf,"detected logo stop (%i)",logoiframe)!=-1)
{
- isyslog(buf);
AddMark(MT_LOGOSTOP,logoiframe,buf);
free(buf);
}
@@ -614,7 +620,6 @@ MarkAdMark *cMarkAdVideo::Process(int LastIFrame)
char *buf=NULL;
if (asprintf(&buf,"detected start of horiz. borders (%i)",borderiframe)!=-1)
{
- isyslog(buf);
AddMark(MT_BORDERSTART,borderiframe,buf);
free(buf);
}
@@ -625,7 +630,6 @@ MarkAdMark *cMarkAdVideo::Process(int LastIFrame)
char *buf=NULL;
if (asprintf(&buf,"detected stop of horiz. borders (%i)",borderiframe)!=-1)
{
- isyslog(buf);
AddMark(MT_BORDERSTOP,borderiframe,buf);
free(buf);
}
@@ -641,7 +645,6 @@ MarkAdMark *cMarkAdVideo::Process(int LastIFrame)
macontext->Video.Info.AspectRatio.Num,
macontext->Video.Info.AspectRatio.Den,LastIFrame)!=-1)
{
- isyslog(buf);
AddMark(MT_ASPECTCHANGE,LastIFrame,buf);
free(buf);
}
diff --git a/video.h b/video.h
index f0ed6d4..e5e35d4 100644
--- a/video.h
+++ b/video.h
@@ -30,7 +30,7 @@ extern "C"
#define LOGO_VMAXCOUNT 3 // count of IFrames for detection of "logo invisible"
#define LOGO_IMAXCOUNT 5 // count of IFrames for detection of "logo invisible"
-#define LOGO_VMARK 0.8 // percantage of pixels for visible
+#define LOGO_VMARK 0.5 // percantage of pixels for visible
#define LOGO_IMARK 0.15 // percentage of pixels for invisible
class cMarkAdLogo