diff options
-rw-r--r-- | command/audio.cpp | 15 | ||||
-rw-r--r-- | command/audio.h | 1 | ||||
-rw-r--r-- | command/demux.cpp | 9 | ||||
-rw-r--r-- | command/demux.h | 1 | ||||
-rw-r--r-- | command/markad-standalone.cpp | 32 | ||||
-rw-r--r-- | command/marks.cpp | 37 | ||||
-rw-r--r-- | command/marks.h | 3 | ||||
-rw-r--r-- | command/pes2es.cpp | 10 | ||||
-rw-r--r-- | command/pes2es.h | 2 | ||||
-rw-r--r-- | command/streaminfo.cpp | 15 | ||||
-rw-r--r-- | command/streaminfo.h | 2 | ||||
-rw-r--r-- | command/ts2pkt.cpp | 5 | ||||
-rw-r--r-- | command/ts2pkt.h | 1 | ||||
-rw-r--r-- | command/vdr2pkt.cpp | 5 | ||||
-rw-r--r-- | command/vdr2pkt.h | 1 | ||||
-rw-r--r-- | command/video.cpp | 24 | ||||
-rw-r--r-- | command/video.h | 4 |
17 files changed, 120 insertions, 47 deletions
diff --git a/command/audio.cpp b/command/audio.cpp index bd35ddc..3882de2 100644 --- a/command/audio.cpp +++ b/command/audio.cpp @@ -14,11 +14,7 @@ cMarkAdAudio::cMarkAdAudio(MarkAdContext *maContext) mark.Comment=NULL; mark.Position=0; mark.Type=0; - channels=0; -#if 0 - lastiframe_gain=-ANALYZEFRAMES; -#endif - lastiframe_silence=-1; + Clear(); } cMarkAdAudio::~cMarkAdAudio() @@ -131,6 +127,15 @@ bool cMarkAdAudio::AnalyzeGain() } #endif +void cMarkAdAudio::Clear() +{ + channels=0; +#if 0 + lastiframe_gain=-ANALYZEFRAMES; +#endif + lastiframe_silence=-1; +} + bool cMarkAdAudio::ChannelChange(int a, int b) { if ((a==0) || (b==0)) return false; diff --git a/command/audio.h b/command/audio.h index 8995732..5249a5a 100644 --- a/command/audio.h +++ b/command/audio.h @@ -53,6 +53,7 @@ public: cMarkAdAudio(MarkAdContext *maContext); ~cMarkAdAudio(); MarkAdMark *Process(int LastIFrame); + void Clear(); }; diff --git a/command/demux.cpp b/command/demux.cpp index 14d5546..76e6003 100644 --- a/command/demux.cpp +++ b/command/demux.cpp @@ -27,6 +27,15 @@ cMarkAdDemux::~cMarkAdDemux() if (queue) delete queue; } +void cMarkAdDemux::Clear() +{ + if (ts2pkt) ts2pkt->Clear(); + if (vdr2pkt) vdr2pkt->Clear(); + if (pes2audioes) pes2audioes->Clear(); + if (pes2videoes) pes2videoes->Clear(); + if (queue) queue->Clear(); +} + void cMarkAdDemux::ProcessVDR(MarkAdPid Pid, uchar *Data, int Count, uchar **Pkt, int *PktLen) { if ((!Pkt) || (!PktLen)) return; diff --git a/command/demux.h b/command/demux.h index 3cb85cc..589d082 100644 --- a/command/demux.h +++ b/command/demux.h @@ -39,6 +39,7 @@ private: public: cMarkAdDemux(); ~cMarkAdDemux(); + void Clear(); int Process(MarkAdPid Pid, uchar *Data, int Count, uchar **Pkt, int *PktLen); }; diff --git a/command/markad-standalone.cpp b/command/markad-standalone.cpp index bc4c058..e80c078 100644 --- a/command/markad-standalone.cpp +++ b/command/markad-standalone.cpp @@ -260,7 +260,7 @@ void cMarkAdStandalone::AddMark(MarkAdMark *Mark) switch (Mark->Type & 0xF) { case MT_START: - marks.Clear(); + marks.DelAll(); iStart=0; break; case MT_STOP: @@ -278,22 +278,23 @@ void cMarkAdStandalone::AddMark(MarkAdMark *Mark) { if (last->type==MT_ASPECTCHANGE) { - isyslog("aspectratio change in \"short\" distance, deleting this mark (%i)", - Mark->Position); + isyslog("aspectratio change in \"short\" distance, using this mark instead (%i->%i)", + last->position,Mark->Position); } else { - isyslog("%s mark in \"short\" distance, deleting this mark (%i)", + isyslog("%s mark in \"short\" distance, using this mark instead (%i->%i)", ((last->type & 0xF)==MT_START) ? "start" : "stop", - Mark->Position); + last->position,Mark->Position); } switch (Mark->Type & 0xF) { case MT_START: - marks.Clear(last->position); + marks.DelTill(last->position); iStart=0; break; case MT_STOP: + marks.DelTill(last->position,false); iStop=0; fastexit=true; break; @@ -301,8 +302,6 @@ void cMarkAdStandalone::AddMark(MarkAdMark *Mark) esyslog("please report this! *2"); break; } - - if ((Mark->Type & 0xF)==MT_START) marks.Clear(last->position); return; } } @@ -472,7 +471,7 @@ void cMarkAdStandalone::SaveFrame(int frame) // Write pixel data if (fwrite(macontext.Video.Data.Plane[0],1, - macontext.Video.Data.PlaneLinesize[0]*macontext.Video.Info.Height,pFile)) {}; + macontext.Video.Data.PlaneLinesize[0]*macontext.Video.Info.Height,pFile)) {}; // Close file fclose(pFile); } @@ -572,6 +571,7 @@ bool cMarkAdStandalone::ProcessFile(const char *Directory, int Number) { if (pkt) { + bool dRes=false; if (streaminfo->FindVideoInfos(&macontext,pkt,pktlen)) { if (!framecnt) @@ -588,10 +588,10 @@ bool cMarkAdStandalone::ProcessFile(const char *Directory, int Number) lastiframe=iframe; CheckStartStop(lastiframe); iframe=framecnt-1; + dRes=true; } } - bool dRes=true; if ((decoder) && (bDecodeVideo)) dRes=decoder->DecodeVideo(&macontext,pkt,pktlen); if (dRes) { @@ -712,7 +712,17 @@ void cMarkAdStandalone::Reset() iStart=0; iStop=0; marksAligned=false; - marks.Clear(); + marks.DelAll(); + + memset(&macontext.Video.Info,0,sizeof(macontext.Video.Info)); + memset(&macontext.Audio.Info,0,sizeof(macontext.Audio.Info)); + + if (streaminfo) streaminfo->Clear(); + if (video_demux) video_demux->Clear(); + if (ac3_demux) ac3_demux->Clear(); + if (mp2_demux) mp2_demux->Clear(); + if (video) video->Clear(); + if (audio) audio->Clear(); } void cMarkAdStandalone::Process(const char *Directory) diff --git a/command/marks.cpp b/command/marks.cpp index 67358fc..929589b 100644 --- a/command/marks.cpp +++ b/command/marks.cpp @@ -32,7 +32,7 @@ clMark::~clMark() clMarks::~clMarks() { - Clear(); + DelAll(); } int clMarks::Count(int Type) @@ -64,25 +64,50 @@ void clMarks::Del(int Type) } } -void clMarks::Clear(int Before) +void clMarks::DelTill(int Position, bool FromStart) { clMark *next,*mark=first; + if (!FromStart) + { + while (mark) + { + if (mark->position>Position) break; + mark=mark->Next(); + } + } + while (mark) { next=mark->Next(); - if (mark->position<Before) + if (FromStart) + { + if (mark->position<Position) + { + Del(mark); + } + } + else { Del(mark); } mark=next; } - if (Before==0x7FFFFFFF) +} + +void clMarks::DelAll() +{ + clMark *next,*mark=first; + while (mark) { - first=NULL; - last=NULL; + next=mark->Next(); + Del(mark); + mark=next; } + first=NULL; + last=NULL; } + void clMarks::Del(clMark *Mark) { if (!Mark) return; diff --git a/command/marks.h b/command/marks.h index 76c137d..a65df34 100644 --- a/command/marks.h +++ b/command/marks.h @@ -98,7 +98,8 @@ public: } } clMark *Add(int Type, int Position, const char *Comment = NULL); - void Clear(int Before=0x7FFFFFFF); + void DelTill(int Position,bool FromStart=true); + void DelAll(); void Del(clMark *Mark); void Del(int Type); clMark *Get(int Position); diff --git a/command/pes2es.cpp b/command/pes2es.cpp index 64565a7..6adbc26 100644 --- a/command/pes2es.cpp +++ b/command/pes2es.cpp @@ -18,9 +18,9 @@ cMarkAdPES2ES::~cMarkAdPES2ES() if (queue) delete queue; } -void cMarkAdPES2ES::Reset() +void cMarkAdPES2ES::Clear() { - queue->Clear(); + if (queue) queue->Clear(); } void cMarkAdPES2ES::Process(MarkAdPid Pid, uchar *PESData, int PESSize, uchar **ESData, int *ESSize) @@ -36,7 +36,7 @@ void cMarkAdPES2ES::Process(MarkAdPid Pid, uchar *PESData, int PESSize, uchar ** // first check some simple things if ((peshdr->Sync1!=0) && (peshdr->Sync2!=0) && (peshdr->Sync3!=1)) { - Reset(); + Clear(); return; } @@ -47,7 +47,7 @@ void cMarkAdPES2ES::Process(MarkAdPid Pid, uchar *PESData, int PESSize, uchar ** if (Length!=PESSize) { if ((peshdr->StreamID & 0xF0)==0xE0) return; - Reset(); + Clear(); return; } @@ -70,7 +70,7 @@ void cMarkAdPES2ES::Process(MarkAdPid Pid, uchar *PESData, int PESSize, uchar ** type=MA_PACKET_MP2; break; default: - Reset(); + Clear(); return; } diff --git a/command/pes2es.h b/command/pes2es.h index 6b7c6bc..5eb2614 100644 --- a/command/pes2es.h +++ b/command/pes2es.h @@ -68,10 +68,10 @@ unsigned Length: cMarkAdPaketQueue *queue; int type; - void Reset(); public: cMarkAdPES2ES(const char *QueueName="PES2ES", int QueueSize=32768); ~cMarkAdPES2ES(); + void Clear(); void Process(MarkAdPid Pid, uchar *PESData, int PESSize, uchar **ESData, int *ESSize); }; diff --git a/command/streaminfo.cpp b/command/streaminfo.cpp index fb2bc9c..566bb45 100644 --- a/command/streaminfo.cpp +++ b/command/streaminfo.cpp @@ -9,6 +9,11 @@ cMarkAdStreamInfo::cMarkAdStreamInfo() { + Clear(); +} + +void cMarkAdStreamInfo::Clear() +{ memset(&H264,0,sizeof(H264)); H264.frame_num=-1; } @@ -489,16 +494,6 @@ bool cMarkAdStreamInfo::FindH264VideoInfos(MarkAdContext *maContext, uchar *pkt, return false; } -const uint8_t *cMarkAdStreamInfo::nextStartCode(const uint8_t *start, const uint8_t *end) -{ - for (end -= 4; start < end; ++start) - { - if ((start[0] == 0x00) && (start[1] == 0x00) && (start[2] == 0x00) && (start[3] == 0x01)) - return start; - } - return (end + 4); -} - bool cMarkAdStreamInfo::FindH262VideoInfos(MarkAdContext *maContext, uchar *pkt, int len) { if ((!maContext) || (!pkt) || (!len)) return false; diff --git a/command/streaminfo.h b/command/streaminfo.h index e08ac7f..762ac8f 100644 --- a/command/streaminfo.h +++ b/command/streaminfo.h @@ -40,11 +40,11 @@ private: } H264; int nalUnescape(uint8_t *dst, const uint8_t *src, int len); - const uint8_t *nextStartCode(const uint8_t *start, const uint8_t *end); bool FindH264VideoInfos(MarkAdContext *maContext, uchar *pkt, int len); bool FindH262VideoInfos(MarkAdContext *maContext, uchar *pkt, int len); public: cMarkAdStreamInfo(); + void Clear(); bool FindVideoInfos(MarkAdContext *maContext, uchar *pkt, int len); bool FindAC3AudioInfos(MarkAdContext *maContext, uchar *espkt, int eslen); }; diff --git a/command/ts2pkt.cpp b/command/ts2pkt.cpp index 0d13df7..c286257 100644 --- a/command/ts2pkt.cpp +++ b/command/ts2pkt.cpp @@ -18,6 +18,11 @@ cMarkAdTS2Pkt::~cMarkAdTS2Pkt() if (queue) delete queue; } +void cMarkAdTS2Pkt::Clear() +{ + Reset(); +} + void cMarkAdTS2Pkt::Reset(int ErrIndex) { sync=false; diff --git a/command/ts2pkt.h b/command/ts2pkt.h index a485d5b..122bc5c 100644 --- a/command/ts2pkt.h +++ b/command/ts2pkt.h @@ -120,6 +120,7 @@ unsigned Length: public: cMarkAdTS2Pkt(const char *QueueName="TS2Pkt", int QueueSize=32768); ~cMarkAdTS2Pkt(); + void Clear(); void Process(MarkAdPid Pid,uchar *TSData, int TSSize, uchar **PktData, int *PktSize); bool InjectVideoPES(uchar *PESData, int PESSize); }; diff --git a/command/vdr2pkt.cpp b/command/vdr2pkt.cpp index 8d5a18f..c7f0ffd 100644 --- a/command/vdr2pkt.cpp +++ b/command/vdr2pkt.cpp @@ -17,6 +17,11 @@ cMarkAdVDR2Pkt::~cMarkAdVDR2Pkt() if (queue) delete queue; } +void cMarkAdVDR2Pkt::Clear() +{ + if (queue) queue->Clear(); +} + void cMarkAdVDR2Pkt::Process(MarkAdPid Pid, uchar *VDRData, int VDRSize, uchar **PktData, int *PktSize) { if ((!PktData) || (!PktSize) || (!queue)) return; diff --git a/command/vdr2pkt.h b/command/vdr2pkt.h index e83013e..f4f7630 100644 --- a/command/vdr2pkt.h +++ b/command/vdr2pkt.h @@ -22,6 +22,7 @@ private: public: cMarkAdVDR2Pkt(const char *QueueName="VDR2PKT", int QueueSize=32768); ~cMarkAdVDR2Pkt(); + void Clear(); void Process(MarkAdPid Pid,uchar *VDRData, int VDRSize, uchar **PktData, int *PktSize); }; diff --git a/command/video.cpp b/command/video.cpp index 92c834d..03ecba5 100644 --- a/command/video.cpp +++ b/command/video.cpp @@ -34,8 +34,6 @@ cMarkAdLogo::cMarkAdLogo(MarkAdContext *maContext) GY[2][1] = -2; GY[2][2] = -1; - memset(&area,0,sizeof(area)); - LOGOHEIGHT=LOGO_DEFHEIGHT; if (maContext->Info.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264) { @@ -46,11 +44,13 @@ cMarkAdLogo::cMarkAdLogo(MarkAdContext *maContext) LOGOWIDTH=LOGO_DEFWIDTH; } - area.status=UNINITIALIZED; + Clear(); } -cMarkAdLogo::~cMarkAdLogo() +void cMarkAdLogo::Clear() { + memset(&area,0,sizeof(area)); + area.status=UNINITIALIZED; } int cMarkAdLogo::Load(char *directory, char *file) @@ -409,6 +409,11 @@ cMarkAdBlackBordersHoriz::cMarkAdBlackBordersHoriz(MarkAdContext *maContext) { macontext=maContext; + Clear(); +} + +void cMarkAdBlackBordersHoriz::Clear() +{ borderstatus=UNINITIALIZED; borderiframe=-1; } @@ -527,14 +532,13 @@ cMarkAdVideo::cMarkAdVideo(MarkAdContext *maContext) { macontext=maContext; - aspectratio.Num=0; - aspectratio.Den=0; mark.Comment=NULL; mark.Position=0; mark.Type=0; hborder=new cMarkAdBlackBordersHoriz(maContext); logo = new cMarkAdLogo(maContext); + Clear(); } cMarkAdVideo::~cMarkAdVideo() @@ -544,6 +548,14 @@ cMarkAdVideo::~cMarkAdVideo() if (logo) delete logo; } +void cMarkAdVideo::Clear() +{ + aspectratio.Num=0; + aspectratio.Den=0; + if (hborder) hborder->Clear(); + if (logo) logo->Clear(); +} + void cMarkAdVideo::ResetMark() { if (mark.Comment) free(mark.Comment); diff --git a/command/video.h b/command/video.h index e2f1d1d..446a61b 100644 --- a/command/video.h +++ b/command/video.h @@ -85,8 +85,8 @@ private: void Save(int lastiframe, uchar *picture); public: cMarkAdLogo(MarkAdContext *maContext); - ~cMarkAdLogo(); int Process(int LastIFrame, int *LogoIFrame); + void Clear(); }; class cMarkAdBlackBordersHoriz @@ -107,6 +107,7 @@ private: public: cMarkAdBlackBordersHoriz(MarkAdContext *maContext); int Process(int LastIFrame,int *BorderIFrame); + void Clear(); }; class cMarkAdVideo @@ -128,6 +129,7 @@ public: cMarkAdVideo(MarkAdContext *maContext); ~cMarkAdVideo(); MarkAdMark *Process(int LastIFrame); + void Clear(); }; #endif |