You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
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>
This commit is contained in:
@@ -640,7 +640,6 @@ static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf,
|
|||||||
MovTextContext *s = avctx->priv_data;
|
MovTextContext *s = avctx->priv_data;
|
||||||
ASSDialog *dialog;
|
ASSDialog *dialog;
|
||||||
int i, length;
|
int i, length;
|
||||||
size_t j;
|
|
||||||
|
|
||||||
s->byte_count = 0;
|
s->byte_count = 0;
|
||||||
s->text_pos = 0;
|
s->text_pos = 0;
|
||||||
@@ -661,10 +660,6 @@ static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf,
|
|||||||
mov_text_dialog(s, dialog);
|
mov_text_dialog(s, dialog);
|
||||||
ff_ass_split_override_codes(&mov_text_callbacks, s, dialog->text);
|
ff_ass_split_override_codes(&mov_text_callbacks, s, dialog->text);
|
||||||
ff_ass_free_dialog(&dialog);
|
ff_ass_free_dialog(&dialog);
|
||||||
|
|
||||||
for (j = 0; j < box_count; j++) {
|
|
||||||
box_types[j].encode(s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->byte_count > UINT16_MAX)
|
if (s->byte_count > UINT16_MAX)
|
||||||
@@ -672,6 +667,9 @@ static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf,
|
|||||||
AV_WB16(buf, s->byte_count);
|
AV_WB16(buf, s->byte_count);
|
||||||
buf += 2;
|
buf += 2;
|
||||||
|
|
||||||
|
for (size_t j = 0; j < box_count; j++)
|
||||||
|
box_types[j].encode(s);
|
||||||
|
|
||||||
if (!av_bprint_is_complete(&s->buffer))
|
if (!av_bprint_is_complete(&s->buffer))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user