diff mbox series

[FFmpeg-devel] avcodec/v4l2_m2m: fix setting the frame rate

Message ID 20200316020030.27484-1-ming.qian@nxp.com
State Superseded
Headers show
Series [FFmpeg-devel] avcodec/v4l2_m2m: fix setting the frame rate
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Ming Qian March 16, 2020, 2 a.m. UTC
v4l2 set the frame rate through frame intervals,
not set frame rate directly.
the frame rate and frame intervals are reciprocal.
so in libavdevice/v4l2.c we can see the following code:
	tpf->numerator   = framerate_q.den;
	tpf->denominator = framerate_q.num;

Signed-off-by: Ming Qian <ming.qian@nxp.com>
---
 libavcodec/v4l2_m2m_enc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Andriy Gelman March 16, 2020, 10:54 p.m. UTC | #1
On Mon, 16. Mar 10:00, Ming Qian wrote:
> v4l2 set the frame rate through frame intervals,
> not set frame rate directly.
> the frame rate and frame intervals are reciprocal.
> so in libavdevice/v4l2.c we can see the following code:
> 	tpf->numerator   = framerate_q.den;
> 	tpf->denominator = framerate_q.num;
> 
> Signed-off-by: Ming Qian <ming.qian@nxp.com>
> ---
>  libavcodec/v4l2_m2m_enc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> index c9f1741bfd..5b954f4435 100644
> --- a/libavcodec/v4l2_m2m_enc.c
> +++ b/libavcodec/v4l2_m2m_enc.c
> @@ -40,8 +40,8 @@ static inline void v4l2_set_timeperframe(V4L2m2mContext *s, unsigned int num, un
>      struct v4l2_streamparm parm = { 0 };
>  
>      parm.type = V4L2_TYPE_IS_MULTIPLANAR(s->output.type) ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : V4L2_BUF_TYPE_VIDEO_OUTPUT;
> -    parm.parm.output.timeperframe.denominator = den;
> -    parm.parm.output.timeperframe.numerator = num;
> +    parm.parm.output.timeperframe.denominator = num;
> +    parm.parm.output.timeperframe.numerator = den;
>  
>      if (ioctl(s->fd, VIDIOC_S_PARM, &parm) < 0)
>          av_log(s->avctx, AV_LOG_WARNING, "Failed to set timeperframe");
> -- 
> 2.25.1
> 

Probably clearer to make the change in the call to the function with:

v4l2_set_timeperframe(s, avctx->framerate.den, avctx->framerate.num);

Otherwise this commit lgtm.

Thanks,
diff mbox series

Patch

diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index c9f1741bfd..5b954f4435 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -40,8 +40,8 @@  static inline void v4l2_set_timeperframe(V4L2m2mContext *s, unsigned int num, un
     struct v4l2_streamparm parm = { 0 };
 
     parm.type = V4L2_TYPE_IS_MULTIPLANAR(s->output.type) ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : V4L2_BUF_TYPE_VIDEO_OUTPUT;
-    parm.parm.output.timeperframe.denominator = den;
-    parm.parm.output.timeperframe.numerator = num;
+    parm.parm.output.timeperframe.denominator = num;
+    parm.parm.output.timeperframe.numerator = den;
 
     if (ioctl(s->fd, VIDIOC_S_PARM, &parm) < 0)
         av_log(s->avctx, AV_LOG_WARNING, "Failed to set timeperframe");