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
30cb3147
Commit
30cb3147
authored
Apr 21, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec: pass VA picture from the decoder to the hardware plugin
parent
27dc2eab
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
58 deletions
+41
-58
modules/codec/avcodec/dxva2.c
modules/codec/avcodec/dxva2.c
+6
-6
modules/codec/avcodec/va.h
modules/codec/avcodec/va.h
+11
-12
modules/codec/avcodec/vaapi.c
modules/codec/avcodec/vaapi.c
+8
-6
modules/codec/avcodec/vda.c
modules/codec/avcodec/vda.c
+8
-12
modules/codec/avcodec/video.c
modules/codec/avcodec/video.c
+3
-5
modules/hw/vdpau/avcodec.c
modules/hw/vdpau/avcodec.c
+5
-17
No files found.
modules/codec/avcodec/dxva2.c
View file @
30cb3147
...
...
@@ -380,8 +380,7 @@ ok:
return
VLC_SUCCESS
;
}
static
int
Extract
(
vlc_va_t
*
va
,
picture_t
*
picture
,
void
*
opaque
,
uint8_t
*
data
)
static
int
Extract
(
vlc_va_t
*
va
,
picture_t
*
picture
,
uint8_t
*
data
)
{
vlc_va_sys_t
*
sys
=
va
->
sys
;
LPDIRECT3DSURFACE9
d3d
=
(
LPDIRECT3DSURFACE9
)(
uintptr_t
)
data
;
...
...
@@ -440,12 +439,11 @@ static int Extract(vlc_va_t *va, picture_t *picture, void *opaque,
/* */
IDirect3DSurface9_UnlockRect
(
d3d
);
(
void
)
opaque
;
return
VLC_SUCCESS
;
}
/* FIXME it is nearly common with VAAPI */
static
int
Get
(
vlc_va_t
*
va
,
void
**
opaque
,
uint8_t
**
data
)
static
int
Get
(
vlc_va_t
*
va
,
picture_t
*
pic
,
uint8_t
**
data
)
{
vlc_va_sys_t
*
sys
=
va
->
sys
;
...
...
@@ -479,15 +477,17 @@ static int Get(vlc_va_t *va, void **opaque, uint8_t **data)
surface
->
refcount
=
1
;
surface
->
order
=
sys
->
surface_order
++
;
*
data
=
(
void
*
)
surface
->
d3d
;
*
opaque
=
surface
;
pic
->
context
=
surface
;
return
VLC_SUCCESS
;
}
static
void
Release
(
void
*
opaque
,
uint8_t
*
data
)
{
vlc_va_surface_t
*
surface
=
opaque
;
picture_t
*
pic
=
opaque
;
vlc_va_surface_t
*
surface
=
pic
->
context
;
surface
->
refcount
--
;
pic
->
context
=
NULL
;
(
void
)
data
;
}
...
...
modules/codec/avcodec/va.h
View file @
30cb3147
...
...
@@ -38,9 +38,9 @@ struct vlc_va_t {
int
pix_fmt
;
int
(
*
setup
)(
vlc_va_t
*
,
AVCodecContext
*
,
vlc_fourcc_t
*
output
);
int
(
*
get
)(
vlc_va_t
*
,
void
**
opaque
,
uint8_t
**
data
);
void
(
*
release
)(
void
*
opaque
,
uint8_t
*
surface
);
int
(
*
extract
)(
vlc_va_t
*
,
picture_t
*
dst
,
void
*
opaque
,
uint8_t
*
data
);
int
(
*
get
)(
vlc_va_t
*
,
picture_t
*
pic
,
uint8_t
**
data
);
void
(
*
release
)(
void
*
pic
,
uint8_t
*
surface
);
int
(
*
extract
)(
vlc_va_t
*
,
picture_t
*
pic
,
uint8_t
*
data
);
};
/**
...
...
@@ -68,7 +68,7 @@ static inline int vlc_va_Setup(vlc_va_t *va, AVCodecContext *avctx,
* The surface will be used as output for the hardware decoder, and possibly
* also as a reference frame to decode other surfaces.
*
* @param
opaque pointer to storage space for surface internal data [
OUT]
* @param
pic pointer to VLC picture being allocated [IN/
OUT]
* @param data pointer to the AVFrame data[0] and data[3] pointers [OUT]
*
* @note This function needs not be reentrant. However it may be called
...
...
@@ -77,25 +77,25 @@ static inline int vlc_va_Setup(vlc_va_t *va, AVCodecContext *avctx,
*
* @return VLC_SUCCESS on success, otherwise an error code.
*/
static
inline
int
vlc_va_Get
(
vlc_va_t
*
va
,
void
**
opaque
,
uint8_t
**
data
)
static
inline
int
vlc_va_Get
(
vlc_va_t
*
va
,
picture_t
*
pic
,
uint8_t
**
data
)
{
return
va
->
get
(
va
,
opaque
,
data
);
return
va
->
get
(
va
,
pic
,
data
);
}
/**
* Releases a hardware surface from a libavcodec frame.
* The surface has been previously allocated with vlc_va_Get().
*
* @param
opaque opaque data pointer of the AVFrame set by vlc_va_Get()
* @param
pic VLC picture being released [IN/OUT]
* @param data data[0] pointer of the AVFrame set by vlc_va_Get()
*
* @note This function needs not be reentrant. However it may be called
* concurrently with vlc_va_Get() and/or vlc_va_Extract() from other threads
* and other frames.
*/
static
inline
void
vlc_va_Release
(
vlc_va_t
*
va
,
void
*
opaque
,
uint8_t
*
data
)
static
inline
void
vlc_va_Release
(
vlc_va_t
*
va
,
picture_t
*
pic
,
uint8_t
*
data
)
{
va
->
release
(
opaque
,
data
);
va
->
release
(
pic
,
data
);
}
/**
...
...
@@ -108,10 +108,9 @@ static inline void vlc_va_Release(vlc_va_t *va, void *opaque, uint8_t *data)
* @note This function needs not be reentrant, but it may run concurrently with
* vlc_va_Get() or vlc_va_Release() in other threads (with distinct frames).
*/
static
inline
int
vlc_va_Extract
(
vlc_va_t
*
va
,
picture_t
*
dst
,
void
*
opaque
,
uint8_t
*
data
)
static
inline
int
vlc_va_Extract
(
vlc_va_t
*
va
,
picture_t
*
pic
,
uint8_t
*
data
)
{
return
va
->
extract
(
va
,
dst
,
opaque
,
data
);
return
va
->
extract
(
va
,
pic
,
data
);
}
/**
...
...
modules/codec/avcodec/vaapi.c
View file @
30cb3147
...
...
@@ -30,6 +30,7 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_fourcc.h>
#include <vlc_picture.h>
#ifdef VLC_VA_BACKEND_XLIB
# include <vlc_xlib.h>
...
...
@@ -272,8 +273,7 @@ error:
return
VLC_EGENERIC
;
}
static
int
Extract
(
vlc_va_t
*
va
,
picture_t
*
p_picture
,
void
*
opaque
,
uint8_t
*
data
)
static
int
Extract
(
vlc_va_t
*
va
,
picture_t
*
p_picture
,
uint8_t
*
data
)
{
vlc_va_sys_t
*
sys
=
va
->
sys
;
VASurfaceID
i_surface_id
=
(
VASurfaceID
)(
uintptr_t
)
data
;
...
...
@@ -346,11 +346,10 @@ static int Extract( vlc_va_t *va, picture_t *p_picture, void *opaque,
vaDestroyImage
(
sys
->
p_display
,
sys
->
image
.
image_id
);
sys
->
image
.
image_id
=
VA_INVALID_ID
;
}
(
void
)
opaque
;
return
VLC_SUCCESS
;
}
static
int
Get
(
vlc_va_t
*
va
,
void
**
opaque
,
uint8_t
**
data
)
static
int
Get
(
vlc_va_t
*
va
,
picture_t
*
pic
,
uint8_t
**
data
)
{
vlc_va_sys_t
*
sys
=
va
->
sys
;
int
i_old
;
...
...
@@ -377,18 +376,21 @@ static int Get( vlc_va_t *va, void **opaque, uint8_t **data )
p_surface
->
i_refcount
=
1
;
p_surface
->
i_order
=
sys
->
i_surface_order
++
;
pic
->
context
=
p_surface
;
*
data
=
(
void
*
)(
uintptr_t
)
p_surface
->
i_id
;
*
opaque
=
p_surface
;
return
VLC_SUCCESS
;
}
static
void
Release
(
void
*
opaque
,
uint8_t
*
data
)
{
vlc_va_surface_t
*
p_surface
=
opaque
;
picture_t
*
pic
=
opaque
;
vlc_va_surface_t
*
p_surface
=
pic
->
context
;
vlc_mutex_lock
(
p_surface
->
p_lock
);
p_surface
->
i_refcount
--
;
vlc_mutex_unlock
(
p_surface
->
p_lock
);
pic
->
context
=
NULL
;
(
void
)
data
;
}
...
...
modules/codec/avcodec/vda.c
View file @
30cb3147
...
...
@@ -47,8 +47,8 @@
static
int
Open
(
vlc_va_t
*
,
AVCodecContext
*
,
const
es_format_t
*
);
static
void
Close
(
vlc_va_t
*
,
AVCodecContext
*
);
static
int
Setup
(
vlc_va_t
*
,
AVCodecContext
*
,
vlc_fourcc_t
*
);
static
int
Get
(
vlc_va_t
*
,
void
*
*
,
uint8_t
**
);
static
int
Extract
(
vlc_va_t
*
,
picture_t
*
,
void
*
,
uint8_t
*
);
static
int
Get
(
vlc_va_t
*
,
picture_t
*
,
uint8_t
**
);
static
int
Extract
(
vlc_va_t
*
,
picture_t
*
,
uint8_t
*
);
static
void
Release
(
void
*
,
uint8_t
*
);
static
void
vda_Copy422YpCbCr8
(
picture_t
*
p_pic
,
...
...
@@ -256,17 +256,16 @@ static void vda_Copy420YpCbCr8Planar( picture_t *p_pic,
CVPixelBufferUnlockBaseAddress
(
buffer
,
0
);
}
static
int
Get
(
vlc_va_t
*
va
,
void
**
opaque
,
uint8_t
**
data
)
static
int
Get
(
vlc_va_t
*
va
,
picture_t
*
pic
,
uint8_t
**
data
)
{
VLC_UNUSED
(
va
);
(
void
)
pic
;
*
data
=
(
uint8_t
*
)
1
;
// dummy
(
void
)
opaque
;
return
VLC_SUCCESS
;
}
static
int
Extract
(
vlc_va_t
*
va
,
picture_t
*
p_picture
,
void
*
opaque
,
uint8_t
*
data
)
static
int
Extract
(
vlc_va_t
*
va
,
picture_t
*
p_picture
,
uint8_t
*
data
)
{
vlc_va_vda_t
*
p_vda
=
vlc_va_vda_Get
(
va
);
CVPixelBufferRef
cv_buffer
=
(
CVPixelBufferRef
)
data
;
...
...
@@ -297,7 +296,6 @@ static int Extract( vlc_va_t *va, picture_t *p_picture, void *opaque,
}
else
vda_Copy422YpCbCr8
(
p_picture
,
cv_buffer
);
(
void
)
opaque
;
return
VLC_SUCCESS
;
}
...
...
@@ -357,16 +355,15 @@ static int Setup( vlc_va_t *va, AVCodecContext *avctx, vlc_fourcc_t *p_chroma )
}
// Never called
static
int
Get
(
vlc_va_t
*
va
,
void
**
opaqu
e
,
uint8_t
**
data
)
static
int
Get
(
vlc_va_t
*
va
,
picture_t
*
p_pictur
e
,
uint8_t
**
data
)
{
VLC_UNUSED
(
va
);
(
void
)
p_picture
;
(
void
)
data
;
(
void
)
opaque
;
return
VLC_SUCCESS
;
}
static
int
Extract
(
vlc_va_t
*
va
,
picture_t
*
p_picture
,
void
*
opaque
,
uint8_t
*
data
)
static
int
Extract
(
vlc_va_t
*
va
,
picture_t
*
p_picture
,
uint8_t
*
data
)
{
CVPixelBufferRef
cv_buffer
=
(
CVPixelBufferRef
)
data
;
...
...
@@ -383,7 +380,6 @@ static int Extract( vlc_va_t *va, picture_t *p_picture, void *opaque,
vda_Copy422YpCbCr8
(
p_picture
,
cv_buffer
);
(
void
)
opaque
;
return
VLC_SUCCESS
;
}
...
...
modules/codec/avcodec/video.c
View file @
30cb3147
...
...
@@ -88,7 +88,6 @@ typedef struct
{
vlc_va_t
*
va
;
picture_t
*
pic
;
void
*
opaque
;
}
lavc_va_picture_t
;
#ifdef HAVE_AVCODEC_MT
...
...
@@ -813,8 +812,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
lavc_va_picture_t
*
vapic
=
p_sys
->
p_ff_pic
->
opaque
;
p_pic
=
vapic
->
pic
;
vlc_va_Extract
(
p_sys
->
p_va
,
p_pic
,
vapic
->
opaque
,
p_sys
->
p_ff_pic
->
data
[
3
]
);
vlc_va_Extract
(
p_sys
->
p_va
,
p_pic
,
p_sys
->
p_ff_pic
->
data
[
3
]
);
picture_Hold
(
p_pic
);
}
else
...
...
@@ -965,7 +963,7 @@ static void lavc_va_ReleaseFrame(void *opaque, uint8_t *data)
{
lavc_va_picture_t
*
vapic
=
opaque
;
vlc_va_Release
(
vapic
->
va
,
vapic
->
opaque
,
data
);
vlc_va_Release
(
vapic
->
va
,
vapic
->
pic
,
data
);
picture_Release
(
vapic
->
pic
);
free
(
vapic
);
}
...
...
@@ -990,7 +988,7 @@ static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame,
vapic
->
va
=
va
;
vapic
->
pic
=
pic
;
if
(
vlc_va_Get
(
va
,
&
vapic
->
opaque
,
&
frame
->
data
[
0
]))
if
(
vlc_va_Get
(
va
,
pic
,
&
frame
->
data
[
0
]))
{
msg_Err
(
dec
,
"hardware acceleration picture allocation failed"
);
picture_Release
(
pic
);
...
...
modules/hw/vdpau/avcodec.c
View file @
30cb3147
...
...
@@ -127,7 +127,7 @@ static vlc_vdp_video_field_t *GetSurface(vlc_va_t *va)
return
CreateSurface
(
va
);
}
static
int
Lock
(
vlc_va_t
*
va
,
void
**
opaque
,
uint8_t
**
data
)
static
int
Lock
(
vlc_va_t
*
va
,
picture_t
*
pic
,
uint8_t
**
data
)
{
vlc_vdp_video_field_t
*
field
;
unsigned
tries
=
(
CLOCK_FREQ
+
VOUT_OUTMEM_SLEEP
)
/
VOUT_OUTMEM_SLEEP
;
...
...
@@ -141,31 +141,19 @@ static int Lock(vlc_va_t *va, void **opaque, uint8_t **data)
msleep
(
VOUT_OUTMEM_SLEEP
);
}
*
opaque
=
field
;
pic
->
context
=
field
;
*
data
=
(
void
*
)(
uintptr_t
)
field
->
frame
->
surface
;
return
VLC_SUCCESS
;
}
static
void
Unlock
(
void
*
opaque
,
uint8_t
*
data
)
{
vlc_vdp_video_field_t
*
field
=
opaque
;
DestroySurface
(
field
);
(
void
)
data
;
(
void
)
opaque
;
(
void
)
data
;
}
static
int
Copy
(
vlc_va_t
*
va
,
picture_t
*
pic
,
void
*
opaque
,
uint8_t
*
data
)
static
int
Copy
(
vlc_va_t
*
va
,
picture_t
*
pic
,
uint8_t
*
data
)
{
vlc_vdp_video_field_t
*
field
=
opaque
;
assert
(
field
!=
NULL
);
field
=
vlc_vdp_video_copy
(
field
);
if
(
unlikely
(
field
==
NULL
))
return
VLC_ENOMEM
;
assert
(
pic
->
context
==
NULL
);
pic
->
context
=
field
;
(
void
)
va
;
(
void
)
data
;
(
void
)
va
;
(
void
)
pic
;
(
void
)
data
;
return
VLC_SUCCESS
;
}
...
...
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