From patchwork Mon Feb 3 19:42:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kuron X-Patchwork-Id: 17679 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 2E38A449AA2 for ; Mon, 3 Feb 2020 21:48:23 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0FDB5689987; Mon, 3 Feb 2020 21:48:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 233E96880E8 for ; Mon, 3 Feb 2020 21:48:17 +0200 (EET) Received: by mail-wm1-f65.google.com with SMTP id t14so715843wmi.5 for ; Mon, 03 Feb 2020 11:48:17 -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=NP41DDj/gAlYgyPufwGcPujx4H5hCqVYAFqB1mJj0V8=; b=jef2qXmaHwMeuyQcXIbv3NPzP5N1wkP50Ez8UutNB+j3qzanzi2Dk3HscdY6e5qlGR uUceFIyURXYUj5ka+0OrGW+o+S0TeHXFtL7looouyOCwKIgZGklP0aYM0f9UWDjtpZMO gsUb6EhdmsvHrAV4yutu1gSxy1oi8ioN+NnOk6++DhPpjFenz+lFjoaVoS/qFmZthxEO OrdENeTOEQVqOBC++xOsR+qs+4NsUD/P+3J2fNrfgtR3UZo8OPsklX+q5u3baun6td4f IqLwzRm/tCa1HdhOQe6qgJeNE0X2NUuuoezXABop7E0a2kQqumSyZ0hEdQJzN1aSZfGA ur9Q== 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=NP41DDj/gAlYgyPufwGcPujx4H5hCqVYAFqB1mJj0V8=; b=C5up0U5mZCrCGr2nPDNOPOaFbFoF/6ISE9i3lI+5QsiqVfWN+qHySjESWLrD9X4yPN puPATtAY3oMvVj1k+GBqsyV1zjvP7avRQxlG6CMVVSssNBqjYRtIhhQBsahQ65l/SqcR 54lM/8CjLwEf7Vqbwj3BhQW93LN+pXay6tarwhPk+bLXhUXAbRR56mqrXoeyh1K8R28N e8o1y6fmiZ0ivjOV8C0oi091qxBEPQb/TeE/DI+wEJgOIx1fZPx9gYptMXXb9vVAojen UxcDFGnhxdc0k5oODYHyWUYb4T32z0660X5jj9sg87hHOTRK8bm2h/OKyK8iggkNiE/y Rx/w== X-Gm-Message-State: APjAAAX7uXH1tAvGFzOz0F2kyK6nh+PJfTyeDACv+KGDTP5bsW4FM6xO n0/OvfOV7SXw5wguItISu4yf+R1X X-Google-Smtp-Source: APXvYqzLTF6CH05/JeOD9xI2yq9ayMLuVO2iYo5VEwROIsK7CE4s/xgQwT9p6D+o7WvTBOaj3bNiPQ== X-Received: by 2002:a7b:c416:: with SMTP id k22mr664528wmi.25.1580758983622; Mon, 03 Feb 2020 11:43:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 11:43:03 -0800 (PST) From: Michael Kuron To: ffmpeg-devel@ffmpeg.org Date: Mon, 3 Feb 2020 20:42:30 +0100 Message-Id: <20200203194231.2448-2-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 2/3] lavc/dvdsubdec: Move palette parsing to new function 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" Signed-off-by: Michael Kuron --- libavcodec/Makefile | 1 + libavcodec/dvdsub.c | 33 +++++++++++++++++++++++++++++++++ libavcodec/dvdsubdec.c | 22 ++++++---------------- libavcodec/internal.h | 2 ++ 4 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 libavcodec/dvdsub.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3cd73fbcc6..ddc923304a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -282,6 +282,7 @@ OBJS-$(CONFIG_DST_DECODER) += dstdec.o dsd.o OBJS-$(CONFIG_DVBSUB_DECODER) += dvbsubdec.o 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_DVAUDIO_DECODER) += dvaudiodec.o OBJS-$(CONFIG_DVVIDEO_DECODER) += dvdec.o dv.o dvdata.o diff --git a/libavcodec/dvdsub.c b/libavcodec/dvdsub.c new file mode 100644 index 0000000000..a03ff27754 --- /dev/null +++ b/libavcodec/dvdsub.c @@ -0,0 +1,33 @@ +/* + * DVD subtitle decoding/encoding + * Copyright (c) 2005 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "internal.h" +#include "libavutil/avstring.h" +#include + +void ff_dvdsub_parse_palette(uint32_t *palette, const char *p) +{ + for (int i = 0; i < 16; i++) { + palette[i] = strtoul(p, &p, 16); + while (*p == ',' || av_isspace(*p)) + p++; + } +} diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index 741ea9fd1e..bf49788e1b 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -27,7 +27,6 @@ #include "libavutil/colorspace.h" #include "libavutil/opt.h" #include "libavutil/imgutils.h" -#include "libavutil/avstring.h" #include "libavutil/bswap.h" typedef struct DVDSubContext @@ -626,18 +625,6 @@ static int dvdsub_decode(AVCodecContext *avctx, return buf_size; } -static void parse_palette(DVDSubContext *ctx, char *p) -{ - int i; - - ctx->has_palette = 1; - for(i=0;i<16;i++) { - ctx->palette[i] = strtoul(p, &p, 16); - while(*p == ',' || av_isspace(*p)) - p++; - } -} - static int parse_ifo_palette(DVDSubContext *ctx, char *p) { FILE *ifo; @@ -719,7 +706,8 @@ static int dvdsub_parse_extradata(AVCodecContext *avctx) break; if (strncmp("palette:", data, 8) == 0) { - parse_palette(ctx, data + 8); + ctx->has_palette = 1; + ff_dvdsub_parse_palette(ctx->palette, data + 8); } else if (strncmp("size:", data, 5) == 0) { int w, h; if (sscanf(data + 5, "%dx%d", &w, &h) == 2) { @@ -748,8 +736,10 @@ static av_cold int dvdsub_init(AVCodecContext *avctx) if (ctx->ifo_str) parse_ifo_palette(ctx, ctx->ifo_str); - if (ctx->palette_str) - parse_palette(ctx, ctx->palette_str); + if (ctx->palette_str) { + ctx->has_palette = 1; + ff_dvdsub_parse_palette(ctx->palette, ctx->palette_str); + } if (ctx->has_palette) { int i; av_log(avctx, AV_LOG_DEBUG, "palette:"); diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 5096ffa1d9..41281b1140 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -424,6 +424,8 @@ int64_t ff_guess_coded_bitrate(AVCodecContext *avctx); int ff_int_from_list_or_default(void *ctx, const char * val_name, int val, const int * array_valid_values, int default_value); +void ff_dvdsub_parse_palette(uint32_t *palette, const char *p); + #if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avcodec) # define av_export_avcodec __declspec(dllimport) #else