The logic here was off. If the packet size is exactly two, then
it's a well-formed empty subtitle, used to mark the end of the
duration of the previous subtitle.
Signed-off-by: Philip Langdale <philipl@overt.org>
Unsurprisingly, if a timing-less subrip decoder is desireable, an
encoder is as well. With this in place, we can move on to remove
the use of the old encoder/decoder with embedded timing and move
all timing handling the (de)muxer where they belong.
Signed-off-by: Philip Langdale <philipl@overt.org>
After various discussions, we concluded that, amongst other things,
it made sense to have a separate subrip decoder that did not use
in-band timing information, and rather relied on the ffmpeg level
timing.
As this is 90% the same as the existing srt decoder, it's implemented
in the same file.
Signed-off-by: Philip Langdale <philipl@overt.org>
this crashes otherwise, and can happen from try_decode_frame() in the case of decoding errors
Fixes Ticket1602
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This function is always called with a non-negative argument, so
those special cases are not needed. In the places the argument
might be zero, the return value for a zero argument does not matter
since it would then be used to scale an array full of zeros.
Signed-off-by: Mans Rullgard <mans@mansr.com>
Note that the symbols used to run the hardware decoder in asynchronous mode
have been marked deprecated and will be dropped at a future version bump.
Signed-off-by: Diego Biurrun <diego@biurrun.de>
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.
Note that the symbols used to run the hardware decoder in asynchronous mode
has been marked as deprecated and will be dropped at a future version dump.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>