Skip to content

Commit

Permalink
VapourSynth/{libavsmash,lwlibav}_source.c, video_output.c, common/lwl…
Browse files Browse the repository at this point in the history
…ibav_video.c: Fix _EncodedFrameTop and _EncodedFrameBottom

Cherry-picked from HomeOfAviSynthPlusEvolution/L-SMASH-Works@9b23bbd.
Original commit message:

    commit 9b23bbdab9bbd2d9285a1e8f102aca545c61a945
    Author: Asd-g <65298684+Asd-g@users.noreply.github.com>
    Date:   Sun Jun 11 03:29:32 2023 +0300

        Fix frame properties

        Fix _EncodedFrameTop and _EncodedFrameTop, close HomeOfAviSynthPlusEvolution/L-SMASH-Works#32. Change behavior - they are showed only when there are frames to be repeated.
        Fix _FieldBased when repeat is not false.

This change only imports the common & VS part and we keep the previous behavior
of always defining _EncodedFrameTop and _EncodedFrameBottom even when not repeating.
  • Loading branch information
AkarinVS committed Sep 3, 2023
1 parent d73d2dc commit d4299f2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
16 changes: 13 additions & 3 deletions VapourSynth/libavsmash_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
16 changes: 13 additions & 3 deletions VapourSynth/lwlibav_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
5 changes: 3 additions & 2 deletions VapourSynth/video_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions common/lwlibav_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit d4299f2

Please sign in to comment.