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

Nicolas George nicolas.george at normalesup.org
Sun Jan 15 16:36:35 CET 2012


Le sextidi 26 nivôse, an CCXX, Stefano Sabatini a écrit :
>     return ts == (AV_NOPTS_VALUE) ? snprintf(buf, buf_size, "NOPTS") :
>                                     snprintf(buf, buf_size, "%"PRId64"", ts);

Note that the return value is not the room taken in the buffer but the size
that the text would have used if there was enough room.

> Do you think this would be a good idea? If yes, where should I put them
> (libavutil/printutils.h may be an option)?

As Reimer points out, I fear it would lack flexibility for some purposes.
But for quick debugging it may be useful.

As a side note, I would like to share the following trick that I have used
in some programs of mine:

char *foo2str_buf(char *buf, size_t buf_size, foo_t foo) {
    <convert>
    return buf;
}

#define foo2str(foo) foo2str_buf((char[42]){ 0 }, 42, foo)

with 42 a constant chosen to be large enough: that way, I can write:

	printf("a = %s\n", foo2str(a));

and the buffer to convert is allocated with automatic storage.

Regards,

-- 
  Nicolas George
-------------- 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-devel/attachments/20120115/52e93e23/attachment.asc>


More information about the ffmpeg-devel mailing list