mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
v4l2: prefer "framerate_q" over "fps" in v4l2_set_parameters()
The variable is used for containing the parsed value of framerate, using a lexically consistent name eases readability/understanding. Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
parent
a5351720cc
commit
e60068baeb
@ -455,11 +455,11 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap)
|
|||||||
struct v4l2_streamparm streamparm = { 0 };
|
struct v4l2_streamparm streamparm = { 0 };
|
||||||
struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe;
|
struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
AVRational fps;
|
AVRational framerate_q;
|
||||||
|
|
||||||
streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
|
|
||||||
if (s->framerate && (ret = av_parse_video_rate(&fps, s->framerate)) < 0) {
|
if (s->framerate && (ret = av_parse_video_rate(&framerate_q, s->framerate)) < 0) {
|
||||||
av_log(s1, AV_LOG_ERROR, "Couldn't parse framerate.\n");
|
av_log(s1, AV_LOG_ERROR, "Couldn't parse framerate.\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -467,7 +467,7 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap)
|
|||||||
if (ap->channel > 0)
|
if (ap->channel > 0)
|
||||||
s->channel = ap->channel;
|
s->channel = ap->channel;
|
||||||
if (ap->time_base.num)
|
if (ap->time_base.num)
|
||||||
fps = (AVRational){ap->time_base.den, ap->time_base.num};
|
framerate_q = (AVRational){ap->time_base.den, ap->time_base.num};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* set tv video input */
|
/* set tv video input */
|
||||||
@ -520,23 +520,23 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fps.num && fps.den) {
|
if (framerate_q.num && framerate_q.den) {
|
||||||
av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n",
|
av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n",
|
||||||
fps.den, fps.num);
|
framerate_q.den, framerate_q.num);
|
||||||
tpf->numerator = fps.den;
|
tpf->numerator = framerate_q.den;
|
||||||
tpf->denominator = fps.num;
|
tpf->denominator = framerate_q.num;
|
||||||
if (ioctl(s->fd, VIDIOC_S_PARM, &streamparm) != 0) {
|
if (ioctl(s->fd, VIDIOC_S_PARM, &streamparm) != 0) {
|
||||||
av_log(s1, AV_LOG_ERROR,
|
av_log(s1, AV_LOG_ERROR,
|
||||||
"ioctl set time per frame(%d/%d) failed\n",
|
"ioctl set time per frame(%d/%d) failed\n",
|
||||||
fps.den, fps.num);
|
framerate_q.den, framerate_q.num);
|
||||||
return AVERROR(EIO);
|
return AVERROR(EIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fps.num != tpf->denominator ||
|
if (framerate_q.num != tpf->denominator ||
|
||||||
fps.den != tpf->numerator) {
|
framerate_q.den != tpf->numerator) {
|
||||||
av_log(s1, AV_LOG_INFO,
|
av_log(s1, AV_LOG_INFO,
|
||||||
"The driver changed the time per frame from %d/%d to %d/%d\n",
|
"The driver changed the time per frame from %d/%d to %d/%d\n",
|
||||||
fps.den, fps.num,
|
framerate_q.den, framerate_q.num,
|
||||||
tpf->numerator, tpf->denominator);
|
tpf->numerator, tpf->denominator);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user