Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avutil/detection_bbox: Cleanup: Remove unneeded bbox_size struct member
@ 2025-02-14  8:47 Leandro Santiago
  2025-02-14  9:56 ` Zhao Zhili
  0 siblings, 1 reply; 3+ messages in thread
From: Leandro Santiago @ 2025-02-14  8:47 UTC (permalink / raw)
  To: ffmpeg-devel

There is no need to store this field in the struct,
as it can be computed as sizeof(AVDetectionBBox).

Signed-off-by: Leandro Santiago <leandrosansilva@gmail.com>
---
 libavutil/detection_bbox.c | 1 -
 libavutil/detection_bbox.h | 7 +------
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/libavutil/detection_bbox.c b/libavutil/detection_bbox.c
index cb157b355b..456c35f87a 100644
--- a/libavutil/detection_bbox.c
+++ b/libavutil/detection_bbox.c
@@ -40,7 +40,6 @@ AVDetectionBBoxHeader *av_detection_bbox_alloc(uint32_t nb_bboxes, size_t *out_s
         return NULL;
 
     header->nb_bboxes     = nb_bboxes;
-    header->bbox_size     = bbox_size;
     header->bboxes_offset = bboxes_offset;
 
     if (out_size)
diff --git a/libavutil/detection_bbox.h b/libavutil/detection_bbox.h
index 011988052c..7844fb05da 100644
--- a/libavutil/detection_bbox.h
+++ b/libavutil/detection_bbox.h
@@ -70,11 +70,6 @@ typedef struct AVDetectionBBoxHeader {
      * the array of bounding boxes starts.
      */
     size_t bboxes_offset;
-
-    /**
-     * Size of each bounding box in bytes.
-     */
-    size_t bbox_size;
 } AVDetectionBBoxHeader;
 
 /*
@@ -85,7 +80,7 @@ av_get_detection_bbox(const AVDetectionBBoxHeader *header, unsigned int idx)
 {
     av_assert0(idx < header->nb_bboxes);
     return (AVDetectionBBox *)((uint8_t *)header + header->bboxes_offset +
-                               idx * header->bbox_size);
+                               idx * sizeof(AVDetectionBBox));
 }
 
 /**
-- 
2.48.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avutil/detection_bbox: Cleanup: Remove unneeded bbox_size struct member
  2025-02-14  8:47 [FFmpeg-devel] [PATCH] avutil/detection_bbox: Cleanup: Remove unneeded bbox_size struct member Leandro Santiago
@ 2025-02-14  9:56 ` Zhao Zhili
  2025-02-14 12:29   ` Leandro Santiago
  0 siblings, 1 reply; 3+ messages in thread
From: Zhao Zhili @ 2025-02-14  9:56 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> On Feb 14, 2025, at 16:47, Leandro Santiago <leandrosansilva@gmail.com> wrote:
> 
> There is no need to store this field in the struct,
> as it can be computed as sizeof(AVDetectionBBox).
> 
> Signed-off-by: Leandro Santiago <leandrosansilva@gmail.com>
> ---
> libavutil/detection_bbox.c | 1 -
> libavutil/detection_bbox.h | 7 +------
> 2 files changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/libavutil/detection_bbox.c b/libavutil/detection_bbox.c
> index cb157b355b..456c35f87a 100644
> --- a/libavutil/detection_bbox.c
> +++ b/libavutil/detection_bbox.c
> @@ -40,7 +40,6 @@ AVDetectionBBoxHeader *av_detection_bbox_alloc(uint32_t nb_bboxes, size_t *out_s
>         return NULL;
> 
>     header->nb_bboxes     = nb_bboxes;
> -    header->bbox_size     = bbox_size;
>     header->bboxes_offset = bboxes_offset;
> 
>     if (out_size)
> diff --git a/libavutil/detection_bbox.h b/libavutil/detection_bbox.h
> index 011988052c..7844fb05da 100644
> --- a/libavutil/detection_bbox.h
> +++ b/libavutil/detection_bbox.h
> @@ -70,11 +70,6 @@ typedef struct AVDetectionBBoxHeader {
>      * the array of bounding boxes starts.
>      */
>     size_t bboxes_offset;
> -
> -    /**
> -     * Size of each bounding box in bytes.
> -     */
> -    size_t bbox_size;
> } AVDetectionBBoxHeader;
> 
> /*
> @@ -85,7 +80,7 @@ av_get_detection_bbox(const AVDetectionBBoxHeader *header, unsigned int idx)
> {
>     av_assert0(idx < header->nb_bboxes);
>     return (AVDetectionBBox *)((uint8_t *)header + header->bboxes_offset +
> -                               idx * header->bbox_size);
> +                               idx * sizeof(AVDetectionBBox));
> }

No, this field is for ABI compatibility. New fields can be added at the end of AVDetectionBBox,
sizeof(AVDetectionBBox) can be different between API user of libavutil and libavutil internal.

> 
> /**
> -- 
> 2.48.1
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avutil/detection_bbox: Cleanup: Remove unneeded bbox_size struct member
  2025-02-14  9:56 ` Zhao Zhili
