[FFmpeg-devel] [PATCH] lavfi/showwaves: fail in case of push_frame() error
Stefano Sabatini
stefasab at gmail.com
Fri Jan 25 19:26:00 CET 2013
On date Thursday 2013-01-24 10:19:57 +0000, Paul B Mahol encoded:
> On 1/24/13, Stefano Sabatini <stefasab at gmail.com> wrote:
> > ---
> > libavfilter/avf_showwaves.c | 15 +++++++++------
> > 1 file changed, 9 insertions(+), 6 deletions(-)
> >
>
> Does this fixes something? If yes please document it in commit.
Not that I know, but it struck me as it was not handling errors (code
predates proper error handling in callbacks).
>
> > diff --git a/libavfilter/avf_showwaves.c b/libavfilter/avf_showwaves.c
> > index 998b4cb..1b9d28d 100644
> > --- a/libavfilter/avf_showwaves.c
> > +++ b/libavfilter/avf_showwaves.c
> > @@ -160,14 +160,16 @@ static int config_output(AVFilterLink *outlink)
> > return 0;
> > }
> >
> > -inline static void push_frame(AVFilterLink *outlink)
> > +inline static int push_frame(AVFilterLink *outlink)
> > {
> > ShowWavesContext *showwaves = outlink->src->priv;
> > + int ret;
> >
> > - ff_filter_frame(outlink, showwaves->outpicref);
> > - showwaves->req_fullfilled = 1;
> > + if ((ret = ff_filter_frame(outlink, showwaves->outpicref)) >= 0)
> > + showwaves->req_fullfilled = 1;
> > showwaves->outpicref = NULL;
> > showwaves->buf_idx = 0;
> > + return ret;
> > }
> >
> > static int request_frame(AVFilterLink *outlink)
> > @@ -198,7 +200,7 @@ static int filter_frame(AVFilterLink *inlink,
> > AVFilterBufferRef *insamples)
> > int linesize = outpicref ? outpicref->linesize[0] : 0;
> > int16_t *p = (int16_t *)insamples->data[0];
> > int nb_channels =
> > av_get_channel_layout_nb_channels(insamples->audio->channel_layout);
> > - int i, j, k, h;
> > + int i, j, k, h, ret = 0;
> > const int n = showwaves->n;
> > const int x = 255 / (nb_channels * n); /* multiplication factor,
> > pre-computed to avoid in-loop divisions */
> >
> > @@ -244,12 +246,13 @@ static int filter_frame(AVFilterLink *inlink,
> > AVFilterBufferRef *insamples)
> > showwaves->buf_idx++;
> > }
> > if (showwaves->buf_idx == showwaves->w)
> > - push_frame(outlink);
> > + if ((ret = push_frame(outlink)) < 0)
> > + break;
> > outpicref = showwaves->outpicref;
> > }
> >
> > avfilter_unref_buffer(insamples);
> > - return 0;
> > + return ret;
> > }
> >
> > static const AVFilterPad showwaves_inputs[] = {
> > --
> > 1.7.9.5
>
> I see nothing obviously wrong.
I'll push the patch soon, thanks.
--
FFmpeg = Frightening and Fiendish Multimedia Purposeless Egregious Gnome
More information about the ffmpeg-devel
mailing list