Le quartidi 14 vendémiaire, an CCXXIV, Ganesh Ajjanagadde a écrit :
> -    ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts);
> +    if (!layouts)
> +        return AVERROR(ENOMEM);
> +    if ((ret = ff_channel_layouts_ref(layouts, 
> &inlink->out_channel_layouts)) < 0) {
> +        ff_channel_layouts_unref(&layouts);
> +        return ret;

This is a pattern that comes frequently, there is probably room for code
factorization.

How about this: currently, ff_formats_ref() and cousins reject NULL with
AVERROR_BUG. If it is changed to return AVERROR(ENOMEM) instead, then all
the "if (!formats) return AVERROR(ENOMEM);" become unnecessary.

Second, if ff_formats_ref() is changed to unref the format list on failure,
then all the unref become unnecessary. The changed code would be just:

     layouts = ff_all_channel_counts();
-    ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts);
+    if ((ret = ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts)) 
< 0)
+        return ret;

That is rather less cluttered.

What do you think about this?

Regards,

-- 
  Nicolas George

Attachment: signature.asc
Description: Digital signature

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to