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
b68aa14e
Commit
b68aa14e
authored
Sep 13, 2014
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vda: cleanup
parent
dcd503d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
109 deletions
+80
-109
modules/codec/avcodec/vda.c
modules/codec/avcodec/vda.c
+80
-109
No files found.
modules/codec/avcodec/vda.c
View file @
b68aa14e
...
...
@@ -105,130 +105,125 @@ struct vlc_va_sys_t
vlc_fourcc_t
i_chroma
;
copy_cache_t
image_cache
;
vlc_object_t
*
p_log
;
};
typedef
struct
vlc_va_sys_t
vlc_va_vda_t
;
static
vlc_va_vda_t
*
vlc_va_vda_Get
(
vlc_va_t
*
p_
va
)
static
vlc_va_vda_t
*
vlc_va_vda_Get
(
vlc_va_t
*
va
)
{
return
p_
va
->
sys
;
return
va
->
sys
;
}
#pragma mark - module handling
static
int
Open
(
vlc_va_t
*
external
,
AVCodecContext
*
ctx
,
static
int
Open
(
vlc_va_t
*
va
,
AVCodecContext
*
ctx
,
const
es_format_t
*
fmt
)
{
msg_Dbg
(
external
,
"opening VDA module"
);
msg_Dbg
(
va
,
"opening VDA module"
);
if
(
ctx
->
codec_id
!=
AV_CODEC_ID_H264
)
{
msg_Warn
(
external
,
"input codec isn't H264, canceling VDA decoding"
);
msg_Warn
(
va
,
"input codec isn't H264, canceling VDA decoding"
);
return
VLC_EGENERIC
;
}
if
(
fmt
->
p_extra
==
NULL
||
fmt
->
i_extra
<
7
)
{
msg_Warn
(
external
,
"VDA requires extradata."
);
msg_Warn
(
va
,
"VDA requires extradata."
);
return
VLC_EGENERIC
;
}
vlc_va_vda_t
*
p_v
a
=
calloc
(
1
,
sizeof
(
*
p_v
a
)
);
if
(
!
p_va
)
vlc_va_vda_t
*
p_v
da
=
calloc
(
1
,
sizeof
(
*
p_vd
a
)
);
if
(
unlikely
(
p_vda
==
NULL
)
)
return
VLC_EGENERIC
;
p_va
->
p_log
=
VLC_OBJECT
(
external
);
p_va
->
p_extradata
=
fmt
->
p_extra
;
p_va
->
i_extradata
=
fmt
->
i_extra
;
p_vda
->
p_extradata
=
fmt
->
p_extra
;
p_vda
->
i_extradata
=
fmt
->
i_extra
;
external
->
sys
=
p_v
a
;
external
->
description
=
"VDA"
;
external
->
pix_fmt
=
PIX_FMT_VDA_VLD
;
external
->
setup
=
Setup
;
external
->
get
=
Get
;
external
->
release
=
Release
;
external
->
extract
=
Extract
;
va
->
sys
=
p_vd
a
;
va
->
description
=
"VDA"
;
va
->
pix_fmt
=
PIX_FMT_VDA_VLD
;
va
->
setup
=
Setup
;
va
->
get
=
Get
;
va
->
release
=
Release
;
va
->
extract
=
Extract
;
return
VLC_SUCCESS
;
}
static
void
Close
(
vlc_va_t
*
external
,
AVCodecContext
*
ctx
)
static
void
Close
(
vlc_va_t
*
va
,
AVCodecContext
*
ctx
)
{
vlc_va_vda_t
*
p_v
a
=
vlc_va_vda_Get
(
external
);
vlc_va_vda_t
*
p_v
da
=
vlc_va_vda_Get
(
va
);
msg_Dbg
(
p_va
->
p_log
,
"destroying VDA decoder"
);
msg_Dbg
(
va
,
"destroying VDA decoder"
);
ff_vda_destroy_decoder
(
&
p_va
->
hw_ctx
)
;
ff_vda_destroy_decoder
(
&
p_v
d
a
->
hw_ctx
)
;
if
(
p_va
->
hw_ctx
.
cv_pix_fmt_type
==
kCVPixelFormatType_420YpCbCr8Planar
)
CopyCleanCache
(
&
p_va
->
image_cache
);
if
(
p_v
d
a
->
hw_ctx
.
cv_pix_fmt_type
==
kCVPixelFormatType_420YpCbCr8Planar
)
CopyCleanCache
(
&
p_v
d
a
->
image_cache
);
free
(
p_va
);
free
(
p_v
d
a
);
(
void
)
ctx
;
}
static
int
Setup
(
vlc_va_t
*
external
,
AVCodecContext
*
avctx
,
vlc_fourcc_t
*
pi_chroma
)
static
int
Setup
(
vlc_va_t
*
va
,
AVCodecContext
*
avctx
,
vlc_fourcc_t
*
pi_chroma
)
{
vlc_va_vda_t
*
p_v
a
=
vlc_va_vda_Get
(
external
);
vlc_va_vda_t
*
p_v
da
=
vlc_va_vda_Get
(
va
);
if
(
p_va
->
hw_ctx
.
width
==
avctx
->
coded_width
&&
p_va
->
hw_ctx
.
height
==
avctx
->
codec_height
&&
p_va
->
hw_ctx
.
decoder
)
if
(
p_v
d
a
->
hw_ctx
.
width
==
avctx
->
coded_width
&&
p_v
d
a
->
hw_ctx
.
height
==
avctx
->
codec_height
&&
p_v
d
a
->
hw_ctx
.
decoder
)
{
avctx
->
hwaccel_context
=
&
p_va
->
hw_ctx
;
*
pi_chroma
=
p_va
->
i_chroma
;
avctx
->
hwaccel_context
=
&
p_v
d
a
->
hw_ctx
;
*
pi_chroma
=
p_v
d
a
->
i_chroma
;
return
VLC_SUCCESS
;
}
if
(
p_va
->
hw_ctx
.
decoder
)
if
(
p_v
d
a
->
hw_ctx
.
decoder
)
{
ff_vda_destroy_decoder
(
&
p_va
->
hw_ctx
);
ff_vda_destroy_decoder
(
&
p_v
d
a
->
hw_ctx
);
goto
ok
;
}
memset
(
&
p_v
a
->
hw_ctx
,
0
,
sizeof
(
p_v
a
->
hw_ctx
)
);
p_va
->
hw_ctx
.
format
=
'
avc1
'
;
p_va
->
hw_ctx
.
use_ref_buffer
=
1
;
memset
(
&
p_v
da
->
hw_ctx
,
0
,
sizeof
(
p_vd
a
->
hw_ctx
)
);
p_v
d
a
->
hw_ctx
.
format
=
'
avc1
'
;
p_v
d
a
->
hw_ctx
.
use_ref_buffer
=
1
;
int
i_pix_fmt
=
var_CreateGetInteger
(
p_va
->
p_log
,
"avcodec-vda-pix-fmt"
);
int
i_pix_fmt
=
var_CreateGetInteger
(
va
,
"avcodec-vda-pix-fmt"
);
switch
(
i_pix_fmt
)
{
case
1
:
p_va
->
hw_ctx
.
cv_pix_fmt_type
=
kCVPixelFormatType_422YpCbCr8
;
p_va
->
i_chroma
=
VLC_CODEC_UYVY
;
msg_Dbg
(
p_va
->
p_log
,
"using pixel format 422YpCbCr8"
);
p_v
d
a
->
hw_ctx
.
cv_pix_fmt_type
=
kCVPixelFormatType_422YpCbCr8
;
p_v
d
a
->
i_chroma
=
VLC_CODEC_UYVY
;
msg_Dbg
(
va
,
"using pixel format 422YpCbCr8"
);
break
;
case
0
:
default
:
p_va
->
hw_ctx
.
cv_pix_fmt_type
=
kCVPixelFormatType_420YpCbCr8Planar
;
p_va
->
i_chroma
=
VLC_CODEC_I420
;
CopyInitCache
(
&
p_va
->
image_cache
,
avctx
->
coded_width
);
msg_Dbg
(
p_va
->
p_log
,
"using pixel format 420YpCbCr8Planar"
);
p_v
d
a
->
hw_ctx
.
cv_pix_fmt_type
=
kCVPixelFormatType_420YpCbCr8Planar
;
p_v
d
a
->
i_chroma
=
VLC_CODEC_I420
;
CopyInitCache
(
&
p_v
d
a
->
image_cache
,
avctx
->
coded_width
);
msg_Dbg
(
va
,
"using pixel format 420YpCbCr8Planar"
);
}
ok:
/* Setup the libavcodec hardware context */
avctx
->
hwaccel_context
=
&
p_va
->
hw_ctx
;
*
pi_chroma
=
p_va
->
i_chroma
;
avctx
->
hwaccel_context
=
&
p_v
d
a
->
hw_ctx
;
*
pi_chroma
=
p_v
d
a
->
i_chroma
;
p_va
->
hw_ctx
.
width
=
avctx
->
coded_width
;
p_va
->
hw_ctx
.
height
=
avctx
->
coded_height
;
p_v
d
a
->
hw_ctx
.
width
=
avctx
->
coded_width
;
p_v
d
a
->
hw_ctx
.
height
=
avctx
->
coded_height
;
/* create the decoder */
int
status
=
ff_vda_create_decoder
(
&
p_va
->
hw_ctx
,
p_va
->
p_extradata
,
p_va
->
i_extradata
);
int
status
=
ff_vda_create_decoder
(
&
p_v
d
a
->
hw_ctx
,
p_v
d
a
->
p_extradata
,
p_v
d
a
->
i_extradata
);
if
(
status
)
{
msg_Err
(
p_va
->
p_log
,
"Failed to create decoder: %i"
,
status
);
msg_Err
(
va
,
"Failed to create decoder: %i"
,
status
);
return
VLC_EGENERIC
;
}
else
msg_Dbg
(
p_va
->
p_log
,
"VDA decoder created"
);
msg_Dbg
(
va
,
"VDA decoder created"
);
return
VLC_SUCCESS
;
}
...
...
@@ -261,44 +256,44 @@ static void vda_Copy420YpCbCr8Planar( picture_t *p_pic,
CVPixelBufferUnlockBaseAddress
(
buffer
,
0
);
}
static
int
Get
(
vlc_va_t
*
external
,
void
**
opaque
,
uint8_t
**
data
)
static
int
Get
(
vlc_va_t
*
va
,
void
**
opaque
,
uint8_t
**
data
)
{
VLC_UNUSED
(
external
);
VLC_UNUSED
(
va
);
*
data
=
(
uint8_t
*
)
1
;
// dummy
(
void
)
opaque
;
return
VLC_SUCCESS
;
}
static
int
Extract
(
vlc_va_t
*
external
,
picture_t
*
p_picture
,
void
*
opaque
,
static
int
Extract
(
vlc_va_t
*
va
,
picture_t
*
p_picture
,
void
*
opaque
,
uint8_t
*
data
)
{
vlc_va_vda_t
*
p_v
a
=
vlc_va_vda_Get
(
external
);
vlc_va_vda_t
*
p_v
da
=
vlc_va_vda_Get
(
va
);
CVPixelBufferRef
cv_buffer
=
(
CVPixelBufferRef
)
data
;
if
(
!
cv_buffer
)
{
msg_Dbg
(
p_va
->
p_log
,
"Frame buffer is empty."
);
msg_Dbg
(
va
,
"Frame buffer is empty."
);
return
VLC_EGENERIC
;
}
if
(
!
CVPixelBufferGetDataSize
(
cv_buffer
)
>
0
)
{
msg_Dbg
(
p_va
->
p_log
,
"Empty frame buffer"
);
msg_Dbg
(
va
,
"Empty frame buffer"
);
return
VLC_EGENERIC
;
}
if
(
p_va
->
hw_ctx
.
cv_pix_fmt_type
==
kCVPixelFormatType_420YpCbCr8Planar
)
if
(
p_v
d
a
->
hw_ctx
.
cv_pix_fmt_type
==
kCVPixelFormatType_420YpCbCr8Planar
)
{
if
(
!
p_va
->
image_cache
.
buffer
)
{
if
(
!
p_v
d
a
->
image_cache
.
buffer
)
{
CVPixelBufferRelease
(
cv_buffer
);
return
VLC_EGENERIC
;
}
vda_Copy420YpCbCr8Planar
(
p_picture
,
cv_buffer
,
p_va
->
hw_ctx
.
width
,
p_va
->
hw_ctx
.
height
,
&
p_va
->
image_cache
);
p_v
d
a
->
hw_ctx
.
width
,
p_v
d
a
->
hw_ctx
.
height
,
&
p_v
d
a
->
image_cache
);
}
else
vda_Copy422YpCbCr8
(
p_picture
,
cv_buffer
);
...
...
@@ -327,48 +322,27 @@ vlc_module_begin ()
set_callbacks
(
Open
,
Close
)
vlc_module_end
()
struct
vlc_va_sys_t
{
vlc_object_t
*
p_log
;
};
typedef
struct
vlc_va_sys_t
vlc_va_vda_t
;
static
vlc_va_vda_t
*
vlc_va_vda_Get
(
vlc_va_t
*
p_va
)
{
return
p_va
->
sys
;
}
static
int
Open
(
vlc_va_t
*
external
,
AVCodecContext
*
avctx
,
const
es_format_t
*
fmt
)
static
int
Open
(
vlc_va_t
*
va
,
AVCodecContext
*
avctx
,
const
es_format_t
*
fmt
)
{
msg_Dbg
(
external
,
"VDA decoder Open"
);
msg_Dbg
(
va
,
"VDA decoder Open"
);
vlc_va_vda_t
*
p_va
=
calloc
(
1
,
sizeof
(
*
p_va
)
);
if
(
!
p_va
)
{
av_vda_default_free
(
avctx
);
return
VLC_EGENERIC
;
}
p_va
->
p_log
=
VLC_OBJECT
(
external
);
external
->
sys
=
p_va
;
external
->
description
=
(
char
*
)
"VDA"
;
external
->
pix_fmt
=
AV_PIX_FMT_VDA
;
external
->
setup
=
Setup
;
external
->
get
=
Get
;
external
->
release
=
Release
;
external
->
extract
=
Extract
;
msg_Dbg
(
external
,
"VDA decoder Open success!"
);
va
->
description
=
(
char
*
)
"VDA"
;
va
->
pix_fmt
=
AV_PIX_FMT_VDA
;
va
->
setup
=
Setup
;
va
->
get
=
Get
;
va
->
release
=
Release
;
va
->
extract
=
Extract
;
msg_Dbg
(
va
,
"VDA decoder Open success!"
);
(
void
)
fmt
;
return
VLC_SUCCESS
;
}
static
void
Close
(
vlc_va_t
*
external
,
AVCodecContext
*
avctx
)
static
void
Close
(
vlc_va_t
*
va
,
AVCodecContext
*
avctx
)
{
av_vda_default_free
(
avctx
);
(
void
)
external
;
(
void
)
va
;
}
static
int
Setup
(
vlc_va_t
*
va
,
AVCodecContext
*
avctx
,
vlc_fourcc_t
*
p_chroma
)
...
...
@@ -382,30 +356,27 @@ static int Setup( vlc_va_t *va, AVCodecContext *avctx, vlc_fourcc_t *p_chroma )
}
// Never called
static
int
Get
(
vlc_va_t
*
external
,
void
**
opaque
,
uint8_t
**
data
)
static
int
Get
(
vlc_va_t
*
va
,
void
**
opaque
,
uint8_t
**
data
)
{
VLC_UNUSED
(
external
);
VLC_UNUSED
(
va
);
(
void
)
data
;
(
void
)
opaque
;
return
VLC_SUCCESS
;
}
static
int
Extract
(
vlc_va_t
*
external
,
picture_t
*
p_picture
,
void
*
opaque
,
static
int
Extract
(
vlc_va_t
*
va
,
picture_t
*
p_picture
,
void
*
opaque
,
uint8_t
*
data
)
{
vlc_va_vda_t
*
p_va
=
vlc_va_vda_Get
(
external
);
CVPixelBufferRef
cv_buffer
=
(
CVPixelBufferRef
)
data
;
if
(
!
cv_buffer
)
{
msg_Dbg
(
p_va
->
p_log
,
"Frame buffer is empty."
);
msg_Dbg
(
va
,
"Frame buffer is empty."
);
return
VLC_EGENERIC
;
}
if
(
!
CVPixelBufferGetDataSize
(
cv_buffer
)
>
0
)
{
msg_Dbg
(
p_va
->
p_log
,
"Empty frame buffer"
);
msg_Dbg
(
va
,
"Empty frame buffer"
);
return
VLC_EGENERIC
;
}
...
...
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