From patchwork Sat Dec 11 18:40:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 32350 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a0c:cdc3:0:0:0:0:0 with SMTP id a3csp5359239qvn; Sat, 11 Dec 2021 10:42:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJziKFEJjYMNbltunFvgUVF6/baiiYchAwwMyZcBqY5ccsetzKZmShoZMnBGd1ztQKdGVhzI X-Received: by 2002:a17:906:782:: with SMTP id l2mr28366756ejc.465.1639248133494; Sat, 11 Dec 2021 10:42:13 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c25si9278272edv.65.2021.12.11.10.42.13; Sat, 11 Dec 2021 10:42:13 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=Wz11+V97; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 63DCA68AF6F; Sat, 11 Dec 2021 20:41:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2045.outbound.protection.outlook.com [40.92.89.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 280AA68AF2C for ; Sat, 11 Dec 2021 20:41:10 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ExUicex5iddWSJrsLf3dnWgbATuBoI/lKr9FsBGlRbENHmMTViOHpPOLxbwy9Q2jDH6aPKf2L2qstN4UpHIUVDTWn0OHWbv2uvg77pV2OD8lV4wN1hJVqUC/rpa1LjObglw2zJBC0y1TGSgVdnB2EB/P4+Yv0EPzCYFoq+rtGQy8jZJlScBNhK6QYTbb8lv7N1z13gJmfWMq4jAtzswPhx670+R/GCBqKPRS0faHT80I+WVxuGmj736LaaghaMr9f+QR5SN3lNYCqwqvTKrz5qq/xqEON6JBaoCJEHEXFz5NZQMEY11GhuwN49NfHViugAEFV+mDHAjVndiREeJ2oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WAQuMUZXp9IRd6BY1CyaqXl2atf5IqnVG/x0eHLuxRw=; b=Phf3xtEmBKoZ9VMFLqXOtbvwDTcOjBuPZGa3Jk3NliuquwdI1vi1NaFM6BrI8/hw2f4d5m3Nv0MJn9CAUY7oCLDHWn1AiXk8UeOQWmdHq++mN7j6tFxvIyUeKK3wi5hiFu4+jtozmlRKQ4GkiclgoKAPSLtn9Ga1DH0fih9bc8BPE2xXrCnBpF0rkL79RmPianBWaDRRvLBVLtp0nliMQ5f48h1I0ZwjnDVF1bOdTzi/KaeANGxCe8+iMmzJE+CzM8lSuG2oTFP3bWXYo2n9OWMQfqiaUlu5/VSizv50TVmmgMZMmP3QPQ6SiIdKUbvJgWXDW0gS9ysntcJeEE8Sew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WAQuMUZXp9IRd6BY1CyaqXl2atf5IqnVG/x0eHLuxRw=; b=Wz11+V97u8fs/b1cZyhNon3Aapo7xaYHit5uLf3w2SeVyTl88TLpD8eUzZcQyzPjui6+J08kPXPXRFJz33KWN68NFrMqMle4d21hoKTdUDSVSsdUk2vb/vBY6lSJPU4fRyXwz1TIzih3f3wdxCimoYo2hWXIOK9CMqWKJI97HG+HA79k7NYxdbCminQH+2n5RCJDt272bzDdXCDJG5gX25mfa7Fba8sqgDeKmINnPtEbcVTsadtR5JPf87UzNsRYbplh7Hapisce1udKTqv15cNtp5/lgczZseUCFQ7sSwwo9ALlhfd8hCkTiSWWgyN40a1RV0S6yCzLkKMEomQqjw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM7PR03MB6450.eurprd03.prod.outlook.com (2603:10a6:20b:1b2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.22; Sat, 11 Dec 2021 18:41:09 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::f0dc:92f5:6bc2:45ca]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::f0dc:92f5:6bc2:45ca%6]) with mapi id 15.20.4778.017; Sat, 11 Dec 2021 18:41:09 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 11 Dec 2021 19:40:24 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [h7WG8fjqEd2wALIhstBz00W5pu6bgaXL] X-ClientProxiedBy: AM4P190CA0008.EURP190.PROD.OUTLOOK.COM (2603:10a6:200:56::18) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211211184025.1430779-10-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed966a25-63fe-4cbf-c463-08d9bcd5cc95 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiS9msLST/hR/FDB3IPfXlmiI+qMuGu7IkXO8a7OYhrF77bxOSJeJJHvpukb8+MNI44FQPVTxjXAh7xp2YALwyqmM6qt+HZQO5ZIpssXuWe34oU1X55Fi5LlA3UjIrEpQShyyBcfR9bGxp6zNuwcUfimAvTJohZLWhJV49o3m35e6j62nTUVD/0jRlr7DBY0oOabd5L7m8KPcgSsesZlTLNuAAq8aTAwMpll58YAUxObFoWhh5BnLxSLX8ao3wuHmR17bYPBh6WYdpqhxdQRwg7DI3GURiHnduRB9Y8fZwA7EXaMFNp9Nth6U0xROGdkhcMxfAYRz//XJEErzDXfcPCq0rrPYdmrRtvfC0t4coXGAd5G94htkDrv8yppxVRLq0cLxn26Zwr4k9hXw6AmSSzyxDuUZpCrskARnud4CEh8p+IVsM6OwwbFiEucxPx5Z+N/RFCBG9yQf24Uup4yBAgaiGtXAvPauDxwbFzrTo1aadH+ko5/LsH5R2ngN8QQ5eb1yBKdEjh3CsLq/aNYZUeCntox0WWKF3qESlCt7UDaFVkkTUHNm9nm5xOMqI+0mb55dIlXa2SYJrKVcRZQ2X+kS/QOGCx433gMWzosQ7RQ5OHu7r3J2emOOleNQr+8fRDAThhupCjmvRvemNCRiWLPljcI0XU8WI0FfLiVrVRqNBCFwXuAptj3A24wlxcWwxa07itmdwyx+HIFSa+7noTDAObKz+TzBAGoJ8lDkRmqMRdIcBIm+hJriLGFBNtQIEE= X-MS-TrafficTypeDiagnostic: AM7PR03MB6450:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +ezs40CeebyrwDpQK5snqpXfjHUzyqTjyPM9fhUdi6xZDYXn3I5uT+QcoL+T+CFhNBPEFPfYLKRvPMgFfl/aFC216bjObl+5W7KSky/2qZ4Osx/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CFgsJfvxCKgx8hJXRrgtWjx7b2h2Tw5c886WPr3JycZRTG6f4P6PPGJiXjW5uZyE5wp0xdR4TbzCViFKxyAS55m1/YQf4Nt1TQyYQU3TsaVxrSbaKAhQQoA8T9qCP8QcHderhhDiXVqKQbhoKdRlzcNMLhZkkZKfuf4l4viME4x80OplYnWVDan15E/hG/0J9DjPoc5d8ZreZ4a7Oi3AgvZfpDEZXaogI58x/6ejRY+N998+iXy5IkHucstlfYoN2GM6w/JuCyODYUxYkhqgWdVohUf2UO2PRT7Ok7P6WXSzU7Y2d1VE90rox468kXXg7Tp+tmdKLuk3qfdhv7g7T81a/nC8PJOWGUXvLWksrb15mfZnin9wg1mHnmJ9mL96IQ8GO2sxnP2EhuVpG23eJS5NtScioulBWilD6z41bHYtqZAHpEjaN6F88KurMQQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed966a25-63fe-4cbf-c463-08d9bcd5cc95 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2021 18:41:09.7621 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR03MB6450 Subject: [FFmpeg-devel] [PATCH 11/12] avcodec/xsubdec: Use dedicated pointer for AVSubtitleRect X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qpRYVU8oSxOf Content-Length: 3418 Improves readability and slightly reduces codesize. Signed-off-by: Andreas Rheinhardt --- libavcodec/xsubdec.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index b483699d0a..85cd7d1c20 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -52,6 +52,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AVSubtitle *sub = data; + AVSubtitleRect *rect; const uint8_t *buf_end = buf + buf_size; uint8_t *bitmap; int w, h, x, y, i, ret; @@ -100,40 +101,40 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, if (!sub->rects) return AVERROR(ENOMEM); - sub->rects[0] = av_mallocz(sizeof(*sub->rects[0])); + sub->rects[0] = rect = av_mallocz(sizeof(*sub->rects[0])); if (!sub->rects[0]) return AVERROR(ENOMEM); sub->num_rects = 1; - sub->rects[0]->x = x; sub->rects[0]->y = y; - sub->rects[0]->w = w; sub->rects[0]->h = h; - sub->rects[0]->type = SUBTITLE_BITMAP; - sub->rects[0]->linesize[0] = w; - sub->rects[0]->data[0] = av_malloc(w * h); - sub->rects[0]->nb_colors = 4; - sub->rects[0]->data[1] = av_mallocz(AVPALETTE_SIZE); - if (!sub->rects[0]->data[0] || !sub->rects[0]->data[1]) + rect->x = x; rect->y = y; + rect->w = w; rect->h = h; + rect->type = SUBTITLE_BITMAP; + rect->linesize[0] = w; + rect->data[0] = av_malloc(w * h); + rect->nb_colors = 4; + rect->data[1] = av_mallocz(AVPALETTE_SIZE); + if (!rect->data[0] || !rect->data[1]) return AVERROR(ENOMEM); // read palette - for (i = 0; i < sub->rects[0]->nb_colors; i++) - ((uint32_t*)sub->rects[0]->data[1])[i] = bytestream_get_be24(&buf); + for (i = 0; i < rect->nb_colors; i++) + ((uint32_t*)rect->data[1])[i] = bytestream_get_be24(&buf); if (!has_alpha) { // make all except background (first entry) non-transparent - for (i = 1; i < sub->rects[0]->nb_colors; i++) - ((uint32_t *)sub->rects[0]->data[1])[i] |= 0xff000000; + for (i = 1; i < rect->nb_colors; i++) + ((uint32_t *)rect->data[1])[i] |= 0xff000000; } else { - for (i = 0; i < sub->rects[0]->nb_colors; i++) - ((uint32_t *)sub->rects[0]->data[1])[i] |= (unsigned)*buf++ << 24; + for (i = 0; i < rect->nb_colors; i++) + ((uint32_t *)rect->data[1])[i] |= (unsigned)*buf++ << 24; } // process RLE-compressed data if ((ret = init_get_bits8(&gb, buf, buf_end - buf)) < 0) return ret; - bitmap = sub->rects[0]->data[0]; + bitmap = rect->data[0]; for (y = 0; y < h; y++) { // interlaced: do odd lines - if (y == (h + 1) / 2) bitmap = sub->rects[0]->data[0] + w; + if (y == (h + 1) / 2) bitmap = rect->data[0] + w; for (x = 0; x < w; ) { int log2 = ff_log2_tab[show_bits(&gb, 8)]; int run = get_bits(&gb, 14 - 4 * (log2 >> 1));