Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
b81a1c5b
Commit
b81a1c5b
authored
Aug 30, 2019
by
Maxime Jourdan
Committed by
Aman Gupta
Sep 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/v4l2_context: set frame SAR using VIDIOC_CROPCAP
Signed-off-by:
Aman Gupta
<
aman@tmm1.net
>
parent
0085c4d4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletion
+23
-1
v4l2_buffers.c
libavcodec/v4l2_buffers.c
+2
-1
v4l2_context.c
libavcodec/v4l2_context.c
+20
-0
v4l2_context.h
libavcodec/v4l2_context.h
+1
-0
No files found.
libavcodec/v4l2_buffers.c
View file @
b81a1c5b
...
@@ -428,9 +428,10 @@ int ff_v4l2_buffer_buf_to_avframe(AVFrame *frame, V4L2Buffer *avbuf)
...
@@ -428,9 +428,10 @@ int ff_v4l2_buffer_buf_to_avframe(AVFrame *frame, V4L2Buffer *avbuf)
frame
->
pts
=
v4l2_get_pts
(
avbuf
);
frame
->
pts
=
v4l2_get_pts
(
avbuf
);
frame
->
pkt_dts
=
AV_NOPTS_VALUE
;
frame
->
pkt_dts
=
AV_NOPTS_VALUE
;
/* these
two
values are updated also during re-init in v4l2_process_driver_event */
/* these values are updated also during re-init in v4l2_process_driver_event */
frame
->
height
=
avbuf
->
context
->
height
;
frame
->
height
=
avbuf
->
context
->
height
;
frame
->
width
=
avbuf
->
context
->
width
;
frame
->
width
=
avbuf
->
context
->
width
;
frame
->
sample_aspect_ratio
=
avbuf
->
context
->
sample_aspect_ratio
;
/* 3. report errors upstream */
/* 3. report errors upstream */
if
(
avbuf
->
buf
.
flags
&
V4L2_BUF_FLAG_ERROR
)
{
if
(
avbuf
->
buf
.
flags
&
V4L2_BUF_FLAG_ERROR
)
{
...
...
libavcodec/v4l2_context.c
View file @
b81a1c5b
...
@@ -63,6 +63,24 @@ static inline unsigned int v4l2_get_height(struct v4l2_format *fmt)
...
@@ -63,6 +63,24 @@ static inline unsigned int v4l2_get_height(struct v4l2_format *fmt)
return
V4L2_TYPE_IS_MULTIPLANAR
(
fmt
->
type
)
?
fmt
->
fmt
.
pix_mp
.
height
:
fmt
->
fmt
.
pix
.
height
;
return
V4L2_TYPE_IS_MULTIPLANAR
(
fmt
->
type
)
?
fmt
->
fmt
.
pix_mp
.
height
:
fmt
->
fmt
.
pix
.
height
;
}
}
static
AVRational
v4l2_get_sar
(
V4L2Context
*
ctx
)
{
struct
AVRational
sar
=
{
0
,
1
};
struct
v4l2_cropcap
cropcap
;
int
ret
;
memset
(
&
cropcap
,
0
,
sizeof
(
cropcap
));
cropcap
.
type
=
ctx
->
type
;
ret
=
ioctl
(
ctx_to_m2mctx
(
ctx
)
->
fd
,
VIDIOC_CROPCAP
,
&
cropcap
);
if
(
ret
)
return
sar
;
sar
.
num
=
cropcap
.
pixelaspect
.
numerator
;
sar
.
den
=
cropcap
.
pixelaspect
.
denominator
;
return
sar
;
}
static
inline
unsigned
int
v4l2_resolution_changed
(
V4L2Context
*
ctx
,
struct
v4l2_format
*
fmt2
)
static
inline
unsigned
int
v4l2_resolution_changed
(
V4L2Context
*
ctx
,
struct
v4l2_format
*
fmt2
)
{
{
struct
v4l2_format
*
fmt1
=
&
ctx
->
format
;
struct
v4l2_format
*
fmt1
=
&
ctx
->
format
;
...
@@ -172,12 +190,14 @@ static int v4l2_handle_event(V4L2Context *ctx)
...
@@ -172,12 +190,14 @@ static int v4l2_handle_event(V4L2Context *ctx)
if
(
full_reinit
)
{
if
(
full_reinit
)
{
s
->
output
.
height
=
v4l2_get_height
(
&
out_fmt
);
s
->
output
.
height
=
v4l2_get_height
(
&
out_fmt
);
s
->
output
.
width
=
v4l2_get_width
(
&
out_fmt
);
s
->
output
.
width
=
v4l2_get_width
(
&
out_fmt
);
s
->
output
.
sample_aspect_ratio
=
v4l2_get_sar
(
&
s
->
output
);
}
}
reinit
=
v4l2_resolution_changed
(
&
s
->
capture
,
&
cap_fmt
);
reinit
=
v4l2_resolution_changed
(
&
s
->
capture
,
&
cap_fmt
);
if
(
reinit
)
{
if
(
reinit
)
{
s
->
capture
.
height
=
v4l2_get_height
(
&
cap_fmt
);
s
->
capture
.
height
=
v4l2_get_height
(
&
cap_fmt
);
s
->
capture
.
width
=
v4l2_get_width
(
&
cap_fmt
);
s
->
capture
.
width
=
v4l2_get_width
(
&
cap_fmt
);
s
->
capture
.
sample_aspect_ratio
=
v4l2_get_sar
(
&
s
->
capture
);
}
}
if
(
full_reinit
||
reinit
)
if
(
full_reinit
||
reinit
)
...
...
libavcodec/v4l2_context.h
View file @
b81a1c5b
...
@@ -69,6 +69,7 @@ typedef struct V4L2Context {
...
@@ -69,6 +69,7 @@ typedef struct V4L2Context {
* or accepts (in case of an output context, e.g. when encoding).
* or accepts (in case of an output context, e.g. when encoding).
*/
*/
int
width
,
height
;
int
width
,
height
;
AVRational
sample_aspect_ratio
;
/**
/**
* Indexed array of V4L2Buffers
* Indexed array of V4L2Buffers
...
...
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