Message ID | 20220104090836.31660-3-ming.qian@nxp.com |
---|---|
State | Accepted |
Commit | 3fc72c9fc16df3b7edc329ed9eeaaa1e65976c33 |
Headers | show |
Series | [FFmpeg-devel,v5,1/7] avcodec/v4l2_context: don't reinit output queue when dynamic resolution change | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_ppc | success | Make finished |
andriy/make_fate_ppc | fail | Make fate failed |
On Tue, 04. Jan 17:08, Ming Qian wrote: > on dynamic resolution change, > The decoding process must be resumed with either a pair of calls to > VIDIOC_STREAMOFF() and VIDIOC_STREAMON() on the CAPTURE queue, or a call > to VIDIOC_DECODER_CMD() with the V4L2_DEC_CMD_START command. > For the patch title, I think something like the following would be better: avcodec/v4l2_context: send start decode command after dynamic resolution change event I'll add that this fixes decoding of https://streams.videolan.org/ffmpeg/incoming/720p60.mp4 on RPi4. > Signed-off-by: Ming Qian <ming.qian@nxp.com> > --- > libavcodec/v4l2_context.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c > index dda5157698c3..a181f884d2a6 100644 > --- a/libavcodec/v4l2_context.c > +++ b/libavcodec/v4l2_context.c > @@ -153,6 +153,21 @@ static inline void v4l2_save_to_context(V4L2Context* ctx, struct v4l2_format_upd > } > } > > +static int v4l2_start_decode(V4L2Context *ctx) > +{ > + struct v4l2_decoder_cmd cmd = { > + .cmd = V4L2_DEC_CMD_START, > + .flags = 0, > + }; > + int ret; > + > + ret = ioctl(ctx_to_m2mctx(ctx)->fd, VIDIOC_DECODER_CMD, &cmd); > + if (ret) > + return AVERROR(errno); > + > + return 0; > +} > + > /** > * handle resolution change event and end of stream event > * returns 1 if reinit was successful, negative if it failed > @@ -190,6 +205,9 @@ static int v4l2_handle_event(V4L2Context *ctx) > s->capture.height = v4l2_get_height(&cap_fmt); > s->capture.width = v4l2_get_width(&cap_fmt); > s->capture.sample_aspect_ratio = v4l2_get_sar(&s->capture); > + } else { > + v4l2_start_decode(ctx); > + return 0; > } > > if (reinit) lgtm otherwise. Thanks
diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c index dda5157698c3..a181f884d2a6 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -153,6 +153,21 @@ static inline void v4l2_save_to_context(V4L2Context* ctx, struct v4l2_format_upd } } +static int v4l2_start_decode(V4L2Context *ctx) +{ + struct v4l2_decoder_cmd cmd = { + .cmd = V4L2_DEC_CMD_START, + .flags = 0, + }; + int ret; + + ret = ioctl(ctx_to_m2mctx(ctx)->fd, VIDIOC_DECODER_CMD, &cmd); + if (ret) + return AVERROR(errno); + + return 0; +} + /** * handle resolution change event and end of stream event * returns 1 if reinit was successful, negative if it failed @@ -190,6 +205,9 @@ static int v4l2_handle_event(V4L2Context *ctx) s->capture.height = v4l2_get_height(&cap_fmt); s->capture.width = v4l2_get_width(&cap_fmt); s->capture.sample_aspect_ratio = v4l2_get_sar(&s->capture); + } else { + v4l2_start_decode(ctx); + return 0; } if (reinit)
on dynamic resolution change, The decoding process must be resumed with either a pair of calls to VIDIOC_STREAMOFF() and VIDIOC_STREAMON() on the CAPTURE queue, or a call to VIDIOC_DECODER_CMD() with the V4L2_DEC_CMD_START command. Signed-off-by: Ming Qian <ming.qian@nxp.com> --- libavcodec/v4l2_context.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)