summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2011-01-30 22:10:59 +0100
committerJochen Dolze <vdr@dolze.de>2011-01-30 22:10:59 +0100
commit9ec3fd7efb449fec370b64782adf32ce04bc96ae (patch)
tree34c681d3482d8952dbb5ecd3df202f74603723b8
parent70d113055698c6b73c8ed13af8a9e2f3b38ab1f0 (diff)
downloadvdr-plugin-markad-9ec3fd7efb449fec370b64782adf32ce04bc96ae.tar.gz
vdr-plugin-markad-9ec3fd7efb449fec370b64782adf32ce04bc96ae.tar.bz2
Further cleanups
-rw-r--r--command/audio.cpp67
-rw-r--r--command/audio.h9
-rw-r--r--command/demux.cpp4
-rw-r--r--command/global.h19
-rw-r--r--command/markad-standalone.cpp577
-rw-r--r--command/markad-standalone.h22
-rw-r--r--command/video.cpp89
-rw-r--r--command/video.h5
8 files changed, 182 insertions, 610 deletions
diff --git a/command/audio.cpp b/command/audio.cpp
index 082010f..1b8ca5c 100644
--- a/command/audio.cpp
+++ b/command/audio.cpp
@@ -16,63 +16,37 @@
cMarkAdAudio::cMarkAdAudio(MarkAdContext *maContext)
{
macontext=maContext;
- mark.Comment=NULL;
mark.Position=0;
mark.Type=0;
- result.CommentBefore=NULL;
- result.CommentAfter=NULL;
Clear();
}
cMarkAdAudio::~cMarkAdAudio()
{
- ResetMark();
+ resetmark();
Clear();
}
void cMarkAdAudio::Clear()
{
channels=0;
- if (result.CommentBefore) free(result.CommentBefore);
- if (result.CommentAfter) free(result.CommentAfter);
- memset(&result,0,sizeof(result));
}
-void cMarkAdAudio::ResetMark()
+void cMarkAdAudio::resetmark()
{
if (!mark.Type) return;
- if (mark.Comment) free(mark.Comment);
- mark.Comment=NULL;
- mark.Position=0;
- mark.Type=0;
+ memset(&mark,0,sizeof(mark));
}
-bool cMarkAdAudio::AddMark(int Type, int Position, const char *Comment)
+void cMarkAdAudio::setmark(int type, int position, int channelsbefore, int channelsafter)
{
- if (!Comment) return false;
- if (mark.Comment)
- {
- int oldlen=strlen(mark.Comment);
- mark.Comment=(char *) realloc(mark.Comment,oldlen+10+strlen(Comment));
- if (!mark.Comment)
- {
- mark.Position=0;
- return false;
- }
- strcat(mark.Comment," [");
- strcat(mark.Comment,Comment);
- strcat(mark.Comment,"]");
- }
- else
- {
- mark.Comment=strdup(Comment);
- }
- mark.Position=Position;
- mark.Type=Type;
- return true;
+ mark.ChannelsBefore=channelsbefore;
+ mark.ChannelsAfter=channelsafter;
+ mark.Position=position;
+ mark.Type=type;
}
-bool cMarkAdAudio::ChannelChange(int a, int b)
+bool cMarkAdAudio::channelchange(int a, int b)
{
if ((a==0) || (b==0)) return false;
if (a!=b) return true;
@@ -82,33 +56,18 @@ bool cMarkAdAudio::ChannelChange(int a, int b)
MarkAdMark *cMarkAdAudio::Process(int FrameNumber, int FrameNumberNext)
{
if ((!FrameNumber) || (!FrameNumberNext)) return NULL;
- ResetMark();
+ resetmark();
- if (ChannelChange(macontext->Audio.Info.Channels,channels))
+ if (channelchange(macontext->Audio.Info.Channels,channels))
{
- char *buf=(char *) calloc(1,256);
- if (!buf) return NULL;
-
- snprintf(buf,255,"audio channel change from %i to %i (", channels,
- macontext->Audio.Info.Channels);
-
if (macontext->Audio.Info.Channels>2)
{
- char nbuf[20];
- snprintf(nbuf,sizeof(nbuf),"%i)*",FrameNumberNext);
- nbuf[19]=0;
- strcat(buf,nbuf);
- AddMark(MT_CHANNELSTART,FrameNumberNext,buf);
+ setmark(MT_CHANNELSTART,FrameNumberNext,macontext->Audio.Info.Channels,channels);
}
else
{
- char nbuf[20];
- snprintf(nbuf,sizeof(nbuf),"%i)",framelast);
- nbuf[19]=0;
- strcat(buf,nbuf);
- AddMark(MT_CHANNELSTOP,framelast,buf);
+ setmark(MT_CHANNELSTOP,framelast,macontext->Audio.Info.Channels,channels);
}
- free(buf);
}
channels=macontext->Audio.Info.Channels;
diff --git a/command/audio.h b/command/audio.h
index 6bb2b2e..4c6c819 100644
--- a/command/audio.h
+++ b/command/audio.h
@@ -16,14 +16,11 @@ private:
MarkAdContext *macontext;
MarkAdMark mark;
- void ResetMark();
- bool AddMark(int Type, int Position, const char *Comment);
-
+ void resetmark();
+ void setmark(int type, int position, int channelsbefore, int channelsafter);
int channels;
- bool ChannelChange(int a, int b);
+ bool channelchange(int a, int b);
int framelast;
-
- MarkAdPos result;
public:
cMarkAdAudio(MarkAdContext *maContext);
~cMarkAdAudio();
diff --git a/command/demux.cpp b/command/demux.cpp
index 9c9bcc8..f185935 100644
--- a/command/demux.cpp
+++ b/command/demux.cpp
@@ -575,7 +575,7 @@ cTS2Pkt::~cTS2Pkt()
{
if (queue)
{
- if (skipped) esyslog("buffer skipped: %-15s %i bytes",queue->Name(),skipped);
+ if (skipped) tsyslog("buffer skipped: %-15s %i bytes",queue->Name(),skipped);
delete queue;
}
}
@@ -733,7 +733,7 @@ cPES2ES::~cPES2ES()
{
if (queue)
{
- if (skipped) esyslog("buffer skipped: %-15s %i bytes",queue->Name(),skipped);
+ if (skipped) tsyslog("buffer skipped: %-15s %i bytes",queue->Name(),skipped);
delete queue;
}
}
diff --git a/command/global.h b/command/global.h
index bfd4703..51da106 100644
--- a/command/global.h
+++ b/command/global.h
@@ -86,11 +86,22 @@ typedef struct MarkAdPos
char *CommentAfter;
} MarkAdPos;
+typedef struct MarkAdAspectRatio
+{
+ int Num;
+ int Den;
+} MarkAdAspectRatio;
+
typedef struct MarkAdMark
{
char Type;
int Position;
- char *Comment;
+ int ChannelsBefore;
+ int ChannelsAfter;
+ MarkAdAspectRatio AspectRatioBefore;
+ MarkAdAspectRatio AspectRatioAfter;
+ bool VerticalBorders;
+ bool Assumed;
} MarkAdMark;
typedef struct MarkAdMarks
@@ -100,12 +111,6 @@ typedef struct MarkAdMarks
int Count;
} MarkAdMarks;
-typedef struct MarkAdAspectRatio
-{
- int Num;
- int Den;
-} MarkAdAspectRatio;
-
#define MARKAD_PIDTYPE_VIDEO_H262 0x10
#define MARKAD_PIDTYPE_VIDEO_H264 0x11
#define MARKAD_PIDTYPE_AUDIO_AC3 0x20
diff --git a/command/markad-standalone.cpp b/command/markad-standalone.cpp
index 70d9aa7..1320c3b 100644
--- a/command/markad-standalone.cpp
+++ b/command/markad-standalone.cpp
@@ -179,21 +179,9 @@ int cOSDMessage::Send(const char *format, ...)
return 0;
}
-void cMarkAdStandalone::AddStartMark()
+void cMarkAdStandalone::InitStartStop()
{
-#if 0
- char *buf;
- if (asprintf(&buf,"start of recording (0)")!=-1)
- {
- MarkAdMark Mark;
- Mark.Position=0;
- Mark.Type=MT_COMMONSTART;
- Mark.Comment=buf;
- AddMark(&Mark);
- free(buf);
- }
-#endif
-
+ if (!macontext.Video.Info.FramesPerSecond) return;
if (tStart)
{
iStart=-(tStart*macontext.Video.Info.FramesPerSecond);
@@ -384,124 +372,7 @@ void cMarkAdStandalone::CheckStartStop(int frame, bool checkend)
iStopCheck=iStop+MARKDIFF;
}
}
-
-void cMarkAdStandalone::CheckLogoMarks(clMark *last)
-{
- clMark *mark=marks.GetFirst();
- while (mark)
- {
- if ((mark->type==MT_LOGOSTOP) && mark->Next() && mark->Next()->type==MT_LOGOSTART)
- {
- int MARKDIFF=(int) (macontext.Video.Info.FramesPerSecond*55);
- if (abs(mark->Next()->position-mark->position)<=MARKDIFF)
- {
- double distance=(mark->Next()->position-mark->position)/
- macontext.Video.Info.FramesPerSecond;
- isyslog("logo distance too short (%.1fs), deleting (%i,%i)",distance,
- mark->position,mark->Next()->position);
- clMark *tmp=mark;
- mark=mark->Next()->Next();
- marks.Del(tmp->Next());
- marks.Del(tmp);
- continue;
- }
- }
- mark=mark->Next();
- if ((last) && (mark==last)) return;
- }
-}
-
-void cMarkAdStandalone::CheckLastMark()
-{
- if (marks.Count()<=2) return; // just two marks -> do nothing
- clMark *last=marks.GetLast();
- if (!last) return;
-
- clMark *nexttolast=last->Prev();
- if (!nexttolast) return;
-
- if ((last->type & 0xF)==(nexttolast->type & 0xF))
- {
- isyslog("removing double stop mark (%i)",last->position);
- marks.Del(last);
- return;
- }
-}
-
-void cMarkAdStandalone::CheckFirstMark()
-{
- if (marksAligned) return;
- clMark *first=marks.GetFirst();
- if (!first) return;
-
- // Check the second mark
- clMark *second=first->Next();
- if (!second) return;
-
- if ((marks.Count(MT_BORDERCHANGE,0xF0)>0) && (marks.Count(MT_ASPECTCHANGE,0xF0)>0))
- {
- // wait till its clear, if we use ASPECT or BORDER
- return;
- }
-
- if ((second->type & 0xF)==MT_START)
- {
- bool delsec=false;
- clMark *third=second->Next();
- if (third)
- {
- if ((third->type & 0xF)==MT_START) delsec=true;
- }
- if (delsec)
- {
- isyslog("removing double start marks (%i,%i)",first->position,second->position);
- marks.Del(second);
- }
- else
- {
- isyslog("removing double start mark (%i)",first->position);
- }
- marks.Del(first);
- marksAligned=true;
- first=marks.GetFirst();
- if (first)
- {
- CalculateStopPosition(first->position,macontext.Video.Info.FramesPerSecond*MAXRANGE);
- }
- return;
- }
-
- if ((second->type & 0xF)==MT_STOP)
- {
- marksAligned=true;
- return;
- }
-
- // If we have an aspectchange, check the next aspectchange mark
- // and the difference between
- if ((second->type==MT_ASPECTCHANGE) && (length))
- {
- clMark *next=marks.GetNext(second->position,MT_ASPECTCHANGE);
- if (next)
- {
- int maxlen=length*(13*60)/(90*60); // max 13 minutes ads on 90 minutes program
- if (maxlen>(13*60)) maxlen=(13*60); // maximum ad block = 13 minutes
- int MAXPOSDIFF=(int) (macontext.Video.Info.FramesPerSecond*maxlen);
- if ((next->position-second->position)>MAXPOSDIFF)
- {
- clMark *first=marks.GetFirst();
- if (first)
- {
- isyslog("removing unaligned start mark (%i)",first->position);
- marks.Del(first);
- marksAligned=true;
- return;
- }
- }
- }
- }
- return;
-}
+#endif
void cMarkAdStandalone::CheckAspectRatio_and_AudioChannels()
{
@@ -509,63 +380,53 @@ void cMarkAdStandalone::CheckAspectRatio_and_AudioChannels()
dsyslog("checking aspectratio and audio channels");
- if (!macontext.Info.Channels)
+ macontext.Info.Channels=macontext.Audio.Info.Channels;
+ if (macontext.Info.Channels==6)
{
- macontext.Info.Channels=macontext.Audio.Info.Channels;
- if (macontext.Info.Channels==2) setAudio20=true;
- if (macontext.Info.Channels==6)
+ isyslog("DolbyDigital5.1 audio detected. logo/border detection disabled");
+ bDecodeVideo=false;
+ marks.Del(MT_ASPECTSTART);
+ marks.Del(MT_ASPECTSTOP);
+ // start mark must be first MT_CHANNELSTART
+ clMark *begin=marks.GetNext(1,MT_CHANNELSTART);
+ if (begin)
{
- isyslog("DolbyDigital5.1 audio detected. logo/border detection disabled");
- bDecodeVideo=false;
- setAudio20=false;
- setAudio51=true;
- reprocess=true;
+ marks.DelTill(begin->position);
+ CalculateStopPosition(begin->position,0);
}
}
- bool aSet=false;
- if (!macontext.Info.AspectRatio.Num)
- {
- isyslog("assuming aspectratio of %i:%i",
- macontext.Video.Info.AspectRatio.Num,macontext.Video.Info.AspectRatio.Den);
- aSet=true;
- }
- else
+ macontext.Info.AspectRatio.Num=macontext.Video.Info.AspectRatio.Num;
+ macontext.Info.AspectRatio.Den=macontext.Video.Info.AspectRatio.Den;
+
+ isyslog("aspectratio of %i:%i detected. %s",
+ macontext.Video.Info.AspectRatio.Num,
+ macontext.Video.Info.AspectRatio.Den,
+ ((macontext.Video.Info.AspectRatio.Num==4) &&
+ (macontext.Video.Info.AspectRatio.Den==3)) ?
+ "logo/border detection disabled" : "");
+
+ if ((macontext.Video.Info.AspectRatio.Num==4) &&
+ (macontext.Video.Info.AspectRatio.Den==3))
{
- if (!bIgnoreVideoInfo)
+ bDecodeVideo=false;
+ marks.Del(MT_CHANNELSTART);
+ marks.Del(MT_CHANNELSTOP);
+ // start mark must be first MT_ASPECTSTART
+ clMark *begin=marks.GetNext(1,MT_ASPECTSTART);
+ if (begin)
{
- if ((macontext.Info.AspectRatio.Num!=macontext.Video.Info.AspectRatio.Num) &&
- (macontext.Info.AspectRatio.Den!=macontext.Video.Info.AspectRatio.Den))
- {
- isyslog("aspectratio in info wrong %i:%i instead of %i:%i",
- macontext.Video.Info.AspectRatio.Num,macontext.Video.Info.AspectRatio.Den,
- macontext.Info.AspectRatio.Num,macontext.Info.AspectRatio.Den);
- aSet=true;
- }
+ marks.DelTill(begin->position);
+ CalculateStopPosition(begin->position,0);
}
}
- if (aSet)
+ if (!bDecodeVideo)
{
- macontext.Info.AspectRatio.Num=macontext.Video.Info.AspectRatio.Num;
- macontext.Info.AspectRatio.Den=macontext.Video.Info.AspectRatio.Den;
-
- if ((macontext.Info.AspectRatio.Num==16) &&
- (macontext.Info.AspectRatio.Den==9))
- {
- macontext.Video.Options.IgnoreAspectRatio=true;
- setVideo169=true;
- setVideo43=false;
- setVideo43LB=false;
- }
-
- if ((macontext.Info.AspectRatio.Num==4) &&
- (macontext.Info.AspectRatio.Den==3))
- {
- setVideo43=true;
- setVideo169=false;
- }
- reprocess=true;
+ marks.Del(MT_LOGOSTART);
+ marks.Del(MT_LOGOSTOP);
+ marks.Del(MT_BORDERSTART);
+ marks.Del(MT_BORDERSTOP);
}
aspectChecked=true;
@@ -574,240 +435,62 @@ void cMarkAdStandalone::CheckAspectRatio_and_AudioChannels()
void cMarkAdStandalone::AddMark(MarkAdMark *Mark)
{
- if (gotendmark) return;
if (!Mark) return;
if (!Mark->Type) return;
- if (!macontext.Video.Info.FramesPerSecond) return;
-
- bool loggedAlready=false;
- if (Mark->Type==MT_ASPECTSTOP)
+ char *comment=NULL;
+ switch (Mark->Type)
{
- // check if last mark is an stop mark in short distance
- clMark *prev=marks.GetLast();
- if (prev)
- {
- if ((prev->type & 0xF)==MT_STOP)
- {
- int MARKDIFF=(int) (macontext.Video.Info.FramesPerSecond*15);
- if ((Mark->Position-prev->position)<MARKDIFF)
- {
- if (Mark->Comment) isyslog("%s",Mark->Comment);
- isyslog("double stop mark in short distance, deleting this mark (%i)",prev->position);
- marks.Del(prev);
- loggedAlready=true;
- }
- }
- if (prev->type==MT_ASPECTSTART)
- {
- int MARKDIFF=(int) macontext.Video.Info.FramesPerSecond;
- if ((Mark->Position-prev->position)<MARKDIFF)
- {
- if (Mark->Comment) isyslog("%s",Mark->Comment);
- double distance=(Mark->Position-prev->position)/macontext.Video.Info.FramesPerSecond;
- isyslog("aspect mark distance too short (%.1fs), deleting (%i,%i)",distance,
- prev->position,Mark->Position);
- marks.Del(prev);
- return;
- }
- }
- }
- }
-
- if (Mark->Type==MT_CHANNELSTART)
- {
- clMark *prev=marks.GetPrev(Mark->Position,MT_CHANNELSTOP);
- if (prev)
- {
- int MARKDIFF=(int) macontext.Video.Info.FramesPerSecond;
- if ((Mark->Position-prev->position)<MARKDIFF)
- {
- if (Mark->Comment) isyslog("%s",Mark->Comment);
- double distance=(Mark->Position-prev->position)/macontext.Video.Info.FramesPerSecond;
- isyslog("channel distance too short (%.1fs), deleting (%i,%i)",distance,
- prev->position,Mark->Position);
- marks.Del(prev);
- return;
- }
- }
- }
-
- clMark *old=marks.Get(Mark->Position);
- if ((old) && (((old->type & 0xF0)==MT_ASPECTCHANGE) || ((old->type & 0xF0)==MT_CHANNELCHANGE)))
- {
- // Aspect- / Channelchange wins over Logo/Border
- return;
- }
-
- if (Mark->Type==MT_LOGOSTOP)
- {
- // check if last mark is an audiochannel stop
- clMark *prev=marks.GetLast();
- if ((prev) && (prev->type==MT_CHANNELSTOP))
- {
- int MARKDIFF=(int) (macontext.Video.Info.FramesPerSecond*15);
- if ((Mark->Position-prev->position)<MARKDIFF)
- {
- if (Mark->Comment) isyslog("%s",Mark->Comment);
- isyslog("audiochannel change in short distance, using this mark (%i->%i)",Mark->Position,prev->position);
- return;
- }
- }
-
- prev=marks.GetPrev(Mark->Position,MT_LOGOSTART);
- if (prev)
- {
- int MARKDIFF=(int) (macontext.Video.Info.FramesPerSecond*240);
- if ((Mark->Position-prev->position)<MARKDIFF)
- {
- if (Mark->Comment) isyslog("%s",Mark->Comment);
- double distance=(Mark->Position-prev->position)/macontext.Video.Info.FramesPerSecond;
- isyslog("logo distance too short (%.1fs), deleting (%i,%i)",distance,
- prev->position,Mark->Position);
- marks.Del(prev);
- return;
- }
- }
- }
-
- if (Mark->Type==MT_LOGOSTART)
- {
- // check if last mark is an aspectratio change
- clMark *prev=marks.GetLast();
- if (prev)
- {
- if ((prev->type & 0xF0)==MT_ASPECTCHANGE)
- {
- int MARKDIFF=(int) (macontext.Video.Info.FramesPerSecond*5);
- if ((Mark->Position-prev->position)<MARKDIFF)
- {
- if (Mark->Comment) isyslog("%s",Mark->Comment);
- isyslog("aspectratio change in short distance, deleting this mark (%i)",
- Mark->Position);
- return;
- }
- }
-
- if (prev->type==MT_CHANNELSTART)
- {
- int MARKDIFF=(int) (macontext.Video.Info.FramesPerSecond*5);
- if ((Mark->Position-prev->position)<MARKDIFF)
- {
- if (Mark->Comment) isyslog("%s",Mark->Comment);
- isyslog("audiochannel change in short distance, deleting this mark (%i)",
- Mark->Position);
- return;
- }
- }
- }
- }
-
- if (length>0)
- {
- if ((Mark->Type==MT_BORDERSTART) && (Mark->Position>chkLEFT) &&
- (Mark->Position<chkRIGHT) && (!macontext.Video.Options.IgnoreLogoDetection))
- {
- if (Mark->Comment)
- {
- isyslog("%s",Mark->Comment);
- loggedAlready=true;
- }
- isyslog("border changes detected. logo detection disabled");
- macontext.Video.Options.IgnoreLogoDetection=true;
- marks.Del((uchar) MT_LOGOSTART);
- marks.Del((uchar) MT_LOGOSTOP);
- }
-
- bool deleteLogoBorder=false;
- if (((Mark->Type & 0xF0)==MT_CHANNELCHANGE) && (Mark->Position>chkLEFT) &&
- (Mark->Position<chkRIGHT) && (macontext.Info.Channels!=6))
- {
- if (!loggedAlready)
- {
- if (Mark->Comment)
- {
- isyslog("%s",Mark->Comment);
- loggedAlready=true;
- }
- }
- isyslog("audio channel changes detected. logo/border detection disabled");
- if (macontext.Info.VPid.Type==MARKAD_PIDTYPE_VIDEO_H262)
- {
- if (!macontext.Info.AspectRatio.Num)
- {
- isyslog("assuming broadcast aspectratio is 16:9");
- macontext.Info.AspectRatio.Num=16;
- macontext.Info.AspectRatio.Den=9;
- macontext.Video.Options.IgnoreAspectRatio=true;
- }
- }
- macontext.Info.Channels=6;
- setAudio51=true;
- setAudio20=false;
- reprocess=true;
- deleteLogoBorder=true;
- }
-
- if (((Mark->Type & 0xF0)==MT_ASPECTCHANGE) && (Mark->Position>chkLEFT) &&
- (Mark->Position<chkRIGHT) && (!macontext.Video.Options.IgnoreLogoDetection))
+ case MT_LOGOSTART:
+ if (asprintf(&comment,"detected logo start (%i)*",Mark->Position)==-1) comment=NULL;
+ break;
+ case MT_LOGOSTOP:
+ if (asprintf(&comment,"detected logo stop (%i)",Mark->Position)==-1) comment=NULL;
+ break;
+ case MT_BORDERSTART:
+ if (asprintf(&comment,"detected start of %s borders (%i)*",
+ Mark->VerticalBorders ? "vert." : "horiz.",
+ Mark->Position)==-1) comment=NULL;
+ break;
+ case MT_BORDERSTOP:
+ if (asprintf(&comment,"detected stop of %s borders (%i)",
+ Mark->VerticalBorders ? "vert." : "horiz.",
+ Mark->Position)==-1) comment=NULL;
+ break;
+ case MT_ASPECTSTART:
+ if (!Mark->AspectRatioBefore.Num)
{
- if (!loggedAlready)
- {
- if (Mark->Comment)
- {
- isyslog("%s",Mark->Comment);
- loggedAlready=true;
- }
- }
- isyslog("aspectratio changes detected. logo/border detection disabled");
-
- if (!macontext.Info.AspectRatio.Num)
- {
- isyslog("assuming broadcast aspectratio is 4:3");
- macontext.Info.AspectRatio.Num=4;
- macontext.Info.AspectRatio.Den=3;
- reprocess=true;
- setVideo43=true;
- }
- else
- {
- if ((macontext.Info.AspectRatio.Num==4) &&
- (macontext.Info.AspectRatio.Den==3))
- {
- if (marks.Count(MT_BORDERSTART)>0)
- {
- isyslog("assuming broadcast is in letterbox format");
- setVideo43LB=true;
- setVideo43=false;
- }
- }
- }
- deleteLogoBorder=true;
+ if (asprintf(&comment,"aspectratio start with %i:%i (%i)*",
+ Mark->AspectRatioAfter.Num,Mark->AspectRatioAfter.Den,
+ Mark->Position)==-1) comment=NULL;
}
-
- if (deleteLogoBorder)
+ else
{
- bDecodeVideo=false;
- macontext.Video.Options.IgnoreLogoDetection=true;
- macontext.Video.Data.Valid=false;
- marks.Del((uchar) MT_LOGOSTART);
- marks.Del((uchar) MT_LOGOSTOP);
- marks.Del((uchar) MT_BORDERSTART);
- marks.Del((uchar) MT_BORDERSTOP);
+ if (asprintf(&comment,"aspectratio change from %i:%i to %i:%i (%i)*",
+ Mark->AspectRatioBefore.Num,Mark->AspectRatioBefore.Den,
+ Mark->AspectRatioAfter.Num,Mark->AspectRatioAfter.Den,
+ Mark->Position)==-1) comment=NULL;
}
+ break;
+ case MT_ASPECTSTOP:
+ if (asprintf(&comment,"aspectratio change from %i:%i to %i:%i (%i)",
+ Mark->AspectRatioBefore.Num,Mark->AspectRatioBefore.Den,
+ Mark->AspectRatioAfter.Num,Mark->AspectRatioAfter.Den,
+ Mark->Position)==-1) comment=NULL;
+ break;
+ case MT_CHANNELSTART:
+ if (asprintf(&comment,"audio channel change from %i to %i (%i)*",
+ Mark->ChannelsBefore,Mark->ChannelsAfter,
+ Mark->Position)==-1) comment=NULL;
+ break;
+ case MT_CHANNELSTOP:
+ if (asprintf(&comment,"audio channel change from %i to %i (%i)",
+ Mark->ChannelsBefore,Mark->ChannelsAfter,
+ Mark->Position)==-1) comment=NULL;
+ break;
}
- if ((iStart==0) && (!marksAligned)) CheckFirstMark();
- if (marksAligned) CheckLogoMarks(marks.GetLast());
-
- if ((Mark->Comment) && (!loggedAlready)) isyslog("%s",Mark->Comment);
- marks.Add(Mark->Type,Mark->Position,Mark->Comment);
-}
-#endif
-void cMarkAdStandalone::AddMark(MarkAdMark *Mark)
-{
- if (!Mark) return;
- if (!Mark->Type) return;
+ if (comment) isyslog("%s",comment);
if ((Mark->Type & 0x0F)==MT_STOP)
{
@@ -825,10 +508,10 @@ void cMarkAdStandalone::AddMark(MarkAdMark *Mark)
}
if ((Mark->Position-prev->position)<MARKDIFF)
{
- if (Mark->Comment) isyslog("%s",Mark->Comment);
double distance=(Mark->Position-prev->position)/macontext.Video.Info.FramesPerSecond;
isyslog("mark distance too short (%.1fs), deleting %i,%i",distance,
prev->position,Mark->Position);
+ if ((prev->type & 0x0F)==MT_START) inBroadCast=false;
marks.Del(prev);
return;
}
@@ -844,7 +527,6 @@ void cMarkAdStandalone::AddMark(MarkAdMark *Mark)
int diff=abs(Mark->Position-prev->position);
if (diff<MARKDIFF)
{
- if (Mark->Comment) isyslog("%s",Mark->Comment);
if (prev->type>Mark->Type)
{
isyslog("previous mark (%i) stronger than actual mark, deleting %i",
@@ -855,15 +537,20 @@ void cMarkAdStandalone::AddMark(MarkAdMark *Mark)
{
isyslog("actual mark stronger then previous mark, deleting %i",prev->position);
marks.Del(prev);
- marks.Add(Mark->Type,Mark->Position,Mark->Comment);
- return;
}
}
}
}
- isyslog("%s",Mark->Comment);
- marks.Add(Mark->Type,Mark->Position,Mark->Comment);
+ if ((Mark->Type & 0x0F)==MT_START)
+ {
+ inBroadCast=true;
+ }
+ else
+ {
+ inBroadCast=false;
+ }
+ marks.Add(Mark->Type,Mark->Position,comment);
}
void cMarkAdStandalone::SaveFrame(int frame)
@@ -891,23 +578,7 @@ void cMarkAdStandalone::SaveFrame(int frame)
fclose(pFile);
}
-#if 0
-void cMarkAdStandalone::CheckBroadcastLength()
-{
- if (length) return;
- if (!macontext.Video.Info.FramesPerSecond) return;
- /* get broadcastlength from length of indexFile */
- int tframecnt=1;
- int iIndexError;
- marks.CheckIndex(directory,isTS,&tframecnt,&iIndexError);
- if (iIndexError!=0) return;
- length=tframecnt/macontext.Video.Info.FramesPerSecond;
- isyslog("got broadcast length of %im from index",length/60);
- reprocess=true;
-}
-#endif
-
-bool cMarkAdStandalone::CheckIndexGrowing()
+void cMarkAdStandalone::CheckIndexGrowing()
{
// Here we check if the index is more
// advanced than our framecounter.
@@ -916,15 +587,15 @@ bool cMarkAdStandalone::CheckIndexGrowing()
#define WAITTIME 15
- if (!indexFile) return false;
- if (macontext.Config->logoExtraction!=-1) return false;
- if (sleepcnt>=2) return false; // we already slept too much
+ if (!indexFile) return;
+ if (macontext.Config->logoExtraction!=-1) return;
+ if (sleepcnt>=2) return; // we already slept too much
bool notenough=true;
do
{
struct stat statbuf;
- if (stat(indexFile,&statbuf)==-1) return false;
+ if (stat(indexFile,&statbuf)==-1) return;
int maxframes=statbuf.st_size/8;
if (maxframes<(framecnt+200))
@@ -936,7 +607,7 @@ bool cMarkAdStandalone::CheckIndexGrowing()
if (time(NULL)>(startTime+(time_t) length))
{
// "old" recording
- return false;
+ return;
}
else
{
@@ -948,13 +619,13 @@ bool cMarkAdStandalone::CheckIndexGrowing()
else
{
// "old" recording
- return false;
+ return;
}
}
marks.Save(directory,macontext.Video.Info.FramesPerSecond,isTS);
sleep(WAITTIME); // now we sleep and hopefully the index will grow
waittime+=WAITTIME;
- if (errno==EINTR) return false;
+ if (errno==EINTR) return;
sleepcnt++;
if (sleepcnt>=2)
{
@@ -975,8 +646,7 @@ bool cMarkAdStandalone::CheckIndexGrowing()
}
}
while (notenough);
- if (!sleepcnt) return true;
- else return false;
+ return;
}
void cMarkAdStandalone::ChangeMarks(clMark **Mark1, clMark **Mark2, MarkAdPos *NewPos)
@@ -1297,10 +967,8 @@ bool cMarkAdStandalone::ProcessFile(int Number)
noticeHEADER=true;
}
- if (!framecnt)
- {
- AddStartMark();
- }
+ if (!framecnt) InitStartStop();
+
if (macontext.Config->GenIndex)
{
marks.WriteIndex(directory,isTS,demux->Offset(),macontext.Video.Info.Pict_Type,Number);
@@ -1310,10 +978,8 @@ bool cMarkAdStandalone::ProcessFile(int Number)
if (macontext.Video.Info.Pict_Type==MA_I_TYPE)
{
lastiframe=iframe;
-#if 0
- CheckStartStop(lastiframe);
- if (lastiframe>chkLEFT) CheckAspectRatio_and_AudioChannels();
-#endif
+ //CheckStartStop(lastiframe);
+ if ((iStart) && (lastiframe>chkLEFT)) CheckAspectRatio_and_AudioChannels();
iframe=framecnt-1;
dRes=true;
}
@@ -1338,7 +1004,7 @@ bool cMarkAdStandalone::ProcessFile(int Number)
AddMark(&vmarks->Number[i]);
}
}
- SaveFrame(lastiframe); // TODO: JUST FOR DEBUGGING!
+ //SaveFrame(lastiframe); // TODO: JUST FOR DEBUGGING!
}
}
}
@@ -1444,28 +1110,14 @@ void cMarkAdStandalone::ProcessFile()
{
if (lastiframe)
{
-#if 0
- CheckStartStop(lastiframe,true);
-#endif
- if ((!gotendmark) && ((iStop<0) || (!tStart)))
+ if ((inBroadCast) && (!gotendmark) && ((iStop<0) || (!tStart)))
{
- char *buf;
MarkAdMark tempmark;
tempmark.Type=MT_COMMONSTOP;
tempmark.Position=lastiframe;
-
- if (asprintf(&buf,"stop of recording (%i)",lastiframe)!=-1)
- {
- tempmark.Comment=buf;
- AddMark(&tempmark);
- free(buf);
- }
+ AddMark(&tempmark);
}
}
-#if 0
- CheckLastMark();
- CheckLogoMarks();
-#endif
}
skipped=demux->Skipped();
}
@@ -1551,6 +1203,7 @@ bool cMarkAdStandalone::SetFileUID(char *File)
return true;
}
+#if 0
bool cMarkAdStandalone::SaveInfo()
{
if ((!setVideo43) && (!setVideo169) && (!setAudio20) && (!setAudio51) && (!setVideo43LB)) return true;
@@ -1764,6 +1417,7 @@ bool cMarkAdStandalone::SaveInfo()
free(dst);
return (err==false);
}
+#endif
time_t cMarkAdStandalone::GetBroadcastStart(time_t start, int fd)
{
@@ -2311,12 +1965,13 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, const MarkAdConfig *
osd=NULL;
memset(&pkt,0,sizeof(pkt));
-
+#if 0
setAudio51=false;
setAudio20=false;
setVideo43=false;
setVideo43LB=false;
setVideo169=false;
+#endif
aspectChecked=false;
noticeVDR_MP2=false;
@@ -3277,7 +2932,7 @@ int main(int argc, char *argv[])
if (!cmasta) return -1;
if (!bPass2Only) cmasta->Process();
- //if (!bPass1Only) cmasta->Process2ndPass();
+ if (!bPass1Only) cmasta->Process2ndPass();
delete cmasta;
return 0;
}
diff --git a/command/markad-standalone.h b/command/markad-standalone.h
index 6f7797d..3f83032 100644
--- a/command/markad-standalone.h
+++ b/command/markad-standalone.h
@@ -205,28 +205,28 @@ unsigned Descriptor_Length:
bool bIgnoreVideoInfo;
bool bIgnoreTimerInfo;
- time_t startTime; // StartTime of broadcast
- int length; // Length in seconds
+ time_t startTime; // starttime of broadcast
+ int length; // length of broadcast in seconds
int tStart; // pretimer in seconds
int iStart; // pretimer as index value
int iStartCheck; // check position for iStart
int iStop; // posttimer as index value
int iStopCheck; // check position for iStop
- int skipped; // Skipped bytes in whole file
-
+ int skipped; // skipped bytes in whole file
+ bool inBroadCast; // are we in a broadcast (or ad)?
+#if 0
bool setAudio51; // set audio to 5.1 in info
bool setAudio20; // set audio to 2.0 in info
bool setVideo43; // set video to 4:3 in info
bool setVideo43LB; // set video to 4:3 letterbox in info
bool setVideo169; // set video to 16:9 in info
-
+#endif
int chkLEFT;
int chkRIGHT;
time_t GetBroadcastStart(time_t start, int fd);
- void CheckBroadcastLength();
- bool CheckIndexGrowing();
+ void CheckIndexGrowing();
char *indexFile;
int sleepcnt;
@@ -238,12 +238,8 @@ unsigned Descriptor_Length:
clMarks marks;
char *IndexToHMSF(int Index);
void CalculateStopPosition(int startframe, int delta);
- void CheckFirstMark();
- void CheckLastMark();
- void CheckStartStop(int frame, bool checkend=false);
void CheckAspectRatio_and_AudioChannels();
- void CheckLogoMarks(clMark *last=NULL);
- void AddStartMark();
+ void InitStartStop();
void AddMark(MarkAdMark *Mark);
bool Reset(bool FirstPass=true);
void ChangeMarks(clMark **Mark1, clMark **Mark2, MarkAdPos *NewPos);
@@ -253,7 +249,7 @@ unsigned Descriptor_Length:
bool CheckPATPMT(off_t Offset=0);
bool CheckTS();
bool LoadInfo();
- bool SaveInfo();
+ //bool SaveInfo();
bool SetFileUID(char *File);
bool RegenerateIndex();
bool ProcessFile2ndPass(clMark **Mark1, clMark **Mark2, int Number, off_t Offset, int Frame, int Frames);
diff --git a/command/video.cpp b/command/video.cpp
index d11d0cd..0f34617 100644
--- a/command/video.cpp
+++ b/command/video.cpp
@@ -217,8 +217,9 @@ int cMarkAdLogo::SobelPlane(int plane)
return 0;
}
- int boundary=15;
+ int boundary=6;
int cutval=127;
+ //int cutval=60;
int width=LOGOWIDTH;
if (plane>0)
@@ -793,18 +794,24 @@ void cMarkAdVideo::Clear()
void cMarkAdVideo::resetmarks()
{
- for (int i=0; i<marks.maxCount; i++)
- {
- if (marks.Number[i].Comment) free(marks.Number[i].Comment);
- }
memset(&marks,0,sizeof(marks));
}
-bool cMarkAdVideo::addmark(int type, int position, const char *comment)
+bool cMarkAdVideo::addmark(int type, int position, MarkAdAspectRatio *before,
+ MarkAdAspectRatio *after, bool verticalborders)
{
- if (!comment) return false;
if (marks.Count>marks.maxCount) return false;
- marks.Number[marks.Count].Comment=strdup(comment);
+ if (before)
+ {
+ marks.Number[marks.Count].AspectRatioBefore.Num=before->Num;
+ marks.Number[marks.Count].AspectRatioBefore.Den=before->Den;
+ }
+ if (after)
+ {
+ marks.Number[marks.Count].AspectRatioAfter.Num=after->Num;
+ marks.Number[marks.Count].AspectRatioAfter.Den=after->Den;
+ }
+ marks.Number[marks.Count].VerticalBorders=verticalborders;
marks.Number[marks.Count].Position=position;
marks.Number[marks.Count].Type=type;
marks.Count++;
@@ -851,22 +858,13 @@ MarkAdMarks *cMarkAdVideo::Process(int FrameNumber, int FrameNumberNext)
int lret=logo->Process(FrameNumber,&logoframenumber);
if ((lret>=-1) && (lret!=0))
{
- char *buf=NULL;
if (lret>0)
{
- if (asprintf(&buf,"detected logo start (%i)",logoframenumber)!=-1)
- {
- addmark(MT_LOGOSTART,logoframenumber,buf);
- free(buf);
- }
+ addmark(MT_LOGOSTART,logoframenumber);
}
else
{
- if (asprintf(&buf,"detected logo stop (%i)",logoframenumber)!=-1)
- {
- addmark(MT_LOGOSTOP,logoframenumber,buf);
- free(buf);
- }
+ addmark(MT_LOGOSTOP,logoframenumber);
}
}
}
@@ -876,24 +874,12 @@ MarkAdMarks *cMarkAdVideo::Process(int FrameNumber, int FrameNumberNext)
if ((hret>0) && (borderframenumber))
{
- char *buf=NULL;
- if (asprintf(&buf,"detected start of horiz. borders (%i [%i])",
- borderframenumber,FrameNumber)!=-1)
- {
- addmark(MT_BORDERSTART,borderframenumber,buf);
- free(buf);
- }
+ addmark(MT_BORDERSTART,borderframenumber);
}
if ((hret<0) && (borderframenumber))
{
- char *buf=NULL;
- if (asprintf(&buf,"detected stop of horiz. borders (%i [%i])",
- borderframenumber,FrameNumber)!=-1)
- {
- addmark(MT_BORDERSTOP,borderframenumber,buf);
- free(buf);
- }
+ addmark(MT_BORDERSTOP,borderframenumber);
}
if (!macontext->Video.Options.IgnoreAspectRatio)
@@ -903,48 +889,21 @@ MarkAdMarks *cMarkAdVideo::Process(int FrameNumber, int FrameNumberNext)
{
if ((logo->Status()==LOGO_VISIBLE) && (!start))
{
- char *buf=NULL;
- if (asprintf(&buf,"assuming logo stop (%i)",framebeforelast)!=-1)
- {
- addmark(MT_LOGOSTOP,framebeforelast,buf);
- free(buf);
- }
+ addmark(MT_LOGOSTOP,framebeforelast);
logo->SetStatusLogoInvisible();
}
- char *buf=(char *) calloc(1,256);
- if (!buf) return NULL;
- if (start)
- {
- snprintf(buf,255,"aspect ratio %i:%i (",
- macontext->Video.Info.AspectRatio.Num,
- macontext->Video.Info.AspectRatio.Den);
- }
- else
- {
- snprintf(buf,255,"aspect ratio change from %i:%i to %i:%i (",
- aspectratio.Num,aspectratio.Den,
- macontext->Video.Info.AspectRatio.Num,
- macontext->Video.Info.AspectRatio.Den);
- }
if ((macontext->Video.Info.AspectRatio.Num==4) &&
(macontext->Video.Info.AspectRatio.Den==3))
{
- char nbuf[20];
- snprintf(nbuf,sizeof(nbuf),"%i)*",start ? FrameNumber : FrameNumberNext);
- nbuf[19]=0;
- strcat(buf,nbuf);
- addmark(MT_ASPECTSTART,FrameNumberNext,buf);
+ addmark(MT_ASPECTSTART,start ? FrameNumber : FrameNumberNext,
+ &aspectratio,&macontext->Video.Info.AspectRatio);
}
else
{
- char nbuf[20];
- snprintf(nbuf,sizeof(nbuf),"%i)",framelast);
- nbuf[19]=0;
- strcat(buf,nbuf);
- addmark(MT_ASPECTSTOP,framelast,buf);
+ addmark(MT_ASPECTSTOP,framelast,&aspectratio,
+ &macontext->Video.Info.AspectRatio);
}
- free(buf);
}
aspectratio.Num=macontext->Video.Info.AspectRatio.Num;
diff --git a/command/video.h b/command/video.h
index 16f8899..bee7d29 100644
--- a/command/video.h
+++ b/command/video.h
@@ -10,7 +10,7 @@
#include "global.h"
-#define LOGO_MAXHEIGHT 170
+#define LOGO_MAXHEIGHT 250
#define LOGO_MAXWIDTH 480
#define LOGO_DEFHEIGHT 100
@@ -166,7 +166,8 @@ private:
cMarkAdOverlap *overlap;
void resetmarks();
- bool addmark(int Type, int position, const char *comment);
+ bool addmark(int type, int position, MarkAdAspectRatio *before=NULL,
+ MarkAdAspectRatio *after=NULL, bool verticalborders=false );
bool aspectratiochange(MarkAdAspectRatio &a, MarkAdAspectRatio &b, bool &start);
int framelast;