From 919cd9728e73a9570a11f0d575b23c0212ca52e4 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Thu, 7 Sep 2017 15:28:55 +0200
Subject: [PATCH] lavf/supenc: Add a raw PGS muxer.
Fixes ticket #2208.
---
Changelog | 1 +
libavformat/Makefile | 1 +
libavformat/allformats.c | 2 +-
libavformat/supenc.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++
libavformat/version.h | 2 +-
5 files changed, 58 insertions(+), 2 deletions(-)
create mode 100644 libavformat/supenc.c
@@ -43,6 +43,7 @@ version <next>:
- add --disable-autodetect build switch
- drop deprecated qtkit input device (use avfoundation instead)
- despill video filter
+- raw PGS subtitle muxer
version 3.3:
- CrystalHD decoder moved to new decode API
@@ -473,6 +473,7 @@ OBJS-$(CONFIG_STR_DEMUXER) += psxstr.o
OBJS-$(CONFIG_SUBVIEWER1_DEMUXER) += subviewer1dec.o subtitles.o
OBJS-$(CONFIG_SUBVIEWER_DEMUXER) += subviewerdec.o subtitles.o
OBJS-$(CONFIG_SUP_DEMUXER) += supdec.o
+OBJS-$(CONFIG_SUP_MUXER) += supenc.o
OBJS-$(CONFIG_SVAG_DEMUXER) += svag.o
OBJS-$(CONFIG_SWF_DEMUXER) += swfdec.o swf.o
OBJS-$(CONFIG_SWF_MUXER) += swfenc.o swf.o
@@ -303,7 +303,7 @@ static void register_all(void)
REGISTER_DEMUXER (STL, stl);
REGISTER_DEMUXER (SUBVIEWER1, subviewer1);
REGISTER_DEMUXER (SUBVIEWER, subviewer);
- REGISTER_DEMUXER (SUP, sup);
+ REGISTER_MUXDEMUX(SUP, sup);
REGISTER_DEMUXER (SVAG, svag);
REGISTER_MUXDEMUX(SWF, swf);
REGISTER_DEMUXER (TAK, tak);
new file mode 100644
@@ -0,0 +1,54 @@
+/*
+ * raw PGS muxer
+ * Copyright (c) 2017 Carl Eugen Hoyos
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "internal.h"
+
+static int sup_write_header(AVFormatContext *s)
+{
+ if (s->nb_streams != 1) {
+ av_log(s, AV_LOG_ERROR, "only exactly one PGS stream is supported\n");
+ return AVERROR(EINVAL);
+ }
+
+ return 0;
+}
+
+static int sup_write_packet(AVFormatContext *s, AVPacket *pkt)
+{
+ AVIOContext *pb = s->pb;
+
+ avio_wb16(pb, 0x5047); /* PG */
+ avio_wb32(pb, pkt->pts == AV_NOPTS_VALUE ? 0 : pkt->pts);
+ avio_wb32(pb, pkt->dts == AV_NOPTS_VALUE ? 0 : pkt->dts);
+ avio_write(pb, pkt->data, pkt->size);
+
+ return 0;
+}
+
+AVOutputFormat ff_sup_muxer = {
+ .name = "sup",
+ .long_name = NULL_IF_CONFIG_SMALL("raw HDMV Presentation Graphic Stream subtitles"),
+ .extensions = "sup",
+ .subtitle_codec = AV_CODEC_ID_HDMV_PGS_SUBTITLE,
+ .write_header = sup_write_header,
+ .write_packet = sup_write_packet,
+};
@@ -32,7 +32,7 @@
// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
// Also please add any ticket numbers that you believe might be affected here
#define LIBAVFORMAT_VERSION_MAJOR 57
-#define LIBAVFORMAT_VERSION_MINOR 81
+#define LIBAVFORMAT_VERSION_MINOR 82
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
--
1.7.10.4