From patchwork Thu Sep 7 13:32:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 5033 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.15.201 with SMTP id 70csp205630jao; Thu, 7 Sep 2017 06:33:28 -0700 (PDT) X-Received: by 10.223.150.133 with SMTP id u5mr2343923wrb.243.1504791208564; Thu, 07 Sep 2017 06:33:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791208; cv=none; d=google.com; s=arc-20160816; b=xS71pJo9WYjWh5BGC0mMlixg1djCSUuFQhV191VGd6z91IAVjQ2tJeiAyNskLCtb9Y HtKS2r67YoeQIwIOwrP+VH51l7jsNOWhmGndkGc0GUeJiP94UjpwSToXkG6k9iU7JuAB dU9i2rCGLwy782MZ0NQFO0GluOqzEK+HTf/Gf6HTD7PSqXSmikc3eBuONuHbDF3M210S yyr1B6DQ3I3sMjQz2P63UdMSsqc5PB7H3oAxUYkU6JeQZ4pJEQrDLyDPMl3mVrr/NQe3 Ow5uEEcQLcOOSC+b2nJGdQWXR5Jn1312mEx9gT3PFwvkYFP+CL3VmVyuwOVIc/Io8UCp 2ACQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:delivered-to :arc-authentication-results; bh=06dYFS/E/kFGTZaGi5d9DUgerMxvtiLekx9hZ6hVbF4=; b=lc0HVOD+XoJz0ex2UDZ0s0tJVL7pF5vIZW/IxIWV40q1aQmzs+wzESFvX+nFL27OVq XS+vuDc4TD2p6mtD8ZeywBVEU+/AA8lPiCqWwWzXf3STvu2ZS/MwnFHTjsuyJd8jGc0u qAdP9hbOSn6Zw2W6r6/BaUXfzP598gsTwvPuTDgMi4sq1UPOdVneH+PoBg753aJw8Ehy 2aFSAyq/gYtBBLXAej9oPVF+fks+5WUTgAYNSgQxsSuoeu++RdQ5G5G5nYgTbTJP3l0z 6bIKTC/MFjRvxx616JqGSIsEsZi3+MeUjaE8ozrEmEFp6fHU2+UEtcEha1R39cHS0H+1 SpIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=k4Z2kotK; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c46si2131164wrg.542.2017.09.07.06.33.27; Thu, 07 Sep 2017 06:33:28 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=k4Z2kotK; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DBB28689EA8; Thu, 7 Sep 2017 16:33:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io0-f177.google.com (mail-io0-f177.google.com [209.85.223.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8C69C68831C for ; Thu, 7 Sep 2017 16:33:16 +0300 (EEST) Received: by mail-io0-f177.google.com with SMTP id b142so4142227ioe.1 for ; Thu, 07 Sep 2017 06:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=ufr6CUqttY66os3JcVojfSqJc8Iur5ozz35aHNnfCqs=; b=k4Z2kotK49/BA7VRi3Cae1O6D/Dzo8ou01CKjRHObY1xXc7P7lWc0Vavt5FqE6p+s6 TlD61CQcHUHmx1NoighPCcco9mKMejWbVBTI9dkmoyUDw1BSCIOqdo2IytIOOlNXmHSr e4Hpq7xSMDfkXqw0kdc7VOTJCl0BPWamesowln3loedx0XLwalSmqY+SPSGuv6UBv7ry H4L/d4PGZvXfYE+6xzf8A385AwU6rEQMoRJeT9s+dn0mRiRGZijaLLInXlzq6MazXG8g x128VoTfFQo4GQSs5tDMqPX16/xU+bcyZ3w+XonHh8HCctzDP3B/DcnYPOysCd2VYJtX EHDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ufr6CUqttY66os3JcVojfSqJc8Iur5ozz35aHNnfCqs=; b=EDYiG1oUVOkjFfGXjjaGNXWGQlchb5UlABDabosm1wLG/nzbIp4VCZRVbwap7WavAX UcMI9lW23CXcnPe7o0B5hrzYvxqJBrsavtzLY8FtLGga5tY521wbL9fJhKmbuJPpfu95 4E54xBh+6BDrdUP0iDPYz0vdbKg1DuF7Dv5eaXbJwzgHMkhraQY9JasYwNpNKovPxoZq qURN6XReN34kWWMHJ8Dm5qgIlLvCh/MEdS17uOjcm/KY0gWidgES9KcNEk+YIfV1CAZ+ ckUvMEj7OYaMGjbE0x0VHDxt64ESd4YcS+8h/WoMOumElweHonwL7AjUG2kvbV6ahtbG 5RzQ== X-Gm-Message-State: AHPjjUjUcspJk72O9pNcCd7Ijz9iDilTwAXt7l3hGwPfgjdfyZApXvT9 4c4fwJcrXUhWD6JLSdUrrMOSiXZq7g== X-Google-Smtp-Source: AOwi7QBe6Qr1EFpoRTgBVyIqOM3H7t8098lwzA0sDwaa0lmzFHGAIWX18tWW1XJSizdUvd6k3QjGh7bf3UPxAi8z3wc= X-Received: by 10.107.26.209 with SMTP id a200mr3312426ioa.49.1504791198923; Thu, 07 Sep 2017 06:33:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.36.72 with HTTP; Thu, 7 Sep 2017 06:32:58 -0700 (PDT) From: Carl Eugen Hoyos Date: Thu, 7 Sep 2017 15:32:58 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH]lavf/supenc: Add a raw PGS muxer X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Hi! Attached patch implements ticket #2208. Please comment, Carl Eugen From 919cd9728e73a9570a11f0d575b23c0212ca52e4 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos 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 diff --git a/Changelog b/Changelog index cae5254..b62291a 100644 --- a/Changelog +++ b/Changelog @@ -43,6 +43,7 @@ version : - 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 diff --git a/libavformat/Makefile b/libavformat/Makefile index de954af..ef44f14 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -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 diff --git a/libavformat/allformats.c b/libavformat/allformats.c index cb09a60..62b0cf8 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -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); diff --git a/libavformat/supenc.c b/libavformat/supenc.c new file mode 100644 index 0000000..bc8cd0b --- /dev/null +++ b/libavformat/supenc.c @@ -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, +}; diff --git a/libavformat/version.h b/libavformat/version.h index 9cca76e..aeb5940 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -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