Skip to content

Commit

Permalink
VapourSynth: set _FrameNumber frame property
Browse files Browse the repository at this point in the history
Signed-off-by: akarin <[email protected]>
  • Loading branch information
AkarinVS committed Jul 31, 2021
1 parent b3ae209 commit 59ef222
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions VapourSynth/libavsmash_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ static void get_sample_duration
static void set_frame_properties
(
libavsmash_video_decode_handler_t *vdhp,
int n,
VSVideoInfo *vi,
AVFrame *av_frame,
VSFrameRef *vs_frame,
Expand All @@ -158,7 +159,7 @@ static void set_frame_properties
int64_t duration_num;
int64_t duration_den;
get_sample_duration( vdhp, vi, sample_number, &duration_num, &duration_den );
vs_set_frame_properties( av_frame, NULL, duration_num, duration_den, vs_frame, vsapi );
vs_set_frame_properties( n, av_frame, NULL, duration_num, duration_den, vs_frame, vsapi );
}

static int prepare_video_decoding
Expand Down Expand Up @@ -272,7 +273,7 @@ static const VSFrameRef *VS_CC vs_filter_get_frame( int n, int activation_reason
vsapi->setFilterError( "lsmas: failed to output a video frame.", frame_ctx );
return NULL;
}
set_frame_properties( vdhp, vi, av_frame, vs_frame, sample_number, vsapi );
set_frame_properties( vdhp, n, vi, av_frame, vs_frame, sample_number, vsapi );
return vs_frame;
}

Expand Down
5 changes: 3 additions & 2 deletions VapourSynth/lwlibav_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ static void VS_CC vs_filter_init( VSMap *in, VSMap *out, void **instance_data, V

static void set_frame_properties
(
int n,
VSVideoInfo *vi,
AVFrame *av_frame,
AVStream *stream,
Expand All @@ -166,7 +167,7 @@ static void set_frame_properties
/* Variable Frame Rate is not supported yet. */
int64_t duration_num = vi->fpsDen;
int64_t duration_den = vi->fpsNum;
vs_set_frame_properties( av_frame, stream, duration_num, duration_den, vs_frame, vsapi );
vs_set_frame_properties( n, av_frame, stream, duration_num, duration_den, vs_frame, vsapi );
}

static int prepare_video_decoding
Expand Down Expand Up @@ -259,7 +260,7 @@ static const VSFrameRef *VS_CC vs_filter_get_frame( int n, int activation_reason
vsapi->setFilterError( "lsmas: failed to output a video frame.", frame_ctx );
return NULL;
}
set_frame_properties( vi, av_frame, vdhp->format->streams[vdhp->stream_index], vs_frame, vsapi );
set_frame_properties( n, vi, av_frame, vdhp->format->streams[vdhp->stream_index], vs_frame, vsapi );
return vs_frame;
}

Expand Down
2 changes: 2 additions & 0 deletions VapourSynth/video_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,7 @@ vs_video_output_handler_t *vs_allocate_video_output_handler

void vs_set_frame_properties
(
int n,
AVFrame *av_frame,
AVStream *stream,
int64_t duration_num,
Expand All @@ -1042,6 +1043,7 @@ void vs_set_frame_properties
)
{
VSMap *props = vsapi->getFramePropsRW( vs_frame );
vsapi->propSetInt( props, "_FrameNumber", n, paReplace );
/* Sample aspect ratio */
vsapi->propSetInt( props, "_SARNum", av_frame->sample_aspect_ratio.num, paReplace );
vsapi->propSetInt( props, "_SARDen", av_frame->sample_aspect_ratio.den, paReplace );
Expand Down
1 change: 1 addition & 0 deletions VapourSynth/video_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ vs_video_output_handler_t *vs_allocate_video_output_handler

void vs_set_frame_properties
(
int n,
AVFrame *av_frame,
AVStream *stream,
int64_t duration_num,
Expand Down

0 comments on commit 59ef222

Please sign in to comment.