summaryrefslogtreecommitdiff
path: root/liboutput
diff options
context:
space:
mode:
authoranbr <vdr07@deltab.de>2013-02-12 19:15:00 +0100
committeranbr <vdr07@deltab.de>2013-02-12 19:15:00 +0100
commitab902d3962df5dbe8c8d707da96cdf279ca3b439 (patch)
tree1bbb74443b1790665e971f4cd1a90a61933ef91a /liboutput
parentc92ba1c907240415fd7caab5b757bbdeb73efc17 (diff)
downloadvdr-plugin-image-ab902d3962df5dbe8c8d707da96cdf279ca3b439.tar.gz
vdr-plugin-image-ab902d3962df5dbe8c8d707da96cdf279ca3b439.tar.bz2
Patch for compiling with VDR 1.7.36, thanks to Ulrich Eckhardt, for summit a patch (Closes: #1251)
Diffstat (limited to 'liboutput')
-rw-r--r--liboutput/encode.c28
-rw-r--r--liboutput/encode.h4
2 files changed, 17 insertions, 15 deletions
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 <libavcodec/avcodec.h>
+#include <libavformat/avformat.h>
+#ifdef HAVE_SWSCALE
+# include <libswscale/swscale.h>
+#endif
}
#include "../setup-image.h"