Browse code

* making it possible to override aspect ratio from the command line

Originally committed as revision 1828 to svn://svn.ffmpeg.org/ffmpeg/trunk

Roman Shaposhnik authored on 2003/04/30 04:46:08
Showing 1 changed files
... ...
@@ -1685,6 +1685,29 @@ static void opt_frame_size(const char *arg)
1685 1685
     }
1686 1686
 }
1687 1687
 
1688
+static void opt_frame_aspect_ratio(const char *arg)
1689
+{
1690
+    int x = 0, y = 0;
1691
+    double ar = 0;
1692
+    const char *p;
1693
+    
1694
+    p = strchr(arg, ':');
1695
+    if (p) {
1696
+        x = strtol(arg, (char **)&arg, 10);
1697
+	if (arg == p)
1698
+	    y = strtol(arg+1, (char **)&arg, 10);
1699
+	if (x > 0 && y > 0)
1700
+	    ar = (double)x / (double)y;
1701
+    } else
1702
+        ar = strtod(arg, (char **)&arg);
1703
+
1704
+    if (!ar) {
1705
+        fprintf(stderr, "Incorrect aspect ratio specification.\n");
1706
+	exit(1);
1707
+    }
1708
+    frame_aspect_ratio = ar;
1709
+}
1710
+
1688 1711
 static void opt_gop_size(const char *arg)
1689 1712
 {
1690 1713
     gop_size = atoi(arg);
... ...
@@ -2677,6 +2700,7 @@ const OptionDef options[] = {
2677 2677
     { "r", HAS_ARG, {(void*)opt_frame_rate}, "set frame rate (in Hz)", "rate" },
2678 2678
     { "re", OPT_BOOL|OPT_EXPERT, {(void*)&rate_emu}, "read input at native frame rate" },
2679 2679
     { "s", HAS_ARG, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" },
2680
+    { "aspect", HAS_ARG, {(void*)opt_frame_aspect_ratio}, "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
2680 2681
     { "croptop", HAS_ARG, {(void*)opt_frame_crop_top}, "set top crop band size (in pixels)", "size" },
2681 2682
     { "cropbottom", HAS_ARG, {(void*)opt_frame_crop_bottom}, "set bottom crop band size (in pixels)", "size" },
2682 2683
     { "cropleft", HAS_ARG, {(void*)opt_frame_crop_left}, "set left crop band size (in pixels)", "size" },