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