[FFmpeg-devel] [RFC] lavu PTS printing utils

Stefano Sabatini stefasab at gmail.com
Fri Jan 20 16:00:18 CET 2012


On date Tuesday 2012-01-17 22:44:21 +0100, Alexander Strasser encoded:
> Hi,
> 
> Stefano Sabatini wrote:
> > +          tsutils.h                                                     \
> 
>   I don't know why we don't use _ in file names anymore, but at least it is
> in line with a few other headers in lavu.
> 
>   Anyway I think concatenation of abbreviations can be quite unreadable and
> the effect will be strengthened as more and more files with that naming style
> are added.
> 
>   Please excuse the rant... I wanted to say this many times before.

Sure, timestamp.h is perfectly fine with me.

> [...]
> > +
> > +static inline char *av_get_ts_string(char *buf, size_t buf_size, int64_t ts)
> > +{
> > +    if (ts == AV_NOPTS_VALUE) snprintf(buf, buf_size, "NOPTS");
> > +    else                      snprintf(buf, buf_size, "%"PRId64"", ts);
> > +    return buf;
> > +}
> > +
> > +#define av_ts2str(ts) av_get_ts_string((char[42]){ 0 }, 42, ts)
> > +
> > +static inline char* av_get_time_string(char *buf, size_t buf_size, int64_t ts, AVRational *tb)
> > +{
> > +    if (ts == AV_NOPTS_VALUE) snprintf(buf, buf_size, "NOPTS");
> > +    else                      snprintf(buf, buf_size, "%f", av_q2d(*tb) * ts);
> > +    return buf;
> > +}
> > +
> > +#define av_time2str(ts, tb) av_get_time_string((char[42]){ 0 }, 42, ts, tb)
> 

>   The naming of the macros is a bit risky. Especially considering how often we
> append numbers to names to introduce a successor. av_time2str2 would be rather
> confusing.

Uhm, the point is keeping the name as short as possible, that's why
time2str is better than time_to_str(), but the macro has also other
problems so I'll likely drop it.

>   Nit: The verb "get" in the function names is IMHO a bit confusing, as you pass
> a buffer in and don't really get any resource. Maybe "make" would be better fit.
> What do you think?

Works for me.

> I still would like to hear a few more voices? Who wants to have these in lavu?
> I am still not sure myself, though it seems small and useful enough.
-- 
FFmpeg = Fostering & Foolish Mega Plastic Enchanting Goblin


More information about the ffmpeg-devel mailing list