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
38415e92
Commit
38415e92
authored
Feb 13, 2012
by
Ilkka Ollakka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec: avoid unneeded memcpy in EncodeVideo/Audio
parent
951ced78
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
24 deletions
+19
-24
modules/codec/avcodec/encoder.c
modules/codec/avcodec/encoder.c
+19
-24
No files found.
modules/codec/avcodec/encoder.c
View file @
38415e92
...
...
@@ -874,20 +874,10 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
* This is done here instead of OpenEncoder() because we need the actual
* bits_per_pixel value, without having to assume anything.
*/
if
(
p_sys
->
p_buffer_out
==
NULL
)
{
int
bytesPerPixel
=
p_enc
->
fmt_out
.
video
.
i_bits_per_pixel
?
p_enc
->
fmt_out
.
video
.
i_bits_per_pixel
/
8
:
3
;
p_sys
->
i_buffer_out
=
p_sys
->
p_context
->
height
*
p_sys
->
p_context
->
width
*
bytesPerPixel
+
200
;
/* some room for potential headers (such as BMP) */
if
(
p_sys
->
i_buffer_out
<
FF_MIN_BUFFER_SIZE
)
p_sys
->
i_buffer_out
=
FF_MIN_BUFFER_SIZE
;
p_sys
->
p_buffer_out
=
malloc
(
p_sys
->
i_buffer_out
);
if
(
p_sys
->
p_buffer_out
==
NULL
)
return
NULL
;
}
const
int
bytesPerPixel
=
p_enc
->
fmt_out
.
video
.
i_bits_per_pixel
?
p_enc
->
fmt_out
.
video
.
i_bits_per_pixel
/
8
:
3
;
const
int
blocksize
=
__MAX
(
FF_MIN_BUFFER_SIZE
,
bytesPerPixel
*
p_sys
->
p_context
->
height
*
p_sys
->
p_context
->
width
+
200
);
block_t
*
p_block
=
block_New
(
p_enc
,
blocksize
);
if
(
likely
(
p_pict
)
)
{
AVFrame
frame
;
...
...
@@ -984,20 +974,22 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
frame
.
pts
/=
p_enc
->
fmt_in
.
video
.
i_frame_rate
;
/* End work-around */
i_out
=
avcodec_encode_video
(
p_sys
->
p_context
,
p_
sys
->
p_buffer_out
,
p_
sys
->
i_buffer_out
,
&
frame
);
i_out
=
avcodec_encode_video
(
p_sys
->
p_context
,
p_
block
->
p_buffer
,
p_
block
->
i_buffer
,
&
frame
);
}
else
{
i_out
=
avcodec_encode_video
(
p_sys
->
p_context
,
p_
sys
->
p_buffer_out
,
p_
sys
->
i_buffer_out
,
NULL
);
i_out
=
avcodec_encode_video
(
p_sys
->
p_context
,
p_
block
->
p_buffer
,
p_
block
->
i_buffer
,
NULL
);
}
if
(
i_out
<=
0
)
{
block_Release
(
p_block
);
return
NULL
;
}
block_t
*
p_block
=
block_New
(
p_enc
,
i_out
);
memcpy
(
p_block
->
p_buffer
,
p_sys
->
p_buffer_out
,
i_out
);
p_block
->
i_buffer
=
i_out
;
/* FIXME, 3-2 pulldown is not handled correctly */
p_block
->
i_length
=
INT64_C
(
1000000
)
*
...
...
@@ -1095,6 +1087,7 @@ static block_t *EncodeAudio( encoder_t *p_enc, aout_buffer_t *p_aout_buf )
{
void
*
p_samples
;
int
i_out
;
p_block
=
block_New
(
p_enc
,
p_sys
->
i_buffer_out
);
if
(
i_samples_delay
)
{
...
...
@@ -1116,8 +1109,8 @@ static block_t *EncodeAudio( encoder_t *p_enc, aout_buffer_t *p_aout_buf )
p_samples
=
p_buffer
;
}
i_out
=
avcodec_encode_audio
(
p_sys
->
p_context
,
p_
sys
->
p_buffer_out
,
p_
sys
->
i_buffer_out
,
p_samples
);
i_out
=
avcodec_encode_audio
(
p_sys
->
p_context
,
p_
block
->
p_buffer
,
p_
block
->
i_buffer
,
p_samples
);
#if 0
msg_Warn( p_enc, "avcodec_encode_audio: %d", i_out );
...
...
@@ -1127,10 +1120,12 @@ static block_t *EncodeAudio( encoder_t *p_enc, aout_buffer_t *p_aout_buf )
i_samples
-=
p_sys
->
i_frame_size
;
if
(
i_out
<=
0
)
{
block_Release
(
p_block
);
continue
;
}
p_block
=
block_New
(
p_enc
,
i_out
);
memcpy
(
p_block
->
p_buffer
,
p_sys
->
p_buffer_out
,
i_out
);
p_block
->
i_buffer
=
i_out
;
p_block
->
i_length
=
(
mtime_t
)
1000000
*
(
mtime_t
)
p_sys
->
i_frame_size
/
...
...
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