mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
v4l2: use C99 struct initializer
Remove some unneeded memsets.
This commit is contained in:
parent
0efd48dfd1
commit
b6db385922
@ -169,14 +169,11 @@ static int device_init(AVFormatContext *ctx, int *width, int *height,
|
||||
{
|
||||
struct video_data *s = ctx->priv_data;
|
||||
int fd = s->fd;
|
||||
struct v4l2_format fmt;
|
||||
struct v4l2_format fmt = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
|
||||
struct v4l2_pix_format *pix = &fmt.fmt.pix;
|
||||
|
||||
int res;
|
||||
|
||||
memset(&fmt, 0, sizeof(struct v4l2_format));
|
||||
|
||||
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
pix->width = *width;
|
||||
pix->height = *height;
|
||||
pix->pixelformat = pix_fmt;
|
||||
@ -334,14 +331,14 @@ static void list_formats(AVFormatContext *ctx, int fd, int type)
|
||||
|
||||
static int mmap_init(AVFormatContext *ctx)
|
||||
{
|
||||
struct video_data *s = ctx->priv_data;
|
||||
struct v4l2_requestbuffers req;
|
||||
int i, res;
|
||||
struct video_data *s = ctx->priv_data;
|
||||
struct v4l2_requestbuffers req = {
|
||||
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
|
||||
.count = desired_video_buffers,
|
||||
.memory = V4L2_MEMORY_MMAP
|
||||
};
|
||||
|
||||
memset(&req, 0, sizeof(struct v4l2_requestbuffers));
|
||||
req.count = desired_video_buffers;
|
||||
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
req.memory = V4L2_MEMORY_MMAP;
|
||||
res = ioctl(s->fd, VIDIOC_REQBUFS, &req);
|
||||
if (res < 0) {
|
||||
if (errno == EINVAL) {
|
||||
@ -374,12 +371,12 @@ static int mmap_init(AVFormatContext *ctx)
|
||||
}
|
||||
|
||||
for (i = 0; i < req.count; i++) {
|
||||
struct v4l2_buffer buf;
|
||||
struct v4l2_buffer buf = {
|
||||
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
|
||||
.index = i,
|
||||
.memory = V4L2_MEMORY_MMAP
|
||||
};
|
||||
|
||||
memset(&buf, 0, sizeof(struct v4l2_buffer));
|
||||
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
buf.memory = V4L2_MEMORY_MMAP;
|
||||
buf.index = i;
|
||||
res = ioctl(s->fd, VIDIOC_QUERYBUF, &buf);
|
||||
if (res < 0) {
|
||||
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYBUF)\n");
|
||||
@ -411,14 +408,13 @@ static int mmap_init(AVFormatContext *ctx)
|
||||
|
||||
static void mmap_release_buffer(AVPacket *pkt)
|
||||
{
|
||||
struct v4l2_buffer buf;
|
||||
struct v4l2_buffer buf = { 0 };
|
||||
int res, fd;
|
||||
struct buff_data *buf_descriptor = pkt->priv;
|
||||
|
||||
if (pkt->data == NULL)
|
||||
return;
|
||||
|
||||
memset(&buf, 0, sizeof(struct v4l2_buffer));
|
||||
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
buf.memory = V4L2_MEMORY_MMAP;
|
||||
buf.index = buf_descriptor->index;
|
||||
@ -437,15 +433,14 @@ static void mmap_release_buffer(AVPacket *pkt)
|
||||
static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
|
||||
{
|
||||
struct video_data *s = ctx->priv_data;
|
||||
struct v4l2_buffer buf;
|
||||
struct v4l2_buffer buf = {
|
||||
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
|
||||
.memory = V4L2_MEMORY_MMAP
|
||||
};
|
||||
struct buff_data *buf_descriptor;
|
||||
struct pollfd p = { .fd = s->fd, .events = POLLIN };
|
||||
int res;
|
||||
|
||||
memset(&buf, 0, sizeof(struct v4l2_buffer));
|
||||
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
buf.memory = V4L2_MEMORY_MMAP;
|
||||
|
||||
res = poll(&p, 1, s->timeout);
|
||||
if (res < 0)
|
||||
return AVERROR(errno);
|
||||
@ -504,12 +499,11 @@ static int mmap_start(AVFormatContext *ctx)
|
||||
int i, res;
|
||||
|
||||
for (i = 0; i < s->buffers; i++) {
|
||||
struct v4l2_buffer buf;
|
||||
|
||||
memset(&buf, 0, sizeof(struct v4l2_buffer));
|
||||
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
buf.memory = V4L2_MEMORY_MMAP;
|
||||
buf.index = i;
|
||||
struct v4l2_buffer buf = {
|
||||
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
|
||||
.index = i,
|
||||
.memory = V4L2_MEMORY_MMAP
|
||||
};
|
||||
|
||||
res = ioctl(s->fd, VIDIOC_QBUF, &buf);
|
||||
if (res < 0) {
|
||||
@ -552,12 +546,12 @@ static void mmap_close(struct video_data *s)
|
||||
static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap)
|
||||
{
|
||||
struct video_data *s = s1->priv_data;
|
||||
struct v4l2_input input;
|
||||
struct v4l2_standard standard;
|
||||
struct v4l2_input input = { 0 };
|
||||
struct v4l2_standard standard = { 0 };
|
||||
struct v4l2_streamparm streamparm = { 0 };
|
||||
struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe;
|
||||
AVRational framerate_q = { 0 };
|
||||
int i, ret;
|
||||
AVRational framerate_q;
|
||||
|
||||
streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
|
||||
@ -569,7 +563,6 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap)
|
||||
}
|
||||
|
||||
/* set tv video input */
|
||||
memset (&input, 0, sizeof (input));
|
||||
input.index = s->channel;
|
||||
if (ioctl(s->fd, VIDIOC_ENUMINPUT, &input) < 0) {
|
||||
av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl enum input failed:\n");
|
||||
@ -589,7 +582,6 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap)
|
||||
av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s\n",
|
||||
s->standard);
|
||||
/* set tv standard */
|
||||
memset (&standard, 0, sizeof (standard));
|
||||
for(i=0;;i++) {
|
||||
standard.index = i;
|
||||
if (ioctl(s->fd, VIDIOC_ENUMSTD, &standard) < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user