mirror of
				https://projects.vdr-developer.org/git/vdr-plugin-softhddevice.git
				synced 2023-10-10 17:16:51 +00:00 
			
		
		
		
	Workaround for ffmpeg 2.6 artifacts.
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
User johns
 | 
			
		||||
Date:
 | 
			
		||||
 | 
			
		||||
    Workaround for ffmpeg 2.6 artifacts.
 | 
			
		||||
    Fix bug: brightness and .. are calculated wrong.
 | 
			
		||||
    Add automatic frame rate detection for older ffmpeg versions.
 | 
			
		||||
    Fix bug: destroyed vdpau surfaces still used in queue.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										35
									
								
								codec.c
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								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):
 | 
			
		||||
///
 | 
			
		||||
@@ -93,6 +93,16 @@
 | 
			
		||||
#include "audio.h"
 | 
			
		||||
#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.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								codec.h
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								codec.h
									
									
									
									
									
								
							@@ -1,7 +1,7 @@
 | 
			
		||||
///
 | 
			
		||||
///	@file codec.h	@brief Codec module headerfile
 | 
			
		||||
///
 | 
			
		||||
///	Copyright (c) 2009 - 2013 by Johns.  All Rights Reserved.
 | 
			
		||||
///	Copyright (c) 2009 - 2013, 2015 by Johns.  All Rights Reserved.
 | 
			
		||||
///
 | 
			
		||||
///	Contributor(s):
 | 
			
		||||
///
 | 
			
		||||
@@ -43,6 +43,13 @@ typedef struct _video_decoder_ VideoDecoder;
 | 
			
		||||
    /// Audio decoder typedef.
 | 
			
		||||
typedef struct _audio_decoder_ AudioDecoder;
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------
 | 
			
		||||
//	Variables
 | 
			
		||||
//----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
    /// Flag prefer fast xhannel switch
 | 
			
		||||
extern char CodecUsePossibleDefectFrames;
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------
 | 
			
		||||
//	Prototypes
 | 
			
		||||
//----------------------------------------------------------------------------
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
///
 | 
			
		||||
///	@file softhddev.c	@brief A software HD device plugin for VDR.
 | 
			
		||||
///
 | 
			
		||||
///	Copyright (c) 2011 - 2014 by Johns.  All Rights Reserved.
 | 
			
		||||
///	Copyright (c) 2011 - 2015 by Johns.  All Rights Reserved.
 | 
			
		||||
///
 | 
			
		||||
///	Contributor(s):
 | 
			
		||||
///
 | 
			
		||||
@@ -2905,6 +2905,7 @@ const char *CommandLineHelp(void)
 | 
			
		||||
	"\talsa-no-close-open\tdisable close open to fix alsa no sound bug\n"
 | 
			
		||||
	"\talsa-close-open-delay\tenable close open delay to fix no sound bug\n"
 | 
			
		||||
	"\tignore-repeat-pict\tdisable repeat pict message\n"
 | 
			
		||||
	"\tuse-possible-defect-frames prefer faster channel switch\n"
 | 
			
		||||
	"  -D\t\tstart in detached mode\n";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -2986,6 +2987,8 @@ int ProcessArgs(int argc, char *const argv[])
 | 
			
		||||
		    AudioAlsaCloseOpenDelay = 1;
 | 
			
		||||
		} else if (!strcasecmp("ignore-repeat-pict", optarg)) {
 | 
			
		||||
		    VideoIgnoreRepeatPict = 1;
 | 
			
		||||
		} else if (!strcasecmp("use-possible-defect-frames", optarg)) {
 | 
			
		||||
		    CodecUsePossibleDefectFrames = 1;
 | 
			
		||||
		} else {
 | 
			
		||||
		    fprintf(stderr, _("Workaround '%s' unsupported\n"),
 | 
			
		||||
			optarg);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user