[FFmpeg-devel] [PATCH V8 1/3] lavu: add side data AV_FRAME_DATA_DETECTION_BBOXES for object detection/classification

Guo, Yejun yejun.guo at intel.com
Wed Apr 14 04:41:19 EEST 2021



> -----Original Message-----
> From: mypopy at gmail.com <mypopy at gmail.com>
> Sent: 2021年4月14日 9:29
> To: FFmpeg development discussions and patches
> <ffmpeg-devel at ffmpeg.org>
> Cc: Guo, Yejun <yejun.guo at intel.com>
> Subject: Re: [FFmpeg-devel] [PATCH V8 1/3] lavu: add side data
> AV_FRAME_DATA_DETECTION_BBOXES for object detection/classification
> 
> On Tue, Apr 13, 2021 at 1:26 PM Guo, Yejun <yejun.guo at intel.com> wrote:
> >
> > ---
> >  doc/APIchanges             |   2 +
> >  libavutil/Makefile         |   2 +
> >  libavutil/detection_bbox.c |  73 +++++++++++++++++++++++++
> >  libavutil/detection_bbox.h | 107
> +++++++++++++++++++++++++++++++++++++
> > +
> > +#include "detection_bbox.h"
> > +
> > +AVDetectionBBoxHeader *av_detection_bbox_alloc(uint32_t nb_bboxes,
> size_t *out_size)
> > +{
> > +    size_t size;
> > +    struct {
> > +           AVDetectionBBoxHeader header;
> > +           AVDetectionBBox boxes[1];
> > +    } *ret;
> > +
> > +    size = sizeof(*ret);
> > +    if (nb_bboxes - 1 > (SIZE_MAX - size) / sizeof(*ret->boxes))
> > +        return NULL;
> > +    size += sizeof(*ret->boxes) * (nb_bboxes - 1);
> > +
> > +    ret = av_mallocz(size);
> > +    if (!ret)
> > +        return NULL;
> > +
> > +    ret->header.nb_bboxes = nb_bboxes;
> > +    ret->header.bbox_size = sizeof(*ret->boxes);
> > +    ret->header.bboxes_offset = (char *)&ret->boxes - (char
> *)&ret->header;
> > +
> > +    if (out_size)
> > +        *out_size = size;
> > +
> > +    return &ret->header;
> > +}
> > +
> > +AVDetectionBBoxHeader
> *av_detection_bbox_create_side_data(AVFrame *frame, uint32_t
> nb_bboxes)
> > +{
> > +    AVBufferRef         *buf;
> > +    AVDetectionBBoxHeader *header;
> > +    size_t size;
> > +
> > +    header = av_detection_bbox_alloc(nb_bboxes, &size);
> > +    if (!header)
> > +        return NULL;
> > +    if (size > INT_MAX) {
> I think need to use SIZE_MAX, not INT_MAX in this case

thanks for the review, I think 'size_t size' could not larger than SIZE_MAX.

actually, the check is referenced from video_enc_params.

btw, this check will be removed after the bump, see more at
http://ffmpeg.org/pipermail/ffmpeg-devel/2021-April/278779.html



More information about the ffmpeg-devel mailing list