[xiph-commits] r16460 - trunk/ffmpeg2theora/src

j at svn.xiph.org j at svn.xiph.org
Sat Aug 8 06:02:05 PDT 2009


Author: j
Date: 2009-08-08 06:02:05 -0700 (Sat, 08 Aug 2009)
New Revision: 16460

Modified:
   trunk/ffmpeg2theora/src/ffmpeg2theora.c
   trunk/ffmpeg2theora/src/ffmpeg2theora.h
Log:
make --max_size also understand 640x480, patch by Mikael Nordfeldth

Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.c	2009-08-08 12:44:58 UTC (rev 16459)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.c	2009-08-08 13:02:05 UTC (rev 16460)
@@ -188,7 +188,8 @@
         this->aspect_numerator=0;
         this->aspect_denominator=0;
         this->frame_aspect=0;
-        this->max_size=-1;
+        this->max_x=-1;
+        this->max_y=-1;
         this->deinterlace=0; // auto by default, if input is flaged as interlaced it will deinterlace.
         this->soft_target=0;
         this->buf_delay=-1;
@@ -703,7 +704,7 @@
                 }
             }
         }
-        if (this->max_size > 0) {
+        if (this->max_x > 0) {
             int width = display_width-this->frame_leftBand-this->frame_rightBand;
             int height = display_height-this->frame_topBand-this->frame_bottomBand;
             if (sample_aspect_ratio.den!=0 && sample_aspect_ratio.num!=0) {
@@ -713,13 +714,13 @@
             }
             if (this->frame_aspect == 0)
                 this->frame_aspect = (float)width/height;
-            if (width > height) {
-                this->picture_width = this->max_size;
-                this->picture_height = this->max_size / this->frame_aspect;
+            if (width > height && this->max_x/this->frame_aspect <= this->max_y) {
+                this->picture_width = this->max_x;
+                this->picture_height = this->max_x / this->frame_aspect;
                 this->picture_height = this->picture_height + this->picture_height%2;
             } else {
-                this->picture_height = this->max_size;
-                this->picture_width = this->max_size * this->frame_aspect;
+                this->picture_height = this->max_y;
+                this->picture_width = this->max_y * this->frame_aspect;
                 this->picture_width = this->picture_width + this->picture_width%2;
             }
         }
@@ -1788,8 +1789,8 @@
 
         "  -x, --width            scale to given width (in pixels)\n"
         "  -y, --height           scale to given height (in pixels)\n"
-        "      --max_size         scale output frame to be withing box of \n"
-        "                         given size (in pixels)\n"
+        "      --max_size         scale output frame to be within box of \n"
+        "                         given size, height optional (%%d[x%%d], i.e. 640x480)\n"
         "      --aspect           define frame aspect ratio: i.e. 4:3 or 16:9\n"
         "  -F, --framerate        output framerate e.g 25:2 or 16\n"
         "      --croptop, --cropbottom, --cropleft, --cropright\n"
@@ -2121,7 +2122,9 @@
                             flag = -1;
                             break;
                         case MAXSIZE_FLAG:
-                            convert->max_size = atoi(optarg);
+                            if(sscanf(optarg, "%dx%d", &convert->max_x, &convert->max_y) != 2) {
+                                convert->max_y = convert->max_x = atoi(optarg);
+                            }
                             flag = -1;
                             break;
                         case INPUTFPS_FLAG:

Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.h
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.h	2009-08-08 12:44:58 UTC (rev 16459)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.h	2009-08-08 13:02:05 UTC (rev 16460)
@@ -58,7 +58,8 @@
     ogg_int32_t aspect_numerator;
     ogg_int32_t aspect_denominator;
     double frame_aspect;
-    int max_size;
+    int max_x;
+    int max_y;
 
     int pix_fmt;
     int video_quality;



More information about the commits mailing list