[FFmpeg-devel] [PATCH 1/4] Implement avfilter_ref_video_buffer().
Michael Niedermayer
michaelni
Thu Nov 25 20:34:42 CET 2010
On Thu, Nov 25, 2010 at 07:36:37PM +0100, Stefano Sabatini wrote:
> On date Thursday 2010-11-25 17:15:42 +0100, Michael Niedermayer encoded:
> > On Wed, Nov 24, 2010 at 07:20:28PM +0100, Stefano Sabatini wrote:
> > > On date Wednesday 2010-11-24 17:03:41 +0100, Michael Niedermayer encoded:
> > > > On Tue, Nov 23, 2010 at 11:23:58PM +0100, Stefano Sabatini wrote:
> > > > > On date Tuesday 2010-11-23 23:11:46 +0100, Michael Niedermayer encoded:
> > > > > > On Tue, Nov 23, 2010 at 12:56:33AM +0100, Stefano Sabatini wrote:
> > [...]
> > > > > > > This change also requires to make public the
> > ^^^^^^^^^^^^^^^^^^^^^^^
> >
> > > > > > > avfilter_default_free_buffer() function, as in the attached patch.
> > > > > >
> > > > > > why?
> > ^^^^
> >
> > > > >
> > > > > I prefer to place the callback for freeing the buffer in the library
> > > > > code,
> > > >
> > > > my question was "why make it public" not "why in the lib" sorry if that was
> > > > unclear
> > >
> > > That's completely indifferent to me, and since it is currently
> > > non-used in application code maybe it's even better to declare them
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >
> > IMHO if its not needed for anything then we should not make it public.
> > The function pointer comparission bugs we had with the matching function
> > for AVPacket cant happen if the function is not public ...
>
> Updated.
> --
> FFmpeg = Fucking and Fundamentalist Mean Portentous Efficient Gem
> defaults.c | 7 ++++---
> internal.h | 3 +++
> 2 files changed, 7 insertions(+), 3 deletions(-)
> 9c8a5b3e04d4ba568dd100d8228edce2080b61a8 0001-Make-avfilter_default_free_buffer-an-internal-shared.patch
> From e1803ceb2686f47a3452d703eaa6a74d636845fa Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Tue, 23 Nov 2010 00:39:57 +0100
> Subject: [PATCH] Make avfilter_default_free_buffer() an internal shared symbol, so that
> it can be referenced outside defaults.c.
>
> ---
> libavfilter/defaults.c | 7 ++++---
> libavfilter/internal.h | 3 +++
> 2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
> index c7b4b47..e895ccd 100644
> --- a/libavfilter/defaults.c
> +++ b/libavfilter/defaults.c
> @@ -23,9 +23,10 @@
> #include "libavcore/imgutils.h"
> #include "libavcore/samplefmt.h"
> #include "avfilter.h"
> +#include "internal.h"
>
> /* TODO: buffer pool. see comment for avfilter_default_get_video_buffer() */
> -static void avfilter_default_free_buffer(AVFilterBuffer *ptr)
> +void ff_avfilter_default_free_buffer(AVFilterBuffer *ptr)
> {
> av_free(ptr->data[0]);
> av_free(ptr);
> @@ -54,7 +55,7 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per
>
> pic->refcount = 1;
> ref->format = link->format;
> - pic->free = avfilter_default_free_buffer;
> + pic->free = ff_avfilter_default_free_buffer;
> av_image_fill_linesizes(pic->linesize, ref->format, ref->video->w);
>
> for (i = 0; i < 4; i++)
> @@ -108,7 +109,7 @@ AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int per
> ref->perms = perms | AV_PERM_READ;
>
> samples->refcount = 1;
> - samples->free = avfilter_default_free_buffer;
> + samples->free = ff_avfilter_default_free_buffer;
>
> sample_size = av_get_bits_per_sample_fmt(sample_fmt) >>3;
> chans_nb = av_get_channel_layout_nb_channels(channel_layout);
> diff --git a/libavfilter/internal.h b/libavfilter/internal.h
> index 37d085d..8f352ef 100644
> --- a/libavfilter/internal.h
> +++ b/libavfilter/internal.h
> @@ -57,4 +57,7 @@ int ff_avfilter_graph_config_links(AVFilterGraph *graphctx, AVClass *log_ctx);
> */
> int ff_avfilter_graph_config_formats(AVFilterGraph *graphctx, AVClass *log_ctx);
>
> +/** default handler for freeing audio/video buffer when there are no references left */
> +void ff_avfilter_default_free_buffer(AVFilterBuffer *buf);
> +
> #endif /* AVFILTER_INTERNAL_H */
> --
> 1.7.1
>
> doc/APIchanges | 3 +++
> libavfilter/avfilter.c | 40 ++++++++++++++++++++++++++++++++++++++++
> libavfilter/avfilter.h | 17 ++++++++++++++++-
> libavfilter/defaults.c | 49 +++++++++++++++----------------------------------
> 4 files changed, 74 insertions(+), 35 deletions(-)
> 8214b1e48338970fe326f52d772e75ea7978d8db 0002-Implement-avfilter_get_video_buffer_ref_from_arrays.patch
> From 6fe8c905545f40275199e8e87ef3effdb19f8170 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Mon, 1 Nov 2010 15:31:50 +0100
> Subject: [PATCH] Implement avfilter_get_video_buffer_ref_from_arrays().
>
> ---
> doc/APIchanges | 3 ++
> libavfilter/avfilter.c | 40 +++++++++++++++++++++++++++++++++++++++
> libavfilter/avfilter.h | 17 +++++++++++++++-
> libavfilter/defaults.c | 49 ++++++++++++++---------------------------------
> 4 files changed, 74 insertions(+), 35 deletions(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 8a3a938..7573d99 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -12,6 +12,9 @@ libavutil: 2009-03-08
>
>
> API changes, most recent first:
> +2010-11-22 - r25804 - lavfi 1.65.0 - avfilter_get_video_buffer_ref_from_arrays()
> + Add function avfilter_get_video_buffer_ref_from_arrays() in
> + avfilter.h.
>
> 2010-11-21 - r25787 - lavcore 0.14.0 - audioconvert.h
> Add a public audio channel API in audioconvert.h, and deprecate the
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index a761c81..6146a3a 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -267,6 +267,46 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int
> return ret;
> }
>
> +AVFilterBufferRef *
> +avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms,
> + int w, int h, enum PixelFormat format)
> +{
> + AVFilterBuffer *pic = av_mallocz(sizeof(AVFilterBuffer));
> + AVFilterBufferRef *picref = av_mallocz(sizeof(AVFilterBufferRef));
> +
> + if (!pic || !picref)
> + goto fail;
> +
> + picref->buf = pic;
> + picref->buf->free = ff_avfilter_default_free_buffer;
> + if (!(picref->video = av_mallocz(sizeof(AVFilterBufferRefVideoProps))))
> + goto fail;
> +
> + picref->video->w = w;
> + picref->video->h = h;
> +
> + /* make sure the buffer gets read permission or it's useless for output */
> + picref->perms = perms | AV_PERM_READ;
> +
> + pic->refcount = 1;
> + picref->type = AVMEDIA_TYPE_VIDEO;
> + picref->format = format;
> +
> + memcpy(pic->data, data, sizeof(pic->data));
> + memcpy(pic->linesize, linesize, sizeof(pic->linesize));
> + memcpy(picref->data, pic->data, sizeof(picref->data));
> + memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize));
> +
> + return picref;
> +
> +fail:
> + if (picref && picref->video)
> + av_free(picref->video);
> + av_free(picref);
> + av_free(pic);
> + return NULL;
> +}
> +
> AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
> enum AVSampleFormat sample_fmt, int size,
> int64_t channel_layout, int planar)
> diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
> index f49a523..8c9092c 100644
> --- a/libavfilter/avfilter.h
> +++ b/libavfilter/avfilter.h
> @@ -25,7 +25,7 @@
> #include "libavutil/avutil.h"
>
> #define LIBAVFILTER_VERSION_MAJOR 1
> -#define LIBAVFILTER_VERSION_MINOR 64
> +#define LIBAVFILTER_VERSION_MINOR 65
> #define LIBAVFILTER_VERSION_MICRO 0
>
> #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
> @@ -649,6 +649,21 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms,
> int w, int h);
>
> /**
> + * Create a buffer reference wrapped around an already allocated video
> + * buffer.
image, picture whatever, not video please
> + *
> + * @param data pointers to the planes of the video buffer to reference
same
> + * @param linesize linesizes for the planes of the video buffer to reference
same
otherwise patches should be ok
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Those who are best at talking, realize last or never when they are wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101125/0bce2511/attachment.pgp>
More information about the ffmpeg-devel
mailing list