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
08baed9d
Commit
08baed9d
authored
Dec 08, 2009
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
davinci codec: fix encoder
parent
1e589246
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
42 deletions
+28
-42
modules/codec/davinci/encoder.c
modules/codec/davinci/encoder.c
+28
-42
No files found.
modules/codec/davinci/encoder.c
View file @
08baed9d
...
...
@@ -78,10 +78,15 @@ int OpenVideoEncoder( vlc_object_t *p_this )
if
(
!
GetDavinciEncoder
(
p_enc
->
fmt_out
.
i_codec
,
&
i_cat
,
&
psz_codec
,
&
psz_namecodec
)
)
{
msg_Dbg
(
p_enc
,
"Unsupported codec : %4.4s"
,(
char
*
)
&
p_enc
->
fmt_
in
.
i_codec
);
msg_Dbg
(
p_enc
,
"Unsupported codec : %4.4s"
,(
char
*
)
&
p_enc
->
fmt_
out
.
i_codec
);
return
VLC_EGENERIC
;
}
msg_Dbg
(
p_enc
,
"found davinci encoder %s for %s (codec=%4.4s, cat=%s)"
,
psz_codec
,
(
char
*
)
&
p_enc
->
fmt_out
.
i_codec
,
psz_namecodec
,
(
i_cat
==
VIDEO_ES
)
?
"video"
:
(
i_cat
==
AUDIO_ES
)
?
"audio"
:
"other"
);
/* Allocate our private structure */
p_enc
->
p_sys
=
(
encoder_sys_t
*
)
calloc
(
1
,
sizeof
(
encoder_sys_t
)
);
if
(
!
p_enc
->
p_sys
)
...
...
@@ -144,17 +149,17 @@ int OpenVideoEncoder( vlc_object_t *p_this )
p_enc
->
i_iframes
*
1000
;
/* Frames per 1000 seconds */
params
.
maxBitRate
=
p_enc
->
fmt_out
.
i_bitrate
+
p_enc
->
i_tolerance
;
//params.maxBitRate *= 10;
params
.
dataEndianness
=
XDM_BYTE
;
params
.
maxInterFrameInterval
=
p_enc
->
i_iframes
;
params
.
maxInterFrameInterval
=
0
;
/* NOTE: should be null */
params
.
inputChromaFormat
=
VlcChromaToXdm
(
p_enc
->
fmt_in
.
i_codec
);
msg_Info
(
p_enc
,
"max %dx%d at %.3f fps (max bitrate %d kBps, I-Frame interval %d)
\n
"
,
(
int
)
params
.
maxWidth
,
(
int
)
params
.
maxHeight
,
((
float
)
params
.
maxFrameRate
)
/
1000
.,
((
int
)
params
.
maxBitRate
)
/
(
8
*
1024
),
(
int
)
params
.
maxInterFrameInterval
);
(
int
)
params
.
maxInterFrameInterval
);
if
(
params
.
inputChromaFormat
==
XDM_CHROMA_NA
)
{
msg_Warn
(
p_enc
,
"Unsupported input chroma (%4.4s), forcing I420."
,
...
...
@@ -219,20 +224,18 @@ void CloseVideoEncoder( vlc_object_t *p_this )
/*****************************************************************************
*
*****************************************************************************/
static
inline
void
davinci_CopyPictureToXDM
(
decoder_t
*
p_de
c
,
XDM_BufDesc
*
p_buf
,
picture_t
*
p_pic
)
static
inline
void
davinci_CopyPictureToXDM
(
encoder_t
*
p_en
c
,
XDM_BufDesc
*
p_buf
,
picture_t
*
p_pic
)
{
VLC_UNUSED
(
p_enc
);
/* Copy input picture */
assert
(
p_pic
->
i_planes
==
p_buf
->
numBufs
);
assert
(
p_pic
->
i_planes
==
1
);
for
(
int
i
=
0
;
i
<
p_pic
->
i_planes
;
i
++
)
{
if
(
p_pic
->
i_type
==
MEMORY_PICTURE
)
{
plane_t
*
p
=
p_pic
->
p
+
i
;
memcpy
(
p_buf
->
bufs
[
i
],
p
->
p_pixels
,
p
->
i_pitch
*
p
->
i_visible_lines
);
}
/* if it's our direct buffer, we have nothing to do */
plane_t
*
p
=
p_pic
->
p
+
i
;
memcpy
(
p_buf
->
bufs
[
i
],
p
->
p_pixels
,
p
->
i_pitch
*
p
->
i_visible_lines
);
}
}
...
...
@@ -259,7 +262,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
dparams
.
refFrameRate
=
p_enc
->
fmt_out
.
video
.
i_frame_rate_base
?
p_enc
->
fmt_out
.
video
.
i_frame_rate
*
1000
/
p_enc
->
fmt_out
.
video
.
i_frame_rate_base
:
25
000
;
/* Frames per 1000 seconds */
p_enc
->
i_iframes
*
1
000
;
/* 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
;
...
...
@@ -276,12 +279,12 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
(
int
)
dparams
.
refFrameRate
/
1000
,
(
int
)
dparams
.
targetBitRate
>>
13
/* / (1024 * 8) */
,
(
int
)
dparams
.
intraFrameInterval
);
goto
error
;
return
NULL
;
}
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
)
/
(
8
*
1024
)
,
((
int
)
dparams
.
targetBitRate
)
>>
13
/* / (8*1024)*/
,
(
int
)
dparams
.
intraFrameInterval
);
/* Configure buffers */
...
...
@@ -289,7 +292,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
!=
VIDENC_EOK
)
{
msg_Err
(
p_enc
,
"Failed to get buffer info"
);
goto
error
;
return
NULL
;
}
/* Allocate input buffer(s) */
...
...
@@ -298,7 +301,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
!=
VLC_SUCCESS
)
{
msg_Err
(
p_enc
,
"Failed to allocate input buffers"
);
goto
error
;
return
NULL
;
}
/* Allocate output buffer */
...
...
@@ -307,27 +310,12 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
!=
VLC_SUCCESS
)
{
msg_Err
(
p_enc
,
"Failed to allocate input buffers"
);
goto
error
;
return
NULL
;
}
}
#if 1
/* Copy input picture */
assert
(
p_pic
->
i_planes
==
p_sys
->
in
.
numBufs
);
assert
(
p_pic
->
i_planes
==
1
);
davinci_CopyPictureToXDM
(
p_enc
,
&
p_sys
->
in
,
p_pic
);
for
(
i
=
0
;
i
<
p_pic
->
i_planes
;
i
++
)
{
if
(
p_pic
->
i_type
==
MEMORY_PICTURE
)
{
plane_t
*
p
=
p_pic
->
p
+
i
;
memcpy
(
p_sys
->
in
.
bufs
[
i
],
p
->
p_pixels
,
p
->
i_pitch
*
p
->
i_visible_lines
);
}
/* if it's our direct buffer, we have nothing to do */
}
#else
davinci_CopyPictureToXDM
(
p_dec
,
p_sys
->
in
,
p_pic
);
#endif
/* Configure input */
in_args
.
size
=
sizeof
(
in_args
);
...
...
@@ -340,20 +328,21 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
&
in_args
,
&
out_args
);
if
(
i
!=
VIDENC_EOK
)
{
msg_Err
(
p_enc
,
"Video encoding failed
: %s"
,
msg_Err
(
p_enc
,
"Video encoding failed
(%d): %s"
,
i
,
davinci_GetExtendedError
(
out_args
.
extendedError
)
);
goto
error
;
return
NULL
;
}
/* 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 );
/* Put everything in the block */
if
(
out_args
.
bytesGenerated
<=
0
)
goto
error
;
return
NULL
;
p_block
=
block_New
(
p_enc
,
out_args
.
bytesGenerated
);
if
(
!
p_block
)
goto
error
;
if
(
!
p_block
)
return
NULL
;
memcpy
(
p_block
->
p_buffer
,
p_sys
->
out
.
bufs
[
0
],
out_args
.
bytesGenerated
);
...
...
@@ -385,7 +374,4 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pic )
p_enc
->
fmt_in
.
video
.
i_frame_rate
;
return
p_block
;
error:
return
NULL
;
}
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