[FFmpeg-devel] [PATCH] Fix colors for DVD subtitles
alexandre at elgato.com
Tue Apr 26 10:53:54 CEST 2011
> On Sat, Apr 23, 2011 at 10:10:52PM +0200, Reimar Döffinger wrote:
>> On Sat, Apr 23, 2011 at 12:46:09PM -0700, Baptiste Coudurier wrote:
>>> On 4/23/11 8:41 AM, Reimar Döffinger wrote:
>>>> On Thu, Apr 21, 2011 at 11:25:33AM +0200, Alexandre Colucci wrote:
>>>>> This patch fixes the DVD subtitle colors/alpha info. See screenshots for before and after the patch.
>>>> I don't think that is correct.
>>>> First, the yellow colour was chosen on purpose, and a lot of DVDs
>>>> use yellow but in principle one is as good as the other.
>>>> Secondly the function is called guess_palette for a reason:
>>>> It is a guess. It will be wrong. But so will yours.
>>>> Unless you have very good data to believe that yours actually
>>>> works better significantly more often I don't think there's a
>>>> good reason to change the code.
>>> Well, I think yellow is ugly personally, I like the patch if it works in
>>> a lot of cases.
>> Well, I don't particularly mind that part, but it definitely shouldn't
>> be committed as a "fix", it does not fix anything it just changes the
>> default colour.
>> For the other part I definitely want a bit more proof of usefulness,
>> there is no value in it if we end up mindlessly switching back and
>> forth between equally bad solutions just depending on which broken
>> DVD images someone has.
>> Note that in most cases after decoding the first subtitle it should
>> be possible to guess quite reliably by analyzing the image, but it
>> is going to be non-trivial.
>> E.g. fully transparent should be most frequent, fully opaque second-most.
> The most common on the border pixels should be transparent, this might
> be slightly more reliable
>> Finding gradients between those should allow figuring out the other two.
> they remainibg 2-3 can be tried by brute force (2 or 6 options)
> and then the resulting grayscale compressed by jpeg or anything else.
> the one compressing best is likely the correct one
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Changing the default color is actually the least significant part of the patch. If personal taste is of importance then it should at least be a user option and not hardcoded to yellow though.
The patch simply makes DVD subtitles look like in VLC with a much simpler detection algorithm. It simply associates the component with the highest alpha (the actual text) with the chosen color. Those with lower alpha become darker. If you need a more complex algorithm check out vlc/modules/codec/spudec/parse.c but it will end up with the same colors as this patch.
More information about the ffmpeg-devel