diff options
author | Jochen Dolze <vdr@dolze.de> | 2012-02-24 20:16:03 +0100 |
---|---|---|
committer | Jochen Dolze <vdr@dolze.de> | 2012-02-24 20:16:03 +0100 |
commit | 91b1ad21bcbe1a5041e180d02a8ff5e11e40d463 (patch) | |
tree | 170fa0dcaf18b0b82fa4ccb8248bdb6ff5fc65ba | |
parent | 22016dfb79e05cf28c5cac9574649cbb13aabd8a (diff) | |
download | vdr-plugin-markad-91b1ad21bcbe1a5041e180d02a8ff5e11e40d463.tar.gz vdr-plugin-markad-91b1ad21bcbe1a5041e180d02a8ff5e11e40d463.tar.bz2 |
Removed AC3 and MP2 audio decoding support (not needed)
Added logo for ATV and ATV2
-rw-r--r-- | command/decoder.cpp | 200 | ||||
-rw-r--r-- | command/decoder.h | 15 | ||||
-rw-r--r-- | command/logos/ATV-A16_9-P0.pgm | bin | 10019 -> 10018 bytes | |||
-rw-r--r-- | command/logos/ATV-A16_9-P2.pgm | bin | 2517 -> 2497 bytes | |||
-rw-r--r-- | command/logos/ATV2-A16_9-P0.pgm | bin | 0 -> 9019 bytes | |||
-rw-r--r-- | command/logos/ATV2-A16_9-P1.pgm (renamed from command/logos/ATV-A16_9-P1.pgm) | bin | 2517 -> 2237 bytes | |||
-rw-r--r-- | command/logos/ATV2-A16_9-P2.pgm | bin | 0 -> 2237 bytes | |||
-rw-r--r-- | command/markad-standalone.cpp | 5 |
8 files changed, 4 insertions, 216 deletions
diff --git a/command/decoder.cpp b/command/decoder.cpp index 3890e15..434ee68 100644 --- a/command/decoder.cpp +++ b/command/decoder.cpp @@ -101,7 +101,7 @@ fail: } #endif -cMarkAdDecoder::cMarkAdDecoder(bool useH264, bool useMP2, bool hasAC3, int Threads) +cMarkAdDecoder::cMarkAdDecoder(bool useH264, int Threads) { avcodec_init(); avcodec_register_all(); @@ -110,8 +110,6 @@ cMarkAdDecoder::cMarkAdDecoder(bool useH264, bool useMP2, bool hasAC3, int Threa skipframes=true; noticeERRVID=false; - noticeERRMP2=false; - noticeERRAC3=false; cpu_set_t cpumask; uint len = sizeof(cpumask); @@ -154,76 +152,6 @@ cMarkAdDecoder::cMarkAdDecoder(bool useH264, bool useMP2, bool hasAC3, int Threa esyslog("dont report bugs about H264, use libavcodec >= 52 instead!"); } - if (useMP2) - { - CodecID mp2_codecid=CODEC_ID_MP2; - AVCodec *mp2_codec= avcodec_find_decoder(mp2_codecid); - if (mp2_codec) - { - mp2_context = avcodec_alloc_context(); - if (mp2_context) - { - mp2_context->codec_id = mp2_codecid; - mp2_context->codec_type = AVMEDIA_TYPE_AUDIO; - if (avcodec_open(mp2_context, mp2_codec) < 0) - { - esyslog("could not open codec for MP2"); - av_free(mp2_context); - mp2_context=NULL; - } - avcodec_thread_init(mp2_context,threadcount); - } - else - { - esyslog("could not allocate mp2 context"); - } - } - else - { - esyslog("codec for MP2 not found"); - mp2_context=NULL; - } - } - else - { - mp2_context=NULL; - } - - if (hasAC3) - { - CodecID ac3_codecid=CODEC_ID_AC3; - AVCodec *ac3_codec= avcodec_find_decoder(ac3_codecid); - if (ac3_codec) - { - ac3_context = avcodec_alloc_context(); - if (ac3_context) - { - ac3_context->codec_id = ac3_codecid; - ac3_context->codec_type = AVMEDIA_TYPE_AUDIO; - if (avcodec_open(ac3_context, ac3_codec) < 0) - { - esyslog("could not open codec for AC3"); - av_free(ac3_context); - ac3_context=NULL; - } - avcodec_thread_init(ac3_context,threadcount); - } - else - { - esyslog("could not allocate ac3 context"); - } - } - else - { - esyslog("codec for AC3 not found"); - ac3_context=NULL; - } - } - else - { - ac3_context=NULL; - } - video_codec=NULL; CodecID video_codecid; @@ -366,15 +294,6 @@ cMarkAdDecoder::cMarkAdDecoder(bool useH264, bool useMP2, bool hasAC3, int Threa } video_context=NULL; } - - if ((ac3_context) || (mp2_context)) - { - audiobuf=(int16_t*) malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); - } - else - { - audiobuf=NULL; - } } cMarkAdDecoder::~cMarkAdDecoder() @@ -386,19 +305,6 @@ cMarkAdDecoder::~cMarkAdDecoder() av_free(video_context); av_free(video_frame); } - - if (ac3_context) - { - avcodec_close(ac3_context); - av_free(ac3_context); - } - - if (mp2_context) - { - avcodec_close(mp2_context); - av_free(mp2_context); - } - if (audiobuf) free(audiobuf); } bool cMarkAdDecoder::Clear() @@ -437,110 +343,6 @@ bool cMarkAdDecoder::Clear() video_context->execute=avcodec_default_execute; } } - if (ac3_context) avcodec_flush_buffers(ac3_context); - if (mp2_context) avcodec_flush_buffers(mp2_context); - return ret; -} - -bool cMarkAdDecoder::SetAudioInfos(MarkAdContext *maContext, AVCodecContext *Audio_Context) -{ - if ((!maContext) || (!Audio_Context)) return false; - - maContext->Audio.Info.SampleRate = Audio_Context->sample_rate; - maContext->Audio.Info.Channels = Audio_Context->channels; - maContext->Audio.Data.SampleBuf=audiobuf; - maContext->Audio.Data.SampleBufLen=audiobufsize; - maContext->Audio.Data.Valid=true; - return true; -} - -bool cMarkAdDecoder::DecodeMP2(MarkAdContext *maContext, uchar *espkt, int eslen) -{ - if (!mp2_context) return false; - maContext->Audio.Data.Valid=false; - AVPacket avpkt; -#if LIBAVCODEC_VERSION_INT >= ((52<<16)+(25<<8)+0) - av_init_packet(&avpkt); -#else - memset(&avpkt,0,sizeof(avpkt)); - avpkt.pts = avpkt.dts = AV_NOPTS_VALUE; - avpkt.pos = -1; -#endif - avpkt.data=espkt; - avpkt.size=eslen; - - audiobufsize=AVCODEC_MAX_AUDIO_FRAME_SIZE; - int ret=false; - while (avpkt.size>0) - { -#if LIBAVCODEC_VERSION_INT < ((52<<16)+(25<<8)+0) - int len=avcodec_decode_audio2(mp2_context,audiobuf,&audiobufsize, - avpkt.data,avpkt.size); -#else - int len=avcodec_decode_audio3(mp2_context,audiobuf,&audiobufsize,&avpkt); -#endif - if (len<0) - { - if (!noticeERRMP2) - { - esyslog("error decoding mp2"); - noticeERRMP2=true; - } - break; - } - if (audiobufsize>0) - { - SetAudioInfos(maContext,mp2_context); - ret=true; - avpkt.size-=len; - avpkt.data+=len; - } - } - return ret; -} - -bool cMarkAdDecoder::DecodeAC3(MarkAdContext *maContext, uchar *espkt, int eslen) -{ - if (!ac3_context) return false; - maContext->Audio.Data.Valid=false; - AVPacket avpkt; -#if LIBAVCODEC_VERSION_INT >= ((52<<16)+(25<<8)+0) - av_init_packet(&avpkt); -#else - memset(&avpkt,0,sizeof(avpkt)); - avpkt.pts = avpkt.dts = AV_NOPTS_VALUE; - avpkt.pos = -1; -#endif - avpkt.data=espkt; - avpkt.size=eslen; - - int ret=false; - while (avpkt.size>0) - { - audiobufsize=AVCODEC_MAX_AUDIO_FRAME_SIZE; -#if LIBAVCODEC_VERSION_INT < ((52<<16)+(25<<8)+0) - int len=avcodec_decode_audio2(ac3_context,audiobuf,&audiobufsize, - avpkt.data,avpkt.size); -#else - int len=avcodec_decode_audio3(ac3_context,audiobuf,&audiobufsize,&avpkt); -#endif - if (len<0) - { - if (!noticeERRAC3) - { - esyslog("error decoding ac3"); - noticeERRAC3=true; - } - break; - } - if (audiobufsize>0) - { - SetAudioInfos(maContext,ac3_context); - ret=true; - avpkt.size-=len; - avpkt.data+=len; - } - } return ret; } diff --git a/command/decoder.h b/command/decoder.h index 0ea6e47..707ca56 100644 --- a/command/decoder.h +++ b/command/decoder.h @@ -40,34 +40,21 @@ class cMarkAdDecoder { private: bool skipframes; - int16_t *audiobuf; - int audiobufsize; AVCodec *video_codec; - AVCodecContext *ac3_context; - AVCodecContext *mp2_context; AVCodecContext *video_context; AVFrame *video_frame; int threadcount; int8_t *last_qscale_table; - static int our_get_buffer(struct AVCodecContext *c, AVFrame *pic); - static void our_release_buffer(struct AVCodecContext *c, AVFrame *pic); - - bool SetAudioInfos(MarkAdContext *maContext, AVCodecContext *Audio_Context); bool SetVideoInfos(MarkAdContext *maContext,AVCodecContext *Video_Context, AVFrame *Video_Frame); - bool noticeERRVID; - bool noticeERRMP2; - bool noticeERRAC3; public: bool DecodeVideo(MarkAdContext *maContext, uchar *pkt, int plen); - bool DecodeMP2(MarkAdContext *maContext, uchar *espkt, int eslen); - bool DecodeAC3(MarkAdContext *maContext, uchar *espkt, int eslen); bool Clear(); - cMarkAdDecoder(bool useH264, bool useMP2, bool hasAC3, int Threads); + cMarkAdDecoder(bool useH264, int Threads); ~cMarkAdDecoder(); }; diff --git a/command/logos/ATV-A16_9-P0.pgm b/command/logos/ATV-A16_9-P0.pgm Binary files differindex 5d55100..daa2553 100644 --- a/command/logos/ATV-A16_9-P0.pgm +++ b/command/logos/ATV-A16_9-P0.pgm diff --git a/command/logos/ATV-A16_9-P2.pgm b/command/logos/ATV-A16_9-P2.pgm Binary files differindex cbe4033..92bf091 100644 --- a/command/logos/ATV-A16_9-P2.pgm +++ b/command/logos/ATV-A16_9-P2.pgm diff --git a/command/logos/ATV2-A16_9-P0.pgm b/command/logos/ATV2-A16_9-P0.pgm Binary files differnew file mode 100644 index 0000000..7684962 --- /dev/null +++ b/command/logos/ATV2-A16_9-P0.pgm diff --git a/command/logos/ATV-A16_9-P1.pgm b/command/logos/ATV2-A16_9-P1.pgm Binary files differindex 0bdcf62..033d3cc 100644 --- a/command/logos/ATV-A16_9-P1.pgm +++ b/command/logos/ATV2-A16_9-P1.pgm diff --git a/command/logos/ATV2-A16_9-P2.pgm b/command/logos/ATV2-A16_9-P2.pgm Binary files differnew file mode 100644 index 0000000..7628654 --- /dev/null +++ b/command/logos/ATV2-A16_9-P2.pgm diff --git a/command/markad-standalone.cpp b/command/markad-standalone.cpp index c247617..5140dd6 100644 --- a/command/markad-standalone.cpp +++ b/command/markad-standalone.cpp @@ -974,7 +974,7 @@ bool cMarkAdStandalone::ProcessFile(int Number) marks.WriteIndex(directory,isTS,demux->Offset(),macontext.Video.Info.Pict_Type,Number); } framecnt++; - if ((macontext.Config->logoExtraction!=-1) && (framecnt>=1000)) + if ((macontext.Config->logoExtraction!=-1) && (framecnt>=256)) { isyslog("finished logo extraction"); abort=true; @@ -2197,8 +2197,7 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, const MarkAdConfig * if (!abort) { - decoder = new cMarkAdDecoder(macontext.Info.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264, - macontext.Info.APid.Num!=0,macontext.Info.DPid.Num!=0,config->threads); + decoder = new cMarkAdDecoder(macontext.Info.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264,config->threads); video = new cMarkAdVideo(&macontext); audio = new cMarkAdAudio(&macontext); streaminfo = new cMarkAdStreamInfo; |