From patchwork Tue Aug 31 18:07:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 29929 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp5156079iov; Tue, 31 Aug 2021 11:10:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2C9UGVZ6EmfLS93C3jvQwannn4H2Ss3XUVP/02l1e1vK7iaBsc90FFCNi8cSGMXBC8C3J X-Received: by 2002:a17:907:d86:: with SMTP id go6mr2064967ejc.475.1630433403604; Tue, 31 Aug 2021 11:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630433403; cv=none; d=google.com; s=arc-20160816; b=siHfdC904vPfDSTWYLZkGRzoLdSDkL7JXf6v0zqgglJcsIfufKNk/PG3dWWO7+utdg kZYBpLrRRdqydclcGbY/7PEzvZ52dS4MCunUdWwyogxkvsM/1O6Gjq2u+EX0xHS+/K3N rOZA9K59oGy/GEz+PWz3UD74Y/kc3YCmLM1NamKdtFLc9IifRwpZtplOq4c4N8lbi//+ lU+Tsl6CmIBk7Ms68AbF4DUIbn4AV7yM0pQLxxPSC+/JuduFKK24fZkmhLmx7EvM5u4u Nm7icnqux/cBIFkTUH/KWfmwHJXgQzTw4TSyiq2upgyeiGOLV/L+XccTIGcc0zbT4A2T NGBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=LM5eefqRiGKFUlRlmZ27aPbtxGB0yQE9Ci2ZQ+euRwc=; b=fZSh6MD+Tr7T+wkGZ9gli8LfEaaUQnhmEI1GWLoeEcIPhZn5rjZ4y27z+6xjmaKOeT OtKZGTJRkrwAV6yF/D0tASTHjoVXFGRQC28lG4hyxJJsdl+Qmx5651zCD+8lG8EmdvfH scYdskvfxWxVLqOZMRq9qb8saw0bMPxCrXmmWSWHPz+eTbI9AMvYsEpDPsum/hwoA4Y8 geU1gYuoy1w3QJ+4nb88ZrSYD13XaR8+88y+tmqA2X569iVVMuJ7CszztmBzXK2dY1rv qcE5gFSywc59IzfaZdbfF7G5Bc5oj4RM4f7lYAc8jx2APV4f36iyaroMZDeGDaMw1W5w iUYw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n8si18195916edo.283.2021.08.31.11.10.03; Tue, 31 Aug 2021 11:10:03 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4E23368A412; Tue, 31 Aug 2021 21:08:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B8F8E68A43A for ; Tue, 31 Aug 2021 21:07:46 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 17VI7j5K030789 for ; Tue, 31 Aug 2021 20:07:46 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id E644BEB5BC; Tue, 31 Aug 2021 20:07:45 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Tue, 31 Aug 2021 20:07:39 +0200 Message-Id: <20210831180739.873390-12-george@nsup.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210831180739.873390-1-george@nsup.org> References: <20210831180739.873390-1-george@nsup.org> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Tue, 31 Aug 2021 20:07:46 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 12/12] tools/dvd2concat: generate VOBSUB extradata X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: QeUQOS0PhEZC The extradata contains the frame size of the subtitles images and the palette. Signed-off-by: Nicolas George --- tools/dvd2concat | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) And with this, we can encode DVDs correctly, and even have the hardcoded subtitles the right color. For muxing the subtitles, some more work to be done, probably: mencoder is still needed. If somebody wants, taking the code from lsdvd and creating a special demuxer that will create a ConcatContext internally would allow us to read DVDs directly. diff --git a/tools/dvd2concat b/tools/dvd2concat index ccc021c4cc..24809fbdf5 100755 --- a/tools/dvd2concat +++ b/tools/dvd2concat @@ -94,6 +94,28 @@ for my $subp (@{$track->{subp}}) { $concat .= "\nstream\nexact_stream_id " . $subp->{streamid} . "\n"; $concat .= "stream_codec dvd_subtitle\n"; $concat .= "stream_meta language " . $subp->{langcode} . "\n" if $subp->{langcode}; + my $extradata = ""; + if ($track->{width} && $track->{height}) { + $extradata .= "size: " . $track->{width} . "x" . $track->{height} . "\n"; + } + if (my $pal = $track->{palette}) { + my @pal; + for my $c (@$pal) { + # Adapted from mplayer/sub/vobsub.c + my $y = ((hex($c) >> 16) & 0xFF); + my $u = ((hex($c) >> 8) & 0xFF) - 128; + my $v = ((hex($c) >> 0) & 0xFF) - 128; + my ($r, $g, $b) = map { int($_ < 0 ? 0 : $_ > 255 ? 255 : $_) } + $y + 1.4022 * $u, + $y - 0.3456 * $u - 0.7145 * $v, + $y + 1.7710 * $v; + push @pal, sprintf "%06x", ($r << 16) | ($g << 8) | $b; + } + $extradata .= "palette: " . join(", ", @pal) . "\n"; + } + if ($extradata ne "") { + $concat .= "stream_extradata " . unpack("H*", $extradata); + } } my $chap_time = 0; for my $chap (@{$track->{chapter}}) {