diff options
author | Clément Bœsch <ubitux@gmail.com> | 2012-10-25 18:50:26 +0200 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2012-10-26 21:48:27 +0200 |
commit | eb36ee1ee11c269e24ad4595fadf50e78463d5e2 (patch) | |
tree | 2d6c8d4431d5d897a10a3fd7901090a77b0cc6f6 /libavcodec/srtenc.c | |
parent | 5b45b66220ffdf37619dbd70e41df31651db3f93 (diff) | |
download | ffmpeg-eb36ee1ee11c269e24ad4595fadf50e78463d5e2.tar.gz |
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.
Diffstat (limited to 'libavcodec/srtenc.c')
-rw-r--r-- | libavcodec/srtenc.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c index 473c88f09a..56f29e9f55 100644 --- a/libavcodec/srtenc.c +++ b/libavcodec/srtenc.c @@ -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); } |