[FFmpeg-devel] [RFC] lavu PTS printing utils
Stefano Sabatini
stefasab at gmail.com
Tue Jan 17 17:18:25 CET 2012
On date Sunday 2012-01-15 16:36:35 +0100, Nicolas George encoded:
> 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.
Updated based on this, with example code.
--
FFmpeg = Frenzy Freak MultiPurpose Extravagant Guide
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0024-lavu-add-tsutils.h-header-with-convenience-timestamp.patch
Type: text/x-diff
Size: 2796 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120117/f95019e4/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0025-ffmpeg-use-tsutils.h-utils-for-timestamp-related-deb.patch
Type: text/x-diff
Size: 1835 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120117/f95019e4/attachment-0001.bin>
More information about the ffmpeg-devel
mailing list