[FFmpeg-devel] [PATCH V3 2/3] libavfilter/buffersink.c: unref private_ref when frame leaves libavfilter

Guo, Yejun yejun.guo at intel.com
Tue Feb 23 02:49:45 EET 2021



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of Nicolas
> George
> Sent: 2021年2月23日 0:05
> To: FFmpeg development discussions and patches <ffmpeg-devel at ffmpeg.org>
> Cc: Guo, Yejun <yejun.guo at intel.com>
> Subject: Re: [FFmpeg-devel] [PATCH V3 2/3] libavfilter/buffersink.c: unref
> private_ref when frame leaves libavfilter
> 
> Guo, Yejun (12021-02-22):
> > ---
> >  libavfilter/buffersink.c | 1 +
> >  1 file changed, 1 insertion(+)
> 
> This does not seem correct: the ref count is not raised by buffersink, it
> probably should not lower it.
> 
> What circumstances are you trying to fix exactly?

The purpose is to support filter object detection. We need a place within AVFrame
to save bounding boxes (the result of object detection, where are the objects, and
what are the objects). And we plan to use AVFrame->private_ref as now, see more discussion
at http://ffmpeg.org/pipermail/ffmpeg-devel/2021-February/276641.html

As at https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/frame.h#L683, 
private_ref is for internal use by a single libav* library. 
It has to be NULL when ownership of the frame leaves the respective library, 

buffersink is the last step when the frame leaves libavfilter, so I add unref here.

In the patch 3 of this patch set, private_ref is allocated in filter vf_dnn_detect.c to save
the detected bounding boxes.

Other filters such as classify, bbox_to_roi (both in plan) will need the bounding boxes, and
we also plan to update vf_drawbox/text to visualize the bounding boxes. 

> 
> Regards,
> 
> --
>   Nicolas George


More information about the ffmpeg-devel mailing list