summaryrefslogtreecommitdiff
path: root/libavcodec/srtdec.c
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2012-10-25 00:01:42 +0200
committerClément Bœsch <ubitux@gmail.com>2012-10-25 00:09:36 +0200
commitc27b3816e4a7bf2047820ba47664ed1c874216c1 (patch)
treec264934cac287a457d7be0305bed8869a983c63a /libavcodec/srtdec.c
parent4d46fd0b3ed14cfcfc4fd7fc1e4fb29f8fcea65c (diff)
srt: make the demuxer output SubRip packets.
The SRT format should never have outputted CODEC_ID_SRT packets in the first place: SRT is a subtitle format containing SubRip text markup events. The timing information is part of the format, not the codec, and thus CODEC_ID_SRT should not exist. Creating packets with the timing information within the payload only leads to problem (such as remuxing with timing alteration not working), especially when the SubRip markup is being used in container like Matroska in addition to this standalone SRT format. The main reason the timing line was included in those CODEC_ID_SRT packets is likely because it contained extra information (the event position) the codec actually needs. This issue is solved by using the AV_PKT_DATA_SUBTITLE_POSITION side data type.
Diffstat (limited to 'libavcodec/srtdec.c')
-rw-r--r--libavcodec/srtdec.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c
index 5824091a4d..ddeabd298d 100644
--- a/libavcodec/srtdec.c
+++ b/libavcodec/srtdec.c
@@ -21,6 +21,7 @@
#include "libavutil/avstring.h"
#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
#include "libavutil/parseutils.h"
#include "avcodec.h"
#include "ass.h"
@@ -219,6 +220,15 @@ static int srt_decode_frame(AVCodecContext *avctx,
char buffer[2048];
const char *ptr = avpkt->data;
const char *end = avpkt->data + avpkt->size;
+ int size;
+ const uint8_t *p = av_packet_get_side_data(avpkt, AV_PKT_DATA_SUBTITLE_POSITION, &size);
+
+ if (p && size == 16) {
+ x1 = AV_RL32(p );
+ y1 = AV_RL32(p + 4);
+ x2 = AV_RL32(p + 8);
+ y2 = AV_RL32(p + 12);
+ }
if (avpkt->size <= 0)
return avpkt->size;
@@ -247,6 +257,7 @@ static int srt_decode_frame(AVCodecContext *avctx,
}
#if CONFIG_SRT_DECODER
+/* deprecated decoder */
AVCodec ff_srt_decoder = {
.name = "srt",
.long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle with embedded timing"),