From patchwork Mon May 31 18:51:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28026 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp3118914iof; Mon, 31 May 2021 11:52:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyU5J7NSbzpIGZMRn5msfJIthSWA9TvR4bz96BVTrRgQf9jYJY9Pv8eZP4pqj8JRCDqpg6M X-Received: by 2002:a05:6402:524b:: with SMTP id t11mr27551627edd.139.1622487140680; Mon, 31 May 2021 11:52:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622487140; cv=none; d=google.com; s=arc-20160816; b=exhFjiD5yNsxaKlUvsc9RmYYsKPtgqszt5NAF6qRHF0es6kt11XdysTooQ+faGnwa+ 3ABnMxOhG3wzxk/v1qRr/aUY5Sdnun9/uaCUTWn9EnamQBbHaRf8Euta5mC0kxso+XbQ aDCId0ZinQ9edtdDi9nRekEVIybeje2hJLzvTytxXMoPLxXwF7QaSYmDJRuhYEBGo5Q4 WzlXW9cZv+cYsx4xOtU0ZdSYE8XyrtcvV72fBCmy8QcNQCJw0i73yRUKMHcREfpgCVkT 36wWBthBvWSKptdZfMebflM7PPsLqquW8gnR/zUyMijtyd/pHsIoiFdHulRveErusFNF Y0XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=kVWjpuqIARDu2Uc36tuiDtpyfScd8qYzBmLJ0Jtjr1E=; b=Zt29krq8Tcg9U0U7hBbssHA75ulm9DyAcunl9DqbFgIDKnGvlqWpTM3yqi6atLfXT6 Jp2P+sXmWBhm6Bvt3vdQu2MVEbFFIzacs0yQTwoKWlQ62f7vg86RILB0NimteU/s+Wcy a5XT2iX2oUGuznUELqjFZdYmmZz3Oi9ouc/Qi8SgPwVBTfLh9HrMsKjxApFz+aCTZG6j 7T5I8bPUHBWRkU2amTuSGFNa5ehIweCBmEorOuJl4y2bzSl0Ospf8N9IJhPuiSdPyMUO EBUNugK/al835bARJ1v8eIoDtXXRRGdzD0hLYQ+5SgQ3Mzy2/yGA4+ldmAjlt4yoZW8e DcUg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t4si14434215edi.183.2021.05.31.11.52.19; Mon, 31 May 2021 11:52:20 -0700 (PDT) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1C1D16883C9; Mon, 31 May 2021 21:52:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4CBEA6806F7 for ; Mon, 31 May 2021 21:52:09 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id E050D240476 for ; Mon, 31 May 2021 20:52:08 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id L7Ux-bG3Q3sY for ; Mon, 31 May 2021 20:52:07 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 9DF8D24042A for ; Mon, 31 May 2021 20:52:07 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 846763A125B; Mon, 31 May 2021 20:52:07 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 20:51:47 +0200 Message-Id: <20210531185147.27314-1-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavu/video_enc_params: make sure blocks are properly aligned 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: raOMsROLApBl --- libavutil/video_enc_params.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavutil/video_enc_params.c b/libavutil/video_enc_params.c index b9cdafddbb..7d903af385 100644 --- a/libavutil/video_enc_params.c +++ b/libavutil/video_enc_params.c @@ -29,10 +29,14 @@ AVVideoEncParams *av_video_enc_params_alloc(enum AVVideoEncParamsType type, unsigned int nb_blocks, size_t *out_size) { + const size_t blocks_offset = offsetof( + struct { + AVVideoEncParams p; + AVVideoBlockParams b; + }, b); + size_t size = blocks_offset; AVVideoEncParams *par; - size_t size; - size = sizeof(*par); if (nb_blocks > (SIZE_MAX - size) / sizeof(AVVideoBlockParams)) return NULL; size += sizeof(AVVideoBlockParams) * nb_blocks; @@ -44,7 +48,7 @@ AVVideoEncParams *av_video_enc_params_alloc(enum AVVideoEncParamsType type, par->type = type; par->nb_blocks = nb_blocks; par->block_size = sizeof(AVVideoBlockParams); - par->blocks_offset = sizeof(*par); + par->blocks_offset = blocks_offset; if (out_size) *out_size = size;