[FFmpeg-devel] [PATCH] lavu: add av_get_media_type_string() convenience function

Stefano Sabatini stefano.sabatini-lala at poste.it
Sun Aug 21 11:52:50 CEST 2011


On date Saturday 2011-08-20 15:17:05 +0200, Nicolas George encoded:
> Le tridi 3 fructidor, an CCXIX, Stefano Sabatini a écrit :
> > This was also more consistent with the behavior of other similar
> > function (av_get_pix_fmt_name(), sample_fmt_name(), etc.).
> > 
> > But I see that this is sometimes clumsy, what about a macro like this:
> > AV_X_IF_NULL(exp, x) ((exp) ? : (exp) : (x))
> 
> I almost suggested the same thing.
> 
> The macro has the drawback that the function is called twice.
> 
> It could be avoided using an inline function rather than a macro:
> 
> static inline const char *av_default_string(const char *str, const char *def)
> {
>     return str ? str : def;
> }
> 
> You could also add av_pure to all these functions, but that will work for
> gcc only. It would be a good thing anyway.

On the other hand the macro can be used also for non char* types,
having both may be an option.
-- 
FFmpeg = Faithful Fabulous Minimal Perennial Ephemeral Ghost


More information about the ffmpeg-devel mailing list