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
82b5aa0a
Commit
82b5aa0a
authored
May 26, 2011
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v4l2: factorize returning error codes.
This will be useful in the following commit.
parent
fd48620e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
v4l2.c
libavdevice/v4l2.c
+17
-11
No files found.
libavdevice/v4l2.c
View file @
82b5aa0a
...
...
@@ -577,13 +577,14 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
{
struct
video_data
*
s
=
s1
->
priv_data
;
AVStream
*
st
;
int
res
;
int
res
=
0
;
uint32_t
desired_format
,
capabilities
;
enum
CodecID
codec_id
;
st
=
av_new_stream
(
s1
,
0
);
if
(
!
st
)
{
return
AVERROR
(
ENOMEM
);
res
=
AVERROR
(
ENOMEM
);
goto
out
;
}
av_set_pts_info
(
st
,
64
,
1
,
1000000
);
/* 64 bits pts in us */
...
...
@@ -593,7 +594,8 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
capabilities
=
0
;
s
->
fd
=
device_open
(
s1
,
&
capabilities
);
if
(
s
->
fd
<
0
)
{
return
AVERROR
(
EIO
);
res
=
AVERROR
(
EIO
);
goto
out
;
}
av_log
(
s1
,
AV_LOG_VERBOSE
,
"[%d]Capabilities: %x
\n
"
,
s
->
fd
,
capabilities
);
...
...
@@ -604,7 +606,8 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
fmt
.
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
;
if
(
ioctl
(
s
->
fd
,
VIDIOC_G_FMT
,
&
fmt
)
<
0
)
{
av_log
(
s1
,
AV_LOG_ERROR
,
"ioctl(VIDIOC_G_FMT): %s
\n
"
,
strerror
(
errno
));
return
AVERROR
(
errno
);
res
=
AVERROR
(
errno
);
goto
out
;
}
s
->
width
=
fmt
.
fmt
.
pix
.
width
;
s
->
height
=
fmt
.
fmt
.
pix
.
height
;
...
...
@@ -617,14 +620,15 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
"codec_id %d, pix_fmt %d.
\n
"
,
s1
->
video_codec_id
,
ap
->
pix_fmt
);
close
(
s
->
fd
);
return
AVERROR
(
EIO
);
res
=
AVERROR
(
EIO
);
goto
out
;
}
if
(
av_image_check_size
(
s
->
width
,
s
->
height
,
0
,
s1
)
<
0
)
return
AVERROR
(
EINVAL
)
;
if
(
(
res
=
av_image_check_size
(
s
->
width
,
s
->
height
,
0
,
s1
)
<
0
)
)
goto
out
;
s
->
frame_format
=
desired_format
;
if
(
v4l2_set_parameters
(
s1
,
ap
)
<
0
)
return
AVERROR
(
EIO
)
;
if
(
(
res
=
v4l2_set_parameters
(
s1
,
ap
)
<
0
)
)
goto
out
;
st
->
codec
->
pix_fmt
=
fmt_v4l2ff
(
desired_format
,
codec_id
);
s
->
frame_size
=
avpicture_get_size
(
st
->
codec
->
pix_fmt
,
s
->
width
,
s
->
height
);
...
...
@@ -641,7 +645,8 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
if
(
res
<
0
)
{
close
(
s
->
fd
);
return
AVERROR
(
EIO
);
res
=
AVERROR
(
EIO
);
goto
out
;
}
s
->
top_field_first
=
first_field
(
s
->
fd
);
...
...
@@ -653,7 +658,8 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st
->
codec
->
time_base
.
num
=
ap
->
time_base
.
num
;
st
->
codec
->
bit_rate
=
s
->
frame_size
*
1
/
av_q2d
(
st
->
codec
->
time_base
)
*
8
;
return
0
;
out:
return
res
;
}
static
int
v4l2_read_packet
(
AVFormatContext
*
s1
,
AVPacket
*
pkt
)
...
...
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