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
b8b84564
Commit
b8b84564
authored
Feb 19, 2010
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
davinci: fix encoding regressions
parent
1422ae7f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
55 deletions
+87
-55
modules/codec/davinci/encoder.c
modules/codec/davinci/encoder.c
+87
-55
No files found.
modules/codec/davinci/encoder.c
View file @
b8b84564
...
@@ -63,7 +63,6 @@ struct encoder_sys_t
...
@@ -63,7 +63,6 @@ struct encoder_sys_t
/* video */
/* video */
VIDENC_Handle
c
;
VIDENC_Handle
c
;
VIDENC_DynamicParams
dparams
;
/* audio */
/* audio */
AUDENC_Handle
a
;
AUDENC_Handle
a
;
...
@@ -71,8 +70,9 @@ struct encoder_sys_t
...
@@ -71,8 +70,9 @@ struct encoder_sys_t
XDM_BufDesc
in
;
XDM_BufDesc
in
;
XDM_BufDesc
out
;
XDM_BufDesc
out
;
#ifdef FPS_DEBUG
/* stats */
/* stats */
#undef DEBUG_FPS
#ifdef DEBUG_FPS
mtime_t
i_pts_start
;
mtime_t
i_pts_start
;
mtime_t
i_pts_end
;
mtime_t
i_pts_end
;
int
i_fps
;
int
i_fps
;
...
@@ -204,11 +204,9 @@ static int GetVideoEncoderSettings( encoder_t *p_enc, const char *psz_codec )
...
@@ -204,11 +204,9 @@ static int GetVideoEncoderSettings( encoder_t *p_enc, const char *psz_codec )
p_enc
->
i_iframes
=
var_CreateGetInteger
(
p_enc
,
ENC_CFG_PREFIX
"keyint"
);
p_enc
->
i_iframes
=
var_CreateGetInteger
(
p_enc
,
ENC_CFG_PREFIX
"keyint"
);
p_enc
->
i_tolerance
=
var_CreateGetInteger
(
p_enc
,
ENC_CFG_PREFIX
"tolerance"
);
p_enc
->
i_tolerance
=
var_CreateGetInteger
(
p_enc
,
ENC_CFG_PREFIX
"tolerance"
);
p_enc
->
i_tolerance
*=
1024
;
/* bits per second */
p_enc
->
i_tolerance
*=
1024
;
/* bits per second */
#ifdef
FPS_DEBUG
#ifdef
DEBUG_FPS
p_sys
->
i_fps
=
p_enc
->
i_iframes
;
p_sys
->
i_fps
=
p_enc
->
i_iframes
;
#endif
#endif
memset
(
&
(
p_sys
->
dparams
),
0
,
sizeof
(
p_sys
->
dparams
)
);
p_sys
->
dparams
.
size
=
sizeof
(
p_sys
->
dparams
);
/* Configure encoder */
/* Configure encoder */
params
.
size
=
sizeof
(
params
);
params
.
size
=
sizeof
(
params
);
...
@@ -274,7 +272,7 @@ static int GetVideoEncoderSettings( encoder_t *p_enc, const char *psz_codec )
...
@@ -274,7 +272,7 @@ static int GetVideoEncoderSettings( encoder_t *p_enc, const char *psz_codec )
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
#ifdef
FPS_DEBUG
#ifdef
DEBUG_FPS
static
inline
void
calculate_fps
(
encoder_t
*
p_enc
)
static
inline
void
calculate_fps
(
encoder_t
*
p_enc
)
{
{
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
...
@@ -319,53 +317,106 @@ static inline void davinci_CopyPictureToXDM( encoder_t *p_enc, XDM_BufDesc *p_bu
...
@@ -319,53 +317,106 @@ static inline void davinci_CopyPictureToXDM( encoder_t *p_enc, XDM_BufDesc *p_bu
}
}
}
}
static
void
davinci_Ini
tDynamicParams
(
encoder_t
*
p_enc
)
static
int
davinci_Se
tDynamicParams
(
encoder_t
*
p_enc
)
{
{
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
VIDENC_DynamicParams
dparams
;
VIDENC_Status
status
;
dparams
.
size
=
sizeof
(
dparams
);
memset
(
&
status
,
0
,
sizeof
(
status
)
);
status
.
size
=
sizeof
(
status
);
p_sys
->
dparams
.
inputHeight
=
p_enc
->
fmt_in
.
video
.
i_height
;
/* Configue the encoder */
p_sys
->
dparams
.
inputWidth
=
p_enc
->
fmt_in
.
video
.
i_width
;
dparams
.
inputHeight
=
p_enc
->
fmt_in
.
video
.
i_height
;
p_sys
->
dparams
.
refFrameRate
=
(
p_enc
->
fmt_out
.
video
.
i_frame_rate_base
!=
0
)
?
dparams
.
inputWidth
=
p_enc
->
fmt_in
.
video
.
i_width
;
dparams
.
refFrameRate
=
(
p_enc
->
fmt_out
.
video
.
i_frame_rate_base
!=
0
)
?
(
p_enc
->
fmt_out
.
video
.
i_frame_rate
*
1000
)
/
(
p_enc
->
fmt_out
.
video
.
i_frame_rate
*
1000
)
/
p_enc
->
fmt_out
.
video
.
i_frame_rate_base
:
p_enc
->
fmt_out
.
video
.
i_frame_rate_base
:
p_enc
->
i_iframes
*
1000
;
/* Frames per 1000 seconds */
p_enc
->
i_iframes
*
1000
;
/* Frames per 1000 seconds */
p_sys
->
dparams
.
targetFrameRate
=
p_sys
->
dparams
.
refFrameRate
;
/* input fps = output fps */
dparams
.
targetFrameRate
=
dparams
.
refFrameRate
;
/* input fps = output fps */
p_sys
->
dparams
.
targetBitRate
=
p_enc
->
fmt_out
.
i_bitrate
;
dparams
.
targetBitRate
=
p_enc
->
fmt_out
.
i_bitrate
;
p_sys
->
dparams
.
intraFrameInterval
=
p_enc
->
i_iframes
;
dparams
.
intraFrameInterval
=
p_enc
->
i_iframes
;
p_sys
->
dparams
.
generateHeader
=
XDM_ENCODE_AU
;
/* don't encode only the header */
dparams
.
generateHeader
=
XDM_ENCODE_AU
;
/* don't encode only the header */
p_sys
->
dparams
.
captureWidth
=
0
;
dparams
.
captureWidth
=
0
;
p_sys
->
dparams
.
forceIFrame
=
1
;
dparams
.
forceIFrame
=
1
;
if
(
VIDENC_control
(
p_sys
->
c
,
XDM_SETPARAMS
,
&
dparams
,
&
status
)
!=
VIDENC_EOK
)
{
msg_Err
(
p_enc
,
"Failed to set encoder parameters: %dx%d @%d fps, "
"%d kBps, I-frame interval %d"
,
(
int
)
dparams
.
inputWidth
,
(
int
)
dparams
.
inputHeight
,
(
int
)
dparams
.
refFrameRate
/
1000
,
(
int
)
dparams
.
targetBitRate
>>
13
/* / (1024 * 8) */
,
(
int
)
dparams
.
intraFrameInterval
);
return
VLC_EGENERIC
;
}
msg_Info
(
p_enc
,
"using %dx%d at %.3f fps (bitrate %d kBps, I-Frame interval %d)
\n
"
,
(
int
)
dparams
.
inputWidth
,
(
int
)
dparams
.
inputHeight
,
((
float
)
dparams
.
targetFrameRate
)
/
1000
.,
((
int
)
dparams
.
targetBitRate
)
>>
13
/* / (8*1024)*/
,
(
int
)
dparams
.
intraFrameInterval
);
return
VLC_SUCCESS
;
}
}
static
int
davinci_
SetDynamicParams
(
encoder_t
*
p_enc
,
VIDENC_Status
*
status
)
static
int
davinci_
InitVideoBuffers
(
encoder_t
*
p_enc
)
{
{
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
VIDENC_DynamicParams
*
dparams
=
&
p_sys
->
dparams
;
int
i_ret
=
VLC_SUCCESS
;
VIDENC_DynamicParams
dparams
;
VIDENC_Status
status
;
dparams
.
size
=
sizeof
(
dparams
);
memset
(
&
status
,
0
,
sizeof
(
status
)
);
status
.
size
=
sizeof
(
status
);
/* Configue the encoder */
/* Configue the encoder */
if
(
VIDENC_control
(
p_sys
->
c
,
XDM_SETPARAMS
,
dparams
,
status
)
dparams
.
inputHeight
=
p_enc
->
fmt_in
.
video
.
i_height
;
dparams
.
inputWidth
=
p_enc
->
fmt_in
.
video
.
i_width
;
dparams
.
refFrameRate
=
(
p_enc
->
fmt_out
.
video
.
i_frame_rate_base
!=
0
)
?
(
p_enc
->
fmt_out
.
video
.
i_frame_rate
*
1000
)
/
p_enc
->
fmt_out
.
video
.
i_frame_rate_base
:
p_enc
->
i_iframes
*
1000
;
/* Frames per 1000 seconds */
dparams
.
targetFrameRate
=
dparams
.
refFrameRate
;
/* input fps = output fps */
dparams
.
targetBitRate
=
p_enc
->
fmt_out
.
i_bitrate
;
dparams
.
intraFrameInterval
=
p_enc
->
i_iframes
;
dparams
.
generateHeader
=
XDM_ENCODE_AU
;
/* don't encode only the header */
dparams
.
captureWidth
=
0
;
dparams
.
forceIFrame
=
1
;
if
(
VIDENC_control
(
p_sys
->
c
,
XDM_SETPARAMS
,
&
dparams
,
&
status
)
!=
VIDENC_EOK
)
!=
VIDENC_EOK
)
{
{
msg_Err
(
p_enc
,
"Failed to set encoder parameters: %dx%d @%d fps, "
msg_Err
(
p_enc
,
"Failed to set encoder parameters: %dx%d @%d fps, "
"%d kBps, I-frame interval %d"
,
"%d kBps, I-frame interval %d"
,
(
int
)
dparams
->
inputWidth
,
(
int
)
dparams
->
inputHeight
,
(
int
)
dparams
.
inputWidth
,
(
int
)
dparams
.
inputHeight
,
(
int
)
dparams
->
refFrameRate
/
1000
,
(
int
)
dparams
.
refFrameRate
/
1000
,
(
int
)
dparams
->
targetBitRate
>>
13
/* / (1024 * 8) */
,
(
int
)
dparams
.
targetBitRate
>>
13
/* / (1024 * 8) */
,
(
int
)
dparams
->
intraFrameInterval
);
(
int
)
dparams
.
intraFrameInterval
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
return
VLC_SUCCESS
;
msg_Info
(
p_enc
,
"using %dx%d at %.3f fps (bitrate %d kBps, I-Frame interval %d)
\n
"
,
}
(
int
)
dparams
.
inputWidth
,
(
int
)
dparams
.
inputHeight
,
((
float
)
dparams
.
targetFrameRate
)
/
1000
.,
((
int
)
dparams
.
targetBitRate
)
>>
13
/* / (8*1024)*/
,
(
int
)
dparams
.
intraFrameInterval
);
static
int
davinci_InitVideoBuffers
(
encoder_t
*
p_enc
,
VIDENC_Status
*
status
)
/* Configure buffers */
{
if
(
VIDENC_control
(
p_sys
->
c
,
XDM_GETBUFINFO
,
&
dparams
,
&
status
)
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
!=
VIDENC_EOK
)
int
i_ret
=
VLC_SUCCESS
;
{
msg_Err
(
p_enc
,
"Failed to get buffer info"
);
return
VLC_EGENERIC
;
}
/* Allocate input buffer(s) */
/* Allocate input buffer(s) */
if
(
(
i_ret
=
davinci_AllocateBuffer
(
status
->
bufInfo
.
minNumInBufs
,
if
(
(
i_ret
=
davinci_AllocateBuffer
(
status
.
bufInfo
.
minNumInBufs
,
status
->
bufInfo
.
minInBufSize
,
&
p_sys
->
in
)
)
status
.
bufInfo
.
minInBufSize
,
&
p_sys
->
in
)
)
!=
VLC_SUCCESS
)
!=
VLC_SUCCESS
)
{
{
msg_Err
(
p_enc
,
"Failed to allocate input buffers"
);
msg_Err
(
p_enc
,
"Failed to allocate input buffers"
);
...
@@ -373,8 +424,8 @@ static int davinci_InitVideoBuffers( encoder_t *p_enc, VIDENC_Status *status )
...
@@ -373,8 +424,8 @@ static int davinci_InitVideoBuffers( encoder_t *p_enc, VIDENC_Status *status )
}
}
/* Allocate output buffer */
/* Allocate output buffer */
if
(
(
i_ret
=
davinci_AllocateBuffer
(
status
->
bufInfo
.
minNumOutBufs
,
if
(
(
i_ret
=
davinci_AllocateBuffer
(
status
.
bufInfo
.
minNumOutBufs
,
status
->
bufInfo
.
minOutBufSize
,
&
p_sys
->
out
)
)
status
.
bufInfo
.
minOutBufSize
,
&
p_sys
->
out
)
)
!=
VLC_SUCCESS
)
!=
VLC_SUCCESS
)
{
{
msg_Err
(
p_enc
,
"Failed to allocate input buffers"
);
msg_Err
(
p_enc
,
"Failed to allocate input buffers"
);
...
@@ -394,31 +445,12 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
...
@@ -394,31 +445,12 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
if
(
p_sys
->
in
.
numBufs
==
0
||
p_sys
->
out
.
numBufs
==
0
)
if
(
p_sys
->
in
.
numBufs
==
0
||
p_sys
->
out
.
numBufs
==
0
)
{
{
VIDENC_Status
status
;
if
(
davinci_InitVideoBuffers
(
p_enc
)
!=
VLC_SUCCESS
)
memset
(
&
status
,
0
,
sizeof
(
status
)
);
status
.
size
=
sizeof
(
status
);
davinci_InitDynamicParams
(
p_enc
);
if
(
davinci_SetDynamicParams
(
p_enc
,
&
status
)
!=
VLC_SUCCESS
)
return
NULL
;
msg_Info
(
p_enc
,
"using %dx%d at %.3f fps (bitrate %d kBps, I-Frame interval %d)
\n
"
,
(
int
)
p_sys
->
dparams
.
inputWidth
,
(
int
)
p_sys
->
dparams
.
inputHeight
,
((
float
)
p_sys
->
dparams
.
targetFrameRate
)
/
1000
.,
((
int
)
p_sys
->
dparams
.
targetBitRate
)
>>
13
/* / (8*1024)*/
,
(
int
)
p_sys
->
dparams
.
intraFrameInterval
);
if
(
davinci_InitVideoBuffers
(
p_enc
,
&
status
)
!=
VLC_SUCCESS
)
return
NULL
;
return
NULL
;
}
}
else
if
(
p_sys
->
i_pics
>=
p_enc
->
i_iframes
)
else
if
(
p_sys
->
i_pics
>=
p_enc
->
i_iframes
)
{
{
VIDENC_Status
status
;
if
(
davinci_SetDynamicParams
(
p_enc
)
!=
VLC_SUCCESS
)
memset
(
&
status
,
0
,
sizeof
(
status
)
);
status
.
size
=
sizeof
(
status
);
if
(
davinci_SetDynamicParams
(
p_enc
,
&
status
)
!=
VLC_SUCCESS
)
msg_Err
(
p_enc
,
"Encoding continues with previous settings"
);
msg_Err
(
p_enc
,
"Encoding continues with previous settings"
);
p_sys
->
i_pics
=
0
;
p_sys
->
i_pics
=
0
;
}
}
...
@@ -445,7 +477,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
...
@@ -445,7 +477,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
/* Print some info */
/* Print some info */
//msg_Dbg( p_enc, "Bytes generated: %d", (int)out_args.bytesGenerated );
//msg_Dbg( p_enc, "Bytes generated: %d", (int)out_args.bytesGenerated );
#ifdef
FPS_DEBUG
#ifdef
DEBUG_FPS
calculate_fps
(
p_enc
);
calculate_fps
(
p_enc
);
#endif
#endif
...
...
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