diff mbox series

[FFmpeg-devel,2/2] libavfilter/dnn_io_proc: Take step into consideration when crop frame

Message ID 20240402081306.1314398-2-wenbin.chen@intel.com
State Accepted
Commit 478d97f3034fd7c0e1d8a1068b649e8fcc16f82f
Headers show
Series [FFmpeg-devel,1/2] libavfilter/dnn_backend_openvino: Check bbox's height | 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 April 2, 2024, 8:13 a.m. UTC
From: Wenbin Chen <wenbin.chen@intel.com>

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 libavfilter/dnn/dnn_io_proc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Guo, Yejun April 4, 2024, 7:04 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: Tuesday, April 2, 2024 4:13 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH 2/2] libavfilter/dnn_io_proc: Take step into
> consideration when crop frame
> 
> From: Wenbin Chen <wenbin.chen@intel.com>
> 
> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> ---
>  libavfilter/dnn/dnn_io_proc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c
> index e5d6edb301..d2ec9f63f5 100644
> --- a/libavfilter/dnn/dnn_io_proc.c
> +++ b/libavfilter/dnn/dnn_io_proc.c
> @@ -350,6 +350,7 @@ int ff_frame_to_dnn_classify(AVFrame *frame,
> DNNData *input, uint32_t bbox_index
>      const AVDetectionBBoxHeader *header;
>      const AVDetectionBBox *bbox;
>      AVFrameSideData *sd = av_frame_get_side_data(frame,
> AV_FRAME_DATA_DETECTION_BBOXES);
> +    int max_step[4] = { 0 };
>      av_assert0(sd);
> 
>      /* (scale != 1 and scale != 0) or mean != 0 */ @@ -405,8 +406,9 @@ int
> ff_frame_to_dnn_classify(AVFrame *frame, DNNData *input, uint32_t
> bbox_index
>      offsety[1] = offsety[2] = AV_CEIL_RSHIFT(top, desc->log2_chroma_h);
>      offsety[0] = offsety[3] = top;
> 
> +    av_image_fill_max_pixsteps(max_step, NULL, desc);
>      for (int k = 0; frame->data[k]; k++)
> -        bbox_data[k] = frame->data[k] + offsety[k] * frame->linesize[k] +
> offsetx[k];
> +        bbox_data[k] = frame->data[k] + offsety[k] * frame->linesize[k]
> + + offsetx[k] * max_step[k];
> 
>      sws_scale(sws_ctx, (const uint8_t *const *)&bbox_data, frame->linesize,
>                         0, height,

Thanks for the catch, will push soon.
diff mbox series

Patch

diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c
index e5d6edb301..d2ec9f63f5 100644
--- a/libavfilter/dnn/dnn_io_proc.c
+++ b/libavfilter/dnn/dnn_io_proc.c
@@ -350,6 +350,7 @@  int ff_frame_to_dnn_classify(AVFrame *frame, DNNData *input, uint32_t bbox_index
     const AVDetectionBBoxHeader *header;
     const AVDetectionBBox *bbox;
     AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DETECTION_BBOXES);
+    int max_step[4] = { 0 };
     av_assert0(sd);
 
     /* (scale != 1 and scale != 0) or mean != 0 */
@@ -405,8 +406,9 @@  int ff_frame_to_dnn_classify(AVFrame *frame, DNNData *input, uint32_t bbox_index
     offsety[1] = offsety[2] = AV_CEIL_RSHIFT(top, desc->log2_chroma_h);
     offsety[0] = offsety[3] = top;
 
+    av_image_fill_max_pixsteps(max_step, NULL, desc);
     for (int k = 0; frame->data[k]; k++)
-        bbox_data[k] = frame->data[k] + offsety[k] * frame->linesize[k] + offsetx[k];
+        bbox_data[k] = frame->data[k] + offsety[k] * frame->linesize[k] + offsetx[k] * max_step[k];
 
     sws_scale(sws_ctx, (const uint8_t *const *)&bbox_data, frame->linesize,
                        0, height,