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

j at svn.xiph.org j at svn.xiph.org
Sat Feb 6 23:10:09 PST 2010


Author: j
Date: 2010-02-06 23:10:09 -0800 (Sat, 06 Feb 2010)
New Revision: 16879

Modified:
   trunk/ffmpeg2theora/src/ffmpeg2theora.c
Log:
deal with --max_size and only width or height in one place

Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.c	2010-02-07 06:08:51 UTC (rev 16878)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.c	2010-02-07 07:10:09 UTC (rev 16879)
@@ -559,16 +559,6 @@
         fprintf(stderr, "ticks per frame: %i\n", venc->ticks_per_frame);
         fprintf(stderr, "FPS used: %f\n", fps);
 #endif
-        if (this->picture_width && !this->picture_height) {
-            this->picture_height = this->picture_width / ((double)display_width/display_height);
-            this->picture_height = this->picture_height - this->picture_height%2;
-        }
-        if (this->picture_height && !this->picture_width) {
-            this->picture_width = this->picture_height * ((double)display_width/display_height);
-            this->picture_width = this->picture_width - this->picture_width%2;
-        }
-
-
         if (this->picture_height==0 &&
             (this->frame_leftBand || this->frame_rightBand || this->frame_topBand || this->frame_bottomBand) ) {
             this->picture_height=display_height-
@@ -728,8 +718,10 @@
                        1024*1024);
             frame_aspect=av_q2d(this->frame_aspect);
         }
+        if ((this->picture_width && !this->picture_height) ||
+            (this->picture_height && !this->picture_width) ||
+            this->max_x > 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) {
@@ -741,16 +733,28 @@
                 this->frame_aspect.num = width;
                 this->frame_aspect.den = height;
             }
-            if (width > height &&
-                this->max_x/av_q2d(this->frame_aspect) <= this->max_y) {
-                this->picture_width = this->max_x;
-                this->picture_height = this->max_x / av_q2d(this->frame_aspect);
+
+            if (this->picture_width && !this->picture_height) {
+                this->picture_height = this->picture_width / av_q2d(this->frame_aspect);
                 this->picture_height = this->picture_height + this->picture_height%2;
-            } else {
-                this->picture_height = this->max_y;
-                this->picture_width = this->max_y * av_q2d(this->frame_aspect);
+            }
+            else if (this->picture_height && !this->picture_width) {
+                this->picture_width = this->picture_height * av_q2d(this->frame_aspect);
                 this->picture_width = this->picture_width + this->picture_width%2;
             }
+
+            if (this->max_x > 0) {
+                if (width > height &&
+                    this->max_x/av_q2d(this->frame_aspect) <= this->max_y) {
+                    this->picture_width = this->max_x;
+                    this->picture_height = this->max_x / av_q2d(this->frame_aspect);
+                    this->picture_height = this->picture_height + this->picture_height%2;
+                } else {
+                    this->picture_height = this->max_y;
+                    this->picture_width = this->max_y * av_q2d(this->frame_aspect);
+                    this->picture_width = this->picture_width + this->picture_width%2;
+                }
+            }
         }
 
         if (this->no_upscaling) {



More information about the commits mailing list