[FFmpeg-devel] avcodec/v4l2_m2m_enc: check for V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME availability before using

Submitted by Aman Gupta on Sept. 13, 2019, 11:31 p.m.

Details

Message ID 20190913233103.46108-1-ffmpeg@tmm1.net
State New
Headers show

Commit Message

Aman Gupta Sept. 13, 2019, 11:31 p.m.
From: Aman Gupta <aman@tmm1.net>

Signed-off-by: Aman Gupta <aman@tmm1.net>
---
 libavcodec/v4l2_m2m_enc.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Guo, Yejun Sept. 15, 2019, 8:43 a.m.
> -----Original Message-----
> From: Aman Gupta [mailto:aman@tmm1.net] On Behalf Of Aman Gupta
> Sent: Saturday, September 14, 2019 7:31 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Guo, Yejun <yejun.guo@intel.com>; Aman Gupta <aman@tmm1.net>
> Subject: [PATCH] avcodec/v4l2_m2m_enc: check for
> V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME availability before using
> 
> From: Aman Gupta <aman@tmm1.net>
> 
> Signed-off-by: Aman Gupta <aman@tmm1.net>
> ---
>  libavcodec/v4l2_m2m_enc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> index 4849bc26c5..474e6bef89 100644
> --- a/libavcodec/v4l2_m2m_enc.c
> +++ b/libavcodec/v4l2_m2m_enc.c
> @@ -245,8 +245,10 @@ static int v4l2_send_frame(AVCodecContext *avctx,
> const AVFrame *frame)
>      V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context;
>      V4L2Context *const output = &s->output;
> 
> +#ifdef V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME
>      if (frame && frame->pict_type == AV_PICTURE_TYPE_I)
>          v4l2_set_ext_ctrl(s, MPEG_CID(FORCE_KEY_FRAME), 0, "force key
> frame");
> +#endif

thanks, the specific build issue is fixed on my system, but I still met other v4l2 build issues on master with this patch.

src/libavcodec/v4l2_m2m_enc.c: In function 'v4l2_set_ext_ctrl':
src/libavcodec/v4l2_m2m_enc.c:51:12: warning: braces around scalar initializer
     struct v4l2_ext_controls ctrls = { { 0 } };
            ^
src/libavcodec/v4l2_m2m_enc.c:51:12: note: (near initialization for 'ctrls.ctrl_class')
src/libavcodec/v4l2_m2m_enc.c: In function 'v4l2_get_ext_ctrl':
src/libavcodec/v4l2_m2m_enc.c:71:12: warning: braces around scalar initializer
     struct v4l2_ext_controls ctrls = { { 0 } };
            ^
src/libavcodec/v4l2_m2m_enc.c:71:12: note: (near initialization for 'ctrls.ctrl_class')
src/libavcodec/v4l2_buffers.c: In function 'v4l2_buffer_swframe_to_buf':
src/libavcodec/v4l2_buffers.c:354:10: error: 'V4L2_PIX_FMT_YUV422M' undeclared (first use in this function)
     case V4L2_PIX_FMT_YUV422M:
          ^
src/libavcodec/v4l2_buffers.c:354:10: note: each undeclared identifier is reported only once for each function it appears in
src/libavcodec/v4l2_buffers.c:355:10: error: 'V4L2_PIX_FMT_YVU422M' undeclared (first use in this function)
     case V4L2_PIX_FMT_YVU422M:
          ^
src/libavcodec/v4l2_buffers.c:356:10: error: 'V4L2_PIX_FMT_YUV444M' undeclared (first use in this function)
     case V4L2_PIX_FMT_YUV444M:
          ^
src/libavcodec/v4l2_buffers.c:357:10: error: 'V4L2_PIX_FMT_YVU444M' undeclared (first use in this function)
     case V4L2_PIX_FMT_YVU444M:
          ^
src/ffbuild/common.mak:59: recipe for target 'libavcodec/v4l2_buffers.o' failed
make: *** [libavcodec/v4l2_buffers.o] Error 1
make: *** Waiting for unfinished jobs....

> 
>      return ff_v4l2_context_enqueue_frame(output, frame);
>  }
> --
> 2.20.1
Michael Niedermayer Sept. 15, 2019, 12:10 p.m.
On Sun, Sep 15, 2019 at 08:43:32AM +0000, Guo, Yejun wrote:
> 
> 
> > -----Original Message-----
> > From: Aman Gupta [mailto:aman@tmm1.net] On Behalf Of Aman Gupta
> > Sent: Saturday, September 14, 2019 7:31 AM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Guo, Yejun <yejun.guo@intel.com>; Aman Gupta <aman@tmm1.net>
> > Subject: [PATCH] avcodec/v4l2_m2m_enc: check for
> > V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME availability before using
> > 
> > From: Aman Gupta <aman@tmm1.net>
> > 
> > Signed-off-by: Aman Gupta <aman@tmm1.net>
> > ---
> >  libavcodec/v4l2_m2m_enc.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> > index 4849bc26c5..474e6bef89 100644
> > --- a/libavcodec/v4l2_m2m_enc.c
> > +++ b/libavcodec/v4l2_m2m_enc.c
> > @@ -245,8 +245,10 @@ static int v4l2_send_frame(AVCodecContext *avctx,
> > const AVFrame *frame)
> >      V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context;
> >      V4L2Context *const output = &s->output;
> > 
> > +#ifdef V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME
> >      if (frame && frame->pict_type == AV_PICTURE_TYPE_I)
> >          v4l2_set_ext_ctrl(s, MPEG_CID(FORCE_KEY_FRAME), 0, "force key
> > frame");
> > +#endif
> 
> thanks, the specific build issue is fixed on my system, but I still met other v4l2 build issues on master with this patch.
> 
> src/libavcodec/v4l2_m2m_enc.c: In function 'v4l2_set_ext_ctrl':
> src/libavcodec/v4l2_m2m_enc.c:51:12: warning: braces around scalar initializer
>      struct v4l2_ext_controls ctrls = { { 0 } };
>             ^
> src/libavcodec/v4l2_m2m_enc.c:51:12: note: (near initialization for 'ctrls.ctrl_class')
> src/libavcodec/v4l2_m2m_enc.c: In function 'v4l2_get_ext_ctrl':
> src/libavcodec/v4l2_m2m_enc.c:71:12: warning: braces around scalar initializer
>      struct v4l2_ext_controls ctrls = { { 0 } };
>             ^
> src/libavcodec/v4l2_m2m_enc.c:71:12: note: (near initialization for 'ctrls.ctrl_class')
> src/libavcodec/v4l2_buffers.c: In function 'v4l2_buffer_swframe_to_buf':
> src/libavcodec/v4l2_buffers.c:354:10: error: 'V4L2_PIX_FMT_YUV422M' undeclared (first use in this function)
>      case V4L2_PIX_FMT_YUV422M:
>           ^
> src/libavcodec/v4l2_buffers.c:354:10: note: each undeclared identifier is reported only once for each function it appears in
> src/libavcodec/v4l2_buffers.c:355:10: error: 'V4L2_PIX_FMT_YVU422M' undeclared (first use in this function)
>      case V4L2_PIX_FMT_YVU422M:
>           ^
> src/libavcodec/v4l2_buffers.c:356:10: error: 'V4L2_PIX_FMT_YUV444M' undeclared (first use in this function)
>      case V4L2_PIX_FMT_YUV444M:
>           ^
> src/libavcodec/v4l2_buffers.c:357:10: error: 'V4L2_PIX_FMT_YVU444M' undeclared (first use in this function)
>      case V4L2_PIX_FMT_YVU444M:
>           ^
> src/ffbuild/common.mak:59: recipe for target 'libavcodec/v4l2_buffers.o' failed
> make: *** [libavcodec/v4l2_buffers.o] Error 1
> make: *** Waiting for unfinished jobs....

ossfuzz also hits these issues
https://oss-fuzz-build-logs.storage.googleapis.com/log-23c6325e-a029-4ee0-8752-b4f573601087.txt

thx

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index 4849bc26c5..474e6bef89 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -245,8 +245,10 @@  static int v4l2_send_frame(AVCodecContext *avctx, const AVFrame *frame)
     V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context;
     V4L2Context *const output = &s->output;
 
+#ifdef V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME
     if (frame && frame->pict_type == AV_PICTURE_TYPE_I)
         v4l2_set_ext_ctrl(s, MPEG_CID(FORCE_KEY_FRAME), 0, "force key frame");
+#endif
 
     return ff_v4l2_context_enqueue_frame(output, frame);
 }