From patchwork Sat Feb 1 22:43:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kuron X-Patchwork-Id: 17650 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 7C9E744ADB6 for ; Sun, 2 Feb 2020 00:51:47 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5493F68979C; Sun, 2 Feb 2020 00:51:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1CD26688155 for ; Sun, 2 Feb 2020 00:51:41 +0200 (EET) Received: by mail-wr1-f67.google.com with SMTP id w12so2126682wrt.2 for ; Sat, 01 Feb 2020 14:51:41 -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:mime-version :content-transfer-encoding; bh=MmU7MJ6U1OnfmPwGPQpCkM/aIcV2kMIeAIokRZlwIFk=; b=ampZH85arAIvNi/a0xd5UERaDD6XSef8WyYwx619bJ4nmwMzRHNbFckNRFUQQBauD3 lBXK5RP8thZaeHXVGVgIb+4Qq9qvhyHv3Wz8rcM6v9YtqQVUq76m14bS5WWRsqWTrUlO 98AengAA2gNqOFOq65GKcV5ebcLMCYmlSp9JhKapkQTCUVT2iImg0DgxAgN/G/jke6Ry Q6aNr3xi3N4zc5AObCYp9ZzR/ckSPpooImHd4EUyNz0eMghwBleuVvheDvLvpjpiISfX 0iugR5paAC9vYQkhFOcYvL09P2XArbpfk5bwQJUQZ5jLeNvpaeh/TD5lcFRRTKdE7tbX XrsQ== 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:mime-version :content-transfer-encoding; bh=MmU7MJ6U1OnfmPwGPQpCkM/aIcV2kMIeAIokRZlwIFk=; b=hCgIy2+IT3v3aVE6OimBo68jO6LfENAAltKvc/eKYb4+hcj240TOO8DNQrA61aPxcc UGAfiReKFUZvgT0cMCLaK7RpCYCHDqDx465G9admQft19wLzmJj1emku4hmDU1SDaH1Z 73kUW6od6aINR3NfeK+iAwsKiKyvxPACF4mV6O5qpQWNMhUylnvPeXyFOOrNR/u61ogZ 35i/Vf64DigbrDL0BoMhe1s0OnngKaciaaawq6/CBbf9I7Rx0Jo8UT+hFtHX8MUDlYkd NCZ4rrfvuv40aAx4/8Yh4zDoCoG8IfB8EkNff1hqoJY0X9MuN9bB0joSWZZGt+FKKP/8 hdww== X-Gm-Message-State: APjAAAVxRWChxABb0rKhVBVlL3Wjpn1WsEba9irK9EE3IPDII4AhSy4p qWGbxMEg5XAPCYvPaVXoiy8SdCt/ X-Google-Smtp-Source: APXvYqyF/+ItBn8Ct2d/eKDUynqiUq4HTCGqUD91hGOZ2EUPPAITWvqmS8yjIkvVJUb1qpkx9cwGvA== X-Received: by 2002:a5d:49c3:: with SMTP id t3mr6039111wrs.113.1580597189987; Sat, 01 Feb 2020 14:46:29 -0800 (PST) Received: from mkuron-mbp-icp.home.kuron-germany.de (i5DB52E3F.pool.tripleplugandplay.com. [93.181.46.63]) by smtp.gmail.com with ESMTPSA id x10sm17836353wrv.60.2020.02.01.14.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Feb 2020 14:46:29 -0800 (PST) From: Michael Kuron To: ffmpeg-devel@ffmpeg.org Date: Sat, 1 Feb 2020 23:43:08 +0100 Message-Id: <20200201224309.3016-1-michael.kuron@gmail.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] 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 --- doc/decoders.texi | 2 +- libavcodec/Makefile | 1 + libavcodec/dvdsub.c | 33 +++++++++++++++++++++++++++++++++ libavcodec/dvdsubdec.c | 22 ++++++---------------- libavcodec/internal.h | 2 ++ 5 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 libavcodec/dvdsub.c diff --git a/doc/decoders.texi b/doc/decoders.texi index 0582b018b0..83515ae363 100644 --- a/doc/decoders.texi +++ b/doc/decoders.texi @@ -280,7 +280,7 @@ palette is stored in the IFO file, and therefore not available when reading from dumped VOB files. The format for this option is a string containing 16 24-bits hexadecimal -numbers (without 0x prefix) separated by comas, for example @code{0d00ee, +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}. 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