[vlc-devel] commit: Used a sar for video_format_Setup. (Laurent Aimar )

git version control git at videolan.org
Wed Dec 16 22:01:25 CET 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Tue Dec 15 20:07:37 2009 +0100| [63b7c098f211a5df53527d4b2601e16b943059a7] | committer: Laurent Aimar 

Used a sar for video_format_Setup.

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

 include/vlc_es.h                                   |    2 +-
 modules/codec/mash.cpp                             |    2 +-
 modules/codec/rawvideo.c                           |    3 ++-
 modules/demux/rawvid.c                             |    3 ++-
 .../dynamicoverlay/dynamicoverlay_commands.c       |    6 +++---
 modules/video_filter/wrapper.c                     |    3 ++-
 modules/video_output/opengl.c                      |    3 ++-
 modules/visualization/projectm.cpp                 |    2 +-
 src/misc/es_format.c                               |   12 ++++++++++--
 src/video_output/vout_pictures.c                   |   10 +++++++---
 10 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/include/vlc_es.h b/include/vlc_es.h
index b5be71e..21b6ea5 100644
--- a/include/vlc_es.h
+++ b/include/vlc_es.h
@@ -175,7 +175,7 @@ static inline void video_format_Clean( video_format_t *p_src )
  * It will fill up a video_format_tvideo_format_t using the given arguments.
  * Becarefull that the video_format_t must already be initialized.
  */
