[FFmpeg-devel] [RFC] check avcodec_open codec paramert != NULL

Reimar Döffinger Reimar.Doeffinger
Tue Dec 25 13:32:48 CET 2007


Hello,
I personally would prefer if the avcodec_open would check if codec is
NULL and return an error then.
The main reason is laziness: You can then just do
avcodec_open(vf->priv->avctx, avcodec_find_encoder(CODEC_ID_PNG))
instead of having an extra variable for the avcodec_find_encoder result
and checking it against NULL.
What do you think? I admit it encourages sloppy error checking but I
just hate doing more checks that absolutely necessary, it clutters the
code too much for my tastes.

Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavcodec/utils.c
===================================================================
--- libavcodec/utils.c	(revision 11315)
+++ libavcodec/utils.c	(working copy)
@@ -848,7 +848,7 @@
         goto end;
     }
 
-    if(avctx->codec)
+    if(avctx->codec || !codec)
         goto end;
 
     if (codec->priv_data_size > 0) {



More information about the ffmpeg-devel mailing list