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
f271aa1b
Commit
f271aa1b
authored
Mar 14, 2013
by
Ilkka Ollakka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec: use encode_video2 if available
closes #8291
parent
4e98f03a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
12 deletions
+32
-12
modules/codec/avcodec/encoder.c
modules/codec/avcodec/encoder.c
+32
-12
No files found.
modules/codec/avcodec/encoder.c
View file @
f271aa1b
...
...
@@ -825,19 +825,16 @@ int OpenEncoder( vlc_object_t *p_this )
p_context
->
channels
;
p_sys
->
i_frame_size
=
p_context
->
frame_size
>
1
?
p_context
->
frame_size
:
RAW_AUDIO_FRAME
_SIZE
;
FF_MIN_BUFFER
_SIZE
;
p_sys
->
p_buffer
=
malloc
(
p_sys
->
i_frame_size
*
p_sys
->
i_sample_bytes
);
if
(
p_sys
->
p_buffer
==
NULL
)
if
(
unlikely
(
p_sys
->
p_buffer
==
NULL
)
)
{
goto
error
;
}
p_enc
->
fmt_out
.
audio
.
i_blockalign
=
p_context
->
block_align
;
p_enc
->
fmt_out
.
audio
.
i_bitspersample
=
aout_BitsPerSample
(
p_enc
->
fmt_out
.
i_codec
);
if
(
p_context
->
frame_size
>
1
)
p_sys
->
i_buffer_out
=
8
*
AVCODEC_MAX_AUDIO_FRAME_SIZE
;
else
p_sys
->
i_buffer_out
=
p_sys
->
i_frame_size
*
p_sys
->
i_sample_bytes
;
p_sys
->
i_buffer_out
=
p_sys
->
i_frame_size
*
p_sys
->
i_sample_bytes
;
}
p_sys
->
frame
=
avcodec_alloc_frame
();
...
...
@@ -865,7 +862,8 @@ error:
static
block_t
*
EncodeVideo
(
encoder_t
*
p_enc
,
picture_t
*
p_pict
)
{
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
int
i_out
,
i_plane
;
int
i_out
,
i_plane
,
i_got_packet
=
1
;
AVPacket
av_pkt
;
/* Initialize the video output buffer the first time.
* This is done here instead of OpenEncoder() because we need the actual
...
...
@@ -876,6 +874,12 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
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_Alloc
(
blocksize
);
#if (LIBAVCODEC_VERSION_MAJOR >= 54)
/*We don't use av_pkt with major_version < 54, so no point init it*/
av_init_packet
(
&
av_pkt
);
av_pkt
.
data
=
p_block
->
p_buffer
;
av_pkt
.
size
=
p_block
->
i_buffer
;
#endif
if
(
likely
(
p_pict
)
)
{
avcodec_get_frame_defaults
(
p_sys
->
frame
);
for
(
i_plane
=
0
;
i_plane
<
p_pict
->
i_planes
;
i_plane
++
)
...
...
@@ -954,21 +958,29 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
p_sys
->
frame
->
quality
=
p_sys
->
i_quality
;
i_out
=
avcodec_encode_video
(
p_sys
->
p_context
,
p_block
->
p_buffer
,
p_block
->
i_buffer
,
p_sys
->
frame
);
#if (LIBAVCODEC_VERSION_MAJOR < 54)
i_out
=
avcodec_encode_video
(
p_sys
->
p_context
,
p_block
->
p_buffer
,
p_block
->
i_buffer
,
p_sys
->
frame
);
#else
i_out
=
avcodec_encode_video2
(
p_sys
->
p_context
,
&
av_pkt
,
p_sys
->
frame
,
&
i_got_packet
);
#endif
}
else
{
i_out
=
avcodec_encode_video
(
p_sys
->
p_context
,
p_block
->
p_buffer
,
p_block
->
i_buffer
,
NULL
);
#if (LIBAVCODEC_VERSION_MAJOR < 54)
i_out
=
avcodec_encode_video
(
p_sys
->
p_context
,
p_block
->
p_buffer
,
p_block
->
i_buffer
,
NULL
);
#else
i_out
=
avcodec_encode_video2
(
p_sys
->
p_context
,
&
av_pkt
,
NULL
,
&
i_got_packet
);
#endif
}
if
(
i_out
<=
0
)
if
(
unlikely
(
i_out
<
0
||
i_got_packet
==
0
)
)
{
block_Release
(
p_block
);
return
NULL
;
}
#if (LIBAVCODEC_VERSION_MAJOR < 54)
p_block
->
i_buffer
=
i_out
;
/* FIXME, 3-2 pulldown is not handled correctly */
...
...
@@ -1016,6 +1028,14 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
* correctly */
p_block
->
i_dts
=
p_block
->
i_pts
=
p_pict
->
date
;
}
#else
p_block
->
i_buffer
=
av_pkt
.
size
;
p_block
->
i_length
=
av_pkt
.
duration
/
p_sys
->
p_context
->
time_base
.
den
;
p_block
->
i_pts
=
av_pkt
.
pts
;
p_block
->
i_dts
=
av_pkt
.
dts
;
#endif
switch
(
p_sys
->
p_context
->
coded_frame
->
pict_type
)
{
...
...
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