Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
1a5e9130
Commit
1a5e9130
authored
Oct 31, 2012
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pthread: avoid copying input packets when possible.
parent
1afddbe5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
pthread.c
libavcodec/pthread.c
+13
-7
No files found.
libavcodec/pthread.c
View file @
1a5e9130
...
@@ -101,7 +101,8 @@ typedef struct PerThreadContext {
...
@@ -101,7 +101,8 @@ typedef struct PerThreadContext {
AVCodecContext
*
avctx
;
///< Context used to decode packets passed to this thread.
AVCodecContext
*
avctx
;
///< Context used to decode packets passed to this thread.
AVPacket
avpkt
;
///< Input packet (for decoding) or output (for encoding).
AVPacket
avpkt
;
///< Input packet (for decoding) or output (for encoding).
int
allocated_buf_size
;
///< Size allocated for avpkt.data
uint8_t
*
buf
;
///< backup storage for packet data when the input packet is not refcounted
int
allocated_buf_size
;
///< Size allocated for buf
AVFrame
frame
;
///< Output frame (for decoding) or input (for encoding).
AVFrame
frame
;
///< Output frame (for decoding) or input (for encoding).
int
got_frame
;
///< The output of got_picture_ptr from the last avcodec_decode_video() call.
int
got_frame
;
///< The output of got_picture_ptr from the last avcodec_decode_video() call.
...
@@ -522,7 +523,6 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
...
@@ -522,7 +523,6 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
FrameThreadContext
*
fctx
=
p
->
parent
;
FrameThreadContext
*
fctx
=
p
->
parent
;
PerThreadContext
*
prev_thread
=
fctx
->
prev_thread
;
PerThreadContext
*
prev_thread
=
fctx
->
prev_thread
;
const
AVCodec
*
codec
=
p
->
avctx
->
codec
;
const
AVCodec
*
codec
=
p
->
avctx
->
codec
;
uint8_t
*
buf
=
p
->
avpkt
.
data
;
if
(
!
avpkt
->
size
&&
!
(
codec
->
capabilities
&
CODEC_CAP_DELAY
))
return
0
;
if
(
!
avpkt
->
size
&&
!
(
codec
->
capabilities
&
CODEC_CAP_DELAY
))
return
0
;
...
@@ -546,11 +546,16 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
...
@@ -546,11 +546,16 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
}
}
}
}
av_
fast_malloc
(
&
buf
,
&
p
->
allocated_buf_size
,
avpkt
->
size
+
FF_INPUT_BUFFER_PADDING_SIZE
);
av_
buffer_unref
(
&
p
->
avpkt
.
buf
);
p
->
avpkt
=
*
avpkt
;
p
->
avpkt
=
*
avpkt
;
p
->
avpkt
.
data
=
buf
;
if
(
avpkt
->
buf
)
memcpy
(
buf
,
avpkt
->
data
,
avpkt
->
size
);
p
->
avpkt
.
buf
=
av_buffer_ref
(
avpkt
->
buf
);
memset
(
buf
+
avpkt
->
size
,
0
,
FF_INPUT_BUFFER_PADDING_SIZE
);
else
{
av_fast_malloc
(
&
p
->
buf
,
&
p
->
allocated_buf_size
,
avpkt
->
size
+
FF_INPUT_BUFFER_PADDING_SIZE
);
p
->
avpkt
.
data
=
p
->
buf
;
memcpy
(
p
->
buf
,
avpkt
->
data
,
avpkt
->
size
);
memset
(
p
->
buf
+
avpkt
->
size
,
0
,
FF_INPUT_BUFFER_PADDING_SIZE
);
}
p
->
state
=
STATE_SETTING_UP
;
p
->
state
=
STATE_SETTING_UP
;
pthread_cond_signal
(
&
p
->
input_cond
);
pthread_cond_signal
(
&
p
->
input_cond
);
...
@@ -762,7 +767,8 @@ static void frame_thread_free(AVCodecContext *avctx, int thread_count)
...
@@ -762,7 +767,8 @@ static void frame_thread_free(AVCodecContext *avctx, int thread_count)
pthread_cond_destroy
(
&
p
->
input_cond
);
pthread_cond_destroy
(
&
p
->
input_cond
);
pthread_cond_destroy
(
&
p
->
progress_cond
);
pthread_cond_destroy
(
&
p
->
progress_cond
);
pthread_cond_destroy
(
&
p
->
output_cond
);
pthread_cond_destroy
(
&
p
->
output_cond
);
av_freep
(
&
p
->
avpkt
.
data
);
av_buffer_unref
(
&
p
->
avpkt
.
buf
);
av_freep
(
&
p
->
buf
);
if
(
i
)
{
if
(
i
)
{
av_freep
(
&
p
->
avctx
->
priv_data
);
av_freep
(
&
p
->
avctx
->
priv_data
);
...
...
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