diff options
author | Jochen Dolze <vdr@dolze.de> | 2010-10-06 17:40:22 +0200 |
---|---|---|
committer | Jochen Dolze <vdr@dolze.de> | 2010-10-06 17:40:22 +0200 |
commit | dd525c902cf68d2a5a9500a3fb8be71d1a71869e (patch) | |
tree | fb6418dcd59cc15bbbab04b11645eb0d0549a1cb | |
parent | cf943e09a29f255ec4f7fa8a7c6fc7813ea9ded0 (diff) | |
download | vdr-plugin-markad-dd525c902cf68d2a5a9500a3fb8be71d1a71869e.tar.gz vdr-plugin-markad-dd525c902cf68d2a5a9500a3fb8be71d1a71869e.tar.bz2 |
Added --pass1only command line argument
Optimized start/stop recognition
-rw-r--r-- | command/markad-standalone.cpp | 114 | ||||
-rw-r--r-- | command/markad-standalone.h | 4 | ||||
-rw-r--r-- | plugin/markad.cpp | 2 | ||||
-rw-r--r-- | plugin/po/de_DE.po | 5 | ||||
-rw-r--r-- | plugin/po/it_IT.po | 5 | ||||
-rw-r--r-- | plugin/setup.cpp | 8 | ||||
-rw-r--r-- | plugin/setup.h | 2 | ||||
-rw-r--r-- | plugin/status.cpp | 3 |
8 files changed, 95 insertions, 48 deletions
diff --git a/command/markad-standalone.cpp b/command/markad-standalone.cpp index 5ad2440..c875b72 100644 --- a/command/markad-standalone.cpp +++ b/command/markad-standalone.cpp @@ -155,12 +155,11 @@ int cOSDMessage::Send(const char *format, ...) return 0; } -void cMarkAdStandalone::CalculateStopPosition(int startframe) +void cMarkAdStandalone::CalculateStopPosition(int startframe, int delta) { int len_in_frames=macontext.Info.Length*macontext.Video.Info.FramesPerSecond; iStop=-(startframe+len_in_frames); - chkLEFT=startframe; - chkLEFT2=startframe+(macontext.Video.Info.FramesPerSecond*361); + chkLEFT=startframe+delta+macontext.Video.Info.FramesPerSecond; chkRIGHT=startframe+(len_in_frames*2/3); } @@ -177,13 +176,12 @@ void cMarkAdStandalone::AddStartMark() if (macontext.Info.Length) { chkLEFT=(int) ((macontext.Video.Info.FramesPerSecond*macontext.Info.Length)/3); - chkLEFT2=chkLEFT; chkRIGHT=(int) ((macontext.Video.Info.FramesPerSecond*macontext.Info.Length)*2/3); if (tStart) { iStart=-(tStart*macontext.Video.Info.FramesPerSecond); - CalculateStopPosition(-iStart); + CalculateStopPosition(-iStart,macontext.Video.Info.FramesPerSecond*MAXRANGE); } } } @@ -199,20 +197,20 @@ void cMarkAdStandalone::CheckStartStop(int frame, bool checkend) clMark *before_iStart=marks.GetPrev(iStart,MT_START,0xF); clMark *after_iStart=marks.GetNext(iStart,MT_START,0xF); - int MINMARKDIFF=(int) (macontext.Video.Info.FramesPerSecond*360); + int MAXMARKDIFF=(int) (macontext.Video.Info.FramesPerSecond*MAXRANGE); int newpos=0; - int delta_before=MINMARKDIFF; - int delta_after=MINMARKDIFF; + int delta_before=MAXMARKDIFF; + int delta_after=MAXMARKDIFF; if (before_iStart) { delta_before=abs(iStart-before_iStart->position); - if (delta_before>MINMARKDIFF) delta_before=MINMARKDIFF; + if (delta_before>MAXMARKDIFF) delta_before=MAXMARKDIFF; } if (after_iStart) { delta_after=abs(after_iStart->position-iStart); - if (delta_after>MINMARKDIFF) delta_after=MINMARKDIFF; + if (delta_after>MAXMARKDIFF) delta_after=MAXMARKDIFF; } if (delta_before>delta_after) @@ -233,7 +231,7 @@ void cMarkAdStandalone::CheckStartStop(int frame, bool checkend) newpos,iStart); marks.Del(iStart); marks.DelTill(newpos); - CalculateStopPosition(newpos); + CalculateStopPosition(newpos,frame-newpos); } iStart=0; iStartCheck=0; @@ -245,20 +243,20 @@ void cMarkAdStandalone::CheckStartStop(int frame, bool checkend) clMark *before_iStop=marks.GetPrev(iStop,MT_STOP,0xF); clMark *after_iStop=marks.GetNext(iStop,MT_STOP,0xF); - int MINMARKDIFF=(int) (macontext.Video.Info.FramesPerSecond*360); + int MAXMARKDIFF=(int) (macontext.Video.Info.FramesPerSecond*MAXRANGE); int newpos=0; - int delta_before=MINMARKDIFF; - int delta_after=MINMARKDIFF; + int delta_before=MAXMARKDIFF; + int delta_after=MAXMARKDIFF; if (before_iStop) { delta_before=abs(iStop-before_iStop->position); - if (delta_before>MINMARKDIFF) delta_before=MINMARKDIFF; + if (delta_before>MAXMARKDIFF) delta_before=MAXMARKDIFF; } if (after_iStop) { delta_after=abs(after_iStop->position-iStop); - if (delta_after>MINMARKDIFF) delta_after=MINMARKDIFF; + if (delta_after>MAXMARKDIFF) delta_after=MAXMARKDIFF; } if (delta_before>delta_after) @@ -295,8 +293,15 @@ void cMarkAdStandalone::CheckStartStop(int frame, bool checkend) AddMark(&mark); free(buf); } - iStartCheck=iStart+(int) (macontext.Video.Info.FramesPerSecond*360); - CalculateStopPosition(iStart); + int MARKDIFF=(int) (macontext.Video.Info.FramesPerSecond*MAXRANGE); + clMark *before_iStart=marks.GetPrev(iStart,MT_START,0xF); + if (before_iStart) + { + int tmpdiff=abs(iStart-before_iStart->position); + if (tmpdiff<MARKDIFF) MARKDIFF=tmpdiff; + } + iStartCheck=iStart+MARKDIFF; + CalculateStopPosition(iStart,MARKDIFF); } if ((iStop<0) && (lastiframe>-iStop)) { @@ -309,7 +314,15 @@ void cMarkAdStandalone::CheckStartStop(int frame, bool checkend) AddMark(&mark); free(buf); } - iStopCheck=iStop+(int) (macontext.Video.Info.FramesPerSecond*360); + + int MARKDIFF=(int) (macontext.Video.Info.FramesPerSecond*MAXRANGE); + clMark *before_iStop=marks.GetPrev(iStart,MT_STOP,0xF); + if (before_iStop) + { + int tmpdiff=abs(iStop-before_iStop->position); + if (tmpdiff<MARKDIFF) MARKDIFF=tmpdiff; + } + iStopCheck=iStop+MARKDIFF; } } @@ -590,27 +603,15 @@ void cMarkAdStandalone::AddMark(MarkAdMark *Mark) if ((((Mark->Type & 0xF0)==MT_CHANNELCHANGE) || ((Mark->Type & 0xF0)==MT_ASPECTCHANGE)) && (Mark->Position>chkLEFT) && (Mark->Position<chkRIGHT) && (bDecodeVideo)) { - if (Mark->Comment) { isyslog("%s",Mark->Comment); loggedAlready=true; } - isyslog("%s changes detected. logo/border detection disabled", - (Mark->Type & 0xF0)==MT_ASPECTCHANGE ? "aspectratio" : "audio channel"); - if ((!macontext.Info.AspectRatio.Num) && ((Mark->Type & 0xF0)==MT_ASPECTCHANGE)) + if ((Mark->Type & 0xF0)==MT_CHANNELCHANGE) { - isyslog("assuming broadcast aspectratio is 4:3"); - macontext.Info.AspectRatio.Num=4; - macontext.Info.AspectRatio.Den=3; - reprocess=true; - setVideo43=true; - } - - if ((bDecodeVideo) && ((Mark->Type & 0xF0)==MT_CHANNELCHANGE)) - { - isyslog("assuming broadcast with DolbyDigital5.1"); + isyslog("audio channel changes detected. logo/border detection disabled"); if (macontext.Info.VPid.Type==MARKAD_PIDTYPE_VIDEO_H262) { if (!macontext.Info.AspectRatio.Num) @@ -625,6 +626,19 @@ void cMarkAdStandalone::AddMark(MarkAdMark *Mark) setAudio20=false; reprocess=true; } + else + { + isyslog("aspectratio changes detected. logo/border detection disabled"); + + if ((!macontext.Info.AspectRatio.Num) && ((Mark->Type & 0xF0)==MT_ASPECTCHANGE)) + { + isyslog("assuming broadcast aspectratio is 4:3"); + macontext.Info.AspectRatio.Num=4; + macontext.Info.AspectRatio.Den=3; + reprocess=true; + setVideo43=true; + } + } bDecodeVideo=false; macontext.Video.Data.Valid=false; @@ -634,7 +648,7 @@ void cMarkAdStandalone::AddMark(MarkAdMark *Mark) marks.Del((uchar) MT_BORDERSTOP); } } - if (Mark->Position>chkLEFT2) CheckFirstMark(); + if (Mark->Position>chkLEFT) CheckFirstMark(); if ((Mark->Comment) && (!loggedAlready)) isyslog("%s",Mark->Comment); marks.Add(Mark->Type,Mark->Position,Mark->Comment); @@ -1126,7 +1140,7 @@ bool cMarkAdStandalone::ProcessFile(int Number) lastiframe=iframe; lastiframetime=iframetime; CheckStartStop(lastiframe); - if (lastiframe>chkLEFT2) CheckInfoAspectRatio(); + if (lastiframe>chkLEFT) CheckInfoAspectRatio(); if (macontext.Info.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264) { @@ -1246,7 +1260,7 @@ bool cMarkAdStandalone::Reset(bool FirstPass) memset(&apkt,0,sizeof(apkt)); iStart=iStartCheck=iStop=iStopCheck=0; - chkLEFT=chkLEFT2=chkRIGHT=0; + chkLEFT=chkRIGHT=0; if (FirstPass) { @@ -2237,7 +2251,7 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, bool BackupMarks, in lastiframetime=0; iframetime=0; audiotime=0; - chkLEFT=chkLEFT2=chkRIGHT=0; + chkLEFT=chkRIGHT=0; gettimeofday(&tv1,&tz); } @@ -2353,8 +2367,10 @@ int usage(int svdrpport) " live-recordings are identified by having a '@' in the\n" " filename so the entry 'Mark instant recording' in the menu\n" " 'Setup - Recording' of the vdr should be set to 'yes'\n" + " --pass1only\n" + " process only first pass, setting of marks\n" " --pass2only\n" - " process only second pass, fine adjustment or marks\n" + " process only second pass, fine adjustment of marks\n" " --svdrphost=<ip/hostname> (default is 127.0.0.1)\n" " ip/hostname of a remote VDR for OSD messages\n" " --svdrpport=<port> (default is %i)\n" @@ -2436,6 +2452,7 @@ int main(int argc, char *argv[]) int ignoreInfo=0; bool bGenIndex=false; bool bPass2Only=false; + bool bPass1Only=false; int online=0; int threads=-1; @@ -2475,14 +2492,12 @@ int main(int argc, char *argv[]) {"markfile",1,0,1}, {"nopid",0,0,5}, {"online",2,0,4}, + {"pass1only",0,0,11}, {"pass2only",0,0,10}, {"pass3only",0,0,7}, {"svdrphost",1,0,8}, {"svdrpport",1,0,9}, {"testmode",0,0,3}, - {"vpid",1,0,11}, - {"apid",1,0,12}, - {"dpid",1,0,13}, {"backupmarks", 0, 0, 'B'}, {"scenechangedetection", 0, 0, 'C'}, @@ -2726,8 +2741,23 @@ int main(int argc, char *argv[]) case 10: // --pass2only bPass2Only=true; + if (bPass1Only) + { + fprintf(stderr, "markad: you cannot use --pass2only with --pass1only\n"); + return 2; + } break; + case 11: // --pass1only + bPass1Only=true; + if (bPass2Only) + { + fprintf(stderr, "markad: you cannot use --pass1only with --pass2only\n"); + return 2; + } + break; + + default: printf ("? getopt returned character code 0%o ? (option_index %d)\n", c,option_index); } @@ -2907,7 +2937,7 @@ int main(int argc, char *argv[]) if (!cmasta) return -1; if (!bPass2Only) cmasta->Process(); - cmasta->Process2ndPass(); + if (!bPass1Only) cmasta->Process2ndPass(); delete cmasta; return 0; } diff --git a/command/markad-standalone.h b/command/markad-standalone.h index 4e506c6..2f8733f 100644 --- a/command/markad-standalone.h +++ b/command/markad-standalone.h @@ -23,6 +23,8 @@ #define DELTATIME 20000 /* equals to 222ms (base is 90kHz PTS) */ +#define MAXRANGE 360 /* range to search for start/stop marks in [s] */ + class cOSDMessage { private: @@ -233,7 +235,7 @@ unsigned Descriptor_Length: bool bBackupMarks; clMarks marks; char *IndexToHMSF(int Index); - void CalculateStopPosition(int startframe); + void CalculateStopPosition(int startframe, int delta); void CheckFirstMark(); void CheckLastMark(); void CheckStartStop(int frame, bool checkend=false); diff --git a/plugin/markad.cpp b/plugin/markad.cpp index bd1e335..75d77ee 100644 --- a/plugin/markad.cpp +++ b/plugin/markad.cpp @@ -36,6 +36,7 @@ cPluginMarkAd::cPluginMarkAd(void) setup.Verbose=false; setup.NoMargins=false; setup.HideMainMenuEntry=false; + setup.SecondPass=true; } cPluginMarkAd::~cPluginMarkAd() @@ -183,6 +184,7 @@ bool cPluginMarkAd::SetupParse(const char *Name, const char *Value) else if (!strcasecmp(Name,"Verbose")) setup.Verbose=atoi(Value); else if (!strcasecmp(Name,"IgnoreMargins")) setup.NoMargins=atoi(Value); else if (!strcasecmp(Name,"HideMainMenuEntry")) setup.HideMainMenuEntry=atoi(Value)?true:false; + else if (!strcasecmp(Name,"SecondPass")) setup.SecondPass=atoi(Value); else return false; return true; } diff --git a/plugin/po/de_DE.po b/plugin/po/de_DE.po index 5515cc4..b46b33f 100644 --- a/plugin/po/de_DE.po +++ b/plugin/po/de_DE.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2010-09-17 18:00+0200\n" +"POT-Creation-Date: 2010-10-06 14:53+0200\n" "PO-Revision-Date: 2009-08-27 14:18+0200\n" "Last-Translator: Jochen Dolze <vdr@dolze.de>\n" "Language-Team: <vdr@linuxtv.org>\n" @@ -69,6 +69,9 @@ msgstr "Kaputte Indexdatei reparieren" msgid "ignore timer margins" msgstr "Timer Vor-/Nachlauf ignorieren" +msgid "detect overlaps" +msgstr "erkenne Überlappungen" + msgid "OSD message" msgstr "OSD Meldung" diff --git a/plugin/po/it_IT.po b/plugin/po/it_IT.po index c7fe1da..c63dedd 100644 --- a/plugin/po/it_IT.po +++ b/plugin/po/it_IT.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2010-09-17 18:09+0200\n" +"POT-Creation-Date: 2010-10-06 14:53+0200\n" "PO-Revision-Date: 2010-08-09 20:05+0100\n" "Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n" "Language-Team: <vdr@linuxtv.org>\n" @@ -72,6 +72,9 @@ msgstr "Ripara indice, se errato" msgid "ignore timer margins" msgstr "Ignora margini timer" +msgid "detect overlaps" +msgstr "" + msgid "OSD message" msgstr "Messaggio OSD" diff --git a/plugin/setup.cpp b/plugin/setup.cpp index 86d7cd1..3f60c72 100644 --- a/plugin/setup.cpp +++ b/plugin/setup.cpp @@ -19,7 +19,8 @@ cSetupMarkAd::cSetupMarkAd(struct setup *Setup) verbose=setup->Verbose; genindex=setup->GenIndex; nomargins=setup->NoMargins; -hidemainmenuentry=setup->HideMainMenuEntry; + hidemainmenuentry=setup->HideMainMenuEntry; + secondpass=setup->SecondPass; processTexts[0]=tr("after"); processTexts[1]=tr("during"); @@ -40,11 +41,12 @@ void cSetupMarkAd::write(void) Add(new cMenuEditBoolItem(tr("repair index, if broken"),&genindex)); Add(new cMenuEditBoolItem(tr("ignore timer margins"),&nomargins)); + Add(new cMenuEditBoolItem(tr("detect overlaps"),&secondpass)); Add(new cMenuEditBoolItem(tr("OSD message"),&osdmsg)); Add(new cMenuEditBoolItem(tr("backup marks"),&backupmarks)); Add(new cMenuEditBoolItem(tr("verbose logging"),&verbose)); - Add(new cMenuEditBoolItem(tr("Hide Mainmenu entry"),&hidemainmenuentry)); + Add(new cMenuEditBoolItem(tr("Hide Mainmenu entry"),&hidemainmenuentry)); Display(); } @@ -80,6 +82,7 @@ void cSetupMarkAd::Store(void) SetupStore("IgnoreMargins",nomargins); SetupStore("BackupMarks",backupmarks); SetupStore("GenIndex",genindex); + SetupStore("SecondPass",secondpass); SetupStore("OSDMessage",osdmsg); SetupStore("Verbose",verbose); SetupStore("HideMainMenuEntry",hidemainmenuentry); @@ -89,6 +92,7 @@ void cSetupMarkAd::Store(void) setup->whileReplaying=(bool) whilereplaying; setup->OSDMessage=(bool) osdmsg; setup->GenIndex=(bool) genindex; + setup->SecondPass=(bool) secondpass; setup->BackupMarks=(bool) backupmarks; setup->Verbose=(bool) verbose; setup->NoMargins=(bool) nomargins; diff --git a/plugin/setup.h b/plugin/setup.h index ab156af..446778f 100644 --- a/plugin/setup.h +++ b/plugin/setup.h @@ -19,6 +19,7 @@ struct setup bool Verbose; bool GenIndex; bool NoMargins; + bool SecondPass; bool HideMainMenuEntry; }; @@ -35,6 +36,7 @@ private: int verbose; int genindex; int nomargins; + int secondpass; int hidemainmenuentry; void write(void); protected: diff --git a/plugin/status.cpp b/plugin/status.cpp index 9fd800e..01a1dc5 100644 --- a/plugin/status.cpp +++ b/plugin/status.cpp @@ -71,12 +71,13 @@ bool cStatusMarkAd::Start(const char *FileName, const char *Name, const bool Dir { if ((Direct) && (Get(FileName)!=-1)) return false; - cString cmd = cString::sprintf("\"%s\"/markad %s%s%s%s%s -l \"%s\" %s \"%s\"",bindir, + cString cmd = cString::sprintf("\"%s\"/markad %s%s%s%s%s%s -l \"%s\" %s \"%s\"",bindir, setup->Verbose ? " -v " : "", setup->BackupMarks ? " -B " : "", setup->GenIndex ? " -G " : "", setup->OSDMessage ? " -O " : "", setup->NoMargins ? " -i 4 " : "", + setup->SecondPass ? "" : " --pass1only ", logodir,Direct ? "-O after" : "--online=2 before", FileName); dsyslog("markad: executing %s",*cmd); if (SystemExec(cmd)!=-1) |