From ab902d3962df5dbe8c8d707da96cdf279ca3b439 Mon Sep 17 00:00:00 2001 From: anbr Date: Tue, 12 Feb 2013 19:15:00 +0100 Subject: Patch for compiling with VDR 1.7.36, thanks to Ulrich Eckhardt, for summit a patch (Closes: #1251) --- liboutput/encode.c | 28 +++++++++++++--------------- liboutput/encode.h | 4 ++++ 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'liboutput') diff --git a/liboutput/encode.c b/liboutput/encode.c index 6098ab0..549f440 100644 --- a/liboutput/encode.c +++ b/liboutput/encode.c @@ -49,13 +49,8 @@ cEncode::cEncode(unsigned int nNumberOfFramesToEncode) bool cEncode::Register() { - avcodec_init(); -#if 0 - // XXX to resolv: dosen't work with osdpip - register_avcodec(&mpeg2video_encoder); -#else + av_register_all(); avcodec_register_all(); -#endif m_pavCodec = avcodec_find_encoder(CODEC_ID_MPEG2VIDEO); if (!m_pavCodec) { @@ -100,7 +95,7 @@ bool cEncode::Encode() AVCodecContext *pAVCC = NULL; AVFrame *pAVF = NULL; - pAVCC = avcodec_alloc_context(); + pAVCC = avcodec_alloc_context3(m_pavCodec); if (! pAVCC) { esyslog("imageplugin: Failed to alloc memory for AVCodecContext."); @@ -116,7 +111,7 @@ bool cEncode::Encode() { SetupEncodingParameters(pAVCC); - if (avcodec_open(pAVCC, m_pavCodec) < 0) + if (avcodec_open2(pAVCC, m_pavCodec, NULL) < 0) { esyslog("imageplugin: Couldn't open Codec."); } @@ -142,7 +137,7 @@ void cEncode::SetupEncodingParameters(AVCodecContext *context) context->height = m_nHeight; #if LIBAVCODEC_BUILD >= 4754 - context->time_base=(AVRational){1, GetFrameRate()}; + context->time_base=(AVRational){1, (int)GetFrameRate()}; #else context->frame_rate=GetFrameRate(); context->frame_rate_base=1; @@ -216,6 +211,8 @@ bool cEncode::ConvertImageToFrame(AVFrame *frame) bool cEncode::EncodeFrames(AVCodecContext *context, AVFrame *frame) { + AVPacket outpkt; + int got_output; if(!m_pFrameSizes) { esyslog("imageplugin: Failed to add MPEG sequence, insufficient memory."); @@ -223,23 +220,24 @@ bool cEncode::EncodeFrames(AVCodecContext *context, AVFrame *frame) } unsigned int i; - + av_init_packet(&outpkt); m_nMPEGSize = 0; // Encode m_nNumberOfFramesToEncode number of frames for(i=0; (i < m_nNumberOfFramesToEncode) && (m_nMPEGSize < m_nMaxMPEGSize); ++i) { - int nFrameSize = avcodec_encode_video(context, m_pMPEG + m_nMPEGSize, - m_nMaxMPEGSize - m_nMPEGSize, frame); - if(nFrameSize < 0) + outpkt.data = ( m_pMPEG + m_nMPEGSize); + outpkt.size = m_nMaxMPEGSize - m_nMPEGSize; + int err = avcodec_encode_video2(context, &outpkt,frame, &got_output); + if(err < 0) { esyslog("imageplugin: Failed to add frame %d, insufficient memory.", i); return false; } - m_nMPEGSize += nFrameSize; - *(m_pFrameSizes + i) = nFrameSize; + m_nMPEGSize += outpkt.size; + *(m_pFrameSizes + i) = outpkt.size; } // Add four bytes MPEG end sequence diff --git a/liboutput/encode.h b/liboutput/encode.h index db7f122..6c47b63 100644 --- a/liboutput/encode.h +++ b/liboutput/encode.h @@ -14,6 +14,10 @@ extern "C" { #include +#include +#ifdef HAVE_SWSCALE +# include +#endif } #include "../setup-image.h" -- cgit v1.2.3