Consider the color space as an hypercone with apex alpha=0
and base alpha=1 instead of an hypercube.
Make the encoder consider very transparent colors more similar
even if the hue is very different.
This corresponds roughly to using the alpha as a weight for the
color difference.
Only 4 bits of alpha are used, because this is what dvdsub uses,
and it avoids overflows.
Fix trac ticket #2005.
This commit also makes sure the extradata and subtitle_header are NUL
terminated, without taking into account the trailing '\0' in account in
the size.
At the same time, it should fix 'warning: dereferencing type-punned
pointer will break strict-aliasing rules' warning for compilers who
don't consider uint8_t** and char** compatibles.
DVD subtitles packets can only encode a single rectangle:
if there are several, copy them into a big transparent one.
DVD subtitles rely on an external 16-colors palette:
use a reasonable default one, stored in the private context,
and encode it into the extradata, as specified by Matroska.
TODO: allow to change the palette with an option.
Each packet can use four colors out of the global palette.
The old logic was to map transparent colors to the color 0
and all other colors to 3, 2, 1, cyclically in descending
frequency order, completely disregarding the original color.
Select the "best" four colors from the global palette, according
to heuristics based on frequency, opacity and brightness, and
arrange them in standard DVD order: background, foreground,
outline, other.
TODO: select the alpha value more finely; see if CHG_COLCON can
allow more than 4 colors per packet.
Reference:
http://dvd.sourceforge.net/dvdinfo/spu.html
With these changes, dvdsubenc can be used to transcode DVB subtitles
and get a very decent result.
Also break some long lines, remove codec function placeholder comments
and add spaces in sample/pixel format lists.
Signed-off-by: Martin Storsjö <martin@martin.st>
None of these symbols should be accessed directly, so declare them as
hidden.
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit d36beb3f69)
Patch by Steve LHomme
Original thread:
Date: 13.10.2006 21:55
Subject: [Ffmpeg-devel] [PATCH] Remove empty structures
Originally committed as revision 6690 to svn://svn.ffmpeg.org/ffmpeg/trunk
Original thread:
Date: 8 Oct 2005 09:35:38 -0000
Subject: [Ffmpeg-devel] [PATCH] dvdsub encoder -- 2nd version
Originally committed as revision 4706 to svn://svn.ffmpeg.org/ffmpeg/trunk