From patchwork Mon Feb 3 19:42:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kuron X-Patchwork-Id: 17678 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id CFBE844BBEA for ; Mon, 3 Feb 2020 21:43:20 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AA0E36898D5; Mon, 3 Feb 2020 21:43:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2EF976897CE for ; Mon, 3 Feb 2020 21:43:14 +0200 (EET) Received: by mail-wr1-f51.google.com with SMTP id c9so19860219wrw.8 for ; Mon, 03 Feb 2020 11:43:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MCJtWrcN/XpnVQNxCc+Oeou2HCPS089M6WmtqqptUoM=; b=tIN+d4W9iW4X1Yjv450UKITquIIr+P3u4/aeZf/g+tcMg0J4S623OGAJS9aoh/+IHF WpzeJnWQ5M+ETAAiJj61r902eFmJ53HtezeJruIyqOgIJ5GJgzjNjYz7m+nstb9l0N/t nh4iuG3tBHSFsGQtlol4PujHyRhR3Zbx+R1cBiWa5ajX2RSgf630vnp+ZKI4uJ1X6miw ZE497mofx5L2p0+95rxfx97+WlzD2ApqITy37LDyN2l8fqSqPBb5Kg5xx7v4yxVOH+0n pMq2fXxTIpSdyWJlqQMPvd/09IHvULIWRX+YMAWQYvjU7LTDeU68/Kwvdij8Ujy6KBso 6tYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MCJtWrcN/XpnVQNxCc+Oeou2HCPS089M6WmtqqptUoM=; b=RleBJgw8G2iOPy2iRxSGT8Uzm83F8XGayo6KQvF9bO/GdczfVyT10ywhK8TVsjOuwD 9dfjLqed8iPW6IeYl3hwEA3vd50Dfa2MaWAHcnKYqqTgYqZoTerfN5wxm4x0u0GMiKcB RkqIhColFi2lJv1AmW9xz6/dHjY5hvThfyLC0Sd+hfb9tPJXVJKRwbynZ+Rq1KQ0dvf0 iRGvYB4GEdodc8t7N78160WIQ37hIrh1DxKxMHypa8ep5Eum0k0LE84Bx8nCkKfnyGvM LY5VYZKHxmU4GclGKplT2fk27mchRswwRWlBEraVgTmdwoNyNsAQV79399RUb2/+oqBJ EFyQ== X-Gm-Message-State: APjAAAWLKrWlqL0X4N1O2xYcbmAY/RKuLCYZrYyxGHYbKWs7Vqd7qmxY KYQHQsMmCIZDG29pIrF1soSIXkMa X-Google-Smtp-Source: APXvYqyvViqQCriEn2vu8nwhSkmKB30UkKrZCUNBJ8/KGtL7lAHsK/xvXJ4G3J5/tYzfwe57KVqhMA== X-Received: by 2002:a5d:4651:: with SMTP id j17mr17732264wrs.237.1580758993482; Mon, 03 Feb 2020 11:43:13 -0800 (PST) Received: from mkuron-mbp-icp.home.kuron-germany.de (i5DB53724.pool.tripleplugandplay.com. [93.181.55.36]) by smtp.gmail.com with ESMTPSA id h13sm15198690wrw.54.2020.02.03.11.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 11:43:13 -0800 (PST) From: Michael Kuron To: ffmpeg-devel@ffmpeg.org Date: Mon, 3 Feb 2020 20:42:31 +0100 Message-Id: <20200203194231.2448-3-michael.kuron@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200203194231.2448-1-michael.kuron@gmail.com> References: <20200203194231.2448-1-michael.kuron@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] lavc/dvdsubenc: accept palette from options X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Michael Kuron Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Previously, the default palette would always be used. Now, we can accept a custom palette, just like dvdsubdec does. Signed-off-by: Michael Kuron --- 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 eefd124751..a04f9f1b62 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3116,6 +3116,14 @@ and they can also be used in Matroska files. @subsection Options @table @option +@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 ddc923304a..71ee8caeb3 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -284,6 +284,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 }, };