aboutsummaryrefslogtreecommitdiffstats
path: root/libavdevice
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2012-01-07 10:59:35 +0100
committerLuca Barbato <lu_zero@gentoo.org>2012-01-10 05:04:22 +0100
commitb6db385922b79939b0dc124d53ddb4824afac040 (patch)
treee3b5873351dab3f2e5b6cc1ac3201a32b5d3d361 /libavdevice
parent0efd48dfd15273a5ac85f2fd42f19d419fafe90d (diff)
downloadffmpeg-b6db385922b79939b0dc124d53ddb4824afac040.tar.gz
v4l2: use C99 struct initializer
Remove some unneeded memsets.
Diffstat (limited to 'libavdevice')
-rw-r--r--libavdevice/v4l2.c58
1 files changed, 25 insertions, 33 deletions
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 2da98728c9..191decde2a 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -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) {