[FFmpeg-cvslog] lavc/dvdsubenc: accept palette from options

Michael Kuron git at videolan.org
Wed Feb 5 01:19:01 EET 2020


ffmpeg | branch: master | Michael Kuron <michael.kuron at gmail.com> | Mon Feb  3 20:42:31 2020 +0100| [d4440c7e91b0ef5f6776d98c51dbb6cd66ea0194] | committer: Michael Niedermayer

lavc/dvdsubenc: accept palette from options

Previously, the default palette would always be used.
Now, we can accept a custom palette, just like dvdsubdec does.

Signed-off-by: Michael Kuron <michael.kuron at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d4440c7e91b0ef5f6776d98c51dbb6cd66ea0194
---

 doc/encoders.texi      | 8 ++++++++
 libavcodec/Makefile    | 1 +
 libavcodec/dvdsubenc.c | 8 +++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index e26d6b5425..7bae39435e 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3211,6 +3211,14 @@ and they can also be used in Matroska files.
 @subsection Options
 
 @table @option
+ at item palette
+Specify the global palette used by the bitmaps.
+
+The format for this option is a string containing 16 24-bits hexadecimal
+numbers (without 0x prefix) separated by commas, for example @code{0d00ee,
+ee450d, 101010, eaeaea, 0ce60b, ec14ed, ebff0b, 0d617a, 7b7b7b, d1d1d1,
+7b2a0e, 0d950c, 0f007b, cf0dec, cfa80c, 7c127b}.
+
 @item even_rows_fix
 When set to 1, enable a work-around that makes the number of pixel rows
 even in all subtitles.  This fixes a problem with some players that
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index a0b828f2f9..f508fee8f9 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -285,6 +285,7 @@ OBJS-$(CONFIG_DVBSUB_ENCODER)          += dvbsub.o
 OBJS-$(CONFIG_DVDSUB_DECODER)          += dvdsubdec.o
 OBJS-$(CONFIG_DVDSUB_DECODER)          += dvdsub.o
 OBJS-$(CONFIG_DVDSUB_ENCODER)          += dvdsubenc.o
+OBJS-$(CONFIG_DVDSUB_ENCODER)          += dvdsub.o
 OBJS-$(CONFIG_DVAUDIO_DECODER)         += dvaudiodec.o
 OBJS-$(CONFIG_DVVIDEO_DECODER)         += dvdec.o dv.o dvdata.o
 OBJS-$(CONFIG_DVVIDEO_ENCODER)         += dvenc.o dv.o dvdata.o
diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c
index ff95ed2002..e54b5f0d7b 100644
--- a/libavcodec/dvdsubenc.c
+++ b/libavcodec/dvdsubenc.c
@@ -29,6 +29,7 @@
 typedef struct {
     AVClass *class;
     uint32_t global_palette[16];
+    char *palette_str;
     int even_rows_fix;
 } DVDSubtitleContext;
 
@@ -436,7 +437,11 @@ static int dvdsub_init(AVCodecContext *avctx)
     int i, ret;
 
     av_assert0(sizeof(dvdc->global_palette) == sizeof(default_palette));
-    memcpy(dvdc->global_palette, default_palette, sizeof(dvdc->global_palette));
+    if (dvdc->palette_str) {
+        ff_dvdsub_parse_palette(dvdc->global_palette, dvdc->palette_str);
+    } else {
+        memcpy(dvdc->global_palette, default_palette, sizeof(dvdc->global_palette));
+    }
 
     av_bprint_init(&extradata, 0, AV_BPRINT_SIZE_AUTOMATIC);
     if (avctx->width && avctx->height)
@@ -467,6 +472,7 @@ static int dvdsub_encode(AVCodecContext *avctx,
 #define OFFSET(x) offsetof(DVDSubtitleContext, x)
 #define SE AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
+    {"palette", "set the global palette", OFFSET(palette_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, SE },
     {"even_rows_fix", "Make number of rows even (workaround for some players)", OFFSET(even_rows_fix), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, SE},
     { NULL },
 };



More information about the ffmpeg-cvslog mailing list