[vlc-devel] [PATCH] transcode: reinit filter-chain when aspect-ratio changes
Ilkka Ollakka
ileoo at videolan.org
Fri Nov 2 16:10:18 CET 2012
---
modules/stream_out/transcode/transcode.h | 1 +
modules/stream_out/transcode/video.c | 36 ++++++++++++++++++++++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/modules/stream_out/transcode/transcode.h b/modules/stream_out/transcode/transcode.h
index 5db1e13..baf8a0a 100644
--- a/modules/stream_out/transcode/transcode.h
+++ b/modules/stream_out/transcode/transcode.h
@@ -43,6 +43,7 @@ struct sout_stream_sys_t
double f_fps;
unsigned int i_width, i_maxwidth;
unsigned int i_height, i_maxheight;
+ unsigned int i_sar_num, i_sar_den;
bool b_deinterlace;
char *psz_deinterlace;
config_chain_t *p_deinterlace_cfg;
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index e8ca26d..df1acd5 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -34,8 +34,8 @@
#include <vlc_spu.h>
#include <vlc_modules.h>
-#define ENC_FRAMERATE (25 * 1000 + .5)
-#define ENC_FRAMERATE_BASE 1000
+#define ENC_FRAMERATE (25 * 1001 + .5)
+#define ENC_FRAMERATE_BASE 1001
struct decoder_owner_sys_t
{
@@ -638,6 +638,36 @@ 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 &&
+ (p_sys->i_sar_num != id->p_decoder->fmt_out.video.i_sar_num ) ||
+ (p_sys->i_sar_den != id->p_decoder->fmt_out.video.i_sar_den )
+ )
+ )
+ {
+ msg_Info( p_stream, "aspect-ratio changed, reiniting. %i -> %i : %i -> %i.",
+ p_sys->i_sar_num, id->p_decoder->fmt_out.video.i_sar_num,
+ p_sys->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 );
+ p_sys->i_sar_num = id->p_decoder->fmt_out.video.i_sar_num;
+ p_sys->i_sar_den = id->p_decoder->fmt_out.video.i_sar_den;
+ }
+
if( unlikely( !id->p_encoder->p_module ) )
{
@@ -645,6 +675,8 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_t *id,
transcode_video_filter_init( p_stream, id );
+ p_sys->i_sar_num = id->p_decoder->fmt_out.video.i_sar_num;
+ p_sys->i_sar_den = id->p_decoder->fmt_out.video.i_sar_den;
if( transcode_video_encoder_open( p_stream, id ) != VLC_SUCCESS )
{
picture_Release( p_pic );
--
1.8.0
More information about the vlc-devel
mailing list