-VLC_EXPORT( void, video_format_Setup, ( video_format_t *, vlc_fourcc_t i_chroma, int i_width, int i_height, int i_aspect ) );
+VLC_EXPORT( void, video_format_Setup, ( video_format_t *, vlc_fourcc_t i_chroma, int i_width, int i_height, int i_sar_num, int i_sar_den ) );
 
 /**
  * This function will check if the first video format is similar
diff --git a/modules/codec/mash.cpp b/modules/codec/mash.cpp
index ffb4555..8624579 100644
--- a/modules/codec/mash.cpp
+++ b/modules/codec/mash.cpp
@@ -192,7 +192,7 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
                   i_height);
         video_format_Setup( &p_dec->fmt_out.video, VLC_CODEC_I420,
                             i_width, i_height,
-                            VOUT_ASPECT_FACTOR * i_width / i_height );
+                            1, 1 );
         p_sys->b_inited = true;
     }
     p_pic = NULL;
diff --git a/modules/codec/rawvideo.c b/modules/codec/rawvideo.c
index 27b0b02..b487422 100644
--- a/modules/codec/rawvideo.c
+++ b/modules/codec/rawvideo.c
@@ -159,7 +159,8 @@ static int OpenDecoder( vlc_object_t *p_this )
     video_format_Setup( &p_dec->fmt_out.video, p_dec->fmt_in.i_codec,
                         p_dec->fmt_in.video.i_width,
                         p_dec->fmt_in.video.i_height,
-                        p_dec->fmt_in.video.i_aspect );
+                        p_dec->fmt_in.video.i_aspect * p_dec->fmt_in.video.i_height,
+                        VOUT_ASPECT_FACTOR           * p_dec->fmt_in.video.i_width );
     p_sys->i_raw_size = p_dec->fmt_out.video.i_bits_per_pixel *
         p_dec->fmt_out.video.i_width * p_dec->fmt_out.video.i_height / 8;
 
diff --git a/modules/demux/rawvid.c b/modules/demux/rawvid.c
index 85b3a86..f396538 100644
--- a/modules/demux/rawvid.c
+++ b/modules/demux/rawvid.c
@@ -357,7 +357,8 @@ static int Open( vlc_object_t * p_this )
 
     es_format_Init( &p_sys->fmt_video, VIDEO_ES, i_chroma );
     video_format_Setup( &p_sys->fmt_video.video,
-                        i_chroma, i_width, i_height, i_aspect );
+                        i_chroma, i_width, i_height,
+                        i_aspect * i_height, VOUT_ASPECT_FACTOR * i_width );
 
     vlc_ureduce( &p_sys->fmt_video.video.i_frame_rate,
                  &p_sys->fmt_video.video.i_frame_rate_base,
diff --git a/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c b/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c
index f8697f2..73299a6 100644
--- a/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c
+++ b/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c
@@ -56,7 +56,7 @@ overlay_t *OverlayCreate( void )
     p_ovl->i_alpha = 0xFF;
     p_ovl->b_active = false;
     video_format_Setup( &p_ovl->format, VLC_FOURCC( '\0','\0','\0','\0') , 0, 0,
-                        VOUT_ASPECT_FACTOR );
+                        1, 1 );
     p_ovl->p_fontstyle = text_style_New();
     p_ovl->data.p_text = NULL;
 
@@ -464,7 +464,7 @@ static int exec_DataSharedMem( filter_t *p_filter,
         }
 
         video_format_Setup( &p_ovl->format, VLC_CODEC_TEXT,
-                            0, 0, 0 );
+                            0, 0, 0, 1 );
 
         p_data = shmat( p_params->i_shmid, NULL, SHM_RDONLY );
         if( p_data == NULL )
@@ -489,7 +489,7 @@ static int exec_DataSharedMem( filter_t *p_filter,
 
         video_format_Setup( &p_ovl->format, p_params->fourcc,
                             p_params->i_width, p_params->i_height,
-                            VOUT_ASPECT_FACTOR );
+                            1, 1 );
         if( vout_AllocatePicture( p_filter, p_ovl->data.p_pic,
                                   p_ovl->format.i_chroma, p_params->i_width,
                                   p_params->i_height, p_ovl->format.i_aspect ) )
diff --git a/modules/video_filter/wrapper.c b/modules/video_filter/wrapper.c
index 94823b6..cc24fb6 100644
--- a/modules/video_filter/wrapper.c
+++ b/modules/video_filter/wrapper.c
@@ -145,7 +145,8 @@ static int Open( vlc_object_t *p_this, const char *psz_name, bool b_filter )
     es_format_Init( &fmt, VIDEO_ES, p_vout->render.i_chroma );
     video_format_Setup( &fmt.video, p_vout->render.i_chroma,
                         p_vout->render.i_width, p_vout->render.i_height,
-                        p_vout->render.i_aspect );
+                        p_vout->render.i_aspect * p_vout->render.i_height,
+                        VOUT_ASPECT_FACTOR      * p_vout->render.i_width );
     if( fmt.video.i_sar_num <= 0 || fmt.video.i_sar_den <= 0 )
     {
         fmt.video.i_sar_num = fmt.video.i_aspect * fmt.video.i_visible_height;
diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c
index 016ec8e..b4eaba8 100644
--- a/modules/video_output/opengl.c
+++ b/modules/video_output/opengl.c
@@ -215,7 +215,8 @@ static int Init( vout_thread_t *p_vout )
                         p_vout->render.i_chroma,
                         p_vout->render.i_width,
                         p_vout->render.i_height,
-                        p_vout->render.i_aspect );
+                        p_vout->render.i_aspect * p_vout->render.i_height,
+                        VOUT_ASPECT_FACTOR      * p_vout->render.i_width );
 
 
     if( vout_display_opengl_Init( &p_sys->vgl, &fmt, &p_sys->gl ) )
diff --git a/modules/visualization/projectm.cpp b/modules/visualization/projectm.cpp
index 229b0ab..095f6b7 100644
--- a/modules/visualization/projectm.cpp
+++ b/modules/visualization/projectm.cpp
@@ -272,7 +272,7 @@ static void *Thread( void *p_data )
     /* */
     video_format_Init( &fmt, 0 );
     video_format_Setup( &fmt, VLC_CODEC_RGB32,
-                        p_sys->i_width, p_sys->i_height, 0 );
+                        p_sys->i_width, p_sys->i_height, 0, 1 );
     fmt.i_sar_num = 1;
     fmt.i_sar_den = 1;
 
