[vlc-devel] [PATCH] transcode aspect ratio: do not divide by zero - fixes #1663

Rémi Denis-Courmont rdenis at simphalempin.com
Mon Jul 7 21:33:47 CEST 2008


Someone should really double check this, especially given the FIXME.
---
 modules/stream_out/transcode.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/modules/stream_out/transcode.c b/modules/stream_out/transcode.c
index 2662e6c..cfe818d 100644
--- a/modules/stream_out/transcode.c
+++ b/modules/stream_out/transcode.c
@@ -1983,8 +1983,11 @@ static int transcode_video_process( sout_stream_t *p_stream,
             fmt = filter_chain_GetFmtOut( id->p_f_chain )->video;
 
             /* FIXME (shouldn't have to be done here) */
-            fmt.i_sar_num = fmt.i_aspect * fmt.i_height / fmt.i_width;
-            fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+            fmt.i_sar_num = fmt.i_aspect * fmt.i_height;
+            fmt.i_sar_den = fmt.i_width * VOUT_ASPECT_FACTOR;
+            int gcd = GCD (fmt.i_sar_num, fmt.i_sar_den);
+            fmt.i_sar_num /= gcd;
+            fmt.i_sar_den /= gcd;
 
             spu_RenderSubpictures( p_sys->p_spu, &fmt, p_pic, p_pic, p_subpic,
                                    i_scale_width, i_scale_height );
-- 
1.5.6



More information about the vlc-devel mailing list