diff mbox series

[FFmpeg-devel,v2,2/3] avcodec/ass: accurately preserve colours

Message ID 20221113195718.17752-3-oneric@oneric.de
State New
Headers show
Series Some small ASS conversion fixes | expand

Checks

Context Check Description
andriy/configure_x86 warning Failed to apply patch
yinshiyou/configure_loongarch64 warning Failed to apply patch

Commit Message

Oneric Nov. 13, 2022, 7:57 p.m. UTC
Colour values used in ASS files without a "YCbCr Matrix" header set to
"None" are subject to colour mangling, due to how ASS was historically
conceived. A more in-depth description can be found in the documetation
inside libass' public ass_types.h header. The important part is, if this
header is not set to "None", the final output colours can deviate from
the literal value specified in the file. When converting from non-ASS
formats we do not want any colour shift to happen, so let's set the
appropiate header.

NB: ffmpeg's subtitle filter, does not follow libass' documentation
regarding colour mangling, thus hiding the bug. Anything based on
VSFilter, XySubFilter or e.g. mpv do and might show the issue.
(Of course native ASS subs, which _do_ rely on colour mangling won't
 work properly with the subtitle filter, but this can be fixed another
 time)
---
Link to libass’ docs regarding colour mangling:
  https://github.com/libass/libass/blob/3df19c2e809b16c9cf7c925fa3bb573e2e6f4fdd/libass/ass_types.h#L152-L232
---
 libavcodec/ass.c                 | 1 +
 tests/ref/fate/sub-aqtitle       | 1 +
 tests/ref/fate/sub-cc            | 1 +
 tests/ref/fate/sub-cc-realtime   | 1 +
 tests/ref/fate/sub-cc-scte20     | 1 +
 tests/ref/fate/sub-charenc       | 1 +
 tests/ref/fate/sub-jacosub       | 1 +
 tests/ref/fate/sub-microdvd      | 1 +
 tests/ref/fate/sub-movtext       | 1 +
 tests/ref/fate/sub-mpl2          | 1 +
 tests/ref/fate/sub-mpsub         | 1 +
 tests/ref/fate/sub-mpsub-frames  | 1 +
 tests/ref/fate/sub-pjs           | 1 +
 tests/ref/fate/sub-realtext      | 1 +
 tests/ref/fate/sub-sami          | 1 +
 tests/ref/fate/sub-sami2         | 1 +
 tests/ref/fate/sub-scc           | 1 +
 tests/ref/fate/sub-srt           | 1 +
 tests/ref/fate/sub-srt-badsyntax | 1 +
 tests/ref/fate/sub-stl           | 1 +
 tests/ref/fate/sub-subviewer     | 1 +
 tests/ref/fate/sub-subviewer1    | 1 +
 tests/ref/fate/sub-vplayer       | 1 +
 tests/ref/fate/sub-webvtt        | 1 +
 tests/ref/fate/sub-webvtt2       | 1 +
 25 files changed, 25 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/ass.c b/libavcodec/ass.c
index fdf55f36ca..d2ea4c62c3 100644
--- a/libavcodec/ass.c
+++ b/libavcodec/ass.c
@@ -41,6 +41,7 @@  int ff_ass_subtitle_header_full(AVCodecContext *avctx,
              "PlayResX: %d\r\n"
              "PlayResY: %d\r\n"
              "ScaledBorderAndShadow: yes\r\n"
+             "YCbCr Matrix: None\r\n"
              "\r\n"
              "[V4+ Styles]\r\n"
 
diff --git a/tests/ref/fate/sub-aqtitle b/tests/ref/fate/sub-aqtitle
index af0c06d7c2..ae5edcd9ab 100644
--- a/tests/ref/fate/sub-aqtitle
+++ b/tests/ref/fate/sub-aqtitle
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-cc b/tests/ref/fate/sub-cc
index 13f393cc86..516d26af9a 100644
--- a/tests/ref/fate/sub-cc
+++ b/tests/ref/fate/sub-cc
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-cc-realtime b/tests/ref/fate/sub-cc-realtime
index 169361f540..98dfef5501 100644
--- a/tests/ref/fate/sub-cc-realtime
+++ b/tests/ref/fate/sub-cc-realtime
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-cc-scte20 b/tests/ref/fate/sub-cc-scte20
index be28084887..a97d29f70b 100644
--- a/tests/ref/fate/sub-cc-scte20
+++ b/tests/ref/fate/sub-cc-scte20
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-charenc b/tests/ref/fate/sub-charenc
index 4efacb073d..339137ae0b 100644
--- a/tests/ref/fate/sub-charenc
+++ b/tests/ref/fate/sub-charenc
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-jacosub b/tests/ref/fate/sub-jacosub
index b574dda54d..32086d9365 100644
--- a/tests/ref/fate/sub-jacosub
+++ b/tests/ref/fate/sub-jacosub
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-microdvd b/tests/ref/fate/sub-microdvd
index 4ddb254c69..11440c2824 100644
--- a/tests/ref/fate/sub-microdvd
+++ b/tests/ref/fate/sub-microdvd
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-movtext b/tests/ref/fate/sub-movtext
index 6e2d2e35db..973e9f1645 100644
--- a/tests/ref/fate/sub-movtext
+++ b/tests/ref/fate/sub-movtext
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-mpl2 b/tests/ref/fate/sub-mpl2
index f78cf68495..d740fbc365 100644
--- a/tests/ref/fate/sub-mpl2
+++ b/tests/ref/fate/sub-mpl2
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-mpsub b/tests/ref/fate/sub-mpsub
index 1a8e757585..4c3d37fa42 100644
--- a/tests/ref/fate/sub-mpsub
+++ b/tests/ref/fate/sub-mpsub
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-mpsub-frames b/tests/ref/fate/sub-mpsub-frames
index abd52ad277..4f69e68948 100644
--- a/tests/ref/fate/sub-mpsub-frames
+++ b/tests/ref/fate/sub-mpsub-frames
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-pjs b/tests/ref/fate/sub-pjs
index 378190a3eb..a327205143 100644
--- a/tests/ref/fate/sub-pjs
+++ b/tests/ref/fate/sub-pjs
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-realtext b/tests/ref/fate/sub-realtext
index 04b1664f89..d80db64daf 100644
--- a/tests/ref/fate/sub-realtext
+++ b/tests/ref/fate/sub-realtext
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-sami b/tests/ref/fate/sub-sami
index dbd1cc310d..3f194bdd02 100644
--- a/tests/ref/fate/sub-sami
+++ b/tests/ref/fate/sub-sami
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-sami2 b/tests/ref/fate/sub-sami2
index dbec842d2b..bab07e4c07 100644
--- a/tests/ref/fate/sub-sami2
+++ b/tests/ref/fate/sub-sami2
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-scc b/tests/ref/fate/sub-scc
index 62cbf6fa4a..ff667eb4ec 100644
--- a/tests/ref/fate/sub-scc
+++ b/tests/ref/fate/sub-scc
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-srt b/tests/ref/fate/sub-srt
index b4eed235ce..a6ed4f31df 100644
--- a/tests/ref/fate/sub-srt
+++ b/tests/ref/fate/sub-srt
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-srt-badsyntax b/tests/ref/fate/sub-srt-badsyntax
index 61f472a84b..27bdd48c40 100644
--- a/tests/ref/fate/sub-srt-badsyntax
+++ b/tests/ref/fate/sub-srt-badsyntax
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-stl b/tests/ref/fate/sub-stl
index 0f326c2173..3e847a68be 100644
--- a/tests/ref/fate/sub-stl
+++ b/tests/ref/fate/sub-stl
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-subviewer b/tests/ref/fate/sub-subviewer
index c68a6442be..e910e154ba 100644
--- a/tests/ref/fate/sub-subviewer
+++ b/tests/ref/fate/sub-subviewer
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-subviewer1 b/tests/ref/fate/sub-subviewer1
index e88729ad5e..2d253288e1 100644
--- a/tests/ref/fate/sub-subviewer1
+++ b/tests/ref/fate/sub-subviewer1
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-vplayer b/tests/ref/fate/sub-vplayer
index d83db9e09f..ef9cb2d9e5 100644
--- a/tests/ref/fate/sub-vplayer
+++ b/tests/ref/fate/sub-vplayer
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-webvtt b/tests/ref/fate/sub-webvtt
index dea535b19b..091cfb5d3f 100644
--- a/tests/ref/fate/sub-webvtt
+++ b/tests/ref/fate/sub-webvtt
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
diff --git a/tests/ref/fate/sub-webvtt2 b/tests/ref/fate/sub-webvtt2
index 357b8178ea..56afed8944 100644
--- a/tests/ref/fate/sub-webvtt2
+++ b/tests/ref/fate/sub-webvtt2
@@ -4,6 +4,7 @@  ScriptType: v4.00+
 PlayResX: 384
 PlayResY: 288
 ScaledBorderAndShadow: yes
+YCbCr Matrix: None
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding