From patchwork Wed Apr 14 06:57:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 26903 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id ECFF544AA35 for ; Wed, 14 Apr 2021 10:04:03 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BF7A7689DFA; Wed, 14 Apr 2021 10:04:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 39094689DFA for ; Wed, 14 Apr 2021 10:03:57 +0300 (EEST) Received: by mail-wr1-f51.google.com with SMTP id 12so18775933wrz.7 for ; Wed, 14 Apr 2021 00:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=aAnSMwyqkLOB/olb55Jq+waA0jQeD/j+DF89tJ0U/Ss=; b=gvqhgK6uUaKMR7ZZfzIujS7RlGiRxkyNKESI2gE9RYooF/UGp00Bse57Xm/NlsPHa5 ybNMtDCvSts8PyRDO0oPwq3I8Oxxy490cdj6TGu5jVrNlwVFRf33uQjLPw2jtuPdMQp0 L/qJ3sBFLZH8+IrtGzAsMeJ85uVvMYQZHTARAFZrBjsvbHL4jX7ZaTIVD/69aBtVBGWp d8EkTBOpI+XVH00kWRZy90O1aWpRvMZdZSRJK1K3hWCRT1J3ZmaIAlZ2O8vC/K5lNv07 MgqaondURYpCaD98jnxF1+sl6MXg11yAC/ahArg6/x0ckNhwJ9qQ0efpIb/IKe1BixDY axUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=aAnSMwyqkLOB/olb55Jq+waA0jQeD/j+DF89tJ0U/Ss=; b=mGv+PBvkuTe8hsUJyOdaTzafvQAFSEpIbN4gywLhzZLpGT0JKYjh4VCHilUVGin9xA G3YhRelEDnHe+YNepfaZf3uQ88FNKHY9CPjp+6iYvbtoJU2gMYc522FKKGvuqA4+0upe uIQTQ8sULtMp8SJnHkwnSIiKG/ZFKcOFejuvOk8ltBosByhXsHlw6wf+MmY4mrIUGX/a pDFbjOZRjd9YmwQ2dJY9Yfaldu05Jt1L6BpHLo+S9cM3BQ1z2WrY/AaHvfLnOGE4Hqmr mp9FyV7sbR05ELWgen8cWnQnj3vubRYFB4z2+jRypAAiSRTVW1rkbHfYjWL7t6f88QsW h1MA== X-Gm-Message-State: AOAM530xQqt7OxOlnVqfTyaPUN4Pdebu6eM0PpxmQwPLJ4iDz940745v h5KGl0ZJhS64YiAmXrPUudqRdu3rbJ4= X-Google-Smtp-Source: ABdhPJxojx2eem4xPDUDuwDekWs8bVgGkcgBjJ3SpO7PtPfiPdwn08TZ9wEF79NIvZiX+xNbfGhLpQ== X-Received: by 2002:ac2:4ecb:: with SMTP id p11mr4222931lfr.537.1618383448435; Tue, 13 Apr 2021 23:57:28 -0700 (PDT) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id w5sm4960167ljo.11.2021.04.13.23.57.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 23:57:27 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Apr 2021 09:57:21 +0300 Message-Id: <20210414065725.8828-1-jeebjp@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 0/4] Initial region (styling) support for TTML 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" Now sets alignment, font size, font family and the region's position and size according to the ASS styles passed to the encoder. Regions are relatively important in TTML, since the spec-defined default region is in raster location (similar to the default with HTML) - it starts from the top left corner and covers the whole screen. Mapping of the ASS script resolution to the cell resolution and using cells as sizing metric is not perfect, but while TTML does have a pixel based reference sizing by means of setting an extent to the root tt element, it is specifically disallowed in the EBU-TT profile, as well as apparently generally frowned upon as opposed to defining the cell resolution. In general, mapping to cell resolution seems to give "close enough" results, though. FATE test output still passes https://github.com/skynav/ttt/ validation, and visually the result can be verified against such renderers as http://sandflow.com/imsc1_1/index.html . Changes from v1: * Removal of unnecessary intermediate AVBprints by printing elements in three steps instead of attempting to do a single one. A bit less pretty, but lets us write straight into the actual output buffer. * Removal of some local scopes. Seems like I'd been utilizing them as a convenient way of having variable definitions after initial sanity checks. * Merging of script play X/Y resolution being zero or smaller checks into just <= 0 checks. * Utilization of extradata buffers as-is after verifying that the buffer ends with a null. Removes the requirement to copy strings out of the extradata into the lavf context, and thus the deinit/free function was no longer necessary. The diff can be checked as follows on my git repository: https://github.com/jeeb/ffmpeg/compare/ttml_add_default_region_v1..ttml_add_default_region_v2 (more easily readable due to file limiting with the following command: git diff ttml_add_default_region_v1..ttml_add_default_region_v2 -- libavcodec/ttmlenc.* libavformat/ttmlenc.* ) Jan Jan Ekström (4): avcodec/ttmlenc: split header writing into its own function avformat/ttmlenc: enable writing out additional header values avcodec/ttmlenc: add initial support for regions and styles avcodec/ttmlenc: add support for region positioning and sizing libavcodec/ttmlenc.c | 267 ++++++++++++++++++++++++++++++++++--- libavcodec/ttmlenc.h | 6 + libavformat/ttmlenc.c | 70 +++++++++- tests/ref/fate/sub-ttmlenc | 88 +++++++----- 4 files changed, 371 insertions(+), 60 deletions(-)