From patchwork Mon Mar 14 19:06:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oneric X-Patchwork-Id: 34733 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp2427043nkb; Mon, 14 Mar 2022 12:07:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvDe29+ZKKNwB7jomH5l/zcMwVY0zXYWvODQrnHGtLlrVsuyPvu72g09g0xNoZPhumiAU6 X-Received: by 2002:a17:906:2a97:b0:6b4:143f:37c6 with SMTP id l23-20020a1709062a9700b006b4143f37c6mr20173680eje.133.1647284854120; Mon, 14 Mar 2022 12:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647284854; cv=none; d=google.com; s=arc-20160816; b=R/JyNIns93rKd9v86/5zOU6FhKcmYdWYpMBrFyGeJ7xPbPqCxMUG8F7uyJomNiw1CI hj1Aw1O8b0MPa50CjrsZ01/JtRQ9k7hkKXPw+wmbU2K43ChrMz89diq8t1yS+drE83OD TkEXDTSik/BQMfnqgWeqywc6pBjWMyCdVPC2iP63v/xf7vfojcTH0Dpu4s/QwSHExfOA 6x9W7eKeXio92whDlhoDNdHcmK8v5XTC33cJctCJI8utd8sEdMRbh9uDpqJhRQxzyZFq hvZEOdW2G7o0BUU1y3I5hRYG59bz6m4rHQ/SHDTW/NcYto/EnaIZlUQ4DP9gQ4NTQPgj WBYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=itDGx0q+7iuNoi/zW08fxUYnck8Aj1dmy9ZOMXBlBMg=; b=0RVYhWzhw0fHieeal8dxFjavkQQ7AG9bFZLB00qCFGJOcSCEN7Yoi/O7ii8S+zNXAO 6nedvStTqLYpZuGD760tj8cMQr1LfbwfCLYuWeSz6iNZeybhzruc2V/Nj7mEEW1EQtdK eODTl7LEU3v6IRWYvdQLkHRfnGBTB23oNg9AKSvjG9IKWgjpOPcCyE6fBezjA7249Q0w VKfCzuSEMO25hJosX+/inKpr/mTjrSMHkBTHQ1pAkwTa8tXeqVOMKj5/ereVFIvHdN1r R1qHL12tyPmZeVoEjqJ6S8GSJe0UJ9pUFylr9licfIzTMhBMBObxQM/sPzScGZ+nAOiA 1yhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@oneric.de header.s=strato-dkim-0002 header.b="BZSO19J/"; 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 z4-20020a05640235c400b004185b1b32fesi5325237edc.361.2022.03.14.12.07.33; Mon, 14 Mar 2022 12:07:34 -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=@oneric.de header.s=strato-dkim-0002 header.b="BZSO19J/"; 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 3442668A77A; Mon, 14 Mar 2022 21:07:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [81.169.146.219]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1D53768A77A for ; Mon, 14 Mar 2022 21:07:23 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1647284842; s=strato-dkim-0002; d=oneric.de; h=Message-Id:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender; bh=PyFi1TsFahGjCZr2v/TXhV5ABuLjif2blsuO9kzHHQU=; b=BZSO19J/6A26DZa8ELoPcPkalskiVR2HlstanJNOTNXAuwH599hFwk5MWhJi9LLGRi kOiV6M2cN1io6mjRamUXoAZ6BwxJN7BxhlT5oAP8DBvUwDsPDv+NO5pZ/EKEqyNFjHui do38EM62+9Cz+H2o229rgGdczpGysOZHCZ6mkBic9k5DTAE5mpii9Sayq2+UjBkRTL98 wHuIU+oxiK0NxBo21R9kmHC/AOfQCoW4Swz3aqMh0azm1EEnDrJ0+y9x6wwpHcqHqOwn x6FR8WuxepXAd+gArYyyiH8DkbtOofAYS1Z/FCYmPVRxupUiQP6vs4HbKDcebNFXShFC c9cQ== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":I2IBZ0mrW/AWQXwgB4oxKM1YsW1lFUznrLvi/XReWqAAlWwZ8wlvfXmGs4jUQ0oz8ZbhHexs8fhgUyQPINwhvX+OIXvEO13Q69d7MAIa" X-RZG-CLASS-ID: mo00 Received: from koenig-desktop.workgroup by smtp.strato.de (RZmta 47.40.1 AUTH) with ESMTPSA id Vf13c3y2EJ7MAVK (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Mon, 14 Mar 2022 20:07:22 +0100 (CET) From: Oneric To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Mar 2022 20:06:39 +0100 Message-Id: <20220314190638.24816-1-oneric@oneric.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avfilter/vf_subtitles: pass storage size to libass 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 Cc: Oneric Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: WAjNOwiO4PXi Due to a quirk of the ASS format some tags depend on the exact storage resolution of the video, so tell libass via ass_set_storage_size. --- ass_set_storage_size exists since libass 0.10.2; ffmpeg since 5.0 already requires 0.11.0. This resolution dependences of ASS was already recognised when the original_size parameter was added, but it actually goes farther than just the aspect ratio. Conveniently this parameter still has all the required information to retain rendering after resizing :) Sample files to show the difference can be found eg here https://code.videolan.org/videolan/vlc/uploads/b54e0761d0d3f4f79b2947ffb83a3b59/vlc-issue_libass-storage-size.tar.xz ./ffmpeg -i test_1080p.mkv -filter:v ass=./test_1080p.ass tmp_1080.mkv ./ffmpeg -i anamorphic_s720x576_d1024x576.mkv -filter:v ass=./anamorphic_s720x576_d1024x576.ass tmp_anam.mkv --- libavfilter/vf_subtitles.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c index 3fc4eeb63d..af6352b315 100644 --- a/libavfilter/vf_subtitles.c +++ b/libavfilter/vf_subtitles.c @@ -146,9 +146,14 @@ static int config_input(AVFilterLink *inlink) ff_draw_init(&ass->draw, inlink->format, ass->alpha ? FF_DRAW_PROCESS_ALPHA : 0); ass_set_frame_size (ass->renderer, inlink->w, inlink->h); - if (ass->original_w && ass->original_h) + if (ass->original_w && ass->original_h) { ass_set_pixel_aspect(ass->renderer, (double)inlink->w / inlink->h / ((double)ass->original_w / ass->original_h)); + ass_set_storage_size(ass->renderer, ass->original_w, ass->original_h); + } else { + ass_set_storage_size(ass->renderer, inlink->w, inlink->h); + } + if (ass->shaping != -1) ass_set_shaper(ass->renderer, ass->shaping);