[FFmpeg-devel] [PATCH 4/5] src_buffer: implement av_buffersrc_add_frame.
Clément Bœsch
ubitux at gmail.com
Thu May 3 20:19:37 CEST 2012
On Thu, May 03, 2012 at 08:02:52PM +0200, Nicolas George wrote:
> It supersedes av_vsrc_buffer_add_frame and handles
> both audio and video.
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> libavfilter/avcodec.h | 12 ++++++++++++
> libavfilter/src_buffer.c | 32 +++++++++++++++++++++-----------
> 2 files changed, 33 insertions(+), 11 deletions(-)
>
>
> Unchanged and approved, sent only for reference.
>
>
> diff --git a/libavfilter/avcodec.h b/libavfilter/avcodec.h
> index 1aa8b9c..cec8471 100644
> --- a/libavfilter/avcodec.h
> +++ b/libavfilter/avcodec.h
> @@ -92,6 +92,18 @@ int avfilter_fill_frame_from_buffer_ref(AVFrame *frame,
> /**
> * Add frame data to buffer_src.
> *
> + * @param buffer_src pointer to a buffer source context
> + * @param frame a frame, or NULL to mark EOF
> + * @param flags a combination of AV_BUFFERSRC_FLAG_*
> + * @return >= 0 in case of success, a negative AVERROR code
> + * in case of failure
> + */
> +int av_buffersrc_add_frame(AVFilterContext *buffer_src,
> + const AVFrame *frame, int flags);
> +
> +/**
> + * Add frame data to buffer_src.
> + *
> * @param buffer_src pointer to a buffer source context
> * @param flags a combination of AV_VSRC_BUF_FLAG_* flags
> * @return >= 0 in case of success, a negative AVERROR code in case of
> diff --git a/libavfilter/src_buffer.c b/libavfilter/src_buffer.c
> index fce30ec..1ed93df 100644
> --- a/libavfilter/src_buffer.c
> +++ b/libavfilter/src_buffer.c
> @@ -303,28 +303,38 @@ int av_buffersrc_buffer(AVFilterContext *s, AVFilterBufferRef *buf)
> #if CONFIG_AVCODEC
> #include "avcodec.h"
>
> -int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src,
> - const AVFrame *frame, int flags)
> +int av_buffersrc_add_frame(AVFilterContext *buffer_src,
> + const AVFrame *frame, int flags)
> {
> - BufferSourceContext *c = buffer_src->priv;
> AVFilterBufferRef *picref;
> int ret;
>
> - if (!frame) {
> - c->eof = 1;
> - return 0;
> - } else if (c->eof)
> - return AVERROR(EINVAL);
> + if (!frame) /* NULL for EOF */
> + return av_buffersrc_add_ref(buffer_src, NULL, flags);
>
> - picref = avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE);
> + switch (buffer_src->outputs[0]->type) {
> + case AVMEDIA_TYPE_VIDEO:
> + picref = avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE);
> + break;
> + case AVMEDIA_TYPE_AUDIO:
> + picref = avfilter_get_audio_buffer_ref_from_frame(frame, AV_PERM_WRITE);
> + break;
> + default:
> + return AVERROR(ENOSYS);
> + }
I know it's already approved, but this can be simplified with a
avfilter_get_buffer_ref_from_frame() (see comment on patch 1/5).
Also another commit to rename picref into ref or bufref would be welcome I
guess.
[...]
PS: sorry if these comments have already been raised, I don't remember
them so just in case...
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120503/f0d9bf57/attachment.asc>
More information about the ffmpeg-devel
mailing list