vlc | branch: master | Francois Cartegnie <[email protected]> | Wed Aug 29 
15:58:23 2018 +0200| [424be6811ddfc4f9051750f6e7cd5abe0ea97627] | committer: 
Francois Cartegnie

transcode: video: handle eos

Allows final or temp still frames to be output.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=424be6811ddfc4f9051750f6e7cd5abe0ea97627
---

 modules/stream_out/transcode/video.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/modules/stream_out/transcode/video.c 
b/modules/stream_out/transcode/video.c
index 24303dcb81..a209482123 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -435,11 +435,24 @@ static picture_t * RenderSubpictures( sout_stream_t 
*p_stream, sout_stream_id_sy
     return p_pic;
 }
 
+static void tag_last_block_with_flag( block_t **out, int i_flag )
+{
+    block_t *p_last = *out;
+    if( p_last )
+    {
+        while( p_last->p_next )
+            p_last = p_last->p_next;
+        p_last->i_flags |= i_flag;
+    }
+}
+
 int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
                                     block_t *in, block_t **out )
 {
     *out = NULL;
 
+    const bool b_eos = in && (in->i_flags & BLOCK_FLAG_END_OF_SEQUENCE);
+
     int ret = id->p_decoder->pf_decode( id->p_decoder, in );
     if( ret != VLCDEC_SUCCESS )
         return VLC_EGENERIC;
@@ -566,6 +579,17 @@ int transcode_video_process( sout_stream_t *p_stream, 
sout_stream_id_sys_t *id,
                 }
             }
         }
+
+        if( b_eos )
+        {
+            msg_Info( p_stream, "Drain/restart on EOS" );
+            if( transcode_encoder_drain( id->encoder, out ) != VLC_SUCCESS )
+                goto error;
+            transcode_encoder_close( id->encoder );
+            if( b_eos )
+                tag_last_block_with_flag( out, BLOCK_FLAG_END_OF_SEQUENCE );
+        }
+
         continue;
 error:
         if( p_pic )
@@ -589,5 +613,8 @@ error:
             msg_Warn( p_stream, "Flushing failed");
     }
 
+    if( b_eos )
+        tag_last_block_with_flag( out, BLOCK_FLAG_END_OF_SEQUENCE );
+
     return id->b_error ? VLC_EGENERIC : VLC_SUCCESS;
 }

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to