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
28f42bf7
Commit
28f42bf7
authored
Jul 20, 2010
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
davinci: video.c: cleanup
No functional changes, but just cleaning up.
parent
776aae9c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
81 deletions
+78
-81
modules/codec/davinci/video.c
modules/codec/davinci/video.c
+78
-81
No files found.
modules/codec/davinci/video.c
View file @
28f42bf7
...
...
@@ -55,6 +55,12 @@ struct decoder_sys_t
Engine_Handle
engine
;
VIDDEC_Handle
handle
;
VIDDEC_InArgs
in_args
;
VIDDEC_OutArgs
out_args
;
VIDDEC_DynamicParams
dparams
;
VIDDEC_Status
status
;
XDM_BufDesc
in
;
XDM_BufDesc
out
;
};
...
...
@@ -92,6 +98,12 @@ int OpenVideoDecoder( vlc_object_t *p_this )
p_sys
=
p_dec
->
p_sys
;
/* setup in_args and out_args */
p_sys
->
in_args
.
size
=
sizeof
(
p_sys
->
in_args
);
p_sys
->
out_args
.
size
=
sizeof
(
p_sys
->
out_args
);
p_sys
->
dparams
.
size
=
sizeof
(
VIDDEC_DynamicParams
);
p_sys
->
status
.
size
=
sizeof
(
VIDDEC_Status
);
p_sys
->
psz_ti_engine
=
var_CreateGetString
(
p_dec
,
DEC_CFG_PREFIX
"engine"
);
if
(
!
p_sys
->
psz_ti_engine
)
{
...
...
@@ -203,7 +215,8 @@ void CloseVideoDecoder( vlc_object_t *p_this )
free
(
p_sys
);
}
static
inline
void
davinci_CopyXDMPicture
(
decoder_t
*
p_dec
,
picture_t
*
p_pic
,
XDM_BufDesc
*
p_buf
)
/* */
static
inline
void
davinci_CopyXDMtoPicture
(
picture_t
*
p_pic
,
XDM_BufDesc
*
p_buf
)
{
/* Copy stuff to picture here */
assert
(
p_pic
->
i_planes
==
p_buf
->
numBufs
);
...
...
@@ -215,6 +228,36 @@ static inline void davinci_CopyXDMPicture( decoder_t *p_dec, picture_t *p_pic, X
}
}
#ifdef DAVINCI_DEBUG
static
void
davinci_FrameType
(
decoder_t
*
p_dec
,
IVIDEO_FrameType
frametype
)
{
const
char
*
frame
;
switch
(
frametype
)
{
case
IVIDEO_NA_FRAME
:
frame
=
"unknown"
;
break
;
case
IVIDEO_I_FRAME
:
frame
=
"I"
;
break
;
case
IVIDEO_P_FRAME
:
frame
=
"P"
;
break
;
case
IVIDEO_B_FRAME
:
frame
=
"B"
;
break
;
case
IVIDEO_IDR_FRAME
:
frame
=
"IDR"
;
break
;
case
IVIDEO_II_FRAME
:
frame
=
"I interlaced"
;
break
;
case
IVIDEO_IP_FRAME
:
frame
=
"IP interlaced"
;
break
;
case
IVIDEO_IB_FRAME
:
frame
=
"IB interlaced"
;
break
;
case
IVIDEO_PI_FRAME
:
frame
=
"PI interlaced"
;
break
;
case
IVIDEO_PP_FRAME
:
frame
=
"PP interlaced"
;
break
;
case
IVIDEO_PB_FRAME
:
frame
=
"PB interlaced"
;
break
;
case
IVIDEO_BI_FRAME
:
frame
=
"BI interlaced"
;
break
;
case
IVIDEO_BP_FRAME
:
frame
=
"BP interlaced"
;
break
;
case
IVIDEO_BB_FRAME
:
frame
=
"BB interlaced"
;
break
;
case
IVIDEO_MBAFF_I_FRAME
:
frame
=
"MBAFF I"
;
break
;
case
IVIDEO_MBAFF_P_FRAME
:
frame
=
"MBAFF P"
;
break
;
case
IVIDEO_MBAFF_B_FRAME
:
frame
=
"MBAFF B"
;
break
;
case
IVIDEO_MBAFF_IDR_FRAME
:
frame
=
"MBAFF IDR"
;
break
;
default:
frame
=
"other"
;
break
;
}
msg_Dbg
(
p_dec
,
"Frametype: %s"
,
frame
);
}
#endif
/****************************************************************************
* DecodeBlock: the whole thing
****************************************************************************/
...
...
@@ -223,10 +266,6 @@ static picture_t *DecodeVideoBlock( decoder_t *p_dec, block_t **pp_block )
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
block_t
*
p_block
;
picture_t
*
p_pic
=
NULL
;
VIDDEC_InArgs
in_args
;
VIDDEC_OutArgs
out_args
;
VIDDEC_DynamicParams
dparams
;
VIDDEC_Status
status
;
if
(
!
pp_block
||
!*
pp_block
)
return
NULL
;
p_block
=
*
pp_block
;
...
...
@@ -237,17 +276,10 @@ static picture_t *DecodeVideoBlock( decoder_t *p_dec, block_t **pp_block )
return
NULL
;
}
memset
(
&
in_args
,
0
,
sizeof
(
in_args
)
);
memset
(
&
out_args
,
0
,
sizeof
(
out_args
)
);
/* Configure video decoder */
dparams
.
size
=
sizeof
(
VIDDEC_DynamicParams
);
memset
(
&
status
,
0
,
sizeof
(
VIDDEC_Status
)
);
status
.
size
=
sizeof
(
VIDDEC_Status
);
if
(
p_sys
->
in
.
numBufs
==
0
||
p_sys
->
out
.
numBufs
==
0
)
{
if
(
VIDDEC_control
(
p_sys
->
handle
,
XDM_GETBUFINFO
,
&
dparams
,
&
status
)
if
(
VIDDEC_control
(
p_sys
->
handle
,
XDM_GETBUFINFO
,
&
p_sys
->
dparams
,
&
p_sys
->
status
)
!=
VIDDEC_EOK
)
{
msg_Err
(
p_dec
,
"Failed to get buffer info"
);
...
...
@@ -257,8 +289,8 @@ static picture_t *DecodeVideoBlock( decoder_t *p_dec, block_t **pp_block )
if
(
p_sys
->
in
.
numBufs
==
0
)
{
/* Allocate input buffer */
if
(
davinci_AllocateBuffer
(
status
.
bufInfo
.
minNumInBufs
,
status
.
bufInfo
.
minInBufSize
,
&
p_sys
->
in
)
if
(
davinci_AllocateBuffer
(
p_sys
->
status
.
bufInfo
.
minNumInBufs
,
p_sys
->
status
.
bufInfo
.
minInBufSize
,
&
p_sys
->
in
)
!=
VLC_SUCCESS
)
{
msg_Err
(
p_dec
,
"Failed to allocate input buffers"
);
...
...
@@ -268,8 +300,8 @@ static picture_t *DecodeVideoBlock( decoder_t *p_dec, block_t **pp_block )
if
(
p_sys
->
out
.
numBufs
==
0
)
{
/* Allocate output buffer(s) */
if
(
davinci_AllocateBuffer
(
status
.
bufInfo
.
minNumOutBufs
,
status
.
bufInfo
.
minOutBufSize
,
&
p_sys
->
out
)
if
(
davinci_AllocateBuffer
(
p_sys
->
status
.
bufInfo
.
minNumOutBufs
,
p_sys
->
status
.
bufInfo
.
minOutBufSize
,
&
p_sys
->
out
)
!=
VLC_SUCCESS
)
{
davinci_FreeBuffer
(
&
p_sys
->
in
);
...
...
@@ -279,7 +311,7 @@ static picture_t *DecodeVideoBlock( decoder_t *p_dec, block_t **pp_block )
}
#ifdef DAVINCI_DEBUG
if
(
VIDDEC_control
(
p_sys
->
handle
,
XDM_GETSTATUS
,
&
dparams
,
&
status
)
if
(
VIDDEC_control
(
p_sys
->
handle
,
XDM_GETSTATUS
,
&
p_sys
->
dparams
,
&
p_sys
->
status
)
!=
VIDDEC_EOK
)
{
msg_Err
(
p_dec
,
"Failed to get decoder status"
);
...
...
@@ -288,10 +320,9 @@ static picture_t *DecodeVideoBlock( decoder_t *p_dec, block_t **pp_block )
#endif
/* Setup input arguments */
in_args
.
size
=
sizeof
(
in_args
);
in_args
.
numBytes
=
__MIN
(
p_dec
->
fmt_in
.
i_extra
+
p_block
->
i_buffer
,
p_sys
->
in_args
.
numBytes
=
__MIN
(
p_dec
->
fmt_in
.
i_extra
+
p_block
->
i_buffer
,
(
size_t
)
p_sys
->
in
.
bufSizes
[
0
]
);
in_args
.
inputID
=
1
;
p_sys
->
in_args
.
inputID
++
;
/* Setup input buffer */
assert
(
p_block
->
i_buffer
<=
(
size_t
)
p_sys
->
in
.
bufSizes
[
0
]
);
...
...
@@ -301,44 +332,47 @@ static picture_t *DecodeVideoBlock( decoder_t *p_dec, block_t **pp_block )
memcpy
(
p_sys
->
in
.
bufs
[
0
],
p_dec
->
fmt_in
.
p_extra
,
p_dec
->
fmt_in
.
i_extra
);
}
memcpy
(
p_sys
->
in
.
bufs
[
0
]
+
p_dec
->
fmt_in
.
i_extra
,
p_block
->
p_buffer
,
in_args
.
numBytes
-
p_dec
->
fmt_in
.
i_extra
);
p_sys
->
in_args
.
numBytes
-
p_dec
->
fmt_in
.
i_extra
);
#ifdef DEBUG_DAVINCI
msg_Dbg
(
p_dec
,
"Frame is %d bytes (%d extra), %dx%d, type %s"
,
(
int
)
in_args
.
numBytes
,
p_dec
->
fmt_in
.
i_extra
,
(
int
)
status
.
outputWidth
,
(
int
)
status
.
outputHeight
,
status
.
contentType
==
IVIDEO_PROGRESSIVE
?
"progressive"
:
status
.
contentType
==
IVIDEO_INTERLACED
?
"interlaced"
:
(
int
)
p_sys
->
in_args
.
numBytes
,
p_dec
->
fmt_in
.
i_extra
,
(
int
)
p_sys
->
status
.
outputWidth
,
(
int
)
p_sys
->
status
.
outputHeight
,
p_sys
->
status
.
contentType
==
IVIDEO_PROGRESSIVE
?
"progressive"
:
p_sys
->
status
.
contentType
==
IVIDEO_INTERLACED
?
"interlaced"
:
"unknown"
);
#endif
/* Setup output arguemnts */
out_args
.
size
=
sizeof
(
out_args
);
/* Decode the video */
if
(
VIDDEC_process
(
p_sys
->
handle
,
&
p_sys
->
in
,
&
p_sys
->
out
,
&
in_args
,
&
out_args
)
!=
VIDDEC_EOK
)
if
(
VIDDEC_process
(
p_sys
->
handle
,
&
p_sys
->
in
,
&
p_sys
->
out
,
&
p_sys
->
in_args
,
&
p_sys
->
out_args
)
!=
VIDDEC_EOK
)
{
msg_Err
(
p_dec
,
"Video decoding failed: %s"
,
davinci_GetExtendedError
(
out_args
.
extendedError
)
);
davinci_GetExtendedError
(
p_sys
->
out_args
.
extendedError
)
);
goto
error
;
}
if
(
VIDDEC_control
(
p_sys
->
handle
,
XDM_GETSTATUS
,
&
dparams
,
&
status
)
!=
VIDDEC_EOK
)
if
(
VIDDEC_control
(
p_sys
->
handle
,
XDM_GETSTATUS
,
&
p_sys
->
dparams
,
&
p_sys
->
status
)
!=
VIDDEC_EOK
)
{
msg_Err
(
p_dec
,
"Failed to get decoder status"
);
goto
error
;
}
if
(
in_args
.
numBytes
>
out_args
.
bytesConsumed
)
msg_Err
(
p_dec
,
"%d bytes were not consumed"
,
(
int
)(
out_args
.
bytesConsumed
-
in_args
.
numBytes
)
);
#ifdef DEBUG_DAVINCI
if
(
p_sys
->
in_args
.
numBytes
>
p_sys
->
out_args
.
bytesConsumed
)
msg_Err
(
p_dec
,
"%d bytes were not consumed"
,
(
int
)(
p_sys
->
out_args
.
bytesConsumed
-
p_sys
->
in_args
.
numBytes
)
);
#endif
p_block
->
p_buffer
+=
out_args
.
bytesConsumed
-
p_dec
->
fmt_in
.
i_extra
;
p_block
->
i_buffer
-=
out_args
.
bytesConsumed
-
p_dec
->
fmt_in
.
i_extra
;
p_block
->
p_buffer
+=
p_sys
->
out_args
.
bytesConsumed
-
p_dec
->
fmt_in
.
i_extra
;
p_block
->
i_buffer
-=
p_sys
->
out_args
.
bytesConsumed
-
p_dec
->
fmt_in
.
i_extra
;
p_dec
->
fmt_out
.
video
.
i_width
=
status
.
outputWidth
;
p_dec
->
fmt_out
.
video
.
i_height
=
status
.
outputHeight
;
p_dec
->
fmt_out
.
video
.
i_aspect
=
VOUT_ASPECT_FACTOR
*
status
.
outputWidth
/
status
.
outputHeight
;
/* FIXME */
p_dec
->
fmt_out
.
video
.
i_width
=
p_sys
->
status
.
outputWidth
;
p_dec
->
fmt_out
.
video
.
i_height
=
p_sys
->
status
.
outputHeight
;
p_dec
->
fmt_out
.
video
.
i_aspect
=
VOUT_ASPECT_FACTOR
*
p_sys
->
status
.
outputWidth
/
p_sys
->
status
.
outputHeight
;
/* FIXME */
/* Get a new picture */
p_pic
=
decoder_NewPicture
(
p_dec
);
...
...
@@ -347,51 +381,14 @@ static picture_t *DecodeVideoBlock( decoder_t *p_dec, block_t **pp_block )
msg_Err
(
p_dec
,
"Could not get picture"
);
goto
error
;
}
p_pic
->
b_progressive
=
(
status
.
contentType
==
IVIDEO_INTERLACED
)
?
p_pic
->
b_progressive
=
(
p_sys
->
status
.
contentType
==
IVIDEO_INTERLACED
)
?
false
:
true
;
#ifdef DEBUG_DAVINCI
switch
(
out_args
.
decodedFrameType
)
{
case
IVIDEO_NA_FRAME
:
msg_Dbg
(
p_dec
,
"Unknown frame type"
);
break
;
case
IVIDEO_I_FRAME
:
msg_Dbg
(
p_dec
,
"I frame"
);
break
;
case
IVIDEO_P_FRAME
:
msg_Dbg
(
p_dec
,
"P frame"
);
break
;
case
IVIDEO_B_FRAME
:
msg_Dbg
(
p_dec
,
"B frame"
);
break
;
case
IVIDEO_II_FRAME
:
msg_Dbg
(
p_dec
,
"Interlaced I frame"
);
break
;
case
IVIDEO_PP_FRAME
:
msg_Dbg
(
p_dec
,
"Interlaced P frame"
);
break
;
case
IVIDEO_BB_FRAME
:
msg_Dbg
(
p_dec
,
"Interlaced B frame"
);
break
;
default:
msg_Dbg
(
p_dec
,
"Other frame type: %d"
,
(
int
)
out_args
.
decodedFrameType
);
break
;
}
davinci_FrameType
(
p_dec
,
p_sys
->
out_args
.
decodedFrameType
);
#endif
#if 1
/* Copy stuff to picture here */
assert
(
p_pic
->
i_planes
==
p_sys
->
out
.
numBufs
);
for
(
int
i
=
0
;
i
<
p_pic
->
i_planes
;
i
++
)
{
plane_t
*
p
=
p_pic
->
p
+
i
;
memcpy
(
p
->
p_pixels
,
p_sys
->
out
.
bufs
[
i
],
p
->
i_pitch
*
p
->
i_visible_lines
);
}
#else
davinci_CopyXDMPicture
(
p_dec
,
p_pic
,
p_sys
->
out
);
#endif
davinci_CopyXDMtoPicture
(
p_pic
,
&
p_sys
->
out
);
/* */
p_pic
->
date
=
p_block
->
i_pts
>
0
?
p_block
->
i_pts
:
p_block
->
i_dts
;
...
...
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