[FFmpeg-devel] [PATCH v3] libavfilter/vf_find_rect: convert the object image to gray8 format instead of failed directly

Michael Niedermayer michael at niedermayer.cc
Sat Jun 8 23:38:15 EEST 2019


On Sat, Jun 08, 2019 at 06:53:58AM +0800, lance.lmwang at gmail.com wrote:
> From: Limin Wang <lance.lmwang at gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
>  libavfilter/vf_find_rect.c | 40 +++++++++++++++++++++++++++-------------
>  1 file changed, 27 insertions(+), 13 deletions(-)
> 
> diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c
> index d7e6579..6fe12fe 100644
> --- a/libavfilter/vf_find_rect.c
> +++ b/libavfilter/vf_find_rect.c
> @@ -28,6 +28,7 @@
>  #include "internal.h"
>  
>  #include "lavfutils.h"
> +#include "lswsutils.h"
>  
>  #define MAX_MIPMAPS 5
>  
> @@ -235,8 +236,6 @@ static av_cold void uninit(AVFilterContext *ctx)
>          av_frame_free(&foc->haystack_frame[i]);
>      }
>  
> -    if (foc->obj_frame)
> -        av_freep(&foc->obj_frame->data[0]);
>      av_frame_free(&foc->obj_frame);
>  }
>  
> @@ -244,6 +243,9 @@ static av_cold int init(AVFilterContext *ctx)
>  {
>      FOCContext *foc = ctx->priv;
>      int ret, i;
> +    uint8_t *tmp_data[4];
> +    int tmp_linesize[4], width, height;
> +    enum AVPixelFormat pix_fmt;
>  
>      if (!foc->obj_filename) {
>          av_log(ctx, AV_LOG_ERROR, "object filename not set\n");
> @@ -254,24 +256,36 @@ static av_cold int init(AVFilterContext *ctx)
>      if (!foc->obj_frame)
>          return AVERROR(ENOMEM);
>  
> -    if ((ret = ff_load_image(foc->obj_frame->data, foc->obj_frame->linesize,
> -                             &foc->obj_frame->width, &foc->obj_frame->height,
> -                             &foc->obj_frame->format, foc->obj_filename, ctx)) < 0)
> -        return ret;
> -
> -    if (foc->obj_frame->format != AV_PIX_FMT_GRAY8) {
> -        av_log(ctx, AV_LOG_ERROR, "object image is not a grayscale image\n");
> -        return AVERROR(EINVAL);
> -    }
> +    if ((ret = ff_load_image(&tmp_data, tmp_linesize,
> +                             &width, &height,
> +                             &pix_fmt, foc->obj_filename, ctx)) < 0)

libavfilter/vf_find_rect.c: In function ‘init’:
libavfilter/vf_find_rect.c:261:30: warning: passing argument 1 of ‘ff_load_image’ from incompatible pointer type [enabled by default]


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190608/2156275b/attachment.sig>


More information about the ffmpeg-devel mailing list