diff --git a/src/misc/es_format.c b/src/misc/es_format.c
index 5f502a3..ab1e43a 100644
--- a/src/misc/es_format.c
+++ b/src/misc/es_format.c
@@ -129,7 +129,9 @@ void video_format_FixRgb( video_format_t *p_fmt )
                  p_fmt->i_bmask );
 }
 
-void video_format_Setup( video_format_t *p_fmt, vlc_fourcc_t i_chroma, int i_width, int i_height, int i_aspect )
+void video_format_Setup( video_format_t *p_fmt, vlc_fourcc_t i_chroma,
+                         int i_width, int i_height,
+                         int i_sar_num, int i_sar_den )
 {
     p_fmt->i_chroma         = vlc_fourcc_GetCodec( VIDEO_ES, i_chroma );
     p_fmt->i_width          =
@@ -138,7 +140,13 @@ void video_format_Setup( video_format_t *p_fmt, vlc_fourcc_t i_chroma, int i_wid
     p_fmt->i_visible_height = i_height;
     p_fmt->i_x_offset       =
     p_fmt->i_y_offset       = 0;
-    p_fmt->i_aspect         = i_aspect;
+    vlc_ureduce( &p_fmt->i_sar_num, &p_fmt->i_sar_den,
+                 i_sar_num, i_sar_den, 0 );
+    if( p_fmt->i_sar_den > 0 && i_height > 0 )
+        p_fmt->i_aspect     = (int64_t)p_fmt->i_sar_num * i_width * VOUT_ASPECT_FACTOR /
+                              p_fmt->i_sar_den / i_height;
+    else
+        p_fmt->i_aspect     = 0;
 
     switch( p_fmt->i_chroma )
     {
diff --git a/src/video_output/vout_pictures.c b/src/video_output/vout_pictures.c
index fe56010..9a1e994 100644
--- a/src/video_output/vout_pictures.c
+++ b/src/video_output/vout_pictures.c
@@ -714,7 +714,8 @@ int picture_Setup( picture_t *p_picture, vlc_fourcc_t i_chroma, int i_width, int
     p_picture->i_qstride = 0;
     p_picture->p_q = NULL;
 
-    video_format_Setup( &p_picture->format, i_chroma, i_width, i_height, i_aspect );
+    video_format_Setup( &p_picture->format, i_chroma, i_width, i_height,
+                        i_aspect * i_height, VOUT_ASPECT_FACTOR * i_width );
 
     /* Make sure the real dimensions are a multiple of 16 */
     i_width_aligned = (i_width + 15) >> 4 << 4;
@@ -947,7 +948,9 @@ picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_r
 
     /* It is needed to be sure all informations are filled */
     video_format_Setup( &fmt, p_fmt->i_chroma,
-                              p_fmt->i_width, p_fmt->i_height, p_fmt->i_aspect );
+                              p_fmt->i_width, p_fmt->i_height,
+                              p_fmt->i_aspect    * p_fmt->i_height,
+                              VOUT_ASPECT_FACTOR * p_fmt->i_width );
 
     /* */
     picture_t *p_picture = calloc( 1, sizeof(*p_picture) );
@@ -996,7 +999,8 @@ picture_t *picture_New( vlc_fourcc_t i_chroma, int i_width, int i_height, int i_
     video_format_t fmt;
 
     memset( &fmt, 0, sizeof(fmt) );
-    video_format_Setup( &fmt, i_chroma, i_width, i_height, i_aspect );
+    video_format_Setup( &fmt, i_chroma, i_width, i_height,
+                        i_aspect * i_height, VOUT_ASPECT_FACTOR * i_width );
 
     return picture_NewFromFormat( &fmt );
 }




More information about the vlc-devel mailing list