Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
804df225
Commit
804df225
authored
Nov 10, 2013
by
Ilkka Ollakka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transcode: encode buffer and flush encoder at the end when using threads
parent
627b5d8e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
11 deletions
+50
-11
modules/stream_out/transcode/video.c
modules/stream_out/transcode/video.c
+50
-11
No files found.
modules/stream_out/transcode/video.c
View file @
804df225
...
@@ -101,35 +101,64 @@ static void* EncoderThread( void *obj )
...
@@ -101,35 +101,64 @@ static void* EncoderThread( void *obj )
{
{
sout_stream_sys_t
*
p_sys
=
(
sout_stream_sys_t
*
)
obj
;
sout_stream_sys_t
*
p_sys
=
(
sout_stream_sys_t
*
)
obj
;
sout_stream_id_t
*
id
=
p_sys
->
id_video
;
sout_stream_id_t
*
id
=
p_sys
->
id_video
;
picture_t
*
p_pic
;
picture_t
*
p_pic
=
NULL
;
int
canc
=
vlc_savecancel
();
int
canc
=
vlc_savecancel
();
block_t
*
p_block
=
NULL
;
for
(
;;
)
for
(
;;
)
{
{
block_t
*
p_block
;
vlc_mutex_lock
(
&
p_sys
->
lock_out
);
vlc_mutex_lock
(
&
p_sys
->
lock_out
);
while
(
!
p_sys
->
b_abort
&&
while
(
!
p_sys
->
b_abort
&&
(
p_pic
=
picture_fifo_Pop
(
p_sys
->
pp_pics
))
==
NULL
)
(
p_pic
=
picture_fifo_Pop
(
p_sys
->
pp_pics
))
==
NULL
)
vlc_cond_wait
(
&
p_sys
->
cond
,
&
p_sys
->
lock_out
);
vlc_cond_wait
(
&
p_sys
->
cond
,
&
p_sys
->
lock_out
);
if
(
p_sys
->
b_abort
)
if
(
p_sys
->
b_abort
&&
!
p_pic
)
{
{
vlc_mutex_unlock
(
&
p_sys
->
lock_out
);
vlc_mutex_unlock
(
&
p_sys
->
lock_out
);
break
;
break
;
}
}
vlc_mutex_unlock
(
&
p_sys
->
lock_out
);
vlc_mutex_unlock
(
&
p_sys
->
lock_out
);
p_block
=
id
->
p_encoder
->
pf_encode_video
(
id
->
p_encoder
,
p_pic
);
if
(
p_pic
)
{
p_block
=
id
->
p_encoder
->
pf_encode_video
(
id
->
p_encoder
,
p_pic
);
vlc_mutex_lock
(
&
p_sys
->
lock_out
);
block_ChainAppend
(
&
p_sys
->
p_buffers
,
p_block
);
vlc_mutex_unlock
(
&
p_sys
->
lock_out
);
picture_Release
(
p_pic
);
}
vlc_mutex_lock
(
&
p_sys
->
lock_out
);
vlc_mutex_lock
(
&
p_sys
->
lock_out
);
if
(
p_sys
->
b_abort
)
{
vlc_mutex_unlock
(
&
p_sys
->
lock_out
);
break
;
}
vlc_mutex_unlock
(
&
p_sys
->
lock_out
);
}
/*Encode what we have in the buffer on closing*/
vlc_mutex_lock
(
&
p_sys
->
lock_out
);
while
(
(
p_pic
=
picture_fifo_Pop
(
p_sys
->
pp_pics
))
!=
NULL
)
{
p_block
=
id
->
p_encoder
->
pf_encode_video
(
id
->
p_encoder
,
p_pic
);
block_ChainAppend
(
&
p_sys
->
p_buffers
,
p_block
);
block_ChainAppend
(
&
p_sys
->
p_buffers
,
p_block
);
vlc_mutex_unlock
(
&
p_sys
->
lock_out
);
picture_Release
(
p_pic
);
picture_Release
(
p_pic
);
}
}
block_ChainRelease
(
p_sys
->
p_buffers
);
/*Now flush encoder*/
do
{
p_block
=
id
->
p_encoder
->
pf_encode_video
(
id
->
p_encoder
,
NULL
);
block_ChainAppend
(
&
p_sys
->
p_buffers
,
p_block
);
}
while
(
p_block
);
vlc_mutex_unlock
(
&
p_sys
->
lock_out
);
vlc_restorecancel
(
canc
);
vlc_restorecancel
(
canc
);
return
NULL
;
return
NULL
;
...
@@ -580,6 +609,7 @@ void transcode_video_close( sout_stream_t *p_stream,
...
@@ -580,6 +609,7 @@ void transcode_video_close( sout_stream_t *p_stream,
vlc_cond_destroy
(
&
p_stream
->
p_sys
->
cond
);
vlc_cond_destroy
(
&
p_stream
->
p_sys
->
cond
);
picture_fifo_Delete
(
p_stream
->
p_sys
->
pp_pics
);
picture_fifo_Delete
(
p_stream
->
p_sys
->
pp_pics
);
block_ChainRelease
(
p_stream
->
p_sys
->
p_buffers
);
p_stream
->
p_sys
->
pp_pics
=
NULL
;
p_stream
->
p_sys
->
pp_pics
=
NULL
;
}
}
...
@@ -716,7 +746,7 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_t *id,
...
@@ -716,7 +746,7 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_t *id,
{
{
sout_stream_sys_t
*
p_sys
=
p_stream
->
p_sys
;
sout_stream_sys_t
*
p_sys
=
p_stream
->
p_sys
;
bool
b_need_duplicate
=
false
;
bool
b_need_duplicate
=
false
;
picture_t
*
p_pic
;
picture_t
*
p_pic
=
NULL
;
*
out
=
NULL
;
*
out
=
NULL
;
if
(
unlikely
(
in
==
NULL
)
)
if
(
unlikely
(
in
==
NULL
)
)
...
@@ -731,10 +761,19 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_t *id,
...
@@ -731,10 +761,19 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_t *id,
}
}
else
else
{
{
/*
msg_Dbg
(
p_stream
,
"Flushing thread and waiting that"
);
* FIXME: we need EncoderThread() to flush buffers and signal us
vlc_mutex_lock
(
&
p_stream
->
p_sys
->
lock_out
);
* when it's done so we can send the last frames to the chain
p_stream
->
p_sys
->
b_abort
=
true
;
*/
vlc_cond_signal
(
&
p_stream
->
p_sys
->
cond
);
vlc_mutex_unlock
(
&
p_stream
->
p_sys
->
lock_out
);
vlc_join
(
p_stream
->
p_sys
->
thread
,
NULL
);
vlc_mutex_lock
(
&
p_sys
->
lock_out
);
*
out
=
p_sys
->
p_buffers
;
p_sys
->
p_buffers
=
NULL
;
vlc_mutex_unlock
(
&
p_sys
->
lock_out
);
msg_Dbg
(
p_stream
,
"Flushing done"
);
}
}
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
...
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