From patchwork Thu Mar 4 18:48:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 26106 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 B7F4D44BB89 for ; Thu, 4 Mar 2021 20:55:12 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A4C8968AC2D; Thu, 4 Mar 2021 20:55:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe05-2.mx.upcmail.net (vie01a-dmta-pe05-2.mx.upcmail.net [84.116.36.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7B98468A8FA for ; Thu, 4 Mar 2021 20:55:06 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1lHt2a-000139-0Y for ffmpeg-devel@ffmpeg.org; Thu, 04 Mar 2021 19:49:40 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id Ht1cldPDOljeHHt1clC5F5; Thu, 04 Mar 2021 19:48:40 +0100 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.3 cv=BoHjPrf5 c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=cdWDK3apVHl2_Jm7dJIA:9 a=pHzHmUro8NiASowvMSCR:22 a=Ew2E2A-JSTLzCXPT_086:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 4 Mar 2021 19:48:36 +0100 Message-Id: <20210304184839.24847-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210304184839.24847-1-michael@niedermayer.cc> References: <20210304184839.24847-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfF1BT/GhxzqAebPnrFafqFg2ZUrDyCJfcLC595E8wW96n1bs2Xlh30V8ar8lomfwARmM9wLA2uucwgZJ4U/TNLb5FBlT7sxyPMiWpHODm1DPBWWVHcXg ViKylg8PThBJPDDnhD3OSIbbSiVwW/w4rERAf82qxOMRDqGAoDXfAN8j Subject: [FFmpeg-devel] [PATCH 4/7] avcodec/dvbsubdec: Support computing clut only once 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This avoids crafted files from consuming excessive resources recomputing the clut after each pixel change Signed-off-by: Michael Niedermayer --- libavcodec/dvbsubdec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index 9bee33e4a2..6f340460d8 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -979,7 +979,8 @@ static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDis } } - region->has_computed_clut = 0; + if (ctx->compute_clut != -2) + region->has_computed_clut = 0; } static int dvbsub_parse_object_segment(AVCodecContext *avctx, @@ -1737,7 +1738,7 @@ end: #define OFFSET(x) offsetof(DVBSubContext, x) static const AVOption options[] = { {"compute_edt", "compute end of time using pts or timeout", OFFSET(compute_edt), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DS}, - {"compute_clut", "compute clut when not available(-1) or always(1) or never(0)", OFFSET(compute_clut), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, DS}, + {"compute_clut", "compute clut when not available(-1) or only once (-2) or always(1) or never(0)", OFFSET(compute_clut), AV_OPT_TYPE_BOOL, {.i64 = -1}, -2, 1, DS}, {"dvb_substream", "", OFFSET(substream), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, DS}, {NULL} };