[FFmpeg-devel] [PATCH 3/3] TTML encoder and muxer

Jan Ekström jeebjp at gmail.com
Tue Dec 8 01:35:46 EET 2020


On Mon, Dec 7, 2020 at 4:03 PM Andreas Rheinhardt
<andreas.rheinhardt at gmail.com> wrote:
> >
> > You are not copying the terminating NUL; and you also don't account for
> > it in the above check. Is this intended?
> >
>
> The srt encoder does it like you, the ass encoder is careful only to
> output a NUL terminated string (with the NUL not accounted for in the
> size); no documentation exists for avcodec_encode_subtitle(). ffmpeg.c
> uses the size of the allocated (not-zeroed) buffer as bufsize; it also
> does not add any padding at all (but it's buffer is huge (1MiB)).
>

Yes, this is probably the roots of this code being based on the webvtt
and srt encoders showing up. I do agree that especially for text
buffers zero-termination makes sense, as long as it doesn't cause
funky things to happen when the packet is being written by muxer(s).

As noted, I have vague memories of AVBPrint handling zero-termination
in some cases, but my memory definitely needs a re-check.

Jan


More information about the ffmpeg-devel mailing list