]> git.sesse.net Git - vlc/commitdiff
only round width and scale height accordingly
authorClément Stenac <zorglub@videolan.org>
Sat, 11 Feb 2006 15:21:21 +0000 (15:21 +0000)
committerClément Stenac <zorglub@videolan.org>
Sat, 11 Feb 2006 15:21:21 +0000 (15:21 +0000)
modules/stream_out/transcode.c

index a6f168bae5b196009035ff494d578a8783aac2cf..2e7567b9f37272b3b7b28b57c41b842ad097a299 100644 (file)
@@ -1547,7 +1547,7 @@ static int transcode_video_encoder_open( sout_stream_t *p_stream,
     if( id->p_encoder->fmt_out.video.i_width <= 0 &&
         id->p_encoder->fmt_out.video.i_height <= 0 && p_sys->f_scale )
     {
-        /* Apply the scaling and round at the nearest 16. Don't allow 0 size */
+        float f_real_scale;
         id->p_encoder->fmt_out.video.i_width = i_width * p_sys->f_scale;
         if( id->p_encoder->fmt_out.video.i_width % 16 <= 7 &&
             id->p_encoder->fmt_out.video.i_width >= 16 )
@@ -1557,14 +1557,14 @@ static int transcode_video_encoder_open( sout_stream_t *p_stream,
             id->p_encoder->fmt_out.video.i_width +=
                     16 - id->p_encoder->fmt_out.video.i_width % 16;
 
-        id->p_encoder->fmt_out.video.i_height = i_height * p_sys->f_scale;
-        if( id->p_encoder->fmt_out.video.i_height % 16 <= 7 &&
-            id->p_encoder->fmt_out.video.i_height >= 16 )
-            id->p_encoder->fmt_out.video.i_height -=
-                    id->p_encoder->fmt_out.video.i_height % 16;
-        else
-            id->p_encoder->fmt_out.video.i_height +=
-                    16 - id->p_encoder->fmt_out.video.i_height % 16;
+        f_real_scale = (float)( id->p_encoder->fmt_out.video.i_width) /
+                                (float)i_width;
+
+        id->p_encoder->fmt_out.video.i_height = __MAX( 16,
+                                                  i_height * f_real_scale );
+        msg_Dbg( p_stream, "scaling to %ix%i",
+                        id->p_encoder->fmt_out.video.i_width,
+                        id->p_encoder->fmt_out.video.i_height  );
     }
     else if( id->p_encoder->fmt_out.video.i_width > 0 &&
              id->p_encoder->fmt_out.video.i_height <= 0 )