[FFmpeg-devel] [PATCH] lavc/srtenc: use bprint for text buffers.

Nicolas George george at nsup.org
Wed Nov 27 12:26:41 CET 2013


Le sextidi 6 frimaire, an CCXXII, Clément Bœsch a écrit :
> Make sure this is tested, it looks sensible, and I can't tell if this is
> correct just from looking (and it's not covered by FATE according to
> http://coverage.ffmpeg.org/ffmpeg/libavcodec/srtenc.c.gcov.html)

I tested in the success case, not in the OOM case. Note that we could
consider having a av_bprint_insert() to do that kind of thing. Noted in the
TODO list.

> This belongs in srt_encode_init().

Of course. New patch incoming.

> I never remember; isn't len supposed to not count the trailing 0? If so, I

Rule of thumb: av_bprint is binary-compatible, the final 0 is there as a
courtesy to make C string functions usable. It is therefore not counted.

> think it should keep the bufsize-1 and copy the last 0 byte as well.

Packets data is binary, not string, it does not need the final 0. As you can
see, the current code returns len, not len+1: it is only wasting the final
byte of the provided buffer.

> Note: this is cool, and we definitely need to make the new subtitles
> encoding API using a codec-allocated buffer of some sort.

Definitely, yes. But since we still do not know what data structure we will
use...

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131127/7bd7a24f/attachment.asc>


More information about the ffmpeg-devel mailing list