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
f0a14143
Commit
f0a14143
authored
Sep 13, 2014
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vdpau/avcodec: cleanup
parent
b68aa14e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
46 deletions
+39
-46
modules/hw/vdpau/avcodec.c
modules/hw/vdpau/avcodec.c
+39
-46
No files found.
modules/hw/vdpau/avcodec.c
View file @
f0a14143
...
...
@@ -52,10 +52,8 @@ vlc_module_end()
struct
vlc_va_sys_t
{
AVVDPAUContext
*
context
;
vdp_t
*
vdp
;
VdpDevice
device
;
VdpDecoderProfile
profile
;
uint16_t
width
;
uint16_t
height
;
};
...
...
@@ -108,16 +106,34 @@ static int Copy(vlc_va_t *va, picture_t *pic, void *opaque, uint8_t *data)
return
VLC_SUCCESS
;
}
static
int
Init
(
vlc_va_t
*
va
,
AVCodecContext
*
avctx
,
vlc_fourcc_t
*
chromap
)
static
int
Setup
(
vlc_va_t
*
va
,
AVCodecContext
*
avctx
,
vlc_fourcc_t
*
chromap
)
{
vlc_va_sys_t
*
sys
=
va
->
sys
;
AVVDPAUContext
*
hwctx
=
avctx
->
hwaccel_context
;
VdpDecoderProfile
profile
;
VdpStatus
err
;
if
(
hwctx
->
decoder
!=
VDP_INVALID_HANDLE
)
{
if
(
sys
->
width
==
avctx
->
coded_width
&&
sys
->
height
==
avctx
->
coded_height
)
return
VLC_SUCCESS
;
vdp_decoder_destroy
(
sys
->
vdp
,
hwctx
->
decoder
);
hwctx
->
decoder
=
VDP_INVALID_HANDLE
;
}
sys
->
width
=
(
avctx
->
coded_width
+
1
)
&
~
1
;
sys
->
height
=
(
avctx
->
coded_height
+
3
)
&
~
3
;
if
(
av_vdpau_get_profile
(
avctx
,
&
profile
))
{
msg_Err
(
va
,
"no longer supported codec profile"
);
return
VLC_EGENERIC
;
}
unsigned
surfaces
=
2
;
switch
(
sys
->
profile
)
switch
(
profile
)
{
case
VDP_DECODER_PROFILE_H264_BASELINE
:
case
VDP_DECODER_PROFILE_H264_MAIN
:
...
...
@@ -126,60 +142,35 @@ static int Init(vlc_va_t *va, AVCodecContext *avctx, vlc_fourcc_t *chromap)
break
;
}
err
=
vdp_decoder_create
(
sys
->
vdp
,
sys
->
device
,
sys
->
profile
,
sys
->
width
,
sys
->
height
,
surfaces
,
&
sys
->
context
->
decoder
);
err
=
vdp_decoder_create
(
sys
->
vdp
,
sys
->
device
,
profile
,
sys
->
width
,
sys
->
height
,
surfaces
,
&
hwctx
->
decoder
);
if
(
err
!=
VDP_STATUS_OK
)
{
msg_Err
(
va
,
"%s creation failure: %s"
,
"decoder"
,
vdp_get_error_string
(
sys
->
vdp
,
err
));
sys
->
context
->
decoder
=
VDP_INVALID_HANDLE
;
hwctx
->
decoder
=
VDP_INVALID_HANDLE
;
return
VLC_EGENERIC
;
}
avctx
->
hwaccel_context
=
sys
->
context
;
/* TODO: select better chromas when appropriate */
*
chromap
=
VLC_CODEC_VDPAU_VIDEO_420
;
return
VLC_SUCCESS
;
}
static
void
Deinit
(
vlc_va_t
*
va
)
{
vlc_va_sys_t
*
sys
=
va
->
sys
;
assert
(
sys
->
context
->
decoder
!=
VDP_INVALID_HANDLE
);
vdp_decoder_destroy
(
sys
->
vdp
,
sys
->
context
->
decoder
);
}
static
int
Setup
(
vlc_va_t
*
va
,
AVCodecContext
*
avctx
,
vlc_fourcc_t
*
chromap
)
{
vlc_va_sys_t
*
sys
=
va
->
sys
;
if
(
sys
->
context
->
decoder
!=
VDP_INVALID_HANDLE
)
{
if
(
sys
->
width
==
avctx
->
coded_width
&&
sys
->
height
==
avctx
->
coded_height
)
return
VLC_SUCCESS
;
Deinit
(
va
);
sys
->
context
->
decoder
=
VDP_INVALID_HANDLE
;
}
return
Init
(
va
,
avctx
,
chromap
);
}
static
int
Open
(
vlc_va_t
*
va
,
AVCodecContext
*
ctx
,
const
es_format_t
*
fmt
)
static
int
Open
(
vlc_va_t
*
va
,
AVCodecContext
*
avctx
,
const
es_format_t
*
fmt
)
{
VdpStatus
err
;
VdpDecoderProfile
profile
;
int
level
=
fmt
->
i_level
;
if
(
av_vdpau_get_profile
(
ctx
,
&
profile
))
if
(
av_vdpau_get_profile
(
av
ctx
,
&
profile
))
{
msg_Err
(
va
,
"unsupported codec %d or profile %d"
,
ctx
->
codec_id
,
msg_Err
(
va
,
"unsupported codec %d or profile %d"
,
av
ctx
->
codec_id
,
fmt
->
i_profile
);
return
VLC_EGENERIC
;
}
switch
(
ctx
->
codec_id
)
switch
(
av
ctx
->
codec_id
)
{
case
AV_CODEC_ID_MPEG1VIDEO
:
level
=
VDP_DECODER_LEVEL_MPEG1_NA
;
...
...
@@ -208,8 +199,8 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const es_format_t *fmt)
if
(
unlikely
(
sys
==
NULL
))
return
VLC_ENOMEM
;
sys
->
context
=
av_vdpau_alloc_context
();
if
(
unlikely
(
sys
->
context
==
NULL
))
avctx
->
hwaccel_
context
=
av_vdpau_alloc_context
();
if
(
unlikely
(
avctx
->
hwaccel_
context
==
NULL
))
{
free
(
sys
);
return
VLC_ENOMEM
;
...
...
@@ -218,7 +209,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const es_format_t *fmt)
err
=
vdp_get_x11
(
NULL
,
-
1
,
&
sys
->
vdp
,
&
sys
->
device
);
if
(
err
!=
VDP_STATUS_OK
)
{
av_free
(
sys
->
context
);
av_free
p
(
&
avctx
->
hwaccel_
context
);
free
(
sys
);
return
VLC_EGENERIC
;
}
...
...
@@ -229,9 +220,10 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const es_format_t *fmt)
if
(
err
!=
VDP_STATUS_OK
)
goto
error
;
sys
->
context
->
decoder
=
VDP_INVALID_HANDLE
;
sys
->
context
->
render
=
func
;
sys
->
profile
=
profile
;
AVVDPAUContext
*
hwctx
=
avctx
->
hwaccel_context
;
hwctx
->
decoder
=
VDP_INVALID_HANDLE
;
hwctx
->
render
=
func
;
/* Check capabilities */
VdpBool
support
;
...
...
@@ -285,7 +277,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const es_format_t *fmt)
error:
vdp_release_x11
(
sys
->
vdp
);
av_free
(
sys
->
context
);
av_free
p
(
&
avctx
->
hwaccel_
context
);
free
(
sys
);
return
VLC_EGENERIC
;
}
...
...
@@ -293,10 +285,11 @@ error:
static
void
Close
(
vlc_va_t
*
va
,
AVCodecContext
*
avctx
)
{
vlc_va_sys_t
*
sys
=
va
->
sys
;
AVVDPAUContext
*
hwctx
=
avctx
->
hwaccel_context
;
if
(
sys
->
context
->
decoder
!=
VDP_INVALID_HANDLE
)
Deinit
(
va
);
if
(
hwctx
->
decoder
!=
VDP_INVALID_HANDLE
)
vdp_decoder_destroy
(
sys
->
vdp
,
hwctx
->
decoder
);
vdp_release_x11
(
sys
->
vdp
);
av_free
(
sys
->
context
);
av_free
p
(
&
avctx
->
hwaccel_
context
);
free
(
sys
);
}
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