From 67dc8e654bf58ea30e8a976d7b34fc8f679f8a24 Mon Sep 17 00:00:00 2001 From: Jochen Dolze Date: Thu, 11 Mar 2010 20:52:03 +0100 Subject: Added info file processing --- decoder.cpp | 4 +- global.h | 5 ++ markad-standalone.cpp | 215 ++++++++++++++++++++++++++++++++++++++++---------- video.cpp | 28 ++++--- 4 files changed, 195 insertions(+), 57 deletions(-) diff --git a/decoder.cpp b/decoder.cpp index a9fb7b4..47fc3af 100644 --- a/decoder.cpp +++ b/decoder.cpp @@ -170,11 +170,11 @@ cMarkAdDecoder::cMarkAdDecoder(int RecvNumber, bool useH264, bool useMP2, bool h else { - dsyslog("markad [%i]: using codec %s",recvnumber,video_codec->long_name); + isyslog("markad [%i]: using codec %s",recvnumber,video_codec->long_name); if (video_context->hwaccel) { - dsyslog("markad [%i]: using hwaccel %s",recvnumber,video_context->hwaccel->name); + isyslog("markad [%i]: using hwaccel %s",recvnumber,video_context->hwaccel->name); } video_frame = avcodec_alloc_frame(); diff --git a/global.h b/global.h index ec74501..295c6fe 100644 --- a/global.h +++ b/global.h @@ -69,6 +69,11 @@ typedef struct MarkAdContext struct Video { + struct Options + { + bool IgnoreAspectRatio; + } Options; + struct Info { int Width; // width of pic diff --git a/markad-standalone.cpp b/markad-standalone.cpp index 8222920..4c43253 100644 --- a/markad-standalone.cpp +++ b/markad-standalone.cpp @@ -17,6 +17,9 @@ int logoWidth=-1; int logoHeight=-1; bool bDecodeVideo=true; bool bDecodeAudio=true; +bool bBackupMarks=false; +bool bIgnoreAudioInfo=false; +bool bIgnoreVideoInfo=false; void syslog_with_tid(int priority, const char *format, ...) { @@ -317,19 +320,74 @@ bool cMarkAdStandalone::LoadInfo(const char *Directory) return false; } - int result=fscanf(f,"%*c %as %*s",&macontext.General.ChannelID); + char *line=NULL; + size_t length; + while (getline(&line,&length,f)!=-1) + { + if (line[0]=='C') + { + int result=sscanf(line,"%*c %as %*s",&macontext.General.ChannelID); + if (result==0 || result==EOF) macontext.General.ChannelID=NULL; + if ((bIgnoreAudioInfo) && (bIgnoreVideoInfo)) break; + } + if (line[0]=='X') + { + int stream=0,type=0; + char descr[256]=""; + int result=sscanf(line,"%*c %i %i %250c",&stream,&type,(char *) &descr); + if ((result!=0) && (result!=EOF)) + { + if ((stream==1) && (!bIgnoreVideoInfo)) + { + if ((type==1) || (type==5)) + { + // we have 4:3 SD, ads are today (in Germany) in 16:9 + // so disable video decoding + if (bDecodeVideo) + { + bDecodeVideo=false; + isyslog("markad [%i]: broadcasts aspectratio is 4:3, disabling video decoding",recvnumber); + } + } + else + { + // we dont have 4:3, so ignore AspectRatio-Changes + macontext.Video.Options.IgnoreAspectRatio=true; + isyslog("markad [%i]: broadcasts aspectratio is not 4:3, disabling aspect ratio",recvnumber); + + } + } + + if ((stream==2) && (!bIgnoreAudioInfo)) + { + if (type==5) + { + // ok, here we have a problem: 5 means DolbyDigital 2.0 and DolbyDigital 5.1! + bool bSet=true; + if (strchr(descr,'2')) bSet=false; // that is really weak! + if ((bSet) && (bDecodeVideo)) + { + bDecodeVideo=false; + macontext.Video.Options.IgnoreAspectRatio=true; + isyslog("markad [%i]: broadcast with DolbyDigital, disabling video decoding",recvnumber); + } + } + } + } + } + } + if (line) free(line); + fclose(f); free(buf); - if (result==0 || result==EOF) + if (!macontext.General.ChannelID) { - macontext.General.ChannelID=NULL; return false; } else { return true; } - } bool cMarkAdStandalone::CheckTS(const char *Directory) @@ -493,6 +551,25 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory) macontext.General.DPid.Type=MARKAD_PIDTYPE_AUDIO_AC3; macontext.General.APid.Type=MARKAD_PIDTYPE_AUDIO_MP2; + isyslog("markad [%i]: starting v%s",recvnumber,VERSION); + + if (!bDecodeAudio) + { + isyslog("markad [%i]: audio decoding disabled by user",recvnumber); + } + if (!bDecodeVideo) + { + isyslog("markad [%i]: video decoding disabled by user",recvnumber); + } + if (bIgnoreAudioInfo) + { + isyslog("markad [%i]: audio info usage disabled by user",recvnumber); + } + if (bIgnoreVideoInfo) + { + isyslog("markad [%i]: video info usage disabled by user",recvnumber); + } + if (!CheckTS(Directory)) { video_demux=NULL; @@ -623,6 +700,10 @@ int usage() "-d --disable=