[vlc-commits] transcode: reinit filter-chain when aspect-ratio changes

Ilkka Ollakka git at videolan.org
Fri Feb 8 14:23:11 CET 2013


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sat Jan 14 23:20:04 2012 +0200| [68b6cc27c7c3a2717abc37aabf6fd89440f10a92] | committer: Ilkka Ollakka

transcode: reinit filter-chain when aspect-ratio changes

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

 modules/stream_out/transcode/transcode.h |    1 +
 modules/stream_out/transcode/video.c     |   29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/modules/stream_out/transcode/transcode.h b/modules/stream_out/transcode/transcode.h
index 5db1e13..fc8bb41 100644
--- a/modules/stream_out/transcode/transcode.h
+++ b/modules/stream_out/transcode/transcode.h
@@ -36,6 +36,7 @@ struct sout_stream_sys_t
 
     /* Video */
     vlc_fourcc_t    i_vcodec;   /* codec video (0 if not transcode) */
+    video_format_t  fmt_input_video;
     char            *psz_venc;
     config_chain_t  *p_video_cfg;
     int             i_vbitrate;
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index e8ca26d..06dd3e9 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -638,12 +638,41 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_t *id,
                 b_need_duplicate = true;
             }
         }
+        if( unlikely (
+             id->p_encoder->p_module &&
+             !video_format_IsSimilar( &p_sys->fmt_input_video, &id->p_decoder->fmt_out.video )
+            )
+          )
+        {
+            msg_Info( p_stream, "aspect-ratio changed, reiniting. %i -> %i : %i -> %i.",
+                        p_sys->fmt_input_video.i_sar_num, id->p_decoder->fmt_out.video.i_sar_num,
+                        p_sys->fmt_input_video.i_sar_den, id->p_decoder->fmt_out.video.i_sar_den
+                    );
+            /* Close filters */
+            if( id->p_f_chain )
+                filter_chain_Delete( id->p_f_chain );
+            id->p_f_chain = NULL;
+            if( id->p_uf_chain )
+                filter_chain_Delete( id->p_uf_chain );
+            id->p_uf_chain = NULL;
+
+            /* Reinitialize filters */
+            id->p_encoder->fmt_out.video.i_width  = p_sys->i_width & ~1;
+            id->p_encoder->fmt_out.video.i_height = p_sys->i_height & ~1;
+            id->p_encoder->fmt_out.video.i_sar_num = id->p_encoder->fmt_out.video.i_sar_den = 0;
+
+            transcode_video_encoder_init( p_stream, id );
+            transcode_video_filter_init( p_stream, id );
+            memcpy( &p_sys->fmt_input_video, &id->p_decoder->fmt_out.video, sizeof(video_format_t));
+        }
+
 
         if( unlikely( !id->p_encoder->p_module ) )
         {
             transcode_video_encoder_init( p_stream, id );
 
             transcode_video_filter_init( p_stream, id );
+            memcpy( &p_sys->fmt_input_video, &id->p_decoder->fmt_out.video, sizeof(video_format_t));
 
             if( transcode_video_encoder_open( p_stream, id ) != VLC_SUCCESS )
             {



More information about the vlc-commits mailing list