@ 2025-02-14 12:29   ` Leandro Santiago
  0 siblings, 0 replies; 3+ messages in thread
From: Leandro Santiago @ 2025-02-14 12:29 UTC (permalink / raw)
  To: FFmpeg development discussions and patches, Zhao Zhili

Oh, I see. I had not noticed that AVDetectionBBox was part of the public API, but it now looks obvious to me.

Thx for pointing it out.

On 2/14/25 10:56, Zhao Zhili wrote:
>
>> On Feb 14, 2025, at 16:47, Leandro Santiago <leandrosansilva@gmail.com> wrote:
>>
>> There is no need to store this field in the struct,
>> as it can be computed as sizeof(AVDetectionBBox).
>>
>> Signed-off-by: Leandro Santiago <leandrosansilva@gmail.com>
>> ---
>> libavutil/detection_bbox.c | 1 -
>> libavutil/detection_bbox.h | 7 +------
>> 2 files changed, 1 insertion(+), 7 deletions(-)
>>
>> diff --git a/libavutil/detection_bbox.c b/libavutil/detection_bbox.c
>> index cb157b355b..456c35f87a 100644
>> --- a/libavutil/detection_bbox.c
>> +++ b/libavutil/detection_bbox.c
>> @@ -40,7 +40,6 @@ AVDetectionBBoxHeader *av_detection_bbox_alloc(uint32_t nb_bboxes, size_t *out_s
>>         return NULL;
>>
>>     header->nb_bboxes     = nb_bboxes;
>> -    header->bbox_size     = bbox_size;
>>     header->bboxes_offset = bboxes_offset;
>>
>>     if (out_size)
>> diff --git a/libavutil/detection_bbox.h b/libavutil/detection_bbox.h
>> index 011988052c..7844fb05da 100644
>> --- a/libavutil/detection_bbox.h
>> +++ b/libavutil/detection_bbox.h
>> @@ -70,11 +70,6 @@ typedef struct AVDetectionBBoxHeader {
>>      * the array of bounding boxes starts.
>>      */
>>     size_t bboxes_offset;
>> -
>> -    /**
>> -     * Size of each bounding box in bytes.
>> -     */
>> -    size_t bbox_size;
>> } AVDetectionBBoxHeader;
>>
>> /*
>> @@ -85,7 +80,7 @@ av_get_detection_bbox(const AVDetectionBBoxHeader *header, unsigned int idx)
>> {
>>     av_assert0(idx < header->nb_bboxes);
>>     return (AVDetectionBBox *)((uint8_t *)header + header->bboxes_offset +
>> -                               idx * header->bbox_size);
>> +                               idx * sizeof(AVDetectionBBox));
>> }
> No, this field is for ABI compatibility. New fields can be added at the end of AVDetectionBBox,
> sizeof(AVDetectionBBox) can be different between API user of libavutil and libavutil internal.
>
>> /**
>> -- 
>> 2.48.1
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-14 12:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-14  8:47 [FFmpeg-devel] [PATCH] avutil/detection_bbox: Cleanup: Remove unneeded bbox_size struct member Leandro Santiago
2025-02-14  9:56 ` Zhao Zhili
2025-02-14 12:29   ` Leandro Santiago

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git