Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
7b664151
Commit
7b664151
authored
May 08, 2010
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Used CopyFromYv12/Nv12 for vaapi picture extraction.
It also adds the support for NV12.
parent
f10016fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
24 deletions
+41
-24
modules/codec/avcodec/vaapi.c
modules/codec/avcodec/vaapi.c
+41
-24
No files found.
modules/codec/avcodec/vaapi.c
View file @
7b664151
...
...
@@ -39,6 +39,7 @@
#include "avcodec.h"
#include "va.h"
#include "copy.h"
#ifdef HAVE_AVCODEC_VAAPI
...
...
@@ -82,6 +83,7 @@ typedef struct
vlc_va_surface_t
*
p_surface
;
VAImage
image
;
copy_cache_t
image_cache
;
}
vlc_va_vaapi_t
;
...
...
@@ -172,7 +174,10 @@ error:
static
void
DestroySurfaces
(
vlc_va_vaapi_t
*
p_va
)
{
if
(
p_va
->
image
.
image_id
)
{
CopyCleanCache
(
&
p_va
->
image_cache
);
vaDestroyImage
(
p_va
->
p_display
,
p_va
->
image
.
image_id
);
}
if
(
p_va
->
i_context_id
)
vaDestroyContext
(
p_va
->
p_display
,
p_va
->
i_context_id
);
...
...
@@ -248,17 +253,13 @@ static int CreateSurfaces( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fourcc_t
for
(
int
i
=
0
;
i
<
i_fmt_count
;
i
++
)
{
if
(
p_fmt
[
i
].
fourcc
==
VA_FOURCC
(
'Y'
,
'V'
,
'1'
,
'2'
)
||
p_fmt
[
i
].
fourcc
==
VA_FOURCC
(
'I'
,
'4'
,
'2'
,
'0'
)
)
p_fmt
[
i
].
fourcc
==
VA_FOURCC
(
'I'
,
'4'
,
'2'
,
'0'
)
||
p_fmt
[
i
].
fourcc
==
VA_FOURCC
(
'N'
,
'V'
,
'1'
,
'2'
)
)
{
i_chroma
=
VLC_
FOURCC
(
'I'
,
'4'
,
'2'
,
'0'
)
;
i_chroma
=
VLC_
CODEC_YV12
;
fmt
=
p_fmt
[
i
];
break
;
}
/* TODO: It seems that these may also be available (but not
* with my setup):
* VA_FOURCC( 'N', 'V', '1', '2')
* VA_FOURCC( 'U', 'Y', 'V', 'Y')
* VA_FOURCC( 'Y', 'U', 'Y', 'V')
*/
}
free
(
p_fmt
);
if
(
!
i_chroma
)
...
...
@@ -271,6 +272,7 @@ static int CreateSurfaces( vlc_va_vaapi_t *p_va, void **pp_hw_ctx, vlc_fourcc_t
p_va
->
image
.
image_id
=
0
;
goto
error
;
}
CopyInitCache
(
&
p_va
->
image_cache
,
i_width
);
/* Setup the ffmpeg hardware context */
*
pp_hw_ctx
=
&
p_va
->
hw_ctx
;
...
...
@@ -318,6 +320,9 @@ static int Extract( vlc_va_t *p_external, picture_t *p_picture, AVFrame *p_ff )
{
vlc_va_vaapi_t
*
p_va
=
vlc_va_vaapi_Get
(
p_external
);
if
(
!
p_va
->
image_cache
.
buffer
)
return
VLC_EGENERIC
;
VASurfaceID
i_surface_id
=
(
VASurfaceID
)(
uintptr_t
)
p_ff
->
data
[
3
];
#if VA_CHECK_VERSION(0,31,0)
...
...
@@ -340,28 +345,40 @@ static int Extract( vlc_va_t *p_external, picture_t *p_picture, AVFrame *p_ff )
if
(
vaMapBuffer
(
p_va
->
p_display
,
p_va
->
image
.
buf
,
&
p_base
)
)
return
VLC_EGENERIC
;
for
(
int
i_plane
=
0
;
i_plane
<
p_picture
->
i_planes
;
i_plane
++
)
const
uint32_t
i_fourcc
=
p_va
->
image
.
format
.
fourcc
;
if
(
i_fourcc
==
VA_FOURCC
(
'Y'
,
'V'
,
'1'
,
'2'
)
||
i_fourcc
==
VA_FOURCC
(
'I'
,
'4'
,
'2'
,
'0'
)
)
{
const
int
i_src_plane
=
((
p_va
->
image
.
format
.
fourcc
==
VA_FOURCC
(
'Y'
,
'V'
,
'1'
,
'2'
))
&&
i_plane
!=
0
)
?
(
3
-
i_plane
)
:
i_plane
;
const
uint8_t
*
p_src
=
(
uint8_t
*
)
p_base
+
p_va
->
image
.
offsets
[
i_src_plane
];
const
int
i_src_stride
=
p_va
->
image
.
pitches
[
i_src_plane
];
bool
b_swap_uv
=
i_fourcc
==
VA_FOURCC
(
'I'
,
'4'
,
'2'
,
'0'
)
;
uint8_t
*
pp_plane
[
3
];
size_t
pi_pitch
[
3
];
uint8_t
*
p_dst
=
p_picture
->
p
[
i_plane
].
p_pixels
;
const
int
i_dst_stride
=
p_picture
->
p
[
i_plane
].
i_pitch
;
if
(
i_src_stride
!=
i_dst_stride
)
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
for
(
int
i
=
0
;
i
<
p_picture
->
p
[
i_plane
].
i_visible_lines
;
i
++
)
{
vlc_memcpy
(
p_dst
,
p_src
,
__MIN
(
i_src_stride
,
i_dst_stride
)
);
p_src
+=
i_src_stride
;
p_dst
+=
i_dst_stride
;
}
const
int
i_src_plane
=
(
b_swap_uv
&&
i
!=
0
)
?
(
3
-
i
)
:
i
;
pp_plane
[
i
]
=
(
uint8_t
*
)
p_base
+
p_va
->
image
.
offsets
[
i_src_plane
];
pi_pitch
[
i
]
=
p_va
->
image
.
pitches
[
i_src_plane
];
}
else
CopyFromYv12
(
p_picture
,
pp_plane
,
pi_pitch
,
p_va
->
i_surface_width
,
p_va
->
i_surface_height
,
&
p_va
->
image_cache
);
}
else
{
assert
(
i_fourcc
==
VA_FOURCC
(
'N'
,
'V'
,
'1'
,
'2'
)
);
uint8_t
*
pp_plane
[
2
];
size_t
pi_pitch
[
2
];
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
vlc_memcpy
(
p_dst
,
p_src
,
p_picture
->
p
[
i_plane
].
i_visible_lines
*
i_src_stride
);
pp_plane
[
i
]
=
(
uint8_t
*
)
p_base
+
p_va
->
image
.
offsets
[
i
];
pi_pitch
[
i
]
=
p_va
->
image
.
pitches
[
i
];
}
CopyFromNv12
(
p_picture
,
pp_plane
,
pi_pitch
,
p_va
->
i_surface_width
,
p_va
->
i_surface_height
,
&
p_va
->
image_cache
);
}
if
(
vaUnmapBuffer
(
p_va
->
p_display
,
p_va
->
image
.
buf
)
)
...
...
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