[FFmpeg-devel,v2,0/4] Initial region (styling) support for TTML

Message ID 20210414065725.8828-1-jeebjp@gmail.com
Headers show


Jan Ekström April 14, 2021, 6:57 a.m. UTC
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:
(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 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(-)