1 From 74f1c9b43b191a9d6b494e90a4a11677fca33c13 Mon Sep 17 00:00:00 2001
2 From: Joakim Plate <elupus@ecce.se>
3 Date: Sun, 11 Sep 2011 19:04:51 +0200
4 Subject: [PATCH 01/13] Support raw dvdsub palette as stored on normal dvd's
6 This is how the palette is stored on dvd's. Currently
7 only xbmc passes the palette information to libavcodec
10 Patch part of the XBMC patch set for ffmpeg, downloaded from
11 https://github.com/xbmc/FFmpeg/.
13 Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
14 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
16 libavcodec/dvdsubdec.c | 24 ++++++++++++++++++++++++
17 1 file changed, 24 insertions(+)
19 diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
20 index 39604f3..a711e16 100644
21 --- a/libavcodec/dvdsubdec.c
22 +++ b/libavcodec/dvdsubdec.c
23 @@ -64,6 +64,24 @@ static void yuv_a_to_rgba(const uint8_t *ycbcr, const uint8_t *alpha, uint32_t *
27 +static void ayvu_to_argb(const uint8_t *ayvu, uint32_t *argb, int num_values)
29 + uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
31 + int i, y, cb, cr, a;
32 + int r_add, g_add, b_add;
34 + for (i = num_values; i > 0; i--) {
39 + YUV_TO_RGB1_CCIR(cb, cr);
40 + YUV_TO_RGB2_CCIR(r, g, b, y);
41 + *argb++ = (a << 24) | (r << 16) | (g << 8) | b;
45 static int decode_run_2bit(GetBitContext *gb, int *color)
48 @@ -697,6 +715,12 @@ static av_cold int dvdsub_init(AVCodecContext *avctx)
49 parse_ifo_palette(ctx, ctx->ifo_str);
51 parse_palette(ctx, ctx->palette_str);
53 + if (!ctx->has_palette && avctx->extradata_size == 64) {
54 + ayvu_to_argb((uint8_t*)avctx->extradata, ctx->palette, 16);
55 + ctx->has_palette = 1;
58 if (ctx->has_palette) {
60 av_log(avctx, AV_LOG_DEBUG, "palette:");