diff mbox series

[FFmpeg-devel] libavfilter/vf_dnn_detect: bbox index may bigger than bbox number

Message ID 20230717053301.2389494-1-wenbin.chen@intel.com
State Accepted
Commit 13f49a7c62094035ca169201b0313c853365651f
Headers show
Series [FFmpeg-devel] libavfilter/vf_dnn_detect: bbox index may bigger than bbox number | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Chen, Wenbin July 17, 2023, 5:33 a.m. UTC
From: Wenbin Chen <wenbin.chen@intel.com>

Fix a bug that queried bbox index may bigger than bbox's total number.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 libavfilter/vf_dnn_detect.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Guo, Yejun July 18, 2023, 8:24 a.m. UTC | #1
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> wenbin.chen-at-intel.com@ffmpeg.org
> Sent: Monday, July 17, 2023 1:33 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH] libavfilter/vf_dnn_detect: bbox index may
> bigger than bbox number
> 
> From: Wenbin Chen <wenbin.chen@intel.com>
> 
> Fix a bug that queried bbox index may bigger than bbox's total number.
> 
> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> ---
>  libavfilter/vf_dnn_detect.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
> index 06efce02a6..6ef04e0958 100644
> --- a/libavfilter/vf_dnn_detect.c
> +++ b/libavfilter/vf_dnn_detect.c
> @@ -106,12 +106,11 @@ static int dnn_detect_post_proc_ov(AVFrame
> *frame, DNNData *output, AVFilterCont
>          float x1     =      detections[i * detect_size + 5];
>          float y1     =      detections[i * detect_size + 6];
> 
> -        bbox = av_get_detection_bbox(header, i);
> -
>          if (conf < conf_threshold) {
>              continue;
>          }
> 
> +        bbox = av_get_detection_bbox(header, header->nb_bboxes -
> nb_bboxes);


Good catch, LGTM, will push soon, thanks.
diff mbox series

Patch

diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
index 06efce02a6..6ef04e0958 100644
--- a/libavfilter/vf_dnn_detect.c
+++ b/libavfilter/vf_dnn_detect.c
@@ -106,12 +106,11 @@  static int dnn_detect_post_proc_ov(AVFrame *frame, DNNData *output, AVFilterCont
         float x1     =      detections[i * detect_size + 5];
         float y1     =      detections[i * detect_size + 6];
 
-        bbox = av_get_detection_bbox(header, i);
-
         if (conf < conf_threshold) {
             continue;
         }
 
+        bbox = av_get_detection_bbox(header, header->nb_bboxes - nb_bboxes);
         bbox->x = (int)(x0 * frame->width);
         bbox->w = (int)(x1 * frame->width) - bbox->x;
         bbox->y = (int)(y0 * frame->height);