[FFmpeg-devel] [PATCH 2/6] dvdsubenc: make it usable for transcoding.
Clément Bœsch
ubitux at gmail.com
Tue Aug 7 22:07:49 CEST 2012
On Tue, Aug 07, 2012 at 09:13:30PM +0200, Nicolas George wrote:
> 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.
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> libavcodec/dvdsubenc.c | 333 ++++++++++++++++++++++++++++++++++++++----------
> 1 file changed, 263 insertions(+), 70 deletions(-)
>
I'd like to look at this patchset and especially this patch deeper if you
give me some time a bit. But just before:
[...]
> +static int dvdsub_init(AVCodecContext *avctx)
> +{
> + DVDSubtitleContext *dvdc = avctx->priv_data;
> + static const uint32_t default_palette[16] = {
> + 0x000000, 0x0000FF, 0x00FF00, 0xFF0000,
> + 0xFFFF00, 0xFF00FF, 0x00FFFF, 0xFFFFFF,
> + 0x808000, 0x8080FF, 0x800080, 0x80FF80,
> + 0x008080, 0xFF8080, 0x555555, 0xAAAAAA,
> + };
> + AVBPrint extradata;
> + int i;
> +
> + av_assert0(sizeof(dvdc->global_palette) == sizeof(default_palette));
> + memcpy(dvdc->global_palette, default_palette, sizeof(dvdc->global_palette));
> +
> + av_bprint_init(&extradata, 0, 1);
> + av_bprintf(&extradata, "palette:");
> + for (i = 0; i < 16; i++)
> + av_bprintf(&extradata, " %06"PRIx32"%c",
> + dvdc->global_palette[i] & 0xFFFFFF, i < 15 ? ',' : '\n');
> + avctx->extradata_size = strlen(extradata.str);
> + avctx->extradata = av_malloc(avctx->extradata_size);
> + if (!avctx->extradata)
> + return AVERROR(ENOMEM);
> + memcpy(avctx->extradata, extradata.str, avctx->extradata_size);
> +
> + return 0;
> }
>
Would it make sense to use that extradata to store for instance the
content of a .IDX (associated with a vob .SUB)?
AFAIK FFmpeg has no support for vobsub, and it might be necessary for a
classic DVD rip workflow.
I must say I have no idea yet what really is the state of FFmpeg on that
regard and it looks like you have a better overview... :)
[...]
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120807/1f4c7f74/attachment.asc>
More information about the ffmpeg-devel
mailing list