[FFmpeg-devel] [PATCH 1/2] avfilter/filters: add ff_inlink_peek_frame and ff_inlink_queued_frames to access frames in the inlink fifo
Nicolas George
george at nsup.org
Mon Oct 1 15:18:02 EEST 2018
Marton Balint (2018-09-30):
> Signed-off-by: Marton Balint <cus at passwd.hu>
> ---
> libavfilter/avfilter.c | 13 +++++++++++++
> libavfilter/filters.h | 14 ++++++++++++++
> 2 files changed, 27 insertions(+)
>
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index 85eff0aa1d..9e4b8e5ca3 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -1448,6 +1448,11 @@ int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts
> return 1;
> }
>
> +size_t ff_inlink_queued_frames(AVFilterLink *link)
> +{
> + return ff_framequeue_queued_frames(&link->fifo);
> +}
> +
> int ff_inlink_check_available_frame(AVFilterLink *link)
> {
> return ff_framequeue_queued_frames(&link->fifo) > 0;
> @@ -1507,6 +1512,14 @@ int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max,
> return 1;
> }
>
> +AVFrame *ff_inlink_peek_frame(AVFilterLink *link, size_t idx)
> +{
> + if (ff_framequeue_queued_frames(&link->fifo) > idx)
> + return ff_framequeue_peek(&link->fifo, idx);
> + else
> + return NULL;
> +}
> +
> int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe)
> {
> AVFrame *frame = *rframe;
> diff --git a/libavfilter/filters.h b/libavfilter/filters.h
> index 4e2652ebe5..b310f1c5a8 100644
> --- a/libavfilter/filters.h
> +++ b/libavfilter/filters.h
> @@ -60,6 +60,12 @@ int ff_inlink_process_commands(AVFilterLink *link, const AVFrame *frame);
> */
> int ff_inlink_evaluate_timeline_at_frame(AVFilterLink *link, const AVFrame *frame);
>
> +/**
> + * Get the number of frames available on the link.
> + * @return the number of frames available in the link fifo.
> + */
> +size_t ff_inlink_queued_frames(AVFilterLink *link);
> +
> /**
> * Test if a frame is available on the link.
> * @return >0 if a frame is available
> @@ -102,6 +108,14 @@ int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe);
> int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max,
> AVFrame **rframe);
>
> +/**
> + * Access a frame in the link fifo without consuming it.
> + * The first frame is numbered 0.
> + * @return the frame at idx position in the link fifo, NULL if idx is greater
> + * or equal to the fifo size.
I would like it better if the behaviour would match the wrapped
behaviour more closely:
* The first frame is numbered 0; the designated frame must exist.
But we can discuss it.
> + */
> +AVFrame *ff_inlink_peek_frame(AVFilterLink *link, size_t idx);
> +
> /**
> * Make sure a frame is writable.
> * This is similar to av_frame_make_writable() except it uses the link's
Apart from that, LGTM.
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20181001/8d210345/attachment.sig>
More information about the ffmpeg-devel
mailing list