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
9a237055
Commit
9a237055
authored
Apr 23, 2015
by
Steve Lhomme
Committed by
Jean-Baptiste Kempf
Apr 27, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DXVA2: lock the buffer pool when getting/releasing a buffer
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
bff2ef9d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
modules/codec/avcodec/dxva2.c
modules/codec/avcodec/dxva2.c
+15
-0
No files found.
modules/codec/avcodec/dxva2.c
View file @
9a237055
...
@@ -311,6 +311,7 @@ typedef struct {
...
@@ -311,6 +311,7 @@ typedef struct {
LPDIRECT3DSURFACE9
d3d
;
LPDIRECT3DSURFACE9
d3d
;
int
refcount
;
int
refcount
;
unsigned
int
order
;
unsigned
int
order
;
vlc_mutex_t
*
p_lock
;
}
vlc_va_surface_t
;
}
vlc_va_surface_t
;
#define VA_DXVA2_MAX_SURFACE_COUNT (64)
#define VA_DXVA2_MAX_SURFACE_COUNT (64)
...
@@ -320,6 +321,8 @@ struct vlc_va_sys_t
...
@@ -320,6 +321,8 @@ struct vlc_va_sys_t
int
width
;
int
width
;
int
height
;
int
height
;
vlc_mutex_t
surface_lock
;
/* DLL */
/* DLL */
HINSTANCE
hd3d9_dll
;
HINSTANCE
hd3d9_dll
;
HINSTANCE
hdxva2_dll
;
HINSTANCE
hdxva2_dll
;
...
@@ -507,6 +510,8 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
...
@@ -507,6 +510,8 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
vlc_mutex_lock
(
&
sys
->
surface_lock
);
/* Grab an unused surface, in case none are, try the oldest
/* Grab an unused surface, in case none are, try the oldest
* XXX using the oldest is a workaround in case a problem happens with libavcodec */
* XXX using the oldest is a workaround in case a problem happens with libavcodec */
unsigned
i
,
old
;
unsigned
i
,
old
;
...
@@ -528,6 +533,9 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
...
@@ -528,6 +533,9 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
surface
->
order
=
sys
->
surface_order
++
;
surface
->
order
=
sys
->
surface_order
++
;
*
data
=
(
void
*
)
surface
->
d3d
;
*
data
=
(
void
*
)
surface
->
d3d
;
pic
->
context
=
surface
;
pic
->
context
=
surface
;
vlc_mutex_unlock
(
&
sys
->
surface_lock
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
@@ -535,11 +543,14 @@ static void Release(void *opaque, uint8_t *data)
...
@@ -535,11 +543,14 @@ static void Release(void *opaque, uint8_t *data)
{
{
picture_t
*
pic
=
opaque
;
picture_t
*
pic
=
opaque
;
vlc_va_surface_t
*
surface
=
pic
->
context
;
vlc_va_surface_t
*
surface
=
pic
->
context
;
vlc_mutex_lock
(
surface
->
p_lock
);
surface
->
refcount
--
;
surface
->
refcount
--
;
pic
->
context
=
NULL
;
pic
->
context
=
NULL
;
picture_Release
(
pic
);
picture_Release
(
pic
);
(
void
)
data
;
(
void
)
data
;
vlc_mutex_unlock
(
surface
->
p_lock
);
}
}
static
void
Close
(
vlc_va_t
*
va
,
AVCodecContext
*
ctx
)
static
void
Close
(
vlc_va_t
*
va
,
AVCodecContext
*
ctx
)
...
@@ -557,6 +568,7 @@ static void Close(vlc_va_t *va, AVCodecContext *ctx)
...
@@ -557,6 +568,7 @@ static void Close(vlc_va_t *va, AVCodecContext *ctx)
FreeLibrary
(
sys
->
hdxva2_dll
);
FreeLibrary
(
sys
->
hdxva2_dll
);
if
(
sys
->
hd3d9_dll
)
if
(
sys
->
hd3d9_dll
)
FreeLibrary
(
sys
->
hd3d9_dll
);
FreeLibrary
(
sys
->
hd3d9_dll
);
vlc_mutex_destroy
(
&
sys
->
surface_lock
);
free
((
char
*
)
va
->
description
);
free
((
char
*
)
va
->
description
);
free
(
sys
);
free
(
sys
);
...
@@ -575,6 +587,8 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
...
@@ -575,6 +587,8 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
va
->
sys
=
sys
;
va
->
sys
=
sys
;
sys
->
codec_id
=
ctx
->
codec_id
;
sys
->
codec_id
=
ctx
->
codec_id
;
vlc_mutex_init
(
&
sys
->
surface_lock
);
/* Load dll*/
/* Load dll*/
sys
->
hd3d9_dll
=
LoadLibrary
(
TEXT
(
"D3D9.DLL"
));
sys
->
hd3d9_dll
=
LoadLibrary
(
TEXT
(
"D3D9.DLL"
));
if
(
!
sys
->
hd3d9_dll
)
{
if
(
!
sys
->
hd3d9_dll
)
{
...
@@ -1018,6 +1032,7 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
...
@@ -1018,6 +1032,7 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
surface
->
d3d
=
sys
->
hw_surface
[
i
];
surface
->
d3d
=
sys
->
hw_surface
[
i
];
surface
->
refcount
=
0
;
surface
->
refcount
=
0
;
surface
->
order
=
0
;
surface
->
order
=
0
;
surface
->
p_lock
=
&
sys
->
surface_lock
;
}
}
msg_Dbg
(
va
,
"IDirectXVideoAccelerationService_CreateSurface succeed with %d surfaces (%dx%d)"
,
msg_Dbg
(
va
,
"IDirectXVideoAccelerationService_CreateSurface succeed with %d surfaces (%dx%d)"
,
sys
->
surface_count
,
fmt
->
i_width
,
fmt
->
i_height
);
sys
->
surface_count
,
fmt
->
i_width
,
fmt
->
i_height
);
...
...
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