aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/detection_bbox.c
diff options
context:
space:
mode:
authorLimin Wang <lance.lmwang@gmail.com>2021-09-25 09:31:17 +0800
committerLimin Wang <lance.lmwang@gmail.com>2021-10-08 10:11:59 +0800
commite724004fd8d2c5d7753f7b997e3d02a2155ceef6 (patch)
tree456eefea6b92b05ed7ee4f788497682cf4e90e7e /libavutil/detection_bbox.c
parentf059b56195da9c0e2c11a5f7f357a3d6101e6bf0 (diff)
downloadffmpeg-e724004fd8d2c5d7753f7b997e3d02a2155ceef6.tar.gz
avutil/detection_bbox: use offsetof for bboxes_offset
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Diffstat (limited to 'libavutil/detection_bbox.c')
-rw-r--r--libavutil/detection_bbox.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavutil/detection_bbox.c b/libavutil/detection_bbox.c
index 40711e6aa9..b7d0c5575f 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;