[FFmpeg-cvslog] lavfi/buffersink: accept parameters as options.

Michael Niedermayer michaelni at gmx.at
Sun Apr 21 03:05:28 CEST 2013


On Fri, Apr 12, 2013 at 12:18:43PM +0200, Nicolas George wrote:
> ffmpeg | branch: master | Nicolas George <nicolas.george at normalesup.org> | Thu Apr 11 14:58:07 2013 +0200| [e48ded8551172b58a78f30303a81dfce125344e0] | committer: Michael Niedermayer
> 
> lavfi/buffersink: accept parameters as options.
> 
> Move validation from init to query_formats().
> Accept the formats lists as binary options.
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
[...]
> @@ -447,32 +430,92 @@ static int asink_query_formats(AVFilterContext *ctx)
>      BufferSinkContext *buf = ctx->priv;
>      AVFilterFormats *formats = NULL;
>      AVFilterChannelLayouts *layouts = NULL;
> +    unsigned i;
> +    int ret;
>  
> -    if (buf->sample_fmts) {
> -        if (!(formats = ff_make_format_list(buf->sample_fmts)))
> -            return AVERROR(ENOMEM);
> +    if (buf->sample_fmts_size     % sizeof(*buf->sample_fmts)     ||
> +        buf->sample_rates_size    % sizeof(*buf->sample_rates)    ||
> +        buf->channel_layouts_size % sizeof(*buf->channel_layouts) ||
> +        buf->channel_counts_size  % sizeof(*buf->channel_counts)) {
> +        av_log(ctx, AV_LOG_ERROR, "Invalid size for format lists\n");
> +#define LOG_ERROR(field) \
> +        if (buf->field ## _size % sizeof(*buf->field)) \
> +            av_log(ctx, AV_LOG_ERROR, "  " #field " is %d, should be " \
> +                   "multiple of %d\n", \
> +                   buf->field ## _size, (int)sizeof(*buf->field));
> +        LOG_ERROR(sample_fmts);
> +        LOG_ERROR(sample_rates);
> +        LOG_ERROR(channel_layouts);
> +        LOG_ERROR(channel_counts);
> +#undef LOG_ERROR
> +        return AVERROR(EINVAL);
> +    }
> +
> +    if (buf->sample_fmts_size) {
> +        for (i = 0; i < NB_ITEMS(buf->sample_fmts); i++)
> +            if ((ret = ff_add_format(&formats, buf->sample_fmts[i])) < 0)
> +                return ret;
>          ff_set_common_formats(ctx, formats);
>      }
>  
> -    if (buf->channel_layouts || buf->all_channel_counts) {
> -            layouts = buf->all_channel_counts ? ff_all_channel_counts() :
> -                      avfilter_make_format64_list(buf->channel_layouts);
> -        if (!layouts)
> -            return AVERROR(ENOMEM);
> +    if (buf->channel_layouts_size || buf->channel_counts_size ||
> +        buf->all_channel_counts) {
> +        for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++)
> +            if ((ret = ff_add_channel_layout(&layouts, buf->channel_layouts[i])) < 0)
> +                return ret;
> +        for (i = 0; i < NB_ITEMS(buf->channel_counts); i++)
> +            if ((ret = ff_add_channel_layout(&layouts, FF_COUNT2LAYOUT(buf->channel_counts[i]))) < 0)
> +                return ret;

coverity thinks this can leak too (CID1005314)

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-cvslog/attachments/20130421/0dcd92eb/attachment.asc>


More information about the ffmpeg-cvslog mailing list