From patchwork Tue Sep 28 13:36:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 30627 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp5210505iob; Tue, 28 Sep 2021 06:37:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAUbDNT1xyw9ES7alvg6eLBNhNT4Hsx2mZ2aefemOIzOeAVUsrERmQ4Xx8LlZGIUHVXzvl X-Received: by 2002:a50:d84c:: with SMTP id v12mr7674845edj.201.1632836229434; Tue, 28 Sep 2021 06:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632836229; cv=none; d=google.com; s=arc-20160816; b=fpFFyvOIkVRvdViQ9cbZ5HlAx+pwztOa+ZLJF5b2L9/EwbIISbmxyow0tsgQJuOi1X 3+2wnjQ8HErm4fqQW8nZmFM2NTRbCjzxaktWjpFq5ZfzisA8lvs2+DtRqixW01RKFmD9 9N+m4zb9+tzbjXo0f5DE243tdqw5UmtUti8ZsdPTVtpONDOI/Z+W1M5pPtzbV0zaVy/j HJjZy4HC9jh83b+VJY4kxqWOwA4fEvKvpB3zlwh3Oly9lA2NwgWdKx+THdLc/EiKpVp3 WdLSPdE4yFdJeqjCpE+clGWqX083JZFiK/t7j/8Vtg5c29H834zkCb2DiXzyY2rJIVUk jhbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=f2go03zz6hBxYefOFdOfHVmNIZdUKbp5Ww9z1otDtSo=; b=woH+AN7E0cjo6rni20o8mBvFFYVTgFuIMUxi7G0rDL2gq9Wl294CoYhaMydpSDK3aR OdYuG0n5AAlqV/FuR4YC/N+6vtBQEtUEZ/fjhZKi2EPw3uDKUVACKohotNWJpSH7gjcX MAsK+6yNYWi6zQscx4Xu1w3wwVF3qg++LmJw5rMqazuqrkbSAipOQ5zeTLPc186GteDz svwfOdqBVBlfwi8bdY2N3Rw+r5fm07lvswhHa7JvCc9AxB4P9q6poi+A8j29GRnhseuQ l10CqRla4u/UwG+b2ry18p2VvPx/CvNYdd7ShQ5O9iBBpgJ1sNm/eHsb3fxL9fxcIZTi mr3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="Wh/GmYFr"; 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=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x15si395004ede.404.2021.09.28.06.37.09; Tue, 28 Sep 2021 06:37:09 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="Wh/GmYFr"; 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=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5F966687F27; Tue, 28 Sep 2021 16:36:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7525C6898FB for ; Tue, 28 Sep 2021 16:36:50 +0300 (EEST) Received: by mail-pf1-f171.google.com with SMTP id 145so18946360pfz.11 for ; Tue, 28 Sep 2021 06:36:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WL7kp/hGprFiG7LAMkWMPIgYsllxpAqzOLJkx3ss+hA=; b=Wh/GmYFrH9cxGbMEjo7Yxjt5gPVoOMm65Tx4wYefjA+mHSGegPcXT920mXnJXKOp4A lOTAUJZ9qSYxn+J97B7vvpKVlVhzj/cc9L4EVHmPC4ZHfJTZY+B73yDnt+Z4Un08fZuQ dEt+ZJfjmOk0Z7LnI3d0+3gEzpb6rfx29Hg7lUT55KIYLT6wL17ZpjLSckU0xDehH8Wu jdrk7XCxAhnCLH2WvnLH7tRtNt1qxGRpuhHNC29EXwbLC/KjyWH4diqkfniwEqPEVzct v7RM1T2j5Ym2J5GxaaTCowP8Q0C/CcecYZjU6grLNIMxnJYcW20w944XW/BPIpjhJCYT xe5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WL7kp/hGprFiG7LAMkWMPIgYsllxpAqzOLJkx3ss+hA=; b=iDhIeefeIoP8JtWjNTJJwXuFFu7ZXaDWE469vZToi6LvfObjseJjJ+tqCCnogX4uvC FOnio9V+jvB+ZqYKAU8jFR9PPiDQdgINilZeTpxob3+eG0byZVdMIJH/x5nitMRUEvRG qbh2F/WJ33R3bZ0Zmv7KZApoAqgQn9YClwq2JX5hCm9+X45nkC6oZCREEzAAE6lHQh5v MUsrh2joaT37qFteE+FsmdgXv+VoIIX9WN6aDwS5dlvO/pytIaZC3rs3nZKMuc6uV10Q q015qFlcj4tIsS06JBIqMTu4drknnz05OqEadGDREqxwZUw6Q+rEGQrRKy0TLE5qv4hY ZMfA== X-Gm-Message-State: AOAM532seY9naSnpJAQjkRGufdvGrgcz6LaWyCdUFxGIxg8ejDZO05rI raSUKVX3fG4uiN4KolFOUFzVMct1T3Y= X-Received: by 2002:aa7:959a:0:b0:43b:adeb:ef58 with SMTP id z26-20020aa7959a000000b0043badebef58mr5360811pfj.19.1632836208555; Tue, 28 Sep 2021 06:36:48 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id u6sm21636839pgr.3.2021.09.28.06.36.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Sep 2021 06:36:48 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 28 Sep 2021 21:36:36 +0800 Message-Id: <1632836198-23044-2-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1632836198-23044-1-git-send-email-lance.lmwang@gmail.com> References: <1632836198-23044-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/4] avutil/detection_bbox: use offsetof for bboxes_offset 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: vj3hiUel0IxL From: Limin Wang Signed-off-by: Limin Wang --- libavutil/detection_bbox.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavutil/detection_bbox.c b/libavutil/detection_bbox.c index d066567..8bfdff7 100644 --- a/libavutil/detection_bbox.c +++ b/libavutil/detection_bbox.c @@ -21,10 +21,11 @@ AVDetectionBBoxHeader *av_detection_bbox_alloc(uint32_t nb_bboxes, size_t *out_size) { size_t size; - struct { + struct BBoxContext { AVDetectionBBoxHeader header; AVDetectionBBox boxes[1]; } *ret; + const size_t bboxes_offset = offsetof(struct BBoxContext, boxes); size = sizeof(*ret); if (nb_bboxes - 1 > (SIZE_MAX - size) / sizeof(*ret->boxes)) @@ -37,7 +38,7 @@ AVDetectionBBoxHeader *av_detection_bbox_alloc(uint32_t nb_bboxes, size_t *out_s ret->header.nb_bboxes = nb_bboxes; ret->header.bbox_size = sizeof(*ret->boxes); - ret->header.bboxes_offset = (char *)&ret->boxes - (char *)&ret->header; + ret->header.bboxes_offset = bboxes_offset; if (out_size) *out_size = size;