lavc/srtenc: fix invalid read in case of SubRip.

Regression since 6057de19b. The ptr-2 is used to eat the \r\n and add
the position information on the timing line. This can't be done in case
of SubRip where the timing isn't present in the payload.

Note that we can't use yet the side data to transmit the position
information since the encode subtitles API is still using buffer+size
instead AVPacket as input.
This commit is contained in:
Clément Bœsch 2012-10-25 18:50:26 +02:00
parent 5b45b66220
commit eb36ee1ee1

View File

@ -203,6 +203,8 @@ static void srt_move_cb(void *priv, int x1, int y1, int x2, int y2,
int t1, int t2)
{
SRTContext *s = priv;
if (s->avctx->codec->id == CODEC_ID_SRT) {
char buffer[32];
int len = snprintf(buffer, sizeof(buffer),
" X1:%03u X2:%03u Y1:%03u Y2:%03u", x1, x2, y1, y2);
@ -211,6 +213,7 @@ static void srt_move_cb(void *priv, int x1, int y1, int x2, int y2,
memcpy(s->dialog_start, buffer, len);
s->ptr += len;
}
}
}
static void srt_end_cb(void *priv)
@ -262,9 +265,9 @@ static int srt_encode_frame(AVCodecContext *avctx,
es = ec/ 1000; ec -= 1000*es;
srt_print(s,"%d\r\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\r\n",
++s->count, sh, sm, ss, sc, eh, em, es, ec);
s->dialog_start = s->ptr - 2;
}
s->alignment_applied = 0;
s->dialog_start = s->ptr - 2;
srt_style_apply(s, dialog->style);
ff_ass_split_override_codes(&srt_callbacks, s, dialog->text);
}