[vlc-devel] commit: v4l2: add aspect-ratio option to give picture aspect-ratio for input ( Ilkka Ollakka )

git version control git at videolan.org
Sat Oct 3 21:37:49 CEST 2009


vlc | branch: 1.0-bugfix | Ilkka Ollakka <ileoo at videolan.org> | Wed Aug 26 16:36:46 2009 +0300| [1daf60e6e51c609edce6b66bab72a4ac9dff0a7f] | committer: Antoine Cellerier 

v4l2: add aspect-ratio option to give picture aspect-ratio for input
(cherry picked from commit e9d65404475f3fcb30fd8aecbb8a5ded767c4a42)

Signed-off-by: Antoine Cellerier <dionoea at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1daf60e6e51c609edce6b66bab72a4ac9dff0a7f
---

 modules/access/v4l2.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/modules/access/v4l2.c b/modules/access/v4l2.c
index 7971393..113162d 100644
--- a/modules/access/v4l2.c
+++ b/modules/access/v4l2.c
@@ -204,6 +204,9 @@ static void AccessClose( vlc_object_t * );
     "please use 'v4l2:/""/ :input-slave=alsa:/""/' or " \
     "'v4l2:/""/ :input-slave=oss:/""/' instead." )
 
+#define ASPECT_TEXT N_("Picture aspect-ratio n:m")
+#define ASPECT_LONGTEXT N_("Define input picture aspect-ratio to use. Default is 4:3" )
+
 typedef enum {
     IO_METHOD_AUTO,
     IO_METHOD_READ,
@@ -259,6 +262,8 @@ vlc_module_begin ()
                 WIDTH_LONGTEXT, true )
     add_integer( CFG_PREFIX "height", -1, NULL, HEIGHT_TEXT,
                 HEIGHT_LONGTEXT, true )
+    add_string( CFG_PREFIX "aspect-ratio", "4:3", NULL, ASPECT_TEXT,
+              ASPECT_LONGTEXT, true )
     add_float( CFG_PREFIX "fps", 0, NULL, FPS_TEXT, FPS_LONGTEXT, true )
     add_integer( CFG_PREFIX "caching", DEFAULT_PTS_DELAY / 1000, NULL,
                 CACHING_TEXT, CACHING_LONGTEXT, true )
@@ -527,6 +532,7 @@ struct demux_sys_t
 
     int i_width;
     int i_height;
+    unsigned int i_aspect;
     float f_fps;            /* <= 0.0 mean to grab at full rate */
     mtime_t i_video_pts;    /* only used when f_fps > 0 */
     int i_fourcc;
@@ -689,6 +695,19 @@ static void GetV4L2Params( demux_sys_t *p_sys, vlc_object_t *p_obj )
 
     p_sys->psz_set_ctrls = var_CreateGetString( p_obj, "v4l2-set-ctrls" );
 
+    char *psz_aspect = var_CreateGetString( p_obj, "v4l2-aspect-ratio" );
+    if( psz_aspect && *psz_aspect && strchr( psz_aspect, ":" ) )
+    {
+        char psz_delim = strchr( psz_aspect, ":" );
+        p_sys->i_aspect = atoi( psz_aspect ) * VOUT_ASPECT_FACTOR / atoi( psz_delim + 1 );
+    }
+    else
+    {
+        p_sys->i_aspect = 4 * VOUT_ASPECT_FACTOR / 3 ;
+
+    }
+    free( psz_aspect );
+
     p_sys->psz_device = NULL;
     p_sys->i_fd = -1;
 
@@ -819,6 +838,17 @@ static void ParseMRL( demux_sys_t *p_sys, char *psz_path, vlc_object_t *p_obj )
                     strtol( psz_parser + strlen( "height=" ),
                             &psz_parser, 0 );
             }
+            else if( !strncmp( psz_parser, "aspect-ratio=",
+                               strlen( "aspect-ratio=" ) ) )
+            {
+                unsigned int num,den;
+                num = strtol( psz_parser + strlen( "aspect-ratio=" ),
+                              &psz_parser, 0 );
+                den = strtol( psz_parser + strlen( ":" ),
+                              &psz_parser, 0 );
+                if( num && den )
+                    p_sys->i_aspect = num * VOUT_ASPECT_FACTOR / den;
+            }
             else if( !strncmp( psz_parser, "controls-reset",
                                strlen( "controls-reset" ) ) )
             {




More information about the vlc-devel mailing list