summaryrefslogtreecommitdiff
path: root/codec.c
diff options
context:
space:
mode:
authorJohns <johns98@gmx.net>2015-04-22 12:14:15 +0200
committerJohns <johns98@gmx.net>2015-04-22 12:14:15 +0200
commite0f4a99b99532d195ad40a161b633d39bcba4725 (patch)
tree501f6af32ba8e076e73f91db01dc514660345ea4 /codec.c
parenta1939eb6cb94ed22d402e8935f3cec294b2af39d (diff)
downloadvdr-plugin-softhddevice-e0f4a99b99532d195ad40a161b633d39bcba4725.tar.gz
vdr-plugin-softhddevice-e0f4a99b99532d195ad40a161b633d39bcba4725.tar.bz2
Workaround for ffmpeg 2.6 artifacts.
Diffstat (limited to 'codec.c')
-rw-r--r--codec.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/codec.c b/codec.c
index 10011c3..cbf6f39 100644
--- a/codec.c
+++ b/codec.c
@@ -1,7 +1,7 @@
///
/// @file codec.c @brief Codec functions
///
-/// Copyright (c) 2009 - 2014 by Johns. All Rights Reserved.
+/// Copyright (c) 2009 - 2015 by Johns. All Rights Reserved.
///
/// Contributor(s):
///
@@ -94,6 +94,16 @@
#include "codec.h"
//----------------------------------------------------------------------------
+
+ // correct is AV_VERSION_INT(56,35,101) but some gentoo i* think
+ // they must change it.
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56,26,100)
+ /// ffmpeg 2.6 started to show artifacts after channel switch
+ /// to SDTV channels
+#define FFMPEG_WORKAROUND_ARTIFACTS 1
+#endif
+
+//----------------------------------------------------------------------------
// Global
//----------------------------------------------------------------------------
@@ -105,6 +115,9 @@
///
static pthread_mutex_t CodecLockMutex;
+ /// Flag prefer fast xhannel switch
+char CodecUsePossibleDefectFrames;
+
//----------------------------------------------------------------------------
// Video
//----------------------------------------------------------------------------
@@ -126,6 +139,9 @@ struct _video_decoder_
int GetFormatDone; ///< flag get format called!
AVCodec *VideoCodec; ///< video codec
AVCodecContext *VideoCtx; ///< video codec context
+#ifdef FFMPEG_WORKAROUND_ARTIFACTS
+ int FirstKeyFrame; ///< flag first frame
+#endif
AVFrame *Frame; ///< decoded video frame
};
@@ -525,6 +541,9 @@ void CodecVideoOpen(VideoDecoder * decoder, const char *name, int codec_id)
}
// reset buggy ffmpeg/libav flag
decoder->GetFormatDone = 0;
+#ifdef FFMPEG_WORKAROUND_ARTIFACTS
+ decoder->FirstKeyFrame = 1;
+#endif
}
/**
@@ -611,8 +630,22 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
}
if (got_frame) { // frame completed
+#ifdef FFMPEG_WORKAROUND_ARTIFACTS
+ if (!CodecUsePossibleDefectFrames && decoder->FirstKeyFrame) {
+ decoder->FirstKeyFrame++;
+ if (frame->key_frame) {
+ Debug((3, "codec: key frame after %d frames\n",
+ decoder->FirstKeyFrame);
+ decoder->FirstKeyFrame = 0;
+ }
+ } else {
+ //DisplayPts(video_ctx, frame);
+ VideoRenderFrame(decoder->HwDecoder, video_ctx, frame);
+ }
+#else
//DisplayPts(video_ctx, frame);
VideoRenderFrame(decoder->HwDecoder, video_ctx, frame);
+#endif
} else {
// some frames are needed for references, interlaced frames ...
// could happen with h264 dvb streams, just drop data.