[FFmpeg-devel] [PATCH] vsrc_buffer: simplify interface

Stefano Sabatini stefano.sabatini-lala at poste.it
Mon May 2 10:06:34 CEST 2011


On date Monday 2011-05-02 02:18:21 +0200, Stefano Sabatini encoded:
> ---
>  ffmpeg.c                  |   18 ++++++++---
>  libavfilter/vsrc_buffer.c |   68 ++++++++++++---------------------------------
>  libavfilter/vsrc_buffer.h |    7 +---
>  3 files changed, 33 insertions(+), 60 deletions(-)
> 
> diff --git a/ffmpeg.c b/ffmpeg.c
> index e36b3e5..98fdbae 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -42,6 +42,7 @@
>  #include "libavutil/colorspace.h"
>  #include "libavutil/fifo.h"
>  #include "libavutil/intreadwrite.h"
> +#include "libavutil/imgutils.h"
>  #include "libavutil/pixdesc.h"
>  #include "libavutil/avstring.h"
>  #include "libavutil/libm.h"
> @@ -1632,13 +1633,20 @@ static int output_packet(AVInputStream *ist, int ist_index,
>              for(i=0;i<nb_ostreams;i++) {
>                  ost = ost_table[i];
>                  if (ost->input_video_filter && ost->source_index == ist_index) {
> +                    // fetch a frame from the filterchain, and buffer it
> +                    AVFilterLink *inlink = ost->input_video_filter->outputs[0];
> +                    AVFilterBufferRef *picref =
> +                        avfilter_get_video_buffer(inlink, AV_PERM_WRITE, picture.width, picture.height);
> +
>                      if (!picture.sample_aspect_ratio.num)
>                          picture.sample_aspect_ratio = ist->st->sample_aspect_ratio;
> -                    // add it to be filtered
> -                    av_vsrc_buffer_add_frame2(ost->input_video_filter, &picture,
> -                                             ist->pts,
> -                                             ist->st->codec->width, ist->st->codec->height,
> -                                             ist->st->codec->pix_fmt, ""); //TODO user setable params
> +                    av_image_copy(picref->data, picref->linesize,
> +                                  picture.data, picture.linesize,
> +                                  picref->format, picref->video->w, picref->video->h);
> +                    avfilter_copy_frame_props(picref, &picture);
> +                    picref->pts = ist->pts;
> +
> +                    av_vsrc_buffer_add_frame2(ost->input_video_filter, picref, "");  //TODO user setable params

Unfortunately this can't work in case the source buffer format differs
from the picture format (e.g. in case of mid-stream format change).

Updated patch (which passes AVFrame instead).
-- 
FFmpeg = Fabulous and Forgiving Moronic Plastic Ermetic Guru
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0007-vsrc_buffer-simplify-interface.patch
Type: text/x-diff
Size: 6142 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110502/c6fb4478/attachment.bin>


More information about the ffmpeg-devel mailing list