From c27b3816e4a7bf2047820ba47664ed1c874216c1 Mon Sep 17 00:00:00 2001 From: Clément Bœsch Date: Thu, 25 Oct 2012 00:01:42 +0200 Subject: 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. --- libavcodec/srtdec.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libavcodec') 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"), -- cgit v1.2.3