avcodec/movtextenc: Fix encoding of subtitles with multiple rects
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Tue, 30 Nov 2021 09:02:13 +0000 (10:02 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Thu, 2 Dec 2021 06:29:02 +0000 (07:29 +0100)
commit0bc3c070fb516319f08d7264af27e3e123f45e95
tree98be28ae5bc7c82fd7c23f462862bd60451439ce
parentf8e5e1c52333e6c330fbb4fe8ec2cb07240ca8c5
avcodec/movtextenc: Fix encoding of subtitles with multiple rects

The format of a mov_text (3GPP Timed Text) sample is:

uint16_t text_length;
uint8_t  text[text_length];
TextSampleModifierBox text_modifier;

Yet in case our encoder receives an AVSubtitle with multiple
ASS AVSubtitleRects, it creates something like this:
uint16_t text_length;
uint8_t  text[text_length_1];
TextSampleModifierBox text_modifier_1;
uint8_t  text[text_length_2];
TextSampleModifierBox text_modifier_2;
...

where text_length is the sum of all the text_length_*.
This commit fixes this by writing the TextSampleModifierBoxes only
after all the rects have been written.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
libavcodec/movtextenc.c