Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
b6db3859
Commit
b6db3859
authored
Jan 07, 2012
by
Luca Barbato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v4l2: use C99 struct initializer
Remove some unneeded memsets.
parent
0efd48df
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
33 deletions
+25
-33
v4l2.c
libavdevice/v4l2.c
+25
-33
No files found.
libavdevice/v4l2.c
View file @
b6db3859
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment