Skip to content

Commit 7ad2fd5

Browse files
committed
Config.Decoder: Introduces KeyFrameValidation which ensures no artifacts on some broken formats [Fixes #638]
1 parent 8acb622 commit 7ad2fd5

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

FlyleafLib/Engine/Config.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,12 @@ public DecoderConfig Clone()
565565
public bool ShowCorrupted { get => _ShowCorrupted; set => SetUI(ref _ShowCorrupted, value); }
566566
bool _ShowCorrupted;
567567

568+
/// <summary>
569+
/// Ensures that after a key packet receives a also key frame (can create artifacts on some broken formats when disabled)
570+
/// </summary>
571+
public bool KeyFrameValidation { get => _KeyFrameValidation; set => SetUI(ref _KeyFrameValidation, value); }
572+
internal bool _KeyFrameValidation;
573+
568574
/// <summary>
569575
/// Forces low delay (Parses AV_CODEC_FLAG2_FAST or AV_CODEC_FLAG_LOW_DELAY -based on DropFrames- to AVCodecContext) (auto-enabled with MaxLatency)
570576
/// </summary>

FlyleafLib/MediaFramework/MediaContext/DecoderContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ public long GetVideoFrame(long timestamp = -1)
531531
if (packet->flags.HasFlag(PktFlags.Key) || packet->pts == VideoDecoder.startPts)
532532
{
533533
VideoDecoder.keyPacketRequired = false;
534-
VideoDecoder.keyFrameRequired = true;
534+
VideoDecoder.keyFrameRequired = Config.Decoder._KeyFrameValidation;
535535
}
536536
else
537537
{

FlyleafLib/MediaFramework/MediaDecoder/VideoDecoder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ protected override void RunInternal()
493493
{
494494
if (packet->flags.HasFlag(PktFlags.Key) || packet->pts == startPts)
495495
{
496-
keyFrameRequired = true;
496+
keyFrameRequired = Config.Decoder._KeyFrameValidation;
497497
keyPacketRequired = false;
498498
}
499499
else
@@ -1086,7 +1086,7 @@ public int DecodeFrameNext()
10861086
if (demuxer.packet->flags.HasFlag(PktFlags.Key) || demuxer.packet->pts == startPts)
10871087
{
10881088
keyPacketRequired = false;
1089-
keyFrameRequired = true;
1089+
keyFrameRequired = Config.Decoder._KeyFrameValidation;
10901090
}
10911091
else
10921092
{

0 commit comments

Comments
 (0)