From patchwork Sun Feb 18 01:41:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46326 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dda5:b0:19e:cdac:8cce with SMTP id kw37csp552509pzb; Sat, 17 Feb 2024 17:39:38 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW+zdLeb2ScfGVTGbQkabaltRu0wWulnq0VhCSmd6fMHYY7gFAwS9nKQQGRGuvs6TTakaVSeTwQymvisIHVOPir+noDMOWpaEUklg== X-Google-Smtp-Source: AGHT+IGdp/MEwZwNpA3A/rcz3qmiBleo5MoHIBdSLCvnbal6/BlykMCoIY2eLKn6yVUu4G5KV6r/ X-Received: by 2002:a17:907:37a:b0:a3e:3633:cf91 with SMTP id rs26-20020a170907037a00b00a3e3633cf91mr1361625ejb.48.1708220378207; Sat, 17 Feb 2024 17:39:38 -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 qc19-20020a170906d8b300b00a3e0db6eb73si1192100ejb.280.2024.02.17.17.39.37; Sat, 17 Feb 2024 17:39:38 -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=ewkYciEO; 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 E89EC68D303; Sun, 18 Feb 2024 03:39:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2084.outbound.protection.outlook.com [40.92.90.84]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AFA3A68D27D for ; Sun, 18 Feb 2024 03:39:27 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cBHsm/f6MsrZOxjSC3AxOlQvryyOebz2d5NToHt0cL3+C6jySvt2SkSV5iFLcElz7g5UEyXboSPW9En+cKUZK/5yWCBRVZH9a111YhKbr0ux1KLJ3NK4C8eIb15UhuWHdYSrI7KB5UuetjjOazE61eXB4pD8wkRnS21664omFXTABkhWi1wQ81SNXm4sXtqS1Gz4QbK3T4AF8Epvh8lUl8LxJzom4Uj8qVeFIanwgtzlJn21ogcDhjyY/zFANpQGKY4E1tualx7pWhFkTYE1OPFrjWNV5xMdvmP1Agl9mDtMoPp5R8Itkf2tTeja19Y7fi0BX6TcMLQ+oSYpUg34Rw== 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=/chAYVP/UzgYTUPMNvsJhdAwiGQ3UEgnKAgzvjSXQiY=; b=YZxnOmyNc6pTVVRFeS7w0QieFnB6b8FyJi6xdwAIFcwyMt4NlgPYacLspKlGFk8l/s6TFDOUxMBCHC4zSMiEJqQxVld8gYD47efz3bZzDaCI6LkKLE66k9V5MY7P3/Bu0Xq5bV+E4r51+44PgiYbc4rBFvEJeHzj0X0GjV5gFSfpM7rYrMZyFXqCbZsX7ENLZyFXG/5/VWifF3nkjVruv+DgL6BuUq5iXiTGsbUV+/Kfn+bwBTk1tIVpNXWbpeFbuK87Lha0kdhb0RLwNHI//i+++8aA8NsrlCCxO9Ci0wFdVL9j6yxbadT7MS1GsmTC7LN8vAsm1AO+8m665r93DA== 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=/chAYVP/UzgYTUPMNvsJhdAwiGQ3UEgnKAgzvjSXQiY=; b=ewkYciEOebrOcGRIBTTpGa152P2WXx61df3YA0u+Ky3E+LylP8n7ika/QBUMQ6rdn5Ntkr0RSvgeczEbrPFGOTQ818+2x4/X0zu2QViVt9EgXC9MRUIHj93Zhwu4KHnQBNBZDtwSpkJ6VuyNsM75iEpUAIQ2vjzIgyqpsefhqIttzpI1Cg7DtqC3Hy8fXhGxNqUa0A0z0StB3ALSQq8oT9LmsFUOy31D4zMbC/UmL2G9DfvlgLG/nXyPp9D6MaBHExdEWF2nBP2oi1+HD9T+fq/N9AOxIEIeLoebrSdnPcFoec3eietwc231vaqSKY6lcRpX7vr7gWEslIYTIG3EWw== Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) by DU2P250MB0319.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:27c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.32; Sun, 18 Feb 2024 01:39:25 +0000 Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504]) by GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504%6]) with mapi id 15.20.7292.026; Sun, 18 Feb 2024 01:39:25 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Feb 2024 02:41:09 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [y09fByK4fzzjFI/5v4N18PHJDT8fG51f261eIhpGBu0=] X-ClientProxiedBy: FR0P281CA0102.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::18) To GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) X-Microsoft-Original-Message-ID: <20240218014115.2819369-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1SPRMB0063:EE_|DU2P250MB0319:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e654bd1-bde0-4a7c-0905-08dc30227005 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TgZ0/S/QwP1mLttvz6o6NePNY2HnXdMuKuAKmDQ26Jev+jkG7VhUYiBijssYClgTg0TlMctXFFJgR8fRVA6//BhXVi8G/5pW1QxFpOfojTK0qip1NVAZ+A/kn8XXcTHaJ82oxy/zvtIRCe8EcKwTswyhUe4URH0ZLmU2DmrAdhwo5vqgGTqzXKsy8sVcwkmwanVhh1GNZ3xOhWi2yvZq6VbT68aEgdRbF1Q03H1NwKrVU3lc54Ou2GTJujkzw1Pl0coVbrPmTBVD89bJIEk6di2Iju4appJ/jdy090WwlX0XACfTfx0vEWkM/lA1xI2XPtvpL96y+VycY4p44tnzhHVrAJURQnOw1WSh+OFy8qow/Ok2YcxJSqTG92X238Fd24pS9svweWWul8kOUzZvG5Xye5jji3nYSK6BTMPu2joOuCRMBuF/cLF0Pu93emrFMRknH2XquqSW5liMQh/Inp23XEKhQmdQikAyMQ8K0485ikP7Btw3sE33fT1DbqjgWkHWLMtogXcgv9BCl7cw+9OndUuRxfygHYa+CDhw0kelBDIcSo6EnLq6224nlxptUB6vrfci7XIP7n0G/PnWOL7nQHeaoKJXLdQQZcN16KCcSfYIqVxc8s68R7AMQ/C8 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-Anti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ewCakfRNiv2oFo5OsU9zbAN/ePp93Rwdq5CzI/u9lZ3uQgrfYxfSRFBk+6G5CMD6mf6zlmcT+fYk7WaPqvayuj37fnpNBvmrXBPaEjdWCsN3jdEOlwoGEsPHYhJthKXggOmNyvKZQUxTyFfUcAQXZRHDR96GVxCxE0AtX4YtdJyKoBS59WxBiAOtWOb104zlzKgqvrgVMuBCM4nGss0zS9LIo1G9+GY04PxLQbA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e654bd1-bde0-4a7c-0905-08dc30227005 X-MS-Exchange-CrossTenant-AuthSource: GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 01:39:24.7893 (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: DU2P250MB0319 Subject: [FFmpeg-devel] [PATCH 1/7] avcodec/assenc: Use size_t for length of string 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: w6o2xm+IL6HM Signed-off-by: Andreas Rheinhardt --- libavcodec/assenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/assenc.c b/libavcodec/assenc.c index e548b9fd3b..e734522729 100644 --- a/libavcodec/assenc.c +++ b/libavcodec/assenc.c @@ -45,7 +45,7 @@ static int ass_encode_frame(AVCodecContext *avctx, unsigned char *buf, int bufsize, const AVSubtitle *sub) { - int len; + size_t len; if (sub->num_rects != 1) { av_log(avctx, AV_LOG_ERROR, "Only one rect per AVSubtitle is supported in ASS.\n"); @@ -59,7 +59,7 @@ static int ass_encode_frame(AVCodecContext *avctx, len = av_strlcpy(buf, sub->rects[0]->ass, bufsize); - if (len > bufsize - 1) { + if (len >= bufsize) { av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n"); return AVERROR_BUFFER_TOO_SMALL; } From patchwork Sun Feb 18 01:43:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46327 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dda5:b0:19e:cdac:8cce with SMTP id kw37csp553278pzb; Sat, 17 Feb 2024 17:41:31 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXuGzmaciE6sbVNq6GvO3DueV6l+LwjFeJxpoEHdNgoHzFf84Vky1wkJKplUZtaT5chFB8DstsDFPPl/Ws6aJq/sOb90iRL/t1K+Q== X-Google-Smtp-Source: AGHT+IHL1CNwxazzfVR9v7yGaDtShbJeE4mweIETRKn2C3/kMRcdTrSfs46dKHJOC6liggQeLUM7 X-Received: by 2002:a2e:9c91:0:b0:2d2:3140:e6f7 with SMTP id x17-20020a2e9c91000000b002d23140e6f7mr911948lji.51.1708220490875; Sat, 17 Feb 2024 17:41:30 -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 i10-20020a05640242ca00b005645fd0e569si44604edc.183.2024.02.17.17.41.30; Sat, 17 Feb 2024 17:41:30 -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=KTJb6iU9; 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 23C3B68D306; Sun, 18 Feb 2024 03:41:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2097.outbound.protection.outlook.com [40.92.74.97]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E2D8D68D164 for ; Sun, 18 Feb 2024 03:41:20 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G05Hod1j7PN31qUeUnpe19sHhL1k8lfKgPDpzkFLKGltQ1uMEBnTK4HkeN0xaM4FS+JA65qYz7kCsuTwnu+vfuxjjZBfQf5Obg/WckZde+Vbl8Sh6bc0HMmn6jDY3RY2udW97gtwxxOdBXluAbRLTH41Nn0PwAn5s7uJuhNaAX2tBFBOdOgNoK+uZz3KcE7MIW94c3ib1UFOUHOt+Ssg9WtTXCB2bcHOVgtOeEm0MAT8Yx+8APv5JleUZBm/JhxxpIs8bl2B+S8i2SN9XkVKTOjABfRDboxfnOvXBSXz5S4I09T45Bnte2VV3sGe81ThNnIVK1aO1QTZacos4KjHqg== 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=kaATnmD+CUTxI8hqs/J1z71vYZYU3NTkJJUUGDoxMx4=; b=UMENAgCapp9QO+Im2VljGNIDRT+0VbcRplVc4q8kC9wKdJ4FNlE3ZcWftA5MCNDe35P+K1+9pT5uX+aIMhPJrEuv22BO4amVyaOw4tk2Y5Ppqx9kbuX2gTEtDyZOrLf15i+pF2AdAvjbveVDOJSpEizp4Ql4kBim5X0YSjVGum7dbi+wKs2acUpnbaa5gtp7dxmtIw9cuqEU0BMJhzGzJxTw4+d+fyay1uS1Jzxs8uYQo8K77ReXQmNLb3pw7RoBGV87A1RrhlS2q4D9nlzxVDxxGimSgwapPaualrOoo4TzJNj9TqcjpCJysxkhGk5QQa2OCCJeGKjmIANa13QpoQ== 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=kaATnmD+CUTxI8hqs/J1z71vYZYU3NTkJJUUGDoxMx4=; b=KTJb6iU9Ie35mcqGV0rv5tYSgNGe0pLxZsuYobSibelJ23Yik6Vp35wjmODLaPj6QvaavVu09w3c4vmc0AVxpaEUn+muvdnKBlXOqFF0CCLEx9SKNaOp/KpC609mjrx9/LEseme642DRUEwve3uKl9a6qoTeKoFymuQyzjAbuuUknOdaGZ4im3KPaJf5vJgxqz62sMl3xjoNq33q+oMlBbZqapnqtZgIfG0Ico3H2XaUHjJGrejGgUhGxms559s8Rf/922f0XR7e/yjz7QrovLOMAbaJoqRwtfIGoC/ruopqtLFjRTdjOeNv6r7LxeHZU57DCZbz9BzqK1BQRkcd/A== Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) by DU2P250MB0319.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:27c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.32; Sun, 18 Feb 2024 01:41:18 +0000 Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504]) by GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504%6]) with mapi id 15.20.7292.026; Sun, 18 Feb 2024 01:41:18 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Feb 2024 02:43:03 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [ah8L4uCb9Paxymxm6NWr80K4bZiZmZX0FvcwmiGMD20=] X-ClientProxiedBy: FR3P281CA0033.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::12) To GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) X-Microsoft-Original-Message-ID: <20240218014308.2819410-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1SPRMB0063:EE_|DU2P250MB0319:EE_ X-MS-Office365-Filtering-Correlation-Id: b02d74c1-2e9a-4236-fd67-08dc3022b3dc X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DPT5v0AfUBvM474QuVGgMMV7Ty3vdygEdSDOuVD9bUyl6kNM2m95WdELAulAZaAIMMXuizbISvDXDlL5D5Mmks1EKcL9wKYDBc40cQIlDbSslL6WK6KoAZvpFWlAKPu3uwRZo1q04Axabh2TaZhGnv7R60IM0S9BOtB2+bY1ydC4GEkz4zylWcga6Y03Pu8GLtDRhfN3yviAzimISj7pKJOFaAsNhAQc6kypyub32HOpJGA+eG5VitlQMjc9Vyfc52TM+MZexUlXPTTnM7yNqKVetql5n0d+DWmUsRfbS+hTVMY39uXW2nfJuMiSt0Pm8IR3RLgyuV5AWuq9FhXUG9NAcriAo3aC26JXSSAIN8KaKJeQwzDnR1UJbneoOQNmD3gfRKCf6nUBSBCfg8DhPujPUzFacP1cpiIKIJThI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ROLXY7IIQr5Uh27dLuTVqFJaJFF/isbMypMNKWNatz+4G1moGUw7MR8GBplWRP3Zya4KX+l/1OaECLw619+ZnyZedVBoPx5XdEYP2Eu/348jRIKYEV+Rtbx5cDM76zxckPYjfarnrTlJjiwWkAazACKFG8wB3s3xKtRis8sc+6TQBNwDqUcYLB8ZZf7fR6z0FA9k0GcTETOvZ0llL2JcIqIjD4iaku7xR0q9TIsZJpiIuzormQf80021TVq2nxctk5vc1dyHmm08xokevSVRnpumtSw9Rgf0gagXQkKYuGMyVzFwKRgFjVu8dYt6MTTAZTjc3N1bDPzLLhSeCJIQm7aFSV9HGqW+N1JYlVxkuZriDoQ6QQ/TB7v2qSZcpB+SiRWkB1m9YFkXLwMEne0u1HKbirpefqJEmHs6p3UpcXoIqcm2/WUlE66kc87HT0rg9TpsjvAGC4AAxRSnyKh6ckWwNd9iqE5g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b02d74c1-2e9a-4236-fd67-08dc3022b3dc X-MS-Exchange-CrossTenant-AuthSource: GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 01:41:18.5707 (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: DU2P250MB0319 Subject: [FFmpeg-devel] [PATCH 2/7] avcodec/srtenc: Don't copy data around unnecessarily 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: R2BwEWWHKA3K Using av_bprint_init_for_buffer() avoids copying data into the internal AVBPrint buffer (or worse: to allocate a temporary buffer in case the internal buffer does not suffice). It also ensures that the data is always 0-terminated, whereas the current code never does this and returns success in case the length of the string to write and the size of the buffer coincide. Signed-off-by: Andreas Rheinhardt --- libavcodec/srtenc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c index 7e36a2200c..9b6f61ebd1 100644 --- a/libavcodec/srtenc.c +++ b/libavcodec/srtenc.c @@ -23,7 +23,6 @@ #include #include "avcodec.h" -#include "libavutil/avstring.h" #include "libavutil/bprint.h" #include "ass_split.h" #include "ass.h" @@ -138,7 +137,6 @@ static av_cold int srt_encode_init(AVCodecContext *avctx) SRTContext *s = avctx->priv_data; s->avctx = avctx; s->ass_ctx = ff_ass_split(avctx->subtitle_header); - av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED); return s->ass_ctx ? 0 : AVERROR_INVALIDDATA; } @@ -237,7 +235,7 @@ static int encode_frame(AVCodecContext *avctx, ASSDialog *dialog; int i; - av_bprint_clear(&s->buffer); + av_bprint_init_for_buffer(&s->buffer, buf, bufsize); for (i=0; inum_rects; i++) { const char *ass = sub->rects[i]->ass; @@ -257,16 +255,13 @@ static int encode_frame(AVCodecContext *avctx, ff_ass_free_dialog(&dialog); } - if (!av_bprint_is_complete(&s->buffer)) - return AVERROR(ENOMEM); if (!s->buffer.len) return 0; - if (s->buffer.len > bufsize) { + if (!av_bprint_is_complete(&s->buffer)) { av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n"); return AVERROR_BUFFER_TOO_SMALL; } - memcpy(buf, s->buffer.str, s->buffer.len); return s->buffer.len; } @@ -287,7 +282,6 @@ static int srt_encode_close(AVCodecContext *avctx) { SRTContext *s = avctx->priv_data; ff_ass_split_free(s->ass_ctx); - av_bprint_finalize(&s->buffer, NULL); return 0; } From patchwork Sun Feb 18 01:43:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46328 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dda5:b0:19e:cdac:8cce with SMTP id kw37csp553307pzb; Sat, 17 Feb 2024 17:41:38 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVz0fswtHyBmMonBn4Q+GIrCLjBGNLmYiYIkBA4tmhKD+H8nPeXPP8BxqETKA1+53iKD2gpLuX5cCHRinqfuM0iK+iuO86GAuVc8A== X-Google-Smtp-Source: AGHT+IEGSJLAuYk6mc+P0CN9wUPjh6dwq2KSNvYEs17zjAcWsDaisiZ/B+GKJmB2c7WAbVFdOIQE X-Received: by 2002:a50:fa8c:0:b0:564:3f11:14d3 with SMTP id w12-20020a50fa8c000000b005643f1114d3mr1076532edr.8.1708220498047; Sat, 17 Feb 2024 17:41:38 -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 bm9-20020a0564020b0900b005621a33cd1asi1230478edb.324.2024.02.17.17.41.37; Sat, 17 Feb 2024 17:41:38 -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=SNxeSLZk; 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 3CD8868D300; Sun, 18 Feb 2024 03:41:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2097.outbound.protection.outlook.com [40.92.74.97]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 86EC468D300 for ; Sun, 18 Feb 2024 03:41:26 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Alok5iUE6NQi71TPYgw5tHKLoO9Se1UiT+R90eLAdBFt9E/3v1g+alIvotTIVq9CLn+AhJ+wGMhKapGo1Q6XaHroRG0tkpZ3Tprvv2luISnHOPpf7kndr2Y3aOne1N3RQhANkrfv5277oGZSs2IZt5ixcpOl88JiIxckTEYOvsGpu9Oj9nt7Tc/1z2DRw0nBC/IEE7IQ7IfxakNFh7iO/ZsFbinJZoiZWlNpQROQOq1SFUJrZEImFQEsKZT5mtO4eJwmQruZYU2XxXJpUHIr504hJPaXp7p61q+PVTncKVNo5nh5SH8WIMxOBLviL+vTHv97aF/jgIqU83rA8hCIHQ== 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=/4icTwmVrSayP2Hjn+er6LqCUNZyuj979X+y6hTZqAo=; b=MbSHIzEjU+YLxv9v64HTAn6H1NS00FJgNa4ib4QeBIl+Ru681pPoIlpS8Sckwwg7KFUP6Sk+aBuQaayrHTZbRzEHGd6yL6BjMf66AjCnftqHUGtKEUCkbadiDDJe6q9kd8v0s3/lloWher7TJQZzxLPgyqY5iGr3lksQLFruRapv04J791qNYejkVZUUX80Ls4MbjnOuqsspjsHv6iLDJ8RCAyqgHbZOhSiGYMtyTBQaOLgZlOIp0p2b6ZrIr6l4dnYdmy5yMgbFhgmZ5yJpWU3EykO98/iG9mq+YDiv8pGlpZ/0JB+k/0zfZerTct5Xtvi+JAq/23ShWahVATyryg== 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=/4icTwmVrSayP2Hjn+er6LqCUNZyuj979X+y6hTZqAo=; b=SNxeSLZkjlGuBner5/CCTKpp8tOt3tMuxMQ6aSvEYJAGSf/lHU2as37u9E4T4/Y2OAf9YRzsr1Tl0vRC0j7cmMj+7lxT/doHavJbZKVf8w2fB9wNZJODMlN1w2r9Eu2QVC4/BCmt6577ZzpgdojGGw1kmKRvFiJIR4Pc8T3JN/NPtbph7m2l30mrB6DaUIKjERmKWamwNWzh5yT8WPt8S3wzH2GUAvQO6seFMhX+pHyxikIqGOKWNuyBB+Tc3Pic0RObm6gDMy+BxMhbJzIbBc84zShQgXN8m06aqxCUcfv2PIDiA1oBrDnKsGRWMPUaiFPvvuUyNDTV0kFoBSdDuQ== Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) by DU2P250MB0319.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:27c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.32; Sun, 18 Feb 2024 01:41:20 +0000 Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504]) by GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504%6]) with mapi id 15.20.7292.026; Sun, 18 Feb 2024 01:41:20 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Feb 2024 02:43:04 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [u05OG10x3heemy1o+jLH2uEuY01g/FUGTBctS/hKk6E=] X-ClientProxiedBy: FR3P281CA0033.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::12) To GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) X-Microsoft-Original-Message-ID: <20240218014308.2819410-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1SPRMB0063:EE_|DU2P250MB0319:EE_ X-MS-Office365-Filtering-Correlation-Id: 5cb46e82-551e-4e3e-dab2-08dc3022b4b7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gSAs8UDEUwgVkvM08Xg4phFZqr4IUuvYqbIMh+WJLsNG8o9WwdH/BR5T4cqFPZG9TsAMtGJOnr6TpKDGLhEpDGEKKdxXyRsBLRfiRcSjImv4oTLgLPnaAy06ugzVJh55h/KKdIv6RfWm/LBEH5CizpE8LVm5ZMZDp27fRMjQBZAD/+Ez+hDhluITUlqU4EaXNdD9QvPICrbSgZp0QX/O3Cq6bhMq7h7HuZsNVWQJsBvE3k68Hsx1WyqnuA4CIXhX/7l92QRaVvTA42oSyryYqukygngFf9kXfMVqvify5B1QZRvz3PHhV62cxdIva8l4VnvK16XyEyOzpXhalg2ofCfGqzBJBFmWz7yvb/1A+D2ZEwb8v51T+E9CAsm/uoltgeoAVeLBMuTx63ILAOzW/h+5Apct1zKyE7hE3GMi82/t1lGpotlZLZKlAwQiUtIMqit0F6QWPQNxn1MPZ8y/Lsg/q2GWePfOlBtWDiDz9MMuFapy644oK7RHDwPkUOqyi95GHp7LjQ0CwNT+ZdTZyk6yAdy/A8oXMKOG06PvkaijiVfygvabtXcPbE4MIrTBvGlxtAUOlqWdovD/z6/XRl8MqFFNKYbCcB7FYvq02tiscgXuZAWeqE5ojqd4I8WH X-MS-Exchange-AntiS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pH7j9JeLEeBxb4/CcvNMEfJhxlXhDB3N3R3wBa+/IppPZvHljeC4eefhimG2dXKNTnwcfFXBVZqgw98WSZPfAK5+8p47ZXTD/TTa41lViw4Cwvn/CPh131jqNxtskeO0TfBvQfUJvXvEZD5M7Mzj09KAADQwBR35ckmRds0Uh/pee1ftCjXB0fK7Xf4dEAaujpaYHyNQ7E2U3ol9jvFynk/WBxxRADMQ82tF7Wg08lF3M9+wPRFDg5UQec2aUgfuWR7mGD/W4sCO27s3woHqg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5cb46e82-551e-4e3e-dab2-08dc3022b4b7 X-MS-Exchange-CrossTenant-AuthSource: GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 01:41:19.9993 (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: DU2P250MB0319 Subject: [FFmpeg-devel] [PATCH 3/7] avcodec/webvttenc: Don't copy data around unnecessarily 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: p5S+NgNwlXlY Using av_bprint_init_for_buffer() avoids copying data into the internal AVBPrint buffer (or worse: to allocate a temporary buffer in case the internal buffer does not suffice). It also ensures that the data is always 0-terminated. Signed-off-by: Andreas Rheinhardt --- libavcodec/webvttenc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libavcodec/webvttenc.c b/libavcodec/webvttenc.c index 4369aacb74..9922f33485 100644 --- a/libavcodec/webvttenc.c +++ b/libavcodec/webvttenc.c @@ -22,7 +22,6 @@ #include #include "avcodec.h" -#include "libavutil/avstring.h" #include "libavutil/bprint.h" #include "ass_split.h" #include "ass.h" @@ -162,7 +161,7 @@ static int webvtt_encode_frame(AVCodecContext *avctx, ASSDialog *dialog; int i; - av_bprint_clear(&s->buffer); + av_bprint_init_for_buffer(&s->buffer, buf, bufsize); for (i=0; inum_rects; i++) { const char *ass = sub->rects[i]->ass; @@ -180,16 +179,13 @@ static int webvtt_encode_frame(AVCodecContext *avctx, ff_ass_free_dialog(&dialog); } - if (!av_bprint_is_complete(&s->buffer)) - return AVERROR(ENOMEM); if (!s->buffer.len) return 0; - if (s->buffer.len > bufsize) { + if (!av_bprint_is_complete(&s->buffer)) { av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n"); return AVERROR_BUFFER_TOO_SMALL; } - memcpy(buf, s->buffer.str, s->buffer.len); return s->buffer.len; } @@ -198,7 +194,6 @@ static int webvtt_encode_close(AVCodecContext *avctx) { WebVTTContext *s = avctx->priv_data; ff_ass_split_free(s->ass_ctx); - av_bprint_finalize(&s->buffer, NULL); return 0; } @@ -207,7 +202,6 @@ static av_cold int webvtt_encode_init(AVCodecContext *avctx) WebVTTContext *s = avctx->priv_data; s->avctx = avctx; s->ass_ctx = ff_ass_split(avctx->subtitle_header); - av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED); return s->ass_ctx ? 0 : AVERROR_INVALIDDATA; } From patchwork Sun Feb 18 01:43:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46329 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dda5:b0:19e:cdac:8cce with SMTP id kw37csp553342pzb; Sat, 17 Feb 2024 17:41:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUcTfMnj2/rzrz4OCoFNfRQedLYiPjL34oYmM+dwE2fFv6kRwjIGK1q9a9QWV1SGRP+Qld7kV8Rj1oPN5ZtfqLty8D9kS3qZrkTqA== X-Google-Smtp-Source: AGHT+IF/gWn8V9sLWy9DIEcIOf7HEtJ+zanVKq99RlGaL0TqxskdGyo/nX2SG4R8M1iU9kOi68Gq X-Received: by 2002:a05:6512:3d0f:b0:512:8a75:53f9 with SMTP id d15-20020a0565123d0f00b005128a7553f9mr6870272lfv.57.1708220505933; Sat, 17 Feb 2024 17:41:45 -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 cq19-20020a056402221300b005620158b65bsi1229310edb.292.2024.02.17.17.41.45; Sat, 17 Feb 2024 17:41:45 -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=HWwTUXrp; 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 4D63468D320; Sun, 18 Feb 2024 03:41:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2097.outbound.protection.outlook.com [40.92.74.97]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A923968D312 for ; Sun, 18 Feb 2024 03:41:31 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ULYsStM6hfOdyw/uqNmuQIsIBV7yycGI5zv50jAh+/t/CwdZl7ZZRef/qgWm+zWDlbHrhAtSc3nU9azQnagWfiGLNlcapZyWSg40/RdkG3El+kOKGtcG0ZZz42ka2pIUtLtI4szp8Oa9DLcA9M4W7TxYVlpENKN9pl62eqGDrVaarz44dINo64Fl2SkYUqT04feOJG4d0W/vxpNfKsMb7lNaiNDDCHo1gkN0vQ+HZZ1JYjGc031Sw55/UIMblUSz5Y6bTxhbcAOy5LV0otpYdpzKYnTYTXKJSX3cKdLWtLyZZTer/rM8HsIab4VdB2ERdMKVUqbTnfZkJBJglW6a8w== 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=3Kz67IpH22CRtHdwFwqZswk7hBDBTfZAVrk+3CGoDWg=; b=SU4eOkH1Hw5x21/h2Xxwrcvbc1fr/A0lpY5qURufIGRDuqYtDw6QpRGCIajl3lm2TwF94dT8OK8snvXNYprNLCtftbPNIzt+W3VMIEVB/uHw0kpwKa6BiW3YKaTx+8XxhWmAB5a9X1MAYw6hPt+9jPEhp/Guz1U7nWUL/GB+orrGwtLuzCsjLYGZ8ZKD91h8tp6Cit9yuq6fkNPnUAec/lMUxnaN26MS+wdCoF3mxpwlvXLJGLEHJ+CGn5d2W3a8XXOnqvUAGGWbr8uXqwsccH/wzLhLECIytjB6HvEifkJlDay+7eYnKHU3/GI5HznJQkIhTNqXMPf2HFODsj/r5Q== 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=3Kz67IpH22CRtHdwFwqZswk7hBDBTfZAVrk+3CGoDWg=; b=HWwTUXrpiofoeBJxAIqt3AbRkMNphzj441Ov4DVpBT0MZMJoh1a509jgDV/8FSaDj2cvhoZjySSfBMFHnazqvhwHc2shhVaarHbP7LPGzwE4XN9Za0rcuyKE8Aa7bdnAP9kGrp48lqA58rQH2FYu+eEUuInmsnvf3w87IbjCl7H9f1Gn2X49+MdTtMhFnVeUetr3YngUGCfynOnT5nKM1RDF5Dblj/c4NeTXgoFja4F1iHQdXqDyHZXDDrnuWTRUREgOQYLq4NmTCB+XnUSSooBe4dEy6lKT3ZY71TqkLmheDEeay0cMNsBQR57LjEk2wdC9lJwv6LzE4t5lERjKUA== Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) by DU2P250MB0319.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:27c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.32; Sun, 18 Feb 2024 01:41:23 +0000 Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504]) by GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504%6]) with mapi id 15.20.7292.026; Sun, 18 Feb 2024 01:41:23 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Feb 2024 02:43:05 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [EJqnldXegLbQ13/9I5YOss9Tdur8xXdbhEjRa0bZlNo=] X-ClientProxiedBy: FR3P281CA0033.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::12) To GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) X-Microsoft-Original-Message-ID: <20240218014308.2819410-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1SPRMB0063:EE_|DU2P250MB0319:EE_ X-MS-Office365-Filtering-Correlation-Id: ac4f7c6f-46a5-4d8d-b5bd-08dc3022b6d9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X4UjNhrheARTFPlVWTpbO+1EwdXLJvb2jwRzn10mvRf1J3dLT5Ie9nguadZDM5Zn1n/pL2fEXNJ9e2Wca+5XVxJXI2v7riPQBy7w2yCFJE4mncn2d1jV8bnj6OZ+LsJDfwknfhI7tWriAbiRUKbYgP1W48BXukgVdIQH64ROij87LWEaeze45BFJrnu0A1B+PooCaEnF4+haQf5iTUOHy8THL1mxhNOKvzpxN3y7TdZeUcocpbLEpckej+0sB/NrQyYNGtNpixHUeLUIZ1oqMbe5UdGD/r7dx2stdPJds0ZWNYGmCRyohLg4+8dPXDP4xIUiTj3RBZFztPA7RDdpdWGy9pRwIs8zIZqI3kKwdC6HEyIBGT2EwokdLK3ZG2vcuVJdRAjdKoK92TAjv5wQypiTKcySH4tHuOQo6Jmr26oYEZmOgE5XAYqflfIFhKBehiJ7D9D22lYjsayTbXvDSWuDiYUPqEzi5y7lubIV8sEf/dmYPbUMgqfrAa+M5Mwd3sgQMVfGd4lpVXSIP3uf1yzJ2OpOWRMVys3yfAe7o5vmWwZDNXci59X7vL/YFvODwOWI2JnB0LrWInE2hGLjtly+lRQjbHEuM5pFqYpfqwQ= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jMdh7DZO+vTLrhwOdeB+RfIkkt5s1jn+8/6lPsFjfDqAr3JGN3mkdv2veZHZZTq7JAuMjosJvFsltCSuMJVFWiDOF8TPdsDxJ5so8AwP/TlFmVT/DdbhgVoqOTEMwKMuZd7hqMIwwpoVWRvE/Qi/L/O6cQ0ZrwdYK/ChKQfZE+ee+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hQWbc4wwYG9smlXdg7OTeCcCCGQqvHJXWID632K87ULeQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac4f7c6f-46a5-4d8d-b5bd-08dc3022b6d9 X-MS-Exchange-CrossTenant-AuthSource: GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 01:41:23.6101 (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: DU2P250MB0319 Subject: [FFmpeg-devel] [PATCH 4/7] avcodec/ttmlenc: Don't copy data around unnecessarily 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: PRnq58QVA7K6 Using av_bprint_init_for_buffer() avoids copying data into the internal AVBPrint buffer (or worse: to allocate a temporary buffer in case the internal buffer does not suffice). Signed-off-by: Andreas Rheinhardt --- libavcodec/ttmlenc.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/libavcodec/ttmlenc.c b/libavcodec/ttmlenc.c index 6a2ab23cab..f48274d2ea 100644 --- a/libavcodec/ttmlenc.c +++ b/libavcodec/ttmlenc.c @@ -29,11 +29,9 @@ #include "avcodec.h" #include "codec_internal.h" -#include "libavutil/avstring.h" #include "libavutil/bprint.h" #include "libavutil/internal.h" #include "ass_split.h" -#include "ass.h" #include "ttmlenc.h" typedef struct { @@ -84,7 +82,7 @@ static int ttml_encode_frame(AVCodecContext *avctx, uint8_t *buf, ASSDialog *dialog; int i; - av_bprint_clear(&s->buffer); + av_bprint_init_for_buffer(&s->buffer, buf, bufsize); for (i=0; inum_rects; i++) { const char *ass = sub->rects[i]->ass; @@ -129,14 +127,9 @@ static int ttml_encode_frame(AVCodecContext *avctx, uint8_t *buf, ff_ass_free_dialog(&dialog); } - if (!av_bprint_is_complete(&s->buffer)) - return AVERROR(ENOMEM); if (!s->buffer.len) return 0; - - // force null-termination, so in case our destination buffer is - // too small, the return value is larger than bufsize minus null. - if (av_strlcpy(buf, s->buffer.str, bufsize) > bufsize - 1) { + if (!av_bprint_is_complete(&s->buffer)) { av_log(avctx, AV_LOG_ERROR, "Buffer too small for TTML event.\n"); return AVERROR_BUFFER_TOO_SMALL; } @@ -150,8 +143,6 @@ static av_cold int ttml_encode_close(AVCodecContext *avctx) ff_ass_split_free(s->ass_ctx); - av_bprint_finalize(&s->buffer, NULL); - return 0; } @@ -306,6 +297,7 @@ static int ttml_write_header_content(AVCodecContext *avctx) const size_t base_extradata_size = TTMLENC_EXTRADATA_SIGNATURE_SIZE + 1 + AV_INPUT_BUFFER_PADDING_SIZE; size_t additional_extradata_size = 0; + int ret; if (script_info.play_res_x <= 0 || script_info.play_res_y <= 0) { av_log(avctx, AV_LOG_ERROR, @@ -314,6 +306,8 @@ static int ttml_write_header_content(AVCodecContext *avctx) return AVERROR_INVALIDDATA; } + av_bprint_init(&s->buffer, 0, INT_MAX - base_extradata_size); + // write the first string in extradata, attributes in the base "tt" element. av_bprintf(&s->buffer, TTML_DEFAULT_NAMESPACING); // the cell resolution is in character cells, so not exactly 1:1 against @@ -329,10 +323,10 @@ static int ttml_write_header_content(AVCodecContext *avctx) av_bprintf(&s->buffer, " \n"); for (int i = 0; i < ass->styles_count; i++) { - int ret = ttml_write_region(avctx, &s->buffer, script_info, - ass->styles[i]); + ret = ttml_write_region(avctx, &s->buffer, script_info, + ass->styles[i]); if (ret < 0) - return ret; + goto fail; } av_bprintf(&s->buffer, " \n"); @@ -340,14 +334,16 @@ static int ttml_write_header_content(AVCodecContext *avctx) av_bprint_chars(&s->buffer, '\0', 1); if (!av_bprint_is_complete(&s->buffer)) { - return AVERROR(ENOMEM); + ret = AVERROR(ENOMEM); + goto fail; } additional_extradata_size = s->buffer.len; if (!(avctx->extradata = av_mallocz(base_extradata_size + additional_extradata_size))) { - return AVERROR(ENOMEM); + ret = AVERROR(ENOMEM); + goto fail; } avctx->extradata_size = @@ -359,9 +355,11 @@ static int ttml_write_header_content(AVCodecContext *avctx) memcpy(avctx->extradata + TTMLENC_EXTRADATA_SIGNATURE_SIZE, s->buffer.str, additional_extradata_size); - av_bprint_clear(&s->buffer); + ret = 0; +fail: + av_bprint_finalize(&s->buffer, NULL); - return 0; + return ret; } static av_cold int ttml_encode_init(AVCodecContext *avctx) @@ -370,8 +368,6 @@ static av_cold int ttml_encode_init(AVCodecContext *avctx) int ret = AVERROR_BUG; s->avctx = avctx; - av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED); - if (!(s->ass_ctx = ff_ass_split(avctx->subtitle_header))) { return AVERROR_INVALIDDATA; } From patchwork Sun Feb 18 01:43:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46330 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dda5:b0:19e:cdac:8cce with SMTP id kw37csp553364pzb; Sat, 17 Feb 2024 17:41:53 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW/pfy7LYD7Q8nH/QAZx+6zLiDxFB6a64l5SpASt/NNFtT54FhdgmSV/W4HMVqQo516jLKfVjK7uFK10AJej8WPtinmoki+fCdqHg== X-Google-Smtp-Source: AGHT+IGJSP0BPpXtO5yha1A86RMwkc5C3nOo28883pUeJbPnPXeFKIzVIEikEft2kgJV3xhOf4HM X-Received: by 2002:a17:906:319a:b0:a3c:fd0a:7d7 with SMTP id 26-20020a170906319a00b00a3cfd0a07d7mr4024250ejy.3.1708220513464; Sat, 17 Feb 2024 17:41:53 -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 jo9-20020a170906f6c900b00a3dd9319294si500626ejb.290.2024.02.17.17.41.53; Sat, 17 Feb 2024 17:41:53 -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=DxAJDTTZ; 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 4597C68D322; Sun, 18 Feb 2024 03:41:39 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2097.outbound.protection.outlook.com [40.92.74.97]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D6A2968D314 for ; Sun, 18 Feb 2024 03:41:36 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dfF3DqaYAvBStuS/vnDYPjPWtuUEcytiNa/Jr7v2T7cTLkM13nrTPWXxDVSJWXCVp2IQloj6E1JDN2/glvTH0DiYo8jYi/V3d8MyWc2aXFCjxNNP/AuksBlTyn7dNbXv3qn+CFigRVLbJ8axBY195DuksHALMd74c2UwH4XDywNnGeNT7ATP9WOwR+rzOe9mHmSze6Cup0lqY4YQ2HKgOOaWpjWYc4rAV5OHVORV4RvBlFBKyqtj67rMj+XQsheQ/ygk27N/X4SToa1diLUGwh9bQeEerIxtTOa9isDQIMpIrCGJFNbJ/bQynvTqvyUv0DcH4jJ56OrRH641Wj+vJw== 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=5I+cJWDnMuvp4jb3/EBx4jal83o68sJYAH4DU9BVg6k=; b=R31x0AwFVbLCrFxd+hkBwjsDLEJ1ml9bKJh4B4nLyfCehcJl5KlZvnw1NJIgY2Mt9Jf0SDjqgGnFOYKUhSakl3na/GYxFsX33tRLQrarB7OqESlpRr7ut6cZIfhJczyM1MfFz5HMSZvHnb4ZaLNdRKFe3Ki29R+6cd7Axb0azGsZHVRx6D/RspHfIvEmToV+xg49h0UI22RJyLLrByaFVijMUdwAKFO037OdGUq9N46YEOhIXs4pGzNvkjubtGE+HdpJfWCWAm+Uhs/kouQX7sBt5FHJpeI9rlZMIeDn/62qJ756udUAjWUmIflwBc8eVfrMYgxLCsWsdW6zmPeRhQ== 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=5I+cJWDnMuvp4jb3/EBx4jal83o68sJYAH4DU9BVg6k=; b=DxAJDTTZDGRiq31n/7h85VjPEFilrhE8hSKdd51xSWsvaYP1fsbZy/wOJ7on/fcttODdWl8OEZaxekNb8N/pHeWaOyc6VGw+XX3jd8jffbR0lQ1IxQMFgbaJvhw/Cv2QcfJB34ZR2BNUs0Gpb0h+IekmC38ub4jbXGBnBQDuuE7tjTBFLh/Je+erzvVFGa2DttJZN3zD0rfn367nomiQLaILnQzzZzBlRe+DnzB1pE6SsJTud97Oj0E3nhhQrRbrphoWxGDwTXCCbVDCGr4krLd026Mh85K7Wbc156ARfK7D3NEdEF0xR/Gw0FrKD826ofjg92k+7Ic9ZbP1BU7hBg== Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) by DU2P250MB0319.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:27c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.32; Sun, 18 Feb 2024 01:41:26 +0000 Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504]) by GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504%6]) with mapi id 15.20.7292.026; Sun, 18 Feb 2024 01:41:25 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Feb 2024 02:43:06 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [+C+Lx/86jJ5rx1tjqQdya26mS7JCdbwpoQlEymkvFFc=] X-ClientProxiedBy: FR3P281CA0033.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::12) To GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) X-Microsoft-Original-Message-ID: <20240218014308.2819410-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1SPRMB0063:EE_|DU2P250MB0319:EE_ X-MS-Office365-Filtering-Correlation-Id: 86dad592-bbc2-48d2-62fd-08dc3022b806 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bHzBLMDbwayTXyiXZDLV4bbSd9HKKXd562plkD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5DYHqJ27xUKcZTdNVNfFSlpC9RD9dTzexpM+ZLiZ2+zGdvg+z77+t16f38jElQb5K4R9JpMx+0KpjfNPE++o6ILcMnaEEqcEu90ukwYmRyx97cX5gK9c64g6kOUMxk9GKANaVUT2jshvO3LObRIIFvewmfnOEnmy5YhZT6ngZGnG4q2FY0NsDFl6A6v+7xYQ5bo7jxv3P6aUAND6+HD27xnamiGncL+IBT1WYOmbv85lRn2dt2aelAcr0oXruE7qHWF0NEjq2RWl/atHxb0yjpYxOlRUo5fcaKih3ES5IVZvYoU8uXVUtjX0vdizfcY5IuxuyaVkqxCwmDTPizYX+69WhSrh2td1RPs56erpQTE58W2Z+yveTF6DTyl1n5HXtHQlmk+IQ6Fn7f9zERbo1ONFa+Vdn9iXeB1VfdO8DUrdMSFsoXrXPvQyZqDTePjSTEN7NP26T07Oahz9mC5ky9zdpBrUquq69jCWjGSgqsGou0TBPH9E4vCyipJgq2yHZclhcOT4lVis4KUmL7MVpZ7Jmvs6aQwZqNJLV0km5cbPUwWrht0Cgbj0yLPB75Xr0pctYQf81wTAzRIoZPJDwLQ4Br/yX+LfHPvW7uTsnCb5NDUQLqkOn9yeKSVkveCIFh4uMNYmBdJZrd14qQfyenrV3Swes7OV8aI+8w0QNuNfn6QN+YDCt+AHUO09ZuT0rHTebvvw4Olma9MfSinQv0OAFr311ttTJ1YcMQ1H74nLNSTGsQWKAzTLLJZK1r6+evXZzswQoz/xKllWg7/qne9oKMyNzjGiy3GVfHutyT9LRvwlvJ+Y5EO+e4xyOqoHCYkbqdcLETI5+pmYBfr8Q3szLc1tXB1DRTEcT/hTApTBjG+3T7i1Ce6mlN6YdcqeA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86dad592-bbc2-48d2-62fd-08dc3022b806 X-MS-Exchange-CrossTenant-AuthSource: GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 01:41:25.6053 (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: DU2P250MB0319 Subject: [FFmpeg-devel] [PATCH 5/7] avcodec/ttmlenc: Remove always-true check 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: f3++OIgZG3Rk Signed-off-by: Andreas Rheinhardt --- libavcodec/ttmlenc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/ttmlenc.c b/libavcodec/ttmlenc.c index f48274d2ea..779cb75199 100644 --- a/libavcodec/ttmlenc.c +++ b/libavcodec/ttmlenc.c @@ -351,9 +351,8 @@ static int ttml_write_header_content(AVCodecContext *avctx) memcpy(avctx->extradata, TTMLENC_EXTRADATA_SIGNATURE, TTMLENC_EXTRADATA_SIGNATURE_SIZE); - if (additional_extradata_size) - memcpy(avctx->extradata + TTMLENC_EXTRADATA_SIGNATURE_SIZE, - s->buffer.str, additional_extradata_size); + memcpy(avctx->extradata + TTMLENC_EXTRADATA_SIGNATURE_SIZE, + s->buffer.str, additional_extradata_size); ret = 0; fail: From patchwork Sun Feb 18 01:43:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46331 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dda5:b0:19e:cdac:8cce with SMTP id kw37csp553394pzb; Sat, 17 Feb 2024 17:42:01 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXVY2f6nkpQGQaSh5qDOIccTEMreX8wyp7Vkb3gSSyhZ1bl3XDcEpnhG0hmqTe1H5PbSPlMHzTbDCtGRt8stmErHTunEDUQBCtqew== X-Google-Smtp-Source: AGHT+IGdr7Gzhinmm03aMbZNCGfZcVSVOlYV3LIevyFAMU4qUfWk3/LYabAedASCA+OnL01CyO7B X-Received: by 2002:aa7:cccd:0:b0:564:4e61:76cf with SMTP id y13-20020aa7cccd000000b005644e6176cfmr436667edt.10.1708220521189; Sat, 17 Feb 2024 17:42:01 -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 ch25-20020a0564021bd900b0056410009311si1303438edb.112.2024.02.17.17.42.00; Sat, 17 Feb 2024 17:42:01 -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=ihD+JFaH; 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 1A85C68D325; Sun, 18 Feb 2024 03:41:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2097.outbound.protection.outlook.com [40.92.74.97]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1612A68D314 for ; Sun, 18 Feb 2024 03:41:37 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UDE7owit0JzpzddyKWz22L7mrNwwQkUXJ7n6PoY4Xuh2DZ0cNj4LGefKfVTAAo3FJDwDdyEYkbQ79qM0nICTFjKYZAar2GvpqicmrT+hY8VYspsuluu+BwMKzmtg+t6FQ7P/5oI7INWhjnceSRCaavwHgteUKorfuYx41mZkVFbXuCIEfBl7kmRVYSzerROOHNnG6uZWi6EhZ1wMY/zoAbcOOraAzLTy9lLqFEYqVyNzT5KvijBNUGNWAFKLGuuJ9AzMJGX+NUu2Z6NQ0TX1+9IuHRVG50H6BkFLc2KrqFbTEdtvLRZtZZzsj3ojEElc6Y55hliMbVSd2Yclt7dVEg== 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=5Gqff2zTPxd5/PvHSevZBMGa8A/c2VgYEoZkpIGlDMk=; b=F+3DCWRAeOvL1xX1RlOi+7GLYlT4zKinYsKotMEJXgc9vmapHOJTQXihCjoLgs5Ecbu6+D5RuUMFE3p4Ip2Q2sN2NJbL4J5bNSaz5WcwpGYytqxcMtWQmGh4ebzBPk9t9AOxHXQqb2O0JTRUZy9jDgVE60mm4vSZ8UuQBkyuqMX30lW4nanT65WBjfz0G71uWEcgvXHE/5jGwr3fOtv2sUHiNLPOsR5vSPnZAGfT2BjfIzC4fkrAONmbsEVUJZ5pJAKl2wJVE15EuC1DmFctfwY1LhkYUeqQZ9IkjTydZB10tpogShzm1mVaKn81j3Qx8PVonUq/RSvpYu1MyD39PQ== 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=5Gqff2zTPxd5/PvHSevZBMGa8A/c2VgYEoZkpIGlDMk=; b=ihD+JFaH2Fh45pWJ/3SheZ7qMPx3RL+umsKrroQbjWNZnxmKzYwabHigSb8kOMONrt4i2FVL0LzGF2B7Agc6IGSrzpeLOtW7eS1DiE+Te/lcGGeYt+nFCjdeXr+VRltddR/1hjgefaPAgB/KKdK8ow7qlof5S4+x4gOw2A34c1f1yUfOqMaYgF10QTuEx9r6O49euUpCmigUGW4cBohGDB+wRZtae5J33RCtMCLHeb1VOqJyQU0r0WlNU8v9OtNgJaeYnQbIbXqwZOrbLzzW8+Po6emGlAmiFxmLUaJWbhnwGAf8RA9n46wsS0K/7wpexnowgasy1CAWPjCqs4u13A== Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) by DU2P250MB0319.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:27c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.32; Sun, 18 Feb 2024 01:41:26 +0000 Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504]) by GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504%6]) with mapi id 15.20.7292.026; Sun, 18 Feb 2024 01:41:26 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Feb 2024 02:43:07 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [yTFaMgtfGQ0X3undf0a6PB3jXORBvG6xr0c9ycDCi3I=] X-ClientProxiedBy: FR3P281CA0033.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::12) To GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) X-Microsoft-Original-Message-ID: <20240218014308.2819410-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1SPRMB0063:EE_|DU2P250MB0319:EE_ X-MS-Office365-Filtering-Correlation-Id: 03c25304-86b6-4ac6-6204-08dc3022b8c5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PA+wgZLY5ftbt5SAmmVlbAmiAjC4PFbCbsV7AmRh+8g/b8zQhBoFdgbCQICiIqVFDWoBeFMJimk0v1YhJ1nnqyw+0y6Ts8kdDLa6/Mm2vMifCjDxpiDHZn9RQdS14b5RM2IMmA/bzwIIp5XIIYTnTgWH9CI8ti1bhobLB7I/9v/hu5lnuQzMEeOxeA4h4uX8lkYbGVn8tVvhAsK2rr0TZ7/yfXOZsWFXgLETzN4DEwQMJ8BOg8EJW0pLHpla+p2sLBWiw8CeT5ofYg0SS9UMJRp3VauFv4DYgsgPooYu5AEGbuPlh+cjgJdYlQq9mRofjh42NODeRehaDa/B0N/pxBDhM+SxzMQiPonLB6bfFbT0MmDQKG8O6ct3o8Q2hZunLymtVniJiTkTgKcSS/b8vho1wQ1TceOgkGx4fO3TJ5JJuJD3OZRB1TE1lt+5M7NKm5dxhsWESvbFgM5s/agKP1irP3AgFnN2oMj2kPeh8/wGND7aYRkU99sd5kVtE4Lc2tWUvBrkjCr+h4nFZwm3JEFZZfPUKthKeknUSdsHysQWOQUL+8gCkJ3mx7nhBd00lH6qPToxJz5He4ZWnyHjHBKurdlBLt2f3Vq8AbVIYrJiE43LEELFBFgdkXax2PBZ X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: t9zJU5p5ILzO0XizFB4P5arKB/kD2ihTmXsF4OAJWifGLrDwQN+NyQGjN1X/fsdlm+2cjxmw48L3QJG9iarXVx1WCHWiMVCd4DsUdLeHEwx0PWBjzdVQ6tHpYGEqaaszbLoKgvwPx0uv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SpUZ4Bk9qoPzGxR6TkY/c5ompMmgulmv5XtEMX75EAD6QzXADxv4LuEgmFsW4hDv7oi7iGG0vPps89RoNBfEMQxLqND7Yw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03c25304-86b6-4ac6-6204-08dc3022b8c5 X-MS-Exchange-CrossTenant-AuthSource: GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 01:41:26.8495 (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: DU2P250MB0319 Subject: [FFmpeg-devel] [PATCH 6/7] avcodec/srtenc, webvttenc: Use av_printf_format 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: 5Rw+pvAl1sqQ Signed-off-by: Andreas Rheinhardt --- libavcodec/srtenc.c | 5 +---- libavcodec/webvttenc.c | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c index 9b6f61ebd1..a607beb990 100644 --- a/libavcodec/srtenc.c +++ b/libavcodec/srtenc.c @@ -41,10 +41,7 @@ typedef struct { } SRTContext; -#ifdef __GNUC__ -__attribute__ ((__format__ (__printf__, 2, 3))) -#endif -static void srt_print(SRTContext *s, const char *str, ...) +static av_printf_format(2, 3) void srt_print(SRTContext *s, const char *str, ...) { va_list vargs; va_start(vargs, str); diff --git a/libavcodec/webvttenc.c b/libavcodec/webvttenc.c index 9922f33485..3b66b4f2dd 100644 --- a/libavcodec/webvttenc.c +++ b/libavcodec/webvttenc.c @@ -38,10 +38,7 @@ typedef struct { int stack_ptr; } WebVTTContext; -#ifdef __GNUC__ -__attribute__ ((__format__ (__printf__, 2, 3))) -#endif -static void webvtt_print(WebVTTContext *s, const char *str, ...) +static av_printf_format(2, 3) void webvtt_print(WebVTTContext *s, const char *str, ...) { va_list vargs; va_start(vargs, str); From patchwork Sun Feb 18 01:43:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46332 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dda5:b0:19e:cdac:8cce with SMTP id kw37csp553425pzb; Sat, 17 Feb 2024 17:42:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVPMTp7Z+5Aj5kaXG4W8WLr5zAYIPzNvX6TPRPtJqXAPUw1FnOYsYc06ayia8uPWWxoG6mWpmoZAMsspPn9+vmocpdfgQoWjCO0/w== X-Google-Smtp-Source: AGHT+IEiVgDPakjRC7jUahcKBMUm+XajZfU9tmCSKESjoZp6/aqQEoMB0yg1fOL/KZ5wqLSRIo8R X-Received: by 2002:a19:4318:0:b0:511:69b3:a47e with SMTP id q24-20020a194318000000b0051169b3a47emr5000498lfa.52.1708220528906; Sat, 17 Feb 2024 17:42:08 -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 r10-20020a1709067fca00b00a3df1ee0c65si1301423ejs.286.2024.02.17.17.42.08; Sat, 17 Feb 2024 17:42:08 -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=Kn9B9E3N; 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 EB04F68D31D; Sun, 18 Feb 2024 03:41:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2097.outbound.protection.outlook.com [40.92.74.97]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3317C68D315 for ; Sun, 18 Feb 2024 03:41:37 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hRueNGx+FthAdCZhUiwUoAmfpx/ZA5FB9YGpT7IJ08Xn4FTPXxzgAZ7SMLl9ANYiAjNsO/t4Z2n3MsJWT/ukIRraOjrUhvVCS062TC55CF0ZDiDIXZw8UXKq174jhLQoinSl78iDwg22OV+a+DXa0zkzYsblJyTmBH/TXsjEmWOGS+nVg6YWjFvF82Eo/j3Hx2N7FLhgMaiS2U88gR8eEyE2BhuJsrNUve92RCGuWLrIINx/Ydyfx11Rr09nLFuWxoOTYuQPxKggk2Y5GUG6+RWosx++6tB3NG0YBDkLr7WnIDovHE2aoJiFKJwYdf0w4wvavWl/m+FopjPdEl7/qw== 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=6R0Lm9p5VbW/E0xs/kzIvIMVXGxv0WEZoJzMMx0H+Ow=; b=DOFVWIjHZYLcap3uuQfWMqNPpnsvS0mzi8ZfCyHndFVW0uYnT4F3ZzpbGZma+ivK9QFpFRuQrd/XCW6lhVzJWA+f4xxve0WuZ9kOM65mCDBLTZafYji35NDY5BqktH8ekiOdzm4ABu/ASGL/wvpHec04optAX5bXApDDqN02Ly6AHxw9L/ttPZfFnP8tCRk4XrfbbUDsyGslw1m7h8lQ3nZyCdykyweoE1Aq64BW4G7dcBsE885/hhmZFXl56G4jFAp/NUEIbdCCX2wAXqISpYCoJF3S9c1L0irLSHxgD3B5vIukV91Df+p6seQtEVQ5M59n9aR8tj/P//r+qXRQLg== 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=6R0Lm9p5VbW/E0xs/kzIvIMVXGxv0WEZoJzMMx0H+Ow=; b=Kn9B9E3NH8hE0kz5CtrhYSpfNRPsLTLjEaAJxotDDnN5ouTWLXpRCPgZDm9GxmRkfwbzVUu5N28bbQ5Hba1mwqvc1ZiViC7t50x5HCoDKaWLL2daErOrrO2EDE2c4EvjVTuQH4sxe2AZiRa48/28/yh3AX2ftR/RWsgK7ihP9FPJpbYOoaceCCnJNj5aoCk7KQHJIDX2Kz7cP6h+h18pcPdW2S+eKjjcH89uuWE5Y/8XmomN81LF/TKTLc8zvVGQaRGiztU4CaLQcL5q7mnMuz0HFBaFLdM6hgyIvPZsJFXOEFKEOIXPbFaD+F8xYaGF/oNZHPkrSODArDz08gFwxQ== Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) by DU2P250MB0319.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:27c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.32; Sun, 18 Feb 2024 01:41:28 +0000 Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504]) by GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504%6]) with mapi id 15.20.7292.026; Sun, 18 Feb 2024 01:41:27 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Feb 2024 02:43:08 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [f7LBRkJDKhG4opJBAcj1lQ6Y0Hlc6CW8rVd6aNLHf6w=] X-ClientProxiedBy: FR3P281CA0033.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::12) To GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) X-Microsoft-Original-Message-ID: <20240218014308.2819410-6-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1SPRMB0063:EE_|DU2P250MB0319:EE_ X-MS-Office365-Filtering-Correlation-Id: 72ad2a6f-9f00-48bb-d3bd-08dc3022b96d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QbJY5X6pF+C4dZiK7Ta6P0gYKjfXrwE8uQv4ytHkcc/r4p+cVWVfpxlSuKsJ1KLASx6uMzNbAW4V4XQEM4ZBaMXOWaTvOEoQCT3lz+DPNJe4KKS+5EsFkFM6xvrPGx070Sik1WZBy1niT13RVio2N7g49e1qTmbioKN7tW6G3N96s8pFfmiGsGuCXbmOtu3/znUPAjFxXkx334bpq44ReWjQWwaOv/NkQP286CIRr96KIxQVS6RhuVv91Gb/fnvQ2eEzf6ijD3kOTcgOqpnom/MUFiJIUrpX1NznCMXJeKloopbXENNwr8w5r79hqnxBhXyEtetYFnTW9wSLxQkVZc6fsok0xX0n0Tz5r2yELQ/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1Vt6hO4V1SZCyksFlcgilOvLXBhOBL7nrywwrBvVowHjig2dAg79EInp4QkVLYcmQUFwPvGlYisr1VN+q+qJX55QIyebS4kyil9Mq5LvsGy0bZQAaTBhj3hUV0d8zQwD4AnCWrEPd4yKAReVouzFWMwkK5Dhexdbg2yrOmoDTWc6/5xlWJbGo5PD9JlpINrqa4ZXVobHirO4VONIx3M41Av4x8/ogQloTJ5wnW6ehCK57OEpTjEUvcYedpy9QcEaAd4gMIO611fmes+NeDhZQ1NOP3oDph1Twhus9omEHo6ivy0PftcxIaa7KpoebmRCO9KFR3qse8JLzRUh9c0w8I3O0CebbOPD4FN/IjvUE4nA7iHxfFs3ERAKf42Dx2Cfnfqe2dUpA0jYB8tTWZTgPu/ytnjrvya679CoRqeKMODumZLb8g9AmF05s0VHPJQ2KyMXlcYghcQac8vokTZ2rcuZlfk5PhxBCiiJ19NCyZ2aP79I7svkVuZ5trKazunXArvcSdJN2EmOydMn4BGOEoai//Fi/M6nCQizZRN4kR8I1A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72ad2a6f-9f00-48bb-d3bd-08dc3022b96d X-MS-Exchange-CrossTenant-AuthSource: GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 01:41:27.9028 (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: DU2P250MB0319 Subject: [FFmpeg-devel] [PATCH 7/7] avcodec/movtextenc: Don't copy data around unnecessarily 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: 7MJYxAW/UBWW Using av_bprint_init_for_buffer() avoids copying data into the internal AVBPrint buffer (or worse: to allocate a temporary buffer in case the internal buffer does not suffice). Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextenc.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 7aa74d7c9d..fd8c7dc9f7 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -22,7 +22,6 @@ #include #include "avcodec.h" #include "libavutil/opt.h" -#include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" #include "libavutil/mem.h" #include "libavutil/common.h" @@ -170,7 +169,6 @@ static int mov_text_encode_close(AVCodecContext *avctx) ff_ass_split_free(s->ass_ctx); av_freep(&s->style_attributes); av_freep(&s->fonts); - av_bprint_finalize(&s->buffer, NULL); return 0; } @@ -183,6 +181,9 @@ static int encode_sample_description(AVCodecContext *avctx) int font_names_total_len = 0; MovTextContext *s = avctx->priv_data; uint8_t buf[30], *p = buf; + int ret; + + av_bprint_init(&s->buffer, 0, INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE + 1); // 0x00, 0x00, 0x00, 0x00, // uint32_t displayFlags // 0x01, // int8_t horizontal-justification @@ -306,19 +307,23 @@ static int encode_sample_description(AVCodecContext *avctx) // }; if (!av_bprint_is_complete(&s->buffer)) { - return AVERROR(ENOMEM); + ret = AVERROR(ENOMEM); + goto fail; } avctx->extradata_size = s->buffer.len; avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { - return AVERROR(ENOMEM); + ret = AVERROR(ENOMEM); + goto fail; } memcpy(avctx->extradata, s->buffer.str, avctx->extradata_size); - av_bprint_clear(&s->buffer); + ret = 0; +fail: + av_bprint_finalize(&s->buffer, NULL); - return 0; + return ret; } static av_cold int mov_text_encode_init(AVCodecContext *avctx) @@ -327,8 +332,6 @@ static av_cold int mov_text_encode_init(AVCodecContext *avctx) MovTextContext *s = avctx->priv_data; s->avctx = avctx; - av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED); - s->ass_ctx = ff_ass_split(avctx->subtitle_header); if (!s->ass_ctx) return AVERROR_INVALIDDATA; @@ -640,10 +643,14 @@ static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf, ASSDialog *dialog; int i, length; + if (bufsize < 3) + goto too_small; + s->text_pos = 0; s->count = 0; s->box_flags = 0; - av_bprint_clear(&s->buffer); + + av_bprint_init_for_buffer(&s->buffer, buf + 2, bufsize - 2); for (i = 0; i < sub->num_rects; i++) { const char *ass = sub->rects[i]->ass; @@ -663,23 +670,19 @@ static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf, if (s->buffer.len > UINT16_MAX) return AVERROR(ERANGE); AV_WB16(buf, s->buffer.len); - buf += 2; for (size_t j = 0; j < box_count; j++) box_types[j].encode(s); - if (!av_bprint_is_complete(&s->buffer)) - return AVERROR(ENOMEM); - if (!s->buffer.len) return 0; - if (s->buffer.len > bufsize - 3) { + if (!av_bprint_is_complete(&s->buffer)) { +too_small: av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n"); return AVERROR_BUFFER_TOO_SMALL; } - memcpy(buf, s->buffer.str, s->buffer.len); length = s->buffer.len + 2; return length;