diff --git a/VapourSynth/libavsmash_source.c b/VapourSynth/libavsmash_source.c index a56b06a5..67f3f3e1 100644 --- a/VapourSynth/libavsmash_source.c +++ b/VapourSynth/libavsmash_source.c @@ -295,9 +295,19 @@ static const VSFrameRef *VS_CC vs_filter_get_frame( int n, int activation_reason vsapi->propSetFrame( props, "_Alpha", vs_frame2, paAppend ); vsapi->freeFrame( vs_frame2 ); } - set_frame_properties( vdhp, n, vi, av_frame, vs_frame, sample_number, - ( vohp->repeat_control ) ? vohp->frame_order_list[n].top : n, - ( vohp->repeat_control ) ? vohp->frame_order_list[n].bottom : n, vsapi ); + int top = -1; + if ( vohp->repeat_control && vohp->repeat_requested ) + { + top = ( vohp->frame_order_list[n].top == vohp->frame_order_list[sample_number].top ) ? vohp->frame_order_list[n - 1].top : + vohp->frame_order_list[n].top; + } + int bottom = -1; + if ( vohp->repeat_control && vohp->repeat_requested ) + { + bottom = ( vohp->frame_order_list[n].bottom == vohp->frame_order_list[sample_number].bottom ) ? vohp->frame_order_list[n - 1].bottom : + vohp->frame_order_list[n].bottom; + } + set_frame_properties( vdhp, n, vi, av_frame, vs_frame, sample_number, top, bottom, vsapi ); return vs_frame; } diff --git a/VapourSynth/lwlibav_source.c b/VapourSynth/lwlibav_source.c index c0db19ee..6d72cc8f 100644 --- a/VapourSynth/lwlibav_source.c +++ b/VapourSynth/lwlibav_source.c @@ -283,9 +283,19 @@ static const VSFrameRef *VS_CC vs_filter_get_frame( int n, int activation_reason vsapi->propSetFrame( props, "_Alpha", vs_frame2, paAppend ); vsapi->freeFrame( vs_frame2 ); } - set_frame_properties( n, vi, av_frame, vdhp->format->streams[vdhp->stream_index], vs_frame, - ( vohp->repeat_control ) ? vohp->frame_order_list[n].top : n, - ( vohp->repeat_control ) ? vohp->frame_order_list[n].bottom : n,vsapi ); + int top = -1; + if ( vohp->repeat_control && vohp->repeat_requested ) + { + top = ( vohp->frame_order_list[n].top == vohp->frame_order_list[frame_number].top ) ? vohp->frame_order_list[n - 1].top : + vohp->frame_order_list[n].top; + } + int bottom = -1; + if ( vohp->repeat_control && vohp->repeat_requested ) + { + bottom = ( vohp->frame_order_list[n].bottom == vohp->frame_order_list[frame_number].bottom ) ? vohp->frame_order_list[n - 1].bottom : + vohp->frame_order_list[n].bottom; + } + set_frame_properties( n, vi, av_frame, vdhp->format->streams[vdhp->stream_index], vs_frame, top, bottom,vsapi ); if ( n == 0 && hp->framelist ) { const char *ftype = "IPB"; diff --git a/VapourSynth/video_output.c b/VapourSynth/video_output.c index 85674896..78bb595d 100644 --- a/VapourSynth/video_output.c +++ b/VapourSynth/video_output.c @@ -1091,8 +1091,9 @@ void vs_set_frame_properties if( av_frame->interlaced_frame ) field_based = av_frame->top_field_first ? 2 : 1; vsapi->propSetInt( props, "_FieldBased", field_based, paReplace ); - vsapi->propSetInt( props, "_EncodedFrameTop", top, paReplace ); - vsapi->propSetInt( props, "_EncodedFrameBottom", bottom, paReplace ); + vsapi->propSetInt(props, "_EncodedFrameTop", top > -1 ? top : n, paReplace); + vsapi->propSetInt(props, "_EncodedFrameBottom", top > -1 ? bottom : n, paReplace); + /* Mastering display color volume */ int frame_has_primaries = 0, frame_has_luminance = 0; const AVFrameSideData *mastering_display_side_data = av_frame_get_side_data( av_frame, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA ); diff --git a/common/lwlibav_video.c b/common/lwlibav_video.c index 342ea82f..cca6f7e2 100644 --- a/common/lwlibav_video.c +++ b/common/lwlibav_video.c @@ -1146,7 +1146,7 @@ static inline int copy_field } } /* Treat this frame as interlaced. */ - dst->interlaced_frame = 1; + dst->interlaced_frame = src->interlaced_frame; dst->top_field_first = top_field_first; return 0; } @@ -1189,7 +1189,7 @@ static int lwlibav_repeat_control if( get_requested_picture( vdhp, vdhp->frame_buffer, first_field_number ) < 0 ) return -1; /* Treat this frame as interlaced. */ - vdhp->frame_buffer->interlaced_frame = 1; + vdhp->frame_buffer->interlaced_frame = vohp->frame_cache_buffers[0]->interlaced_frame; return 0; } }