Removed es_format_t::i_aspect.
authorLaurent Aimar <fenrir@videolan.org>
Wed, 16 Dec 2009 20:54:54 +0000 (21:54 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Wed, 16 Dec 2009 21:00:47 +0000 (22:00 +0100)
It was duplicated with es_format_t::i_sar_num/den.

85 files changed:
include/vlc_es.h
modules/access/dshow/dshow.cpp
modules/access/dvdnav.c
modules/access/dvdread.c
modules/access/imem.c
modules/access/qtcapture.m
modules/access/screen/screen.c
modules/access/v4l.c
modules/access/v4l2.c
modules/codec/avcodec/encoder.c
modules/codec/avcodec/subtitle.c
modules/codec/avcodec/video.c
modules/codec/cc.c
modules/codec/cdg.c
modules/codec/cvdsub.c
modules/codec/dirac.c
modules/codec/dmo/dmo.c
modules/codec/dvbsub.c
modules/codec/fake.c
modules/codec/invmem.c
modules/codec/kate.c
modules/codec/libmpeg2.c
modules/codec/png.c
modules/codec/quicktime.c
modules/codec/rawvideo.c
modules/codec/realvideo.c
modules/codec/schroedinger.c
modules/codec/sdl_image.c
modules/codec/spudec/parse.c
modules/codec/subtitles/subsdec.c
modules/codec/subtitles/subsusf.c
modules/codec/svcdsub.c
modules/codec/tarkin.c
modules/codec/telx.c
modules/codec/theora.c
modules/codec/x264.c
modules/codec/zvbi.c
modules/demux/asf/asf.c
modules/demux/avformat/mux.c
modules/demux/mkv/matroska_segment_parse.cpp
modules/demux/mp4/mp4.c
modules/demux/nuv.c
modules/demux/rawvid.c
modules/gui/fbosd.c
modules/misc/freetype.c
modules/misc/quartztext.c
modules/misc/stats/decoder.c
modules/misc/svg.c
modules/mux/asf.c
modules/mux/mp4.c
modules/packetizer/h264.c
modules/packetizer/mpegvideo.c
modules/packetizer/vc1.c
modules/stream_out/mosaic_bridge.c
modules/stream_out/transcode/video.c
modules/video_filter/audiobargraph_v.c
modules/video_filter/canvas.c
modules/video_filter/crop.c
modules/video_filter/deinterlace.c
modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c
modules/video_filter/logo.c
modules/video_filter/marq.c
modules/video_filter/osdmenu.c
modules/video_filter/remoteosd.c
modules/video_filter/rss.c
modules/video_filter/transform.c
modules/video_filter/wall.c
modules/video_filter/wrapper.c
modules/video_output/msw/common_vo.c
modules/video_output/omapfb.c
modules/video_output/opengl.c
modules/video_output/wrapper.c
modules/visualization/goom.c
modules/visualization/visual/visual.c
src/input/decoder.c
src/misc/es_format.c
src/misc/image.c
src/osd/osd_text.c
src/osd/osd_widgets.c
src/video_output/display.c
src/video_output/video_output.c
src/video_output/video_text.c
src/video_output/vout_intf.c
src/video_output/vout_pictures.c
src/video_output/vout_subpictures.c

index 21b6ea5..02cd8c8 100644 (file)
@@ -105,7 +105,6 @@ struct audio_format_t
 struct video_format_t
 {
     vlc_fourcc_t i_chroma;                               /**< picture chroma */
-    unsigned int i_aspect;                                 /**< aspect ratio */
 
     unsigned int i_width;                                 /**< picture width */
     unsigned int i_height;                               /**< picture height */
index c5e8636..bc0a89b 100644 (file)
@@ -647,7 +647,8 @@ static int DemuxOpen( vlc_object_t *p_this )
 
             fmt.video.i_width  = p_stream->header.video.bmiHeader.biWidth;
             fmt.video.i_height = p_stream->header.video.bmiHeader.biHeight;
-            fmt.video.i_aspect = 4 * VOUT_ASPECT_FACTOR / 3;
+            fmt.video.i_sar_num = 4 * fmt.video.i_height;
+            fmt.video.i_sar_den = 4 * fmt.video.i_width;
 
             if( !p_stream->header.video.bmiHeader.biCompression )
             {
index 54e3c68..d157893 100644 (file)
@@ -139,8 +139,6 @@ struct demux_sys_t
     bool b_spu_change;
 
     /* */
-    int i_aspect;
-
     int           i_title;
     input_title_t **title;
 
@@ -228,7 +226,6 @@ static int Open( vlc_object_t *p_this )
     p_sys->b_reset_pcr = false;
 
     ps_track_init( p_sys->tk );
-    p_sys->i_aspect = -1;
     p_sys->i_mux_rate = 0;
     p_sys->i_pgc_length = 0;
     p_sys->b_spu_change = false;
@@ -728,10 +725,6 @@ static int Demux( demux_t *p_demux )
         msg_Dbg( p_demux, "     - vtsN=%d", event->new_vtsN );
         msg_Dbg( p_demux, "     - domain=%d", event->new_domain );
 
-        /* dvdnav_get_video_aspect / dvdnav_get_video_scale_permission */
-        /* TODO check if we always have VTS and CELL */
-        p_sys->i_aspect = dvdnav_get_video_aspect( p_sys->dvdnav );
-
         /* reset PCR */
         es_out_Control( p_demux->out, ES_OUT_RESET_PCR );
 
@@ -1183,16 +1176,6 @@ static void ESNew( demux_t *p_demux, int i_id )
     /* Add a new ES */
     if( tk->fmt.i_cat == VIDEO_ES )
     {
-        switch( p_sys->i_aspect )
-        {
-        case 1: tk->fmt.video.i_aspect = VOUT_ASPECT_FACTOR; break;
-        case 2: tk->fmt.video.i_aspect = VOUT_ASPECT_FACTOR * 4 / 3; break;
-        case 3: tk->fmt.video.i_aspect = VOUT_ASPECT_FACTOR * 16 / 9; break;
-        case 4: tk->fmt.video.i_aspect = VOUT_ASPECT_FACTOR * 221 / 10; break;
-        default:
-            tk->fmt.video.i_aspect = 0;
-            break;
-        }
         b_select = true;
     }
     else if( tk->fmt.i_cat == AUDIO_ES )
index 5325e61..3758fbf 100644 (file)
@@ -172,7 +172,8 @@ struct demux_sys_t
     input_title_t **titles;
 
     /* Video */
-    int i_aspect;
+    int i_sar_num;
+    int i_sar_den;
 
     /* SPU */
     uint32_t clut[16];
@@ -266,7 +267,8 @@ static int Open( vlc_object_t *p_this )
     DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
 
     ps_track_init( p_sys->tk );
-    p_sys->i_aspect = -1;
+    p_sys->i_sar_num = 0;
+    p_sys->i_sar_den = 0;
     p_sys->i_title_cur_time = (mtime_t) 0;
     p_sys->i_cell_cur_time = (mtime_t) 0;
     p_sys->i_cell_duration = (mtime_t) 0;
@@ -713,16 +715,8 @@ static void ESNew( demux_t *p_demux, int i_id, int i_lang )
     /* Add a new ES */
     if( tk->fmt.i_cat == VIDEO_ES )
     {
-        switch( p_sys->i_aspect )
-        {
-        case 1: tk->fmt.video.i_aspect = VOUT_ASPECT_FACTOR; break;
-        case 2: tk->fmt.video.i_aspect = VOUT_ASPECT_FACTOR * 4 / 3; break;
-        case 3: tk->fmt.video.i_aspect = VOUT_ASPECT_FACTOR * 16 / 9; break;
-        case 4: tk->fmt.video.i_aspect = VOUT_ASPECT_FACTOR * 221 / 10; break;
-        default:
-            tk->fmt.video.i_aspect = 0;
-            break;
-        }
+        tk->fmt.video.i_sar_num = p_sys->i_sar_num;
+        tk->fmt.video.i_sar_den = p_sys->i_sar_den;
     }
     else if( tk->fmt.i_cat == AUDIO_ES )
     {
@@ -906,7 +900,41 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
 
 
         ESNew( p_demux, 0xe0, 0 ); /* Video, FIXME ? */
-        p_sys->i_aspect = p_vts->vtsi_mat->vts_video_attr.display_aspect_ratio;
+        const video_attr_t *p_attr = &p_vts->vtsi_mat->vts_video_attr;
+        int i_video_height = p_attr->video_format != 0 ? 576 : 480;
+        int i_video_width;
+        switch( p_attr->picture_size )
+        {
+        case 0:
+            i_video_width = 720;
+            break;
+        case 1:
+            i_video_width = 704;
+            break;
+        case 2:
+            i_video_width = 352;
+            break;
+        default:
+        case 3:
+            i_video_width = 352;
+            i_video_height /= 2;
+            break;
+        }
+        switch( p_attr->display_aspect_ratio )
+        {
+        case 0:
+            p_sys->i_sar_num = 4 * i_video_height;
+            p_sys->i_sar_den = 3 * i_video_width;
+            break;
+        case 3:
+            p_sys->i_sar_num = 16 * i_video_height;
+            p_sys->i_sar_den =  9 * i_video_width;
+            break;
+        default:
+            p_sys->i_sar_num = 0;
+            p_sys->i_sar_den = 0;
+            break;
+        }
 
 #define audio_control \
     p_sys->p_vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc->audio_control[i-1]
index e1a750d..ac904b1 100644 (file)
@@ -254,7 +254,6 @@ static int Open(vlc_object_t *object)
         fmt.video.i_height = var_CreateGetInteger(demux, "imem-height");
         unsigned num, den;
         if (!var_CreateGetRational(demux, &num, &den, "imem-dar") && num > 0 && den > 0) {
-            fmt.video.i_aspect = VOUT_ASPECT_FACTOR * num / den;
             if (fmt.video.i_width > 0 && fmt.video.i_height > 0) {
                 fmt.video.i_sar_num = num * fmt.video.i_height;
                 fmt.video.i_sar_den = den * fmt.video.i_width;
index bbee5bf..712385f 100644 (file)
@@ -195,7 +195,6 @@ static int Open( vlc_object_t *p_this )
     int i;
     int i_width;
     int i_height;
-    int i_aspect;
     int result = 0;
 
     /* Only when selected */
@@ -285,7 +284,8 @@ static int Open( vlc_object_t *p_this )
     fmt.video.i_height = p_sys->height = encoded_size.height;
     if( par_size.width != encoded_size.width )
     {
-        fmt.video.i_aspect = par_size.width * VOUT_ASPECT_FACTOR / encoded_size.width ;
+        fmt.video.i_sar_num = (int64_t)encoded_size.height * par_size.width / encoded_size.width;
+        fmt.video.i_sar_den = encoded_size.width;
     }
 
     NSLog( @"encoded_size %d %d", (int)encoded_size.width, (int)encoded_size.height );
index 7ad87de..4ab498e 100644 (file)
@@ -340,8 +340,8 @@ void RenderCursor( demux_t *p_demux, int i_x, int i_y,
                        p_sys->fmt.video.i_chroma,
                        p_sys->fmt.video.i_width,
                        p_sys->fmt.video.i_height,
-                       p_sys->fmt.video.i_aspect * p_sys->fmt.video.i_height,
-                       VOUT_ASPECT_FACTOR        * p_sys->fmt.video.i_width );
+                       p_sys->fmt.video.i_sar_num,
+                       p_sys->fmt.video.i_sar_den );
     if( !p_sys->p_blend )
     {
         p_sys->p_blend = vlc_object_create( p_demux, sizeof(filter_t) );
index d54bd50..06b67d9 100644 (file)
@@ -360,7 +360,8 @@ static int Open( vlc_object_t *p_this )
     es_format_Init( &fmt, VIDEO_ES, p_sys->i_fourcc );
     fmt.video.i_width  = p_sys->i_width;
     fmt.video.i_height = p_sys->i_height;
-    fmt.video.i_aspect = 4 * VOUT_ASPECT_FACTOR / 3;
+    fmt.video.i_sar_num = 4 * fmt.video.i_height;
+    fmt.video.i_sar_den = 3 * fmt.video.i_width;
 
     /* Setup rgb mask for RGB formats */
     switch( p_sys->i_fourcc )
index a330819..5e685c8 100644 (file)
@@ -2282,7 +2282,8 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
         es_fmt.video.i_height = p_sys->i_height;
 
         /* Get aspect-ratio */
-        es_fmt.video.i_aspect = p_sys->i_aspect;
+        es_fmt.video.i_sar_num = p_sys->i_aspect    * es_fmt.video.i_height;
+        es_fmt.video.i_sar_den = VOUT_ASPECT_FACTOR * es_fmt.video.i_width;
 
         demux_t *p_demux = (demux_t *) p_obj;
         msg_Dbg( p_demux, "added new video es %4.4s %dx%d",
index 8c85a9f..87ce339 100644 (file)
@@ -386,8 +386,6 @@ int OpenEncoder( vlc_object_t *p_this )
 
     if( p_enc->fmt_in.i_cat == VIDEO_ES )
     {
-        int i_aspect_num, i_aspect_den;
-
         if( !p_enc->fmt_in.video.i_width || !p_enc->fmt_in.video.i_height )
         {
             msg_Warn( p_enc, "invalid size %ix%i", p_enc->fmt_in.video.i_width,
@@ -430,13 +428,10 @@ int OpenEncoder( vlc_object_t *p_this )
                p_enc->fmt_out.i_codec == VLC_CODEC_MP1V ) )
             p_context->flags |= CODEC_FLAG_LOW_DELAY;
 
-        av_reduce( &i_aspect_num, &i_aspect_den,
-                   p_enc->fmt_in.video.i_aspect,
-                   VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ );
         av_reduce( &p_context->sample_aspect_ratio.num,
                    &p_context->sample_aspect_ratio.den,
-                   i_aspect_num * (int64_t)p_context->height,
-                   i_aspect_den * (int64_t)p_context->width, 1 << 30 );
+                   p_enc->fmt_in.video.i_sar_num,
+                   p_enc->fmt_in.video.i_sar_den, 1 << 30 );
 
         p_sys->i_buffer_out = p_context->height * p_context->width * 3;
         if( p_sys->i_buffer_out < FF_MIN_BUFFER_SIZE )
index 1415f8b..89fad76 100644 (file)
@@ -189,7 +189,6 @@ static subpicture_region_t *ConvertRegionRGBA(AVSubtitleRect *ffregion)
     video_format_t fmt;
     memset(&fmt, 0, sizeof(fmt));
     fmt.i_chroma         = VLC_FOURCC('R','G','B','A');
-    fmt.i_aspect         = 0;
     fmt.i_width          =
     fmt.i_visible_width  = ffregion->w;
     fmt.i_height         =
index 7125a6f..4fd33ac 100644 (file)
@@ -150,22 +150,20 @@ static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec,
     p_dec->fmt_out.i_codec = p_dec->fmt_out.video.i_chroma;
 
     /* If an aspect-ratio was specified in the input format then force it */
-    if( p_dec->fmt_in.video.i_aspect )
+    if( p_dec->fmt_in.video.i_sar_num > 0 && p_dec->fmt_in.video.i_sar_den > 0 )
     {
-        p_dec->fmt_out.video.i_aspect = p_dec->fmt_in.video.i_aspect;
+        p_dec->fmt_out.video.i_sar_num = p_dec->fmt_in.video.i_sar_num;
+        p_dec->fmt_out.video.i_sar_den = p_dec->fmt_in.video.i_sar_den;
     }
     else
     {
-        p_dec->fmt_out.video.i_aspect =
-            VOUT_ASPECT_FACTOR * ( av_q2d(p_context->sample_aspect_ratio) *
-                p_context->width / p_context->height );
         p_dec->fmt_out.video.i_sar_num = p_context->sample_aspect_ratio.num;
         p_dec->fmt_out.video.i_sar_den = p_context->sample_aspect_ratio.den;
 
-        if( p_dec->fmt_out.video.i_aspect == 0 )
+        if( !p_dec->fmt_out.video.i_sar_num || !p_dec->fmt_out.video.i_sar_den )
         {
-            p_dec->fmt_out.video.i_aspect =
-                VOUT_ASPECT_FACTOR * p_context->width / p_context->height;
+            p_dec->fmt_out.video.i_sar_num = 1;
+            p_dec->fmt_out.video.i_sar_den = 1;
         }
     }
 
@@ -644,22 +642,18 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
             p_sys->b_has_b_frames = true;
         }
 
-        if( !p_dec->fmt_in.video.i_aspect )
+        if( !p_dec->fmt_in.video.i_sar_num || !p_dec->fmt_in.video.i_sar_den )
         {
             /* Fetch again the aspect ratio in case it changed */
-            p_dec->fmt_out.video.i_aspect =
-                VOUT_ASPECT_FACTOR
-                    * ( av_q2d(p_sys->p_context->sample_aspect_ratio)
-                    * p_sys->p_context->width / p_sys->p_context->height );
             p_dec->fmt_out.video.i_sar_num
                 = p_sys->p_context->sample_aspect_ratio.num;
             p_dec->fmt_out.video.i_sar_den
                 = p_sys->p_context->sample_aspect_ratio.den;
 
-            if( p_dec->fmt_out.video.i_aspect == 0 )
+            if( !p_dec->fmt_out.video.i_sar_num || !p_dec->fmt_out.video.i_sar_den )
             {
-                p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR
-                    * p_sys->p_context->width / p_sys->p_context->height;
+                p_dec->fmt_out.video.i_sar_num = 1;
+                p_dec->fmt_out.video.i_sar_den = 1;
             }
         }
 
index 3e380f9..0e8ecb5 100644 (file)
@@ -340,7 +340,6 @@ static subpicture_t *Subtitle( decoder_t *p_dec, char *psz_subtitle, char *psz_h
     /* Create a new subpicture region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_TEXT;
-    fmt.i_aspect = 0;
     fmt.i_width = fmt.i_height = 0;
     fmt.i_x_offset = fmt.i_y_offset = 0;
     p_spu->p_region = subpicture_region_New( &fmt );
index 13a234e..31ecd0e 100644 (file)
@@ -116,8 +116,8 @@ static int Open( vlc_object_t *p_this )
     p_dec->fmt_out.i_codec = VLC_CODEC_RGB32;
     p_dec->fmt_out.video.i_width = CDG_DISPLAY_WIDTH;
     p_dec->fmt_out.video.i_height = CDG_DISPLAY_HEIGHT;
-    p_dec->fmt_out.video.i_aspect =
-        VOUT_ASPECT_FACTOR * p_dec->fmt_out.video.i_width / p_dec->fmt_out.video.i_height;
+    p_dec->fmt_out.video.i_sar_num = 1;
+    p_dec->fmt_out.video.i_sar_den = 1;
     p_dec->fmt_out.video.i_rmask = 0xff << CDG_COLOR_R_SHIFT;
     p_dec->fmt_out.video.i_gmask = 0xff << CDG_COLOR_G_SHIFT;
     p_dec->fmt_out.video.i_bmask = 0xff << CDG_COLOR_B_SHIFT;
index 0ca7c0d..90635d7 100644 (file)
@@ -510,7 +510,8 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
     /* Create new SPU region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_YUVP;
-    fmt.i_aspect = VOUT_ASPECT_FACTOR;
+    fmt.i_sar_num = 1;
+    fmt.i_sar_den = 1;
     fmt.i_width = fmt.i_visible_width = p_sys->i_width;
     fmt.i_height = fmt.i_visible_height = p_sys->i_height;
     fmt.i_x_offset = fmt.i_y_offset = 0;
index f24dd18..50b29e8 100644 (file)
@@ -506,9 +506,8 @@ static int OpenEncoder( vlc_object_t *p_this )
     p_sys->ctx.src_params.frame_rate.denominator = p_enc->fmt_in.video.i_frame_rate_base;
     unsigned u_asr_num, u_asr_den;
     vlc_ureduce( &u_asr_num, &u_asr_den,
-                 p_enc->fmt_in.video.i_height * p_enc->fmt_in.video.i_aspect,
-                 p_enc->fmt_in.video.i_width * VOUT_ASPECT_FACTOR,
-                 0 );
+                 p_enc->fmt_in.video.i_sar_num,
+                 p_enc->fmt_in.video.i_sar_den, 0 );
     p_sys->ctx.src_params.pix_asr.numerator = u_asr_num;
     p_sys->ctx.src_params.pix_asr.denominator = u_asr_den;
 
index 057eb90..d105d93 100644 (file)
@@ -520,14 +520,16 @@ static int DecOpen( decoder_t *p_dec )
         p_dec->fmt_out.video.i_bits_per_pixel = i_bpp;
 
         /* If an aspect-ratio was specified in the input format then force it */
-        if( p_dec->fmt_in.video.i_aspect )
+        if( p_dec->fmt_in.video.i_sar_num > 0 &&
+            p_dec->fmt_in.video.i_sar_den > 0 )
         {
-            p_dec->fmt_out.video.i_aspect = p_dec->fmt_in.video.i_aspect;
+            p_dec->fmt_out.video.i_sar_num = p_dec->fmt_in.video.i_sar_num;
+            p_dec->fmt_out.video.i_sar_den = p_dec->fmt_in.video.i_sar_den;
         }
         else
         {
-            p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR *
-                p_dec->fmt_out.video.i_width / p_dec->fmt_out.video.i_height;
+            p_dec->fmt_out.video.i_sar_num = 1;
+            p_dec->fmt_out.video.i_sar_den = 1;
         }
 
         p_bih = &p_vih->bmiHeader;
index 6a9867c..105b692 100644 (file)
@@ -1582,7 +1582,8 @@ static subpicture_t *render( decoder_t *p_dec )
         /* Create new SPU region */
         memset( &fmt, 0, sizeof(video_format_t) );
         fmt.i_chroma = VLC_CODEC_YUVP;
-        fmt.i_aspect = 0; /* 0 means use aspect ratio of background video */
+        fmt.i_sar_num = 0; /* 0 means use aspect ratio of background video */
+        fmt.i_sar_den = 1;
         fmt.i_width = fmt.i_visible_width = p_region->i_width;
         fmt.i_height = fmt.i_visible_height = p_region->i_height;
         fmt.i_x_offset = fmt.i_y_offset = 0;
@@ -1635,7 +1636,8 @@ static subpicture_t *render( decoder_t *p_dec )
             /* Create new SPU region */
             memset( &fmt, 0, sizeof(video_format_t) );
             fmt.i_chroma = VLC_CODEC_TEXT;
-            fmt.i_aspect = VOUT_ASPECT_FACTOR;
+            fmt.i_sar_num = 1;
+            fmt.i_sar_den = 1;
             fmt.i_width = fmt.i_visible_width = p_region->i_width;
             fmt.i_height = fmt.i_visible_height = p_region->i_height;
             fmt.i_x_offset = fmt.i_y_offset = 0;
index ec08079..5a3b70f 100644 (file)
@@ -269,12 +269,13 @@ static int OpenDecoder( vlc_object_t *p_this )
 
     if ( i_aspect )
     {
-        fmt_out.i_aspect = i_aspect;
+        fmt_out.i_sar_num = i_aspect           * fmt_out.i_height;
+        fmt_out.i_sar_den = VOUT_ASPECT_FACTOR * fmt_out.i_width;
     }
     else
     {
-        fmt_out.i_aspect = fmt_out.i_width
-                            * VOUT_ASPECT_FACTOR / fmt_out.i_height;
+        fmt_out.i_sar_num = 1;
+        fmt_out.i_sar_den = 1;
     }
 
     if( var_CreateGetBool( p_dec, "fake-deinterlace" ) )
index fddab7f..ad2094a 100644 (file)
@@ -212,7 +212,8 @@ static int OpenDecoder( vlc_object_t *p_this )
     p_dec->fmt_out.i_codec = chroma;
     p_dec->fmt_out.video.i_width = p_dec->p_sys->i_width;
     p_dec->fmt_out.video.i_height = p_dec->p_sys->i_height;
-    p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_dec->p_sys->i_width / p_dec->p_sys->i_height;
+    p_dec->fmt_out.video.i_sar_num = 1;
+    p_dec->fmt_out.video.i_sar_den = 1;
     p_dec->fmt_out.i_cat = VIDEO_ES;
 
     p_sys->i_pitch = pitch;
index 3dee692..156199d 100644 (file)
@@ -1332,7 +1332,6 @@ static subpicture_t *SetupSimpleKateSPU( decoder_t *p_dec, subpicture_t *p_spu,
         /* create a separate region for the bitmap */
         memset( &fmt, 0, sizeof(video_format_t) );
         fmt.i_chroma = VLC_CODEC_YUVP;
-        fmt.i_aspect = 0;
         fmt.i_width = fmt.i_visible_width = ev->bitmap->width;
         fmt.i_height = fmt.i_visible_height = ev->bitmap->height;
         fmt.i_x_offset = fmt.i_y_offset = 0;
@@ -1355,7 +1354,8 @@ static subpicture_t *SetupSimpleKateSPU( decoder_t *p_dec, subpicture_t *p_spu,
 
     /* text region */
     fmt.i_chroma = VLC_CODEC_TEXT;
-    fmt.i_aspect = 0;
+    fmt.i_sar_num = 0;
+    fmt.i_sar_den = 1;
     fmt.i_width = fmt.i_height = 0;
     fmt.i_x_offset = fmt.i_y_offset = 0;
     p_spu->p_region = subpicture_region_New( &fmt );
index b0239e7..8a56276 100644 (file)
@@ -83,7 +83,6 @@ struct decoder_sys_t
      * Output properties
      */
     decoder_synchro_t *p_synchro;
-    int             i_aspect;
     int             i_sar_num;
     int             i_sar_den;
     mtime_t         i_last_frame_pts;
@@ -173,7 +172,8 @@ static int OpenDecoder( vlc_object_t *p_this )
     p_sys->i_previous_pts = 0;
     p_sys->i_current_dts  = 0;
     p_sys->i_previous_dts = 0;
-    p_sys->i_aspect = 0;
+    p_sys->i_sar_num = 0;
+    p_sys->i_sar_den = 0;
     p_sys->b_garbage_pic = false;
     p_sys->b_slice_i  = false;
     p_sys->b_second_field = false;
@@ -281,7 +281,8 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             mpeg2_custom_fbuf( p_sys->p_mpeg2dec, 1 );
 
             /* Set the first 2 reference frames */
-            p_sys->i_aspect = 0;
+            p_sys->i_sar_num = 0;
+            p_sys->i_sar_den = 0;
             GetAR( p_dec );
             for( int i = 0; i < 2; i++ )
             {
@@ -651,7 +652,6 @@ static picture_t *GetNewPicture( decoder_t *p_dec )
     p_dec->fmt_out.video.i_height = p_sys->p_info->sequence->height;
     p_dec->fmt_out.video.i_visible_height =
         p_sys->p_info->sequence->picture_height;
-    p_dec->fmt_out.video.i_aspect = p_sys->i_aspect;
     p_dec->fmt_out.video.i_sar_num = p_sys->i_sar_num;
     p_dec->fmt_out.video.i_sar_den = p_sys->i_sar_den;
 
@@ -719,24 +719,21 @@ static block_t *GetCc( decoder_t *p_dec, bool pb_present[4] )
 static void GetAR( decoder_t *p_dec )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
-    int i_old_aspect = p_sys->i_aspect;
+    int i_old_sar_num = p_sys->i_sar_num;
+    int i_old_sar_den = p_sys->i_sar_den;
 
     /* Check whether the input gave a particular aspect ratio */
-    if( p_dec->fmt_in.video.i_aspect )
+    if( p_dec->fmt_in.video.i_sar_num > 0 &&
+        p_dec->fmt_in.video.i_sar_den > 0 )
     {
-        p_sys->i_aspect = p_dec->fmt_in.video.i_aspect;
+        p_sys->i_sar_num = p_dec->fmt_in.video.i_sar_num;
+        p_sys->i_sar_den = p_dec->fmt_in.video.i_sar_den;
     }
     else
     {
         /* Use the value provided in the MPEG sequence header */
         if( p_sys->p_info->sequence->pixel_height > 0 )
         {
-            p_sys->i_aspect =
-                ((uint64_t)p_sys->p_info->sequence->display_width) *
-                p_sys->p_info->sequence->pixel_width *
-                VOUT_ASPECT_FACTOR /
-                p_sys->p_info->sequence->display_height /
-                p_sys->p_info->sequence->pixel_height;
             p_sys->i_sar_num = p_sys->p_info->sequence->pixel_width;
             p_sys->i_sar_den = p_sys->p_info->sequence->pixel_height;
         }
@@ -745,23 +742,23 @@ static void GetAR( decoder_t *p_dec )
             /* Invalid aspect, assume 4:3.
              * This shouldn't happen and if it does it is a bug
              * in libmpeg2 (likely triggered by an invalid stream) */
-            p_sys->i_aspect = VOUT_ASPECT_FACTOR * 4 / 3;
             p_sys->i_sar_num = p_sys->p_info->sequence->picture_height * 4;
             p_sys->i_sar_den = p_sys->p_info->sequence->picture_width * 3;
         }
     }
 
-    if( p_sys->i_aspect == i_old_aspect )
+    if( p_sys->i_sar_num == i_old_sar_num &&
+        p_sys->i_sar_den == i_old_sar_den )
         return;
 
     if( p_sys->p_info->sequence->frame_period > 0 )
         msg_Dbg( p_dec,
-                 "%dx%d (display %d,%d), aspect %d, sar %i:%i, %u.%03u fps",
+                 "%dx%d (display %d,%d), sar %i:%i, %u.%03u fps",
                  p_sys->p_info->sequence->picture_width,
                  p_sys->p_info->sequence->picture_height,
                  p_sys->p_info->sequence->display_width,
                  p_sys->p_info->sequence->display_height,
-                 p_sys->i_aspect, p_sys->i_sar_num, p_sys->i_sar_den,
+                 p_sys->i_sar_num, p_sys->i_sar_den,
                  (uint32_t)((uint64_t)1001000000 * 27 /
                      p_sys->p_info->sequence->frame_period / 1001),
                  (uint32_t)((uint64_t)1001000000 * 27 /
index 081c32c..5dd4c2e 100644 (file)
@@ -184,7 +184,8 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     p_dec->fmt_out.i_codec = VLC_CODEC_RGBA;
     p_dec->fmt_out.video.i_width = i_width;
     p_dec->fmt_out.video.i_height = i_height;
-    p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * i_width / i_height;
+    p_dec->fmt_out.video.i_sar_num = 1;
+    p_dec->fmt_out.video.i_sar_den = 1;
     p_dec->fmt_out.video.i_rmask = 0x000000ff;
     p_dec->fmt_out.video.i_gmask = 0x0000ff00;
     p_dec->fmt_out.video.i_bmask = 0x00ff0000;
index 146c4f2..ae154fa 100644 (file)
@@ -844,7 +844,8 @@ static int OpenVideo( decoder_t *p_dec )
     es_format_Init( &p_dec->fmt_out, VIDEO_ES, VLC_CODEC_YUYV);
     p_dec->fmt_out.video.i_width = p_dec->fmt_in.video.i_width;
     p_dec->fmt_out.video.i_height= p_dec->fmt_in.video.i_height;
-    p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_dec->fmt_in.video.i_width / p_dec->fmt_in.video.i_height;
+    p_dec->fmt_out.video.i_sar_num = 1;
+    p_dec->fmt_out.video.i_sar_den = 1;
 
     vlc_mutex_unlock( &qt_mutex );
     return VLC_SUCCESS;
index 6ab2272..5691eb4 100644 (file)
@@ -159,15 +159,15 @@ 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_height,
-                        VOUT_ASPECT_FACTOR           * p_dec->fmt_in.video.i_width );
+                        p_dec->fmt_in.video.i_sar_num,
+                        p_dec->fmt_in.video.i_sar_den );
     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;
 
-    if( !p_dec->fmt_in.video.i_aspect )
+    if( !p_dec->fmt_in.video.i_sar_num || !p_dec->fmt_in.video.i_sar_den )
     {
-        p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR *
-            p_dec->fmt_out.video.i_width / p_dec->fmt_out.video.i_height;
+        p_dec->fmt_out.video.i_sar_num = 1;
+        p_dec->fmt_out.video.i_sar_den = 1;
     }
 
     /* Set callbacks */
index 1a8160f..ec88dcc 100644 (file)
@@ -355,7 +355,8 @@ static int InitVideo(decoder_t *p_dec)
      
     p_dec->fmt_out.video.i_width = p_dec->fmt_in.video.i_width;
     p_dec->fmt_out.video.i_height= p_dec->fmt_in.video.i_height;
-    p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_dec->fmt_in.video.i_width / p_dec->fmt_in.video.i_height;
+    p_dec->fmt_out.video.i_sar_num = 1;
+    p_dec->fmt_out.video.i_sar_den = 1;
     p_sys->inited = 0;
 
     vlc_mutex_unlock( &rm_mutex );
@@ -527,7 +528,8 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
                     p_dec->fmt_out.video.i_visible_height = 
                     p_dec->fmt_in.video.i_height= transform_out[4];
 
-                    p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_dec->fmt_in.video.i_width / p_dec->fmt_in.video.i_height;
+                    p_dec->fmt_out.video.i_sar_num = 1;
+                    p_dec->fmt_out.video.i_sar_den = 1;
                 }
                 else
                 {
index 8439c04..fceae03 100644 (file)
@@ -130,7 +130,6 @@ static int OpenDecoder( vlc_object_t *p_this )
 static void SetVideoFormat( decoder_t *p_dec )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
-    double f_aspect;
 
     p_sys->p_format = schro_decoder_get_video_format(p_sys->p_schro);
     if( p_sys->p_format == NULL ) return;
@@ -158,11 +157,8 @@ static void SetVideoFormat( decoder_t *p_dec )
     p_dec->fmt_out.video.i_height = p_sys->p_format->height;
 
     /* aspect_ratio_[numerator|denominator] describes the pixel aspect ratio */
-    f_aspect = (double)
-        ( p_sys->p_format->aspect_ratio_numerator * p_sys->p_format->width ) /
-        ( p_sys->p_format->aspect_ratio_denominator * p_sys->p_format->height);
-
-    p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * f_aspect;
+    p_dec->fmt_out.video.i_sar_num = p_sys->p_format->aspect_ratio_numerator;
+    p_dec->fmt_out.video.i_sar_den = p_sys->p_format->aspect_ratio_denominator;
 
     p_dec->fmt_out.video.i_frame_rate =
         p_sys->p_format->frame_rate_numerator;
index 6f21547..4a9f5d2 100644 (file)
@@ -173,8 +173,8 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     }
     p_dec->fmt_out.video.i_width = p_surface->w;
     p_dec->fmt_out.video.i_height = p_surface->h;
-    p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_surface->w
-                                     / p_surface->h;
+    p_dec->fmt_out.video.i_sar_num = 1;
+    p_dec->fmt_out.video.i_sar_den = 1;
 
     /* Get a new picture. */
     p_pic = decoder_NewPicture( p_dec );
index 5287272..3b23650 100644 (file)
@@ -688,7 +688,8 @@ static void Render( decoder_t *p_dec, subpicture_t *p_spu,
     /* Create a new subpicture region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_YUVP;
-    fmt.i_aspect = 0; /* 0 means use aspect ratio of background video */
+    fmt.i_sar_num = 0; /* 0 means use aspect ratio of background video */
+    fmt.i_sar_den = 1;
     fmt.i_width = fmt.i_visible_width = p_spu_properties->i_width;
     fmt.i_height = fmt.i_visible_height = p_spu_properties->i_height -
         p_spu_data->i_y_top_offset - p_spu_data->i_y_bottom_offset;
index 2d45794..f6af33c 100644 (file)
@@ -493,7 +493,6 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
     /* Create a new subpicture region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_TEXT;
-    fmt.i_aspect = 0;
     fmt.i_width = fmt.i_height = 0;
     fmt.i_x_offset = fmt.i_y_offset = 0;
     p_spu->p_region = subpicture_region_New( &fmt );
index 8c15ceb..5754137 100644 (file)
@@ -383,7 +383,6 @@ static subpicture_region_t *CreateTextRegion( decoder_t *p_dec,
     /* Create a new subpicture region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_TEXT;
-    fmt.i_aspect = 0;
     fmt.i_width = fmt.i_height = 0;
     fmt.i_x_offset = fmt.i_y_offset = 0;
     p_text_region = subpicture_region_New( &fmt );
@@ -1163,7 +1162,6 @@ static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec,
     memset( &fmt_out, 0, sizeof( video_format_t));
 
     fmt_out.i_chroma = VLC_CODEC_YUVA;
-    fmt_out.i_aspect = VOUT_ASPECT_FACTOR;
     fmt_out.i_sar_num = fmt_out.i_sar_den = 1;
     fmt_out.i_width =
         fmt_out.i_visible_width = p_pic->format.i_visible_width;
index 86293c7..d170f28 100644 (file)
@@ -488,7 +488,8 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
        Two candidates are the video and the other possibility would be
        the access module.
     */
-    fmt.i_aspect = VOUT_ASPECT_FACTOR;
+    fmt.i_sar_num = p_sys->i_height;
+    fmt.i_sar_den = p_sys->i_width;
 
     fmt.i_width = fmt.i_visible_width = p_sys->i_width;
     fmt.i_height = fmt.i_visible_height = p_sys->i_height;
index f032741..0976832 100644 (file)
@@ -260,8 +260,8 @@ static picture_t *DecodePacket( decoder_t *p_dec, block_t **pp_block,
         p_dec->fmt_out.video.i_width = i_width;
         p_dec->fmt_out.video.i_height = i_height;
 
-        p_dec->fmt_out.video.i_aspect =
-            VOUT_ASPECT_FACTOR * i_width / i_height;
+        p_dec->fmt_out.video.i_sar_num = 1;
+        p_dec->fmt_out.video.i_sar_den = 1;
         p_dec->fmt_out.i_codec = i_chroma;
 
         /* Get a new picture */
index ffa8083..d3aeb83 100644 (file)
@@ -695,7 +695,6 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
     /* Create a new subpicture region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_TEXT;
-    fmt.i_aspect = 0;
     fmt.i_width = fmt.i_height = 0;
     fmt.i_x_offset = fmt.i_y_offset = 0;
     p_spu->p_region = subpicture_region_New( &fmt );
index 6f96ff5..d934500 100644 (file)
@@ -313,14 +313,13 @@ static int ProcessHeaders( decoder_t *p_dec )
 
     if( p_sys->ti.aspect_denominator && p_sys->ti.aspect_numerator )
     {
-        p_dec->fmt_out.video.i_aspect = ((int64_t)VOUT_ASPECT_FACTOR) *
-            ( p_sys->ti.aspect_numerator * p_dec->fmt_out.video.i_width ) /
-            ( p_sys->ti.aspect_denominator * p_dec->fmt_out.video.i_height );
+        p_dec->fmt_out.video.i_sar_num = p_sys->ti.aspect_numerator;
+        p_dec->fmt_out.video.i_sar_den = p_sys->ti.aspect_denominator;
     }
     else
     {
-        p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR *
-            p_sys->ti.frame_width / p_sys->ti.frame_height;
+        p_dec->fmt_out.video.i_sar_num = 1;
+        p_dec->fmt_out.video.i_sar_den = 1;
     }
 
     if( p_sys->ti.fps_numerator > 0 && p_sys->ti.fps_denominator > 0 )
@@ -664,14 +663,12 @@ static int OpenEncoder( vlc_object_t *p_this )
         p_sys->ti.fps_denominator = p_enc->fmt_in.video.i_frame_rate_base;
     }
 
-    if( p_enc->fmt_in.video.i_aspect )
+    if( p_enc->fmt_in.video.i_sar_num > 0 && p_enc->fmt_in.video.i_sar_den > 0 )
     {
-        uint64_t i_num, i_den;
         unsigned i_dst_num, i_dst_den;
-
-        i_num = p_enc->fmt_in.video.i_aspect * (int64_t)p_sys->ti.height;
-        i_den = VOUT_ASPECT_FACTOR * p_sys->ti.width;
-        vlc_ureduce( &i_dst_num, &i_dst_den, i_num, i_den, 0 );
+        vlc_ureduce( &i_dst_num, &i_dst_den,
+                     p_enc->fmt_in.video.i_sar_num,
+                     p_enc->fmt_in.video.i_sar_den, 0 );
         p_sys->ti.aspect_numerator = i_dst_num;
         p_sys->ti.aspect_denominator = i_dst_den;
     }
index 44842b8..49ad607 100644 (file)
@@ -1018,16 +1018,13 @@ static int  Open ( vlc_object_t *p_this )
     p_sys->param.analyse.b_transform_8x8 = var_GetBool( p_enc,
                                     SOUT_CFG_PREFIX "8x8dct" );
 
-    if( p_enc->fmt_in.video.i_aspect > 0 )
+    if( p_enc->fmt_in.video.i_sar_num > 0 &&
+        p_enc->fmt_in.video.i_sar_den > 0 )
     {
-        int64_t i_num, i_den;
         unsigned int i_dst_num, i_dst_den;
-
-        i_num = p_enc->fmt_in.video.i_aspect *
-            (int64_t)p_enc->fmt_in.video.i_height;
-        i_den = VOUT_ASPECT_FACTOR * p_enc->fmt_in.video.i_width;
-        vlc_ureduce( &i_dst_num, &i_dst_den, i_num, i_den, 0 );
-
+        vlc_ureduce( &i_dst_num, &i_dst_den,
+                     p_enc->fmt_in.video.i_sar_num,
+                     p_enc->fmt_in.video.i_sar_den );
         p_sys->param.vui.i_sar_width = i_dst_num;
         p_sys->param.vui.i_sar_height = i_dst_den;
     }
index 26672f2..50c4edf 100644 (file)
@@ -467,14 +467,16 @@ static subpicture_t *Subpicture( decoder_t *p_dec, video_format_t *p_fmt,
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = b_text ? VLC_CODEC_TEXT :
                                    VLC_CODEC_RGBA;
-    fmt.i_aspect = b_text ? 0 : VOUT_ASPECT_FACTOR;
     if( b_text )
     {
         fmt.i_bits_per_pixel = 0;
+        fmt.i_sar_num = 0;
+        fmt.i_sar_den = 0;
     }
     else
     {
-        fmt.i_sar_num = fmt.i_sar_den = 1;
+        fmt.i_sar_num = 1;
+        fmt.i_sar_den = 1;
         fmt.i_width = fmt.i_visible_width = i_columns * 12;
         fmt.i_height = fmt.i_visible_height = i_rows * 10;
         fmt.i_bits_per_pixel = 32;
index 3985cdf..54a4515 100644 (file)
@@ -887,9 +887,8 @@ static int DemuxInit( demux_t *p_demux )
 
                 if( i_aspect_x && i_aspect_y )
                 {
-                    fmt.video.i_aspect = i_aspect_x *
-                        (int64_t)fmt.video.i_width * VOUT_ASPECT_FACTOR /
-                        fmt.video.i_height / i_aspect_y;
+                    fmt.video.i_sar_num = i_aspect_x;
+                    fmt.video.i_sar_den = i_aspect_y;
                 }
             }
 
index 1c75c26..c48eee8 100644 (file)
@@ -245,13 +245,10 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
         codec->codec_type = CODEC_TYPE_VIDEO;
         codec->width = p_input->p_fmt->video.i_width;
         codec->height = p_input->p_fmt->video.i_height;
-        av_reduce( &i_aspect_num, &i_aspect_den,
-                   p_input->p_fmt->video.i_aspect,
-                   VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ );
         av_reduce( &codec->sample_aspect_ratio.num,
                    &codec->sample_aspect_ratio.den,
-                   i_aspect_num * (int64_t)codec->height,
-                   i_aspect_den * (int64_t)codec->width, 1 << 30 );
+                   p_input->p_fmt->video.i_sar_num,
+                   p_input->p_fmt->video.i_sar_den, 1 << 30 /* something big */ );
 #if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(21<<8)+0)
         stream->sample_aspect_ratio.num = codec->sample_aspect_ratio.num;
         stream->sample_aspect_ratio.den = codec->sample_aspect_ratio.den;
index ff17863..3ff89ab 100644 (file)
@@ -563,7 +563,10 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
                 }
             }
             if( i_display_height && i_display_width )
-                tk->fmt.video.i_aspect = VOUT_ASPECT_FACTOR * i_display_width / i_display_height;
+            {
+                tk->fmt.video.i_sar_num = i_display_width  * tk->fmt.video.i_height;
+                tk->fmt.video.i_sar_den = i_display_height * tk->fmt.video.i_width;
+            }
             if( i_crop_left || i_crop_right || i_crop_top || i_crop_bottom )
             {
                 tk->fmt.video.i_visible_width = tk->fmt.video.i_width;
index 3fa1468..8f23e63 100644 (file)
@@ -1553,8 +1553,10 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
         if( p_track->i_width > 0 && p_track->i_height > 0 &&
             /* Work-around buggy muxed files */
             p_sample->data.p_sample_vide->i_width != p_track->i_width )
-            p_track->fmt.video.i_aspect =
-                VOUT_ASPECT_FACTOR * p_track->i_width / p_track->i_height;
+        {
+            p_track->fmt.video.i_sar_num = p_track->i_width  / p_track->fmt.video.i_height;
+            p_track->fmt.video.i_sar_den = p_track->i_height * p_track->fmt.video.i_width;
+        }
 
         /* Support for cropping (eg. in H263 files) */
         p_track->fmt.video.i_visible_width = p_track->fmt.video.i_width;
index 257efd6..3f80660 100644 (file)
@@ -306,7 +306,8 @@ static int Open( vlc_object_t * p_this )
         fmt.video.i_height = p_sys->hdr.i_height;
         fmt.i_extra = p_sys->i_extra_f;
         fmt.p_extra = p_sys->p_extra_f;
-        fmt.video.i_aspect = VOUT_ASPECT_FACTOR * p_sys->hdr.d_aspect;
+        fmt.video.i_sar_num = p_sys->hdr.d_aspect * fmt.video.i_height;
+        fmt.video.i_sar_den = fmt.video.i_width;
 
         p_sys->p_es_video = es_out_Add( p_demux->out, &fmt );
     }
index f396538..4b13aa2 100644 (file)
@@ -132,7 +132,8 @@ static int Open( vlc_object_t * p_this )
     unsigned u_fps_num=0, u_fps_den=1;
     char *psz_ext;
     vlc_fourcc_t i_chroma;
-    unsigned int i_aspect = 0;
+    unsigned int i_sar_num = 0;
+    unsigned int i_sar_den = 0;
     const struct preset_t *p_preset = NULL;
     const uint8_t *p_peek;
     bool b_valid = false;
@@ -182,7 +183,8 @@ static int Open( vlc_object_t * p_this )
         i_height = p_preset->i_height;
         u_fps_num = p_preset->u_fps_num;
         u_fps_den = p_preset->u_fps_den;
-        i_aspect = VOUT_ASPECT_FACTOR * p_preset->u_ar_num / p_preset->u_ar_den;
+        i_sar_num = p_preset->u_ar_num * p_preset->i_height;
+        i_sar_den = p_preset->u_ar_den * p_preset->i_width;
         i_chroma = p_preset->i_chroma;
     }
 
@@ -226,11 +228,11 @@ static int Open( vlc_object_t * p_this )
         READ_FRAC( " F", u_fps_num, u_fps_den );
         READ_FRAC( " A", a, b );
 #undef READ_FRAC
-        /* Try to calculate aspect ratio here, rather than store ratio
-         * in u_ar_{num,den}, since width may be overridden by then.
-         * Plus, a:b is sar. */
         if( b != 0 )
-            i_aspect = VOUT_ASPECT_FACTOR * a * i_width / (b * i_height);
+        {
+            i_sar_num = a;
+            i_sar_den = b;
+        }
 
         psz_buf = strstr( psz+9, " C" );
         if( psz_buf )
@@ -329,8 +331,8 @@ static int Open( vlc_object_t * p_this )
         if( psz_denominator )
         {
             *psz_denominator++ = '\0';
-            i_aspect = atoi( psz_tmp ) * VOUT_ASPECT_FACTOR
-                     / atoi( psz_denominator );
+            i_sar_num = atoi( psz_tmp )         * i_height;
+            i_sar_den = atoi( psz_denominator ) * i_width;
         }
         free( psz_tmp );
     }
@@ -349,16 +351,17 @@ static int Open( vlc_object_t * p_this )
     }
 
     /* fixup anything missing with sensible assumptions */
-    if( !i_aspect )
+    if( i_sar_num <= 0 || i_sar_den <= 0 )
     {
         /* assume 1:1 sar */
-        i_aspect = i_width * VOUT_ASPECT_FACTOR / i_height;
+        i_sar_num = 1;
+        i_sar_den = 1;
     }
 
     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_height, VOUT_ASPECT_FACTOR * i_width );
+                        i_sar_num, i_sar_den );
 
     vlc_ureduce( &p_sys->fmt_video.video.i_frame_rate,
                  &p_sys->fmt_video.video.i_frame_rate_base,
index ea43afd..8aa5a17 100644 (file)
@@ -331,6 +331,10 @@ static int Create( vlc_object_t *p_this )
     p_sys->i_alpha = var_CreateGetIntegerCommand( p_intf, "fbosd-alpha" );
     var_AddCallback( p_intf, "fbosd-alpha", OverlayCallback, NULL );
 
+    /* Use PAL by default */
+    p_sys->i_width  = p_sys->fmt_out.i_width  = 704;
+    p_sys->i_height = p_sys->fmt_out.i_height = 576;
+
     p_sys->i_aspect = -1;
     psz_aspect =
             var_CreateGetNonEmptyString( p_intf, "fbosd-aspect-ratio" );
@@ -343,7 +347,8 @@ static int Create( vlc_object_t *p_this )
             *psz_parser++ = '\0';
             p_sys->i_aspect = ( atoi( psz_aspect )
                               * VOUT_ASPECT_FACTOR ) / atoi( psz_parser );
-            p_sys->fmt_out.i_aspect = p_sys->i_aspect;
+            p_sys->fmt_out.i_sar_num = p_sys->i_aspect    * p_sys->i_height;
+            p_sys->fmt_out.i_sar_den = VOUT_ASPECT_FACTOR * p_sys->i_width;
         }
         msg_Dbg( p_intf, "using aspect ratio %d:%d",
                   atoi( psz_aspect ), atoi( psz_parser ) );
@@ -351,10 +356,6 @@ static int Create( vlc_object_t *p_this )
         free( psz_aspect );
     }
 
-    /* Use PAL by default */
-    p_sys->i_width  = p_sys->fmt_out.i_width  = 704;
-    p_sys->i_height = p_sys->fmt_out.i_height = 576;
-
     psz_tmp = var_CreateGetNonEmptyStringCommand( p_intf, "fbosd-image" );
     var_AddCallback( p_intf, "fbosd-image", OverlayCallback, NULL );
     if( psz_tmp && *psz_tmp )
@@ -532,8 +533,10 @@ static int OpenBlending( intf_thread_t *p_intf )
     vlc_object_attach( p_intf->p_sys->p_blend, p_intf );
     p_intf->p_sys->p_blend->fmt_out.video.i_x_offset =
         p_intf->p_sys->p_blend->fmt_out.video.i_y_offset = 0;
-    p_intf->p_sys->p_blend->fmt_out.video.i_aspect =
-            p_intf->p_sys->fmt_out.i_aspect;
+    p_intf->p_sys->p_blend->fmt_out.video.i_sar_num =
+            p_intf->p_sys->fmt_out.i_sar_num;
+    p_intf->p_sys->p_blend->fmt_out.video.i_sar_den =
+            p_intf->p_sys->fmt_out.i_sar_den;
     p_intf->p_sys->p_blend->fmt_out.video.i_chroma =
             p_intf->p_sys->fmt_out.i_chroma;
     if( config_GetInt( p_intf, "freetype-yuvp" ) )
@@ -845,7 +848,6 @@ static picture_t *RenderText( intf_thread_t *p_intf, const char *psz_string,
 
         memset( &fmt, 0, sizeof(fmt) );
         fmt.i_chroma = VLC_CODEC_TEXT;
-        fmt.i_aspect = 0;
         fmt.i_width  = fmt.i_visible_width = 0;
         fmt.i_height = fmt.i_visible_height = 0;
         fmt.i_x_offset = 0;
@@ -981,12 +983,14 @@ static int Init( intf_thread_t *p_intf )
     /* Assume we have square pixels */
     if( p_sys->i_aspect < 0 )
     {
-        p_sys->fmt_out.i_aspect = ( p_sys->i_width
-                                  * VOUT_ASPECT_FACTOR ) / p_sys->i_height;
+        p_sys->fmt_out.i_sar_num = 1;
+        p_sys->fmt_out.i_sar_den = 1;
+    }
+    else
+    {
+        p_sys->fmt_out.i_sar_num = p_sys->i_aspect    * p_sys->i_height;
+        p_sys->fmt_out.i_sar_den = VOUT_ASPECT_FACTOR * p_sys->i_width;
     }
-    else p_sys->fmt_out.i_aspect = p_sys->i_aspect;
-
-    p_sys->fmt_out.i_sar_num = p_sys->fmt_out.i_sar_den = 1;
 
     /* Allocate overlay buffer */
     p_sys->p_overlay = AllocatePicture( &p_sys->fmt_out );
index 70e6ec9..b78da48 100644 (file)
@@ -622,7 +622,6 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region,
     /* Create a new subpicture region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_YUVP;
-    fmt.i_aspect = 0;
     fmt.i_width = fmt.i_visible_width = i_width + 4;
     fmt.i_height = fmt.i_visible_height = i_height + 4;
     if( p_region->fmt.i_visible_width > 0 )
@@ -888,7 +887,6 @@ static int RenderYUVA( filter_t *p_filter, subpicture_region_t *p_region,
     /* Create a new subpicture region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_YUVA;
-    fmt.i_aspect = 0;
     fmt.i_width = fmt.i_visible_width = i_width + 6;
     fmt.i_height = fmt.i_visible_height = i_height + 6;
     if( p_region->fmt.i_visible_width > 0 )
index 0590b7e..732f276 100644 (file)
@@ -1045,7 +1045,6 @@ static int RenderYUVA( filter_t *p_filter, subpicture_region_t *p_region,
     // Create a new subpicture region
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_YUVA;
-    fmt.i_aspect = 0;
     fmt.i_width = fmt.i_visible_width = i_width;
     fmt.i_height = fmt.i_visible_height = __MIN( i_height, i_textblock_height + VERTICAL_MARGIN * 2);
     fmt.i_x_offset = fmt.i_y_offset = 0;
index f981dd2..9039371 100644 (file)
@@ -56,7 +56,8 @@ int OpenDecoder ( vlc_object_t *p_this )
     es_format_Init( &p_dec->fmt_out, VIDEO_ES, VLC_CODEC_I420 );
     p_dec->fmt_out.video.i_width = 100;
     p_dec->fmt_out.video.i_height = 100;
-    p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR;
+    p_dec->fmt_out.video.i_sar_num = 1;
+    p_dec->fmt_out.video.i_sar_den = 1;
 
     return VLC_SUCCESS;
 }
index 4135d33..2f3ee44 100644 (file)
@@ -278,10 +278,11 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region,
     /* Create a new subpicture region */
     memset( &fmt, 0, sizeof( video_format_t ) );
     fmt.i_chroma = VLC_CODEC_YUVA;
-    fmt.i_aspect = VOUT_ASPECT_FACTOR;
     fmt.i_width = fmt.i_visible_width = i_width;
     fmt.i_height = fmt.i_visible_height = i_height;
     fmt.i_x_offset = fmt.i_y_offset = 0;
+    fmt.i_sar_num = 1;
+    fmt.i_sar_den = 1;
 
     p_region->p_picture = picture_NewFromFormat( &fmt );
     if( !p_region->p_picture )
index d937bc7..031a646 100644 (file)
@@ -931,7 +931,9 @@ static block_t *asf_header_create( sout_mux_t *p_mux, bool b_broadcast )
     for( i = 0; i < vlc_array_count( p_sys->p_tracks ); i++ )
     {
         const asf_track_t *p_track = vlc_array_item_at_index( p_sys->p_tracks, i );
-        if( p_track->i_cat == VIDEO_ES && p_track->fmt.video.i_aspect != 0 )
+        if( p_track->i_cat == VIDEO_ES &&
+            p_track->fmt.video.i_sar_num != 0 &&
+            p_track->fmt.video.i_sar_den != 0 )
         {
             i_cm_size = 26 + 2 * (16 + 2 * sizeof("AspectRatio?"));
             break;
@@ -1039,10 +1041,9 @@ static block_t *asf_header_create( sout_mux_t *p_mux, bool b_broadcast )
         }
         assert( tk != NULL );
 
-        i_num = tk->fmt.video.i_aspect *
-            (int64_t)tk->fmt.video.i_height;
-        i_den = VOUT_ASPECT_FACTOR * tk->fmt.video.i_width;
-        vlc_ureduce( &i_dst_num, &i_dst_den, i_num, i_den, 0 );
+        vlc_ureduce( &i_dst_num, &i_dst_den,
+                     tk->fmt.video.i_sar_num,
+                     tk->fmt.video.i_sar_den, 0 );
 
         msg_Dbg( p_mux, "pixel aspect-ratio: %i/%i", i_dst_num, i_dst_den );
 
index bfd9866..d5a8614 100644 (file)
@@ -1632,11 +1632,12 @@ static bo_t *GetMoovBox( sout_mux_t *p_mux )
         else if( p_stream->fmt.i_cat == VIDEO_ES )
         {
             int i_width = p_stream->fmt.video.i_width << 16;
-            if( p_stream->fmt.video.i_aspect > 0 )
+            if( p_stream->fmt.video.i_sar_num > 0 &&
+                p_stream->fmt.video.i_sar_den > 0 )
             {
-                i_width = (int64_t)p_stream->fmt.video.i_aspect *
-                          ((int64_t)p_stream->fmt.video.i_height << 16) /
-                          VOUT_ASPECT_FACTOR;
+                i_width = (int64_t)p_stream->fmt.video.i_sar_num *
+                          ((int64_t)p_stream->fmt.video.i_width << 16) /
+                          p_stream->fmt.video.i_sar_den;
             }
             // width (presentation)
             bo_add_32be( tkhd, i_width );
@@ -1653,12 +1654,14 @@ static bo_t *GetMoovBox( sout_mux_t *p_mux )
                 mp4_stream_t *tk = p_sys->pp_streams[i];
                 if( tk->fmt.i_cat == VIDEO_ES )
                 {
-                    if( p_stream->fmt.video.i_aspect )
-                        i_width = (int64_t)p_stream->fmt.video.i_aspect *
-                                   ((int64_t)p_stream->fmt.video.i_height<<16) / VOUT_ASPECT_FACTOR;
+                    if( tk->fmt.video.i_sar_num > 0 &&
+                        tk->fmt.video.i_sar_den > 0 )
+                        i_width = (int64_t)tk->fmt.video.i_sar_num *
+                                  ((int64_t)tk->fmt.video.i_width << 16) /
+                                  tk->fmt.video.i_sar_den;
                     else
-                        i_width = p_stream->fmt.video.i_width << 16;
-                    i_height = p_stream->fmt.video.i_height;
+                        i_width = tk->fmt.video.i_width << 16;
+                    i_height = tk->fmt.video.i_height;
                     break;
                 }
             }
index 147507b..886f12c 100644 (file)
@@ -911,12 +911,16 @@ static void PutSPS( decoder_t *p_dec, block_t *p_frag )
                 h = 0;
             }
 
-            if( h != 0 )
-                p_dec->fmt_out.video.i_aspect = (int64_t)VOUT_ASPECT_FACTOR *
-                        ( w * p_dec->fmt_out.video.i_width ) /
-                        ( h * p_dec->fmt_out.video.i_height);
+            if( w != 0 && h != 0 )
+            {
+                p_dec->fmt_out.video.i_sar_num = w;
+                p_dec->fmt_out.video.i_sar_den = h;
+            }
             else
-                p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR;
+            {
+                p_dec->fmt_out.video.i_sar_num = 1;
+                p_dec->fmt_out.video.i_sar_den = 1;
+            }
         }
     }
 
index d6f27ee..a09016f 100644 (file)
@@ -610,10 +610,12 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
              * of aspect ratio change, we're screwed. --Meuuh
              */
 #if 0
-            p_dec->fmt_out.video.i_aspect =
+            p_dec->fmt_out.video.i_sar_num =
                 mpeg2_aspect[p_sys->i_aspect_ratio_info][0] *
-                VOUT_ASPECT_FACTOR /
-                mpeg2_aspect[p_sys->i_aspect_ratio_info][1];
+                p_dec->fmt_out.video.i_height;
+            p_dec->fmt_out.video.i_sar_den =
+                mpeg2_aspect[p_sys->i_aspect_ratio_info][1] *
+                p_dec->fmt_out.video.i_width;
 #endif
 
         }
index 679ee15..0293feb 100644 (file)
@@ -492,7 +492,8 @@ static block_t *ParseIDU( decoder_t *p_dec, bool *pb_used_ts, block_t *p_frag )
                 const int i_display_width  = bs_read( &s, 14 )+1;
                 const int i_display_height = bs_read( &s, 14 )+1;
 
-                p_es->video.i_aspect = VOUT_ASPECT_FACTOR * i_display_width / i_display_height;
+                p_es->video.i_sar_num = i_display_width  * p_es->video.i_height;
+                p_es->video.i_sar_den = i_display_height * p_es->video.i_width;
 
                 if( !p_sys->b_sequence_header )
                     msg_Dbg( p_dec, "display size %dx%d", i_display_width, i_display_height );
index 54c986b..5f950e7 100644 (file)
@@ -555,17 +555,21 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
             else
                 fmt_out.i_chroma = VLC_CODEC_I420;
 
+            const unsigned i_fmt_in_aspect =
+                (int64_t)VOUT_ASPECT_FACTOR *
+                fmt_in.i_sar_num * fmt_in.i_width /
+                (fmt_in.i_sar_den * fmt_in.i_height);
             if ( !p_sys->i_height )
             {
                 fmt_out.i_width = p_sys->i_width;
                 fmt_out.i_height = (p_sys->i_width * VOUT_ASPECT_FACTOR
-                    * p_sys->i_sar_num / p_sys->i_sar_den / fmt_in.i_aspect)
+                    * p_sys->i_sar_num / p_sys->i_sar_den / i_fmt_in_aspect)
                       & ~0x1;
             }
             else if ( !p_sys->i_width )
             {
                 fmt_out.i_height = p_sys->i_height;
-                fmt_out.i_width = (p_sys->i_height * fmt_in.i_aspect
+                fmt_out.i_width = (p_sys->i_height * i_fmt_in_aspect
                     * p_sys->i_sar_den / p_sys->i_sar_num / VOUT_ASPECT_FACTOR)
                       & ~0x1;
             }
@@ -592,8 +596,8 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
 
             p_new_pic = picture_New( p_pic->format.i_chroma,
                                      p_pic->format.i_width, p_pic->format.i_height,
-                                     p_sys->p_decoder->fmt_out.video.i_aspect * p_pic->format.i_height,
-                                     VOUT_ASPECT_FACTOR                       * p_pic->format.i_width );
+                                     p_sys->p_decoder->fmt_out.video.i_sar_num,
+                                     p_sys->p_decoder->fmt_out.video.i_sar_den );
             if( !p_new_pic )
             {
                 picture_Release( p_pic );
@@ -636,18 +640,9 @@ static picture_t *video_new_buffer( vlc_object_t *p_this,
     if( fmt_out->video.i_width != p_sys->video.i_width ||
         fmt_out->video.i_height != p_sys->video.i_height ||
         fmt_out->video.i_chroma != p_sys->video.i_chroma ||
-        fmt_out->video.i_aspect != p_sys->video.i_aspect )
+        (int64_t)fmt_out->video.i_sar_num * p_sys->video.i_sar_den !=
+        (int64_t)fmt_out->video.i_sar_den * p_sys->video.i_sar_num )
     {
-        if( !fmt_out->video.i_sar_num ||
-            !fmt_out->video.i_sar_den )
-        {
-            fmt_out->video.i_sar_num =
-                fmt_out->video.i_aspect * fmt_out->video.i_height;
-
-            fmt_out->video.i_sar_den =
-                VOUT_ASPECT_FACTOR * fmt_out->video.i_width;
-        }
-
         vlc_ureduce( &fmt_out->video.i_sar_num,
                      &fmt_out->video.i_sar_den,
                      fmt_out->video.i_sar_num,
index 352041e..5e3ed94 100644 (file)
@@ -285,7 +285,6 @@ int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_t *id )
     }
     return VLC_SUCCESS;
 }
-
 static void transcode_video_encoder_init( sout_stream_t *p_stream,
                                           sout_stream_id_t *id )
 {
@@ -305,11 +304,12 @@ static void transcode_video_encoder_init( sout_stream_t *p_stream,
     int i_dst_height;
 
     /* aspect ratio */
-    float f_aspect = (float)id->p_decoder->fmt_out.video.i_aspect /
-                            VOUT_ASPECT_FACTOR;
+    float f_aspect = (double)id->p_decoder->fmt_out.video.i_sar_num *
+                     id->p_decoder->fmt_out.video.i_width /
+                     id->p_decoder->fmt_out.video.i_sar_den /
+                     id->p_decoder->fmt_out.video.i_height;
 
-    msg_Dbg( p_stream, "decoder aspect is %i:%i",
-                 id->p_decoder->fmt_out.video.i_aspect, VOUT_ASPECT_FACTOR );
+    msg_Dbg( p_stream, "decoder aspect is %f:1", f_aspect );
 
     /* Change f_aspect from source frame to source pixel */
     f_aspect = f_aspect * i_src_height / i_src_width;
@@ -432,16 +432,22 @@ static void transcode_video_encoder_init( sout_stream_t *p_stream,
                id->p_encoder->fmt_out.video.i_frame_rate_base );
 
     /* Check whether a particular aspect ratio was requested */
-    if( !id->p_encoder->fmt_out.video.i_aspect )
+    if( id->p_encoder->fmt_out.video.i_sar_num <= 0 ||
+        id->p_encoder->fmt_out.video.i_sar_den <= 0 )
     {
-        id->p_encoder->fmt_out.video.i_aspect =
-                (int)( f_aspect * VOUT_ASPECT_FACTOR + 0.5 );
+        id->p_encoder->fmt_out.video.i_sar_num =
+            f_aspect * id->p_encoder->fmt_out.video.i_height + 0.5;
+        id->p_encoder->fmt_out.video.i_sar_num =
+            VOUT_ASPECT_FACTOR * id->p_encoder->fmt_out.video.i_width;
     }
-    id->p_encoder->fmt_in.video.i_aspect =
-        id->p_encoder->fmt_out.video.i_aspect;
+    id->p_encoder->fmt_in.video.i_sar_num =
+        id->p_encoder->fmt_out.video.i_sar_num;
+    id->p_encoder->fmt_in.video.i_sar_den =
+        id->p_encoder->fmt_out.video.i_sar_den;
 
     msg_Dbg( p_stream, "encoder aspect is %i:%i",
-             id->p_encoder->fmt_out.video.i_aspect, VOUT_ASPECT_FACTOR );
+             id->p_encoder->fmt_out.video.i_sar_num * id->p_encoder->fmt_out.video.i_width,
+             id->p_encoder->fmt_out.video.i_sar_den * id->p_encoder->fmt_out.video.i_height );
 
     id->p_encoder->fmt_in.video.i_chroma = id->p_encoder->fmt_in.i_codec;
 }
@@ -633,8 +639,10 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_t *id,
                     id->p_encoder->fmt_in.video.i_width;
                 id->p_encoder->fmt_out.video.i_height =
                     id->p_encoder->fmt_in.video.i_height;
-                id->p_encoder->fmt_out.video.i_aspect =
-                    id->p_encoder->fmt_in.video.i_aspect;
+                id->p_encoder->fmt_out.video.i_sar_num =
+                    id->p_encoder->fmt_in.video.i_sar_num;
+                id->p_encoder->fmt_out.video.i_sar_den =
+                    id->p_encoder->fmt_in.video.i_sar_den;
             }
 
             if( transcode_video_encoder_open( p_stream, id ) != VLC_SUCCESS )
@@ -683,10 +691,6 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_t *id,
             else
                 fmt = id->p_decoder->fmt_out.video;
 
-            /* FIXME (shouldn't have to be done here) */
-            fmt.i_sar_num = fmt.i_aspect * fmt.i_height / fmt.i_width;
-            fmt.i_sar_den = VOUT_ASPECT_FACTOR;
-
             /* FIXME the mdate() seems highly suspicious */
             spu_RenderSubpictures( p_sys->p_spu, p_pic, &fmt,
                                    p_subpic, &id->p_decoder->fmt_out.video, mdate() );
index a7279e6..44359cc 100644 (file)
@@ -342,7 +342,6 @@ static subpicture_t *FilterSub( filter_t *p_filter, mtime_t date )
     /* Create new SPU region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_YUVA;
-    fmt.i_aspect = VOUT_ASPECT_FACTOR;
     fmt.i_sar_num = fmt.i_sar_den = 1;
     fmt.i_width = fmt.i_visible_width = p_pic->p[Y_PLANE].i_visible_pitch;
     fmt.i_height = fmt.i_visible_height = p_pic->p[Y_PLANE].i_visible_lines;
index acb8bd3..ce5573a 100644 (file)
@@ -144,6 +144,7 @@ static int Activate( vlc_object_t *p_this )
     int i_padd,i_offset;
     char *psz_aspect, *psz_parser;
     bool b_padd;
+    unsigned i_fmt_in_aspect;
 
     if( !p_filter->b_allow_fmt_out_change )
     {
@@ -177,6 +178,11 @@ static int Activate( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
+    i_fmt_in_aspect = (int64_t)p_filter->fmt_in.video.i_sar_num *
+                      p_filter->fmt_in.video.i_width *
+                      VOUT_ASPECT_FACTOR /
+                      p_filter->fmt_in.video.i_sar_den /
+                      p_filter->fmt_in.video.i_height;
     psz_aspect = var_CreateGetNonEmptyString( p_filter, CFG_PREFIX "aspect" );
     if( psz_aspect )
     {
@@ -200,7 +206,7 @@ static int Activate( vlc_object_t *p_this )
         /* aspect = subpic_sar * canvas_width / canvas_height
          *  where subpic_sar = subpic_ph * subpic_par / subpic_pw */
         i_canvas_aspect = (uint64_t) p_filter->fmt_in.video.i_height
-                        * p_filter->fmt_in.video.i_aspect
+                        * i_fmt_in_aspect
                         * i_canvas_width
                         / (i_canvas_height * p_filter->fmt_in.video.i_width);
     }
@@ -230,7 +236,7 @@ static int Activate( vlc_object_t *p_this )
     if( b_padd )
     {
         /* Padd */
-        if( i_canvas_aspect > p_filter->fmt_in.video.i_aspect )
+        if( i_canvas_aspect > i_fmt_in_aspect )
         {
             /* The canvas has a wider aspect than the subpicture:
              *  ie, pillarbox the [scaled] subpicture */
@@ -239,7 +245,7 @@ static int Activate( vlc_object_t *p_this )
              *  where canvas_sar = canvas_width / (canvas_height * canvas_par)
              * then simplify */
             fmt.video.i_width = i_canvas_width
-                              * p_filter->fmt_in.video.i_aspect
+                              * i_fmt_in_aspect
                               / i_canvas_aspect;
             if( fmt.video.i_width & 1 ) fmt.video.i_width -= 1;
 
@@ -254,7 +260,7 @@ static int Activate( vlc_object_t *p_this )
              *  ie, letterbox the [scaled] subpicture */
             fmt.video.i_height = i_canvas_height
                                * i_canvas_aspect
-                               / p_filter->fmt_in.video.i_aspect;
+                               / i_fmt_in_aspect;
             if( fmt.video.i_height & 1 ) fmt.video.i_height -= 1;
 
             i_padd = (i_canvas_height - fmt.video.i_height ) / 2;
@@ -266,12 +272,12 @@ static int Activate( vlc_object_t *p_this )
     else
     {
         /* Crop */
-        if( i_canvas_aspect < p_filter->fmt_in.video.i_aspect )
+        if( i_canvas_aspect < i_fmt_in_aspect )
         {
             /* The canvas has a narrower aspect than the subpicture:
              *  ie, crop the [scaled] subpicture horizontally */
             fmt.video.i_width = i_canvas_width
-                              * p_filter->fmt_in.video.i_aspect
+                              * i_fmt_in_aspect
                               / i_canvas_aspect;
             if( fmt.video.i_width & 1 ) fmt.video.i_width -= 1;
 
@@ -286,7 +292,7 @@ static int Activate( vlc_object_t *p_this )
              *  ie, crop the [scaled] subpicture vertically */
             fmt.video.i_height = i_canvas_height
                                * i_canvas_aspect
-                               / p_filter->fmt_in.video.i_aspect;
+                               / i_fmt_in_aspect;
             if( fmt.video.i_height & 1 ) fmt.video.i_height -= 1;
 
             i_padd = (fmt.video.i_height - i_canvas_height) / 2;
@@ -312,7 +318,10 @@ static int Activate( vlc_object_t *p_this )
     fmt = *filter_chain_GetFmtOut( p_sys->p_chain );
     es_format_Copy( &p_filter->fmt_out, &fmt );
 
-    p_filter->fmt_out.video.i_aspect = i_canvas_aspect;
+    p_filter->fmt_out.video.i_sar_num =
+        i_canvas_aspect    * p_filter->fmt_out.video.i_height;
+    p_filter->fmt_out.video.i_sar_den =
+        VOUT_ASPECT_FACTOR * p_filter->fmt_out.video.i_width;
 
     if( p_filter->fmt_out.video.i_width != i_canvas_width
      || p_filter->fmt_out.video.i_height != i_canvas_height )
index 8253d7b..464a470 100644 (file)
@@ -351,9 +351,9 @@ static int Init( vout_thread_t *p_vout )
                      p_vout->p_sys->i_x, p_vout->p_sys->i_y,
                      p_vout->p_sys->b_autocrop ? "" : "not " );
     /* Set current output image properties */
-    p_vout->p_sys->i_aspect = p_vout->fmt_out.i_aspect
-           * p_vout->fmt_out.i_visible_height / p_vout->p_sys->i_height
-           * p_vout->p_sys->i_width / p_vout->fmt_out.i_visible_width;
+    p_vout->p_sys->i_aspect = (int64_t)VOUT_ASPECT_FACTOR *
+        p_vout->fmt_out.i_sar_num * p_vout->p_sys->i_width /
+        (p_vout->fmt_out.i_sar_den * p_vout->p_sys->i_height);
 
 #ifdef BEST_AUTOCROP
     msg_Info( p_vout, "ratio %d",  p_vout->p_sys->i_aspect / 432);
@@ -362,9 +362,8 @@ static int Init( vout_thread_t *p_vout )
     fmt.i_height = fmt.i_visible_height = p_vout->p_sys->i_height;
     fmt.i_x_offset = fmt.i_y_offset = 0;
     fmt.i_chroma = p_vout->render.i_chroma;
-    fmt.i_aspect = p_vout->p_sys->i_aspect;
-    fmt.i_sar_num = p_vout->p_sys->i_aspect * fmt.i_height / fmt.i_width;
-    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+    fmt.i_sar_num = p_vout->p_sys->i_aspect * fmt.i_height;
+    fmt.i_sar_den = VOUT_ASPECT_FACTOR * fmt.i_width;
 
     /* Try to open the real video output */
     p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
@@ -455,7 +454,6 @@ static int Manage( vout_thread_t *p_vout )
     fmt.i_height = fmt.i_visible_height = p_vout->p_sys->i_height;
     fmt.i_x_offset = fmt.i_y_offset = 0;
     fmt.i_chroma = p_vout->render.i_chroma;
-    fmt.i_aspect = p_vout->p_sys->i_aspect;
     fmt.i_sar_num = p_vout->p_sys->i_aspect * fmt.i_height / fmt.i_width;
     fmt.i_sar_den = VOUT_ASPECT_FACTOR;
 
index b9d2546..e4aa704 100644 (file)
@@ -535,7 +535,6 @@ static void Render ( vout_thread_t *p_vout, picture_t *p_pic )
     {
         p_vout->i_changes &= ~VOUT_ASPECT_CHANGE;
 
-        p_vout->fmt_out.i_aspect = p_vout->fmt_in.i_aspect;
         p_vout->fmt_out.i_sar_num = p_vout->fmt_in.i_sar_num;
         p_vout->fmt_out.i_sar_den = p_vout->fmt_in.i_sar_den;
 
index 766c5c5..300431c 100644 (file)
@@ -493,8 +493,8 @@ static int exec_DataSharedMem( filter_t *p_filter,
         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 * p_params->i_height,
-                                  VOUT_ASPECT_FACTOR     * p_params->i_width ) )
+                                  p_ovl->format.i_sar_num,
+                                  p_ovl->format.i_sar_den ) )
         {
             msg_Err( p_filter, "Unable to allocate picture" );
             free( p_ovl->data.p_pic );
index 844d4bc..6b583c9 100644 (file)
@@ -383,7 +383,6 @@ static subpicture_t *FilterSub( filter_t *p_filter, mtime_t date )
     /* Create new SPU region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_YUVA;
-    fmt.i_aspect = VOUT_ASPECT_FACTOR;
     fmt.i_sar_num = fmt.i_sar_den = 1;
     fmt.i_width = fmt.i_visible_width = p_pic->p[Y_PLANE].i_visible_pitch;
     fmt.i_height = fmt.i_visible_height = p_pic->p[Y_PLANE].i_visible_lines;
index e4607e3..43bba5c 100644 (file)
@@ -285,7 +285,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
 
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_TEXT;
-    fmt.i_aspect = 0;
     fmt.i_width = fmt.i_height = 0;
     fmt.i_x_offset = 0;
     fmt.i_y_offset = 0;
index 751dbf0..732d185 100644 (file)
@@ -372,7 +372,6 @@ static subpicture_region_t *create_text_region( filter_t *p_filter, subpicture_t
     /* Create new SPU region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_TEXT;
-    fmt.i_aspect = VOUT_ASPECT_FACTOR;
     fmt.i_sar_num = fmt.i_sar_den = 1;
     fmt.i_width = fmt.i_visible_width = i_width;
     fmt.i_height = fmt.i_visible_height = i_height;
@@ -410,7 +409,6 @@ static subpicture_region_t *create_picture_region( filter_t *p_filter, subpictur
     /* Create new SPU region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = (p_pic == NULL) ? VLC_CODEC_YUVP : VLC_CODEC_YUVA;
-    fmt.i_aspect = VOUT_ASPECT_FACTOR;
     fmt.i_sar_num = fmt.i_sar_den = 1;
     fmt.i_width = fmt.i_visible_width = i_width;
     fmt.i_height = fmt.i_visible_height = i_height;
index 68a464c..a1721aa 100644 (file)
@@ -1152,7 +1152,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
     /* Create new SPU region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_YUVA;
-    fmt.i_aspect = VOUT_ASPECT_FACTOR;
     fmt.i_sar_num = fmt.i_sar_den = 1;
     fmt.i_width = fmt.i_visible_width = p_pic->p[Y_PLANE].i_visible_pitch;
     fmt.i_height = fmt.i_visible_height = p_pic->p[Y_PLANE].i_visible_lines;
index 36e3437..f00eed1 100644 (file)
@@ -501,7 +501,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
         memset( &fmt_out, 0, sizeof(video_format_t) );
 
         fmt_out.i_chroma = VLC_CODEC_YUVA;
-        fmt_out.i_aspect = VOUT_ASPECT_FACTOR;
         fmt_out.i_sar_num = fmt_out.i_sar_den = 1;
         fmt_out.i_width =
             fmt_out.i_visible_width = p_pic->p[Y_PLANE].i_visible_pitch;
index 0ecd450..9630e77 100644 (file)
@@ -242,9 +242,6 @@ static int Init( vout_thread_t *p_vout )
         fmt.i_visible_height = p_vout->fmt_out.i_visible_width;
         fmt.i_y_offset = p_vout->fmt_out.i_x_offset;
 
-        fmt.i_aspect = VOUT_ASPECT_FACTOR *
-            (uint64_t)VOUT_ASPECT_FACTOR / fmt.i_aspect;
-
         fmt.i_sar_num = p_vout->fmt_out.i_sar_den;
         fmt.i_sar_den = p_vout->fmt_out.i_sar_num;
     }
index 1a6837b..12141c5 100644 (file)
@@ -351,8 +351,8 @@ static int Open( vlc_object_t *p_this )
             p_cfg->fmt.i_width          = p_output->i_width;
             p_cfg->fmt.i_visible_height =
             p_cfg->fmt.i_height         = p_output->i_height;
-            p_cfg->fmt.i_aspect         = (int64_t)i_aspect * i_target_height * p_output->i_width / i_target_width / p_output->i_height;
-
+            p_cfg->fmt.i_sar_num        = (int64_t)i_aspect * i_target_height;
+            p_cfg->fmt.i_sar_den        = VOUT_ASPECT_FACTOR * i_target_width;
             p_cfg->window.i_x     = p_output->i_left; /* FIXME relative to video-x/y (TODO in wrapper.c) ? */
             p_cfg->window.i_y     = p_output->i_top;
             p_cfg->window.i_align = p_output->i_align;
index cc24fb6..46ac870 100644 (file)
@@ -147,11 +147,6 @@ static int Open( vlc_object_t *p_this, const char *psz_name, bool b_filter )
                         p_vout->render.i_width, p_vout->render.i_height,
                         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;
-        fmt.video.i_sar_den = VOUT_ASPECT_FACTOR * fmt.video.i_visible_width;
-    }
 
     /* Try to open our real module */
     filter_chain_t   *p_chain = NULL;
index f2bbc97..b59db02 100644 (file)
@@ -224,7 +224,6 @@ void CommonManage( vout_thread_t *p_vout )
         p_vout->fmt_out.i_y_offset = p_vout->fmt_in.i_y_offset;
         p_vout->fmt_out.i_visible_width = p_vout->fmt_in.i_visible_width;
         p_vout->fmt_out.i_visible_height = p_vout->fmt_in.i_visible_height;
-        p_vout->fmt_out.i_aspect = p_vout->fmt_in.i_aspect;
         p_vout->fmt_out.i_sar_num = p_vout->fmt_in.i_sar_num;
         p_vout->fmt_out.i_sar_den = p_vout->fmt_in.i_sar_den;
         p_vout->output.i_aspect = p_vout->fmt_in.i_aspect;
index d18616b..45d7716 100644 (file)
@@ -232,7 +232,9 @@ static int Init( vout_thread_t *p_vout )
     vout_sys_t *p_sys = (vout_sys_t *)p_vout->p_sys;
 
     // We want to keep the same aspect
-    p_vout->fmt_out.i_aspect = p_vout->output.i_aspect = p_vout->render.i_aspect;
+    p_vout->output.i_aspect = p_vout->render.i_aspect;
+    p_vout->fmt_out.i_sar_num = p_vout->render.i_aspect * p_vout->render.i_height;
+    p_vout->fmt_out.i_sar_den = VOUT_ASPECT_FACTOR      * p_vout->render.i_width;
     // We ask where the video should be displayed in the video area
     vout_PlacePicture( p_vout, p_sys->main_window.i_width,
                        p_sys->main_window.i_height,
index b4eaba8..93b8b1f 100644 (file)
@@ -319,13 +319,12 @@ static int Manage( vout_thread_t *p_vout )
         p_vout->fmt_in.i_visible_width;
     p_vout->fmt_out.i_visible_height = p_sys->p_vout->fmt_in.i_visible_height =
         p_vout->fmt_in.i_visible_height;
-    p_vout->fmt_out.i_aspect = p_sys->p_vout->fmt_in.i_aspect =
-        p_vout->fmt_in.i_aspect;
     p_vout->fmt_out.i_sar_num = p_sys->p_vout->fmt_in.i_sar_num =
         p_vout->fmt_in.i_sar_num;
     p_vout->fmt_out.i_sar_den = p_sys->p_vout->fmt_in.i_sar_den =
         p_vout->fmt_in.i_sar_den;
-    p_vout->output.i_aspect = p_vout->fmt_in.i_aspect;
+    p_vout->output.i_aspect = (int64_t)p_vout->fmt_in.i_sar_num * p_vout->fmt_in.i_width * VOUT_ASPECT_FACTOR /
+                              p_vout->fmt_in.i_sar_den / p_vout->fmt_in.i_height;
 
     p_sys->p_vout->i_changes = p_vout->i_changes;
     i_ret = p_sys->p_vout->pf_manage( p_sys->p_vout );
index edf19fb..b7563ad 100644 (file)
@@ -247,7 +247,7 @@ static int Init(vout_thread_t *vout)
     vout->output.i_chroma = source.i_chroma;
     vout->output.i_width  = source.i_width;
     vout->output.i_height = source.i_height;
-    vout->output.i_aspect = source.i_aspect;
+    vout->output.i_aspect = (int64_t)source.i_sar_num * source.i_width * VOUT_ASPECT_FACTOR / source.i_sar_den / source.i_height;
     vout->output.i_rmask  = source.i_rmask;
     vout->output.i_gmask  = source.i_gmask;
     vout->output.i_bmask  = source.i_bmask;
@@ -259,7 +259,8 @@ static int Init(vout_thread_t *vout)
     vout->fmt_out.i_visible_width  = vout->output.i_width;
     vout->fmt_out.i_height         =
     vout->fmt_out.i_visible_height = vout->output.i_height;
-    vout->fmt_out.i_aspect         = vout->output.i_aspect;
+    vout->fmt_out.i_sar_num        = vout->output.i_aspect * vout->output.i_height;
+    vout->fmt_out.i_sar_den        = VOUT_ASPECT_FACTOR    * vout->output.i_width;
     vout->fmt_out.i_x_offset       = 0;
     vout->fmt_out.i_y_offset       = 0;
 
@@ -318,8 +319,7 @@ static int Init(vout_thread_t *vout)
             vout_AllocatePicture(VLC_OBJECT(vd), picture,
                                  vd->source.i_chroma,
                                  vd->source.i_width, vd->source.i_height,
-                                 vd->source.i_aspect * vd->source.i_height,
-                                 VOUT_ASPECT_FACTOR  * vd->source.i_width);
+                                 vd->source.i_sar_num, vd->source.i_sar_den);
             if (!picture->i_planes)
                 break;
             picture->p_sys->direct = NULL;
@@ -380,8 +380,8 @@ static int Manage(vout_thread_t *vout)
             vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
         }
         if (vout->i_changes & VOUT_ASPECT_CHANGE) {
-            vout->output.i_aspect   =
-            vout->fmt_out.i_aspect  = vout->fmt_in.i_aspect;
+            vout->output.i_aspect   = (int64_t)vout->fmt_in.i_sar_num * vout->fmt_in.i_width * VOUT_ASPECT_FACTOR /
+                                      vout->fmt_in.i_sar_den / vout->fmt_in.i_height;
             vout->fmt_out.i_sar_num = vout->fmt_in.i_sar_num;
             vout->fmt_out.i_sar_den = vout->fmt_in.i_sar_den;
 
index 26d9a9d..f6922dd 100644 (file)
@@ -167,7 +167,6 @@ static int Open( vlc_object_t *p_this )
     fmt.i_width = fmt.i_visible_width = width;
     fmt.i_height = fmt.i_visible_height = height;
     fmt.i_chroma = VLC_CODEC_RGB32;
-    fmt.i_aspect = VOUT_ASPECT_FACTOR * width/height;
     fmt.i_sar_num = fmt.i_sar_den = 1;
 
     p_thread->p_vout = aout_filter_RequestVout( p_filter, NULL, &fmt );
index c34d9d1..b63c7b2 100644 (file)
@@ -307,7 +307,6 @@ static int Open( vlc_object_t *p_this )
     fmt.i_width = fmt.i_visible_width = p_sys->i_width;
     fmt.i_height = fmt.i_visible_height = p_sys->i_height;
     fmt.i_chroma = VLC_CODEC_I420;
-    fmt.i_aspect = VOUT_ASPECT_FACTOR * p_sys->i_width/p_sys->i_height;
     fmt.i_sar_num = fmt.i_sar_den = 1;
 
     p_sys->p_vout = aout_filter_RequestVout( p_filter, NULL, &fmt );
index 6ac1bc8..ab6ee4c 100644 (file)
@@ -2253,7 +2253,8 @@ static picture_t *vout_new_buffer( decoder_t *p_dec )
         p_dec->fmt_out.video.i_width != p_owner->video.i_width ||
         p_dec->fmt_out.video.i_height != p_owner->video.i_height ||
         p_dec->fmt_out.video.i_chroma != p_owner->video.i_chroma ||
-        p_dec->fmt_out.video.i_aspect != p_owner->video.i_aspect )
+        (int64_t)p_dec->fmt_out.video.i_sar_num * p_owner->video.i_sar_den !=
+        (int64_t)p_dec->fmt_out.video.i_sar_den * p_owner->video.i_sar_num )
     {
         vout_thread_t *p_vout;
 
@@ -2299,11 +2300,8 @@ static picture_t *vout_new_buffer( decoder_t *p_dec )
         if( !p_dec->fmt_out.video.i_sar_num ||
             !p_dec->fmt_out.video.i_sar_den )
         {
-            p_dec->fmt_out.video.i_sar_num = p_dec->fmt_out.video.i_aspect *
-              p_dec->fmt_out.video.i_visible_height;
-
-            p_dec->fmt_out.video.i_sar_den = VOUT_ASPECT_FACTOR *
-              p_dec->fmt_out.video.i_visible_width;
+            p_dec->fmt_out.video.i_sar_num = 1;
+            p_dec->fmt_out.video.i_sar_den = 1;
         }
 
         vlc_ureduce( &p_dec->fmt_out.video.i_sar_num,
index ab1e43a..6885c41 100644 (file)
@@ -142,11 +142,6 @@ void video_format_Setup( video_format_t *p_fmt, vlc_fourcc_t i_chroma,
     p_fmt->i_y_offset       = 0;
     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 )
     {
index 70ff48c..f337727 100644 (file)
@@ -157,12 +157,18 @@ static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block,
     if( !p_fmt_out->i_chroma )
         p_fmt_out->i_chroma = p_image->p_dec->fmt_out.video.i_chroma;
     if( !p_fmt_out->i_width && p_fmt_out->i_height )
-        p_fmt_out->i_width = p_fmt_out->i_height
-                              * p_image->p_dec->fmt_out.video.i_aspect
-                              / VOUT_ASPECT_FACTOR;
+        p_fmt_out->i_width = (int64_t)p_image->p_dec->fmt_out.video.i_width *
+                             p_image->p_dec->fmt_out.video.i_sar_num *
+                             p_fmt_out->i_height /
+                             p_image->p_dec->fmt_out.video.i_height /
+                             p_image->p_dec->fmt_out.video.i_sar_den;
+
     if( !p_fmt_out->i_height && p_fmt_out->i_width )
-        p_fmt_out->i_height = p_fmt_out->i_width * VOUT_ASPECT_FACTOR
-                               / p_image->p_dec->fmt_out.video.i_aspect;
+        p_fmt_out->i_height = (int64_t)p_image->p_dec->fmt_out.video.i_height *
+                              p_image->p_dec->fmt_out.video.i_sar_den *
+                              p_fmt_out->i_width /
+                              p_image->p_dec->fmt_out.video.i_width /
+                              p_image->p_dec->fmt_out.video.i_sar_num;
     if( !p_fmt_out->i_width )
         p_fmt_out->i_width = p_image->p_dec->fmt_out.video.i_width;
     if( !p_fmt_out->i_height )
@@ -426,7 +432,6 @@ static picture_t *ImageConvert( image_handler_t *p_image, picture_t *p_pic,
         p_fmt_out->i_height = p_fmt_out->i_visible_height = p_fmt_in->i_height;
     if( !p_fmt_out->i_sar_num ) p_fmt_out->i_sar_num = p_fmt_in->i_sar_num;
     if( !p_fmt_out->i_sar_den ) p_fmt_out->i_sar_den = p_fmt_in->i_sar_den;
-    if( !p_fmt_out->i_aspect ) p_fmt_out->i_aspect = p_fmt_in->i_aspect;
 
     if( p_image->p_filter )
     if( p_image->p_filter->fmt_in.video.i_chroma != p_fmt_in->i_chroma ||
index 375a02a..8b73c4c 100644 (file)
@@ -91,7 +91,6 @@ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel,
     /* Create a new subpicture region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_TEXT;
-    fmt.i_aspect = 0;
     fmt.i_width = fmt.i_height = 0;
     fmt.i_x_offset = fmt.i_y_offset = 0;
     p_spu->p_region = subpicture_region_New( &fmt );
index 32af4b8..ef9dd7b 100644 (file)
@@ -160,7 +160,6 @@ static int CreatePicture( spu_t *p_spu, subpicture_t *p_subpic,
     /* Create a new subpicture region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_YUVA;
-    fmt.i_aspect = 0;
     fmt.i_width = fmt.i_visible_width = i_width;
     fmt.i_height = fmt.i_visible_height = i_height;
     fmt.i_x_offset = fmt.i_y_offset = 0;
index 8f3681d..4dd9304 100644 (file)
@@ -105,7 +105,6 @@ static vout_display_t *vout_display_New(vlc_object_t *obj,
 
     /* Picture buffer does not have the concept of aspect ratio */
     video_format_Copy(&vd->fmt, fmt);
-    vd->fmt.i_aspect = 0;
     vd->fmt.i_sar_num = 0;
     vd->fmt.i_sar_den = 0;
 
@@ -376,12 +375,10 @@ static void VoutDisplayCreateRender(vout_display_t *vd)
     osys->filters = NULL;
 
     video_format_t v_src = vd->source;
-    v_src.i_aspect  = 0;
     v_src.i_sar_num = 0;
     v_src.i_sar_den = 0;
 
     video_format_t v_dst = vd->fmt;
-    v_dst.i_aspect  = 0;
     v_dst.i_sar_num = 0;
     v_dst.i_sar_den = 0;
 
index a50d20f..0c09a45 100644 (file)
@@ -71,8 +71,6 @@ static void     ErrorThread       ( vout_thread_t * );
 static void     CleanThread       ( vout_thread_t * );
 static void     EndThread         ( vout_thread_t * );
 
-static void     AspectRatio       ( int, int *, int * );
-
 static void VideoFormatImportRgb( video_format_t *, const picture_heap_t * );
 static void PictureHeapFixRgb( picture_heap_t * );
 
@@ -224,44 +222,37 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout,
         else
         {
             /* This video output is cool! Hijack it. */
-            if( p_vout->fmt_render.i_aspect != p_fmt->i_aspect )
-            {
-                /* Correct aspect ratio on change
-                 * FIXME factorize this code with other aspect ration related code */
-                unsigned int i_sar_num;
-                unsigned int i_sar_den;
-                unsigned int i_aspect;
-
-                i_aspect = p_fmt->i_aspect;
-                vlc_ureduce( &i_sar_num, &i_sar_den,
-                             p_fmt->i_sar_num, p_fmt->i_sar_den, 50000 );
+            /* Correct aspect ratio on change
+             * FIXME factorize this code with other aspect ration related code */
+            unsigned int i_sar_num;
+            unsigned int i_sar_den;
+            vlc_ureduce( &i_sar_num, &i_sar_den,
+                         p_fmt->i_sar_num, p_fmt->i_sar_den, 50000 );
 #if 0
-                /* What's that, it does not seems to be used correcly everywhere
-                 * beside the previous p_vout->fmt_render.i_aspect != p_fmt->i_aspect
-                 * should be fixed to use it too then */
-                if( p_vout->i_par_num > 0 && p_vout->i_par_den > 0 )
-                {
-                    i_sar_num *= p_vout->i_par_den;
-                    i_sar_den *= p_vout->i_par_num;
-                    i_aspect = i_aspect * p_vout->i_par_den / p_vout->i_par_num;
-                }
+            /* What's that, it does not seems to be used correcly everywhere */
+            if( p_vout->i_par_num > 0 && p_vout->i_par_den > 0 )
+            {
+                i_sar_num *= p_vout->i_par_den;
+                i_sar_den *= p_vout->i_par_num;
+            }
 #endif
 
-                if( i_sar_num > 0 && i_sar_den > 0 && i_aspect > 0 )
-                {
-                    p_vout->fmt_in.i_sar_num = i_sar_num;
-                    p_vout->fmt_in.i_sar_den = i_sar_den;
-                    p_vout->fmt_in.i_aspect  = i_aspect;
-
-                    p_vout->fmt_render.i_sar_num = i_sar_num;
-                    p_vout->fmt_render.i_sar_den = i_sar_den;
-                    p_vout->fmt_render.i_aspect  = i_aspect;
-
-                    p_vout->render.i_aspect   = i_aspect;
-
-                    p_vout->i_changes |= VOUT_ASPECT_CHANGE;
-
-                }
+            if( i_sar_num > 0 && i_sar_den > 0 &&
+                ( i_sar_num != p_vout->fmt_render.i_sar_num ||
+                  i_sar_den != p_vout->fmt_render.i_sar_den ) )
+            {
+                p_vout->fmt_in.i_sar_num = i_sar_num;
+                p_vout->fmt_in.i_sar_den = i_sar_den;
+
+                p_vout->fmt_render.i_sar_num = i_sar_num;
+                p_vout->fmt_render.i_sar_den = i_sar_den;
+
+                p_vout->render.i_aspect = (int64_t)i_sar_num *
+                                                   p_vout->fmt_render.i_width *
+                                                   VOUT_ASPECT_FACTOR /
+                                                   i_sar_den /
+                                                   p_vout->fmt_render.i_height;
+                p_vout->i_changes |= VOUT_ASPECT_CHANGE;
             }
             vlc_mutex_unlock( &p_vout->change_lock );
 
@@ -305,19 +296,23 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
     unsigned int i_width = p_fmt->i_width;
     unsigned int i_height = p_fmt->i_height;
     vlc_fourcc_t i_chroma = vlc_fourcc_GetCodec( VIDEO_ES, p_fmt->i_chroma );
-    unsigned int i_aspect = p_fmt->i_aspect;
 
     config_chain_t *p_cfg;
     char *psz_parser;
     char *psz_name;
 
-    if( i_width <= 0 || i_height <= 0 || i_aspect <= 0 )
+    if( i_width <= 0 || i_height <= 0 )
         return NULL;
 
     vlc_ureduce( &p_fmt->i_sar_num, &p_fmt->i_sar_den,
                  p_fmt->i_sar_num, p_fmt->i_sar_den, 50000 );
     if( p_fmt->i_sar_num <= 0 || p_fmt->i_sar_den <= 0 )
         return NULL;
+    unsigned int i_aspect = (int64_t)p_fmt->i_sar_num *
+                                     i_width *
+                                     VOUT_ASPECT_FACTOR /
+                                     p_fmt->i_sar_den /
+                                     i_height;
 
     /* Allocate descriptor */
     static const char typename[] = "video output";
@@ -807,7 +802,7 @@ static bool ChromaIsEqual( const picture_heap_t *p_output, const picture_heap_t
 
 static int InitThread( vout_thread_t *p_vout )
 {
-    int i, i_aspect_x, i_aspect_y;
+    int i;
 
     /* Initialize output method, it allocates direct buffers for us */
     if( p_vout->pf_init( p_vout ) )
@@ -833,10 +828,6 @@ static int InitThread( vout_thread_t *p_vout )
 
     msg_Dbg( p_vout, "got %i direct buffer(s)", I_OUTPUTPICTURES );
 
-    AspectRatio( p_vout->fmt_render.i_aspect, &i_aspect_x, &i_aspect_y );
-
-    AspectRatio( p_vout->fmt_in.i_aspect, &i_aspect_x, &i_aspect_y );
-
     if( !p_vout->fmt_out.i_width || !p_vout->fmt_out.i_height )
     {
         p_vout->fmt_out.i_width = p_vout->fmt_out.i_visible_width =
@@ -845,12 +836,11 @@ static int InitThread( vout_thread_t *p_vout )
             p_vout->output.i_height;
         p_vout->fmt_out.i_x_offset =  p_vout->fmt_out.i_y_offset = 0;
 
-        p_vout->fmt_out.i_aspect = p_vout->output.i_aspect;
         p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
     }
     if( !p_vout->fmt_out.i_sar_num || !p_vout->fmt_out.i_sar_num )
     {
-        p_vout->fmt_out.i_sar_num = p_vout->fmt_out.i_aspect *
+        p_vout->fmt_out.i_sar_num = p_vout->output.i_aspect *
             p_vout->fmt_out.i_height;
         p_vout->fmt_out.i_sar_den = VOUT_ASPECT_FACTOR *
             p_vout->fmt_out.i_width;
@@ -859,8 +849,6 @@ static int InitThread( vout_thread_t *p_vout )
     vlc_ureduce( &p_vout->fmt_out.i_sar_num, &p_vout->fmt_out.i_sar_den,
                  p_vout->fmt_out.i_sar_num, p_vout->fmt_out.i_sar_den, 0 );
 
-    AspectRatio( p_vout->fmt_out.i_aspect, &i_aspect_x, &i_aspect_y );
-
     /* FIXME removed the need of both fmt_* and heap infos */
     /* Calculate shifts from system-updated masks */
     PictureHeapFixRgb( &p_vout->render );
@@ -871,33 +859,30 @@ static int InitThread( vout_thread_t *p_vout )
 
     /* print some usefull debug info about different vout formats
      */
-    msg_Dbg( p_vout, "pic render sz %ix%i, of (%i,%i), vsz %ix%i, 4cc %4.4s, ar %i:%i, sar %i:%i, msk r0x%x g0x%x b0x%x",
+    msg_Dbg( p_vout, "pic render sz %ix%i, of (%i,%i), vsz %ix%i, 4cc %4.4s, sar %i:%i, msk r0x%x g0x%x b0x%x",
              p_vout->fmt_render.i_width, p_vout->fmt_render.i_height,
              p_vout->fmt_render.i_x_offset, p_vout->fmt_render.i_y_offset,
              p_vout->fmt_render.i_visible_width,
              p_vout->fmt_render.i_visible_height,
              (char*)&p_vout->fmt_render.i_chroma,
-             i_aspect_x, i_aspect_y,
              p_vout->fmt_render.i_sar_num, p_vout->fmt_render.i_sar_den,
              p_vout->fmt_render.i_rmask, p_vout->fmt_render.i_gmask, p_vout->fmt_render.i_bmask );
 
-    msg_Dbg( p_vout, "pic in sz %ix%i, of (%i,%i), vsz %ix%i, 4cc %4.4s, ar %i:%i, sar %i:%i, msk r0x%x g0x%x b0x%x",
+    msg_Dbg( p_vout, "pic in sz %ix%i, of (%i,%i), vsz %ix%i, 4cc %4.4s, sar %i:%i, msk r0x%x g0x%x b0x%x",
              p_vout->fmt_in.i_width, p_vout->fmt_in.i_height,
              p_vout->fmt_in.i_x_offset, p_vout->fmt_in.i_y_offset,
              p_vout->fmt_in.i_visible_width,
              p_vout->fmt_in.i_visible_height,
              (char*)&p_vout->fmt_in.i_chroma,
-             i_aspect_x, i_aspect_y,
              p_vout->fmt_in.i_sar_num, p_vout->fmt_in.i_sar_den,
              p_vout->fmt_in.i_rmask, p_vout->fmt_in.i_gmask, p_vout->fmt_in.i_bmask );
 
-    msg_Dbg( p_vout, "pic out sz %ix%i, of (%i,%i), vsz %ix%i, 4cc %4.4s, ar %i:%i, sar %i:%i, msk r0x%x g0x%x b0x%x",
+    msg_Dbg( p_vout, "pic out sz %ix%i, of (%i,%i), vsz %ix%i, 4cc %4.4s, sar %i:%i, msk r0x%x g0x%x b0x%x",
              p_vout->fmt_out.i_width, p_vout->fmt_out.i_height,
              p_vout->fmt_out.i_x_offset, p_vout->fmt_out.i_y_offset,
              p_vout->fmt_out.i_visible_width,
              p_vout->fmt_out.i_visible_height,
              (char*)&p_vout->fmt_out.i_chroma,
-             i_aspect_x, i_aspect_y,
              p_vout->fmt_out.i_sar_num, p_vout->fmt_out.i_sar_den,
              p_vout->fmt_out.i_rmask, p_vout->fmt_out.i_gmask, p_vout->fmt_out.i_bmask );
 
@@ -1555,12 +1540,6 @@ static void ChromaDestroy( vout_thread_t *p_vout )
 }
 
 /* following functions are local */
-static void AspectRatio( int i_aspect, int *i_aspect_x, int *i_aspect_y )
-{
-    const int i_pgcd = i_aspect ? GCD( i_aspect, VOUT_ASPECT_FACTOR ) : 1;
-    *i_aspect_x = i_aspect / i_pgcd;
-    *i_aspect_y = VOUT_ASPECT_FACTOR / i_pgcd;
-}
 
 /**
  * This function copies all RGB informations from a picture_heap_t into
index d5a8f62..10639f3 100644 (file)
@@ -93,7 +93,6 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
     /* Create a new subpicture region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_TEXT;
-    fmt.i_aspect = 0;
     fmt.i_width = fmt.i_height = 0;
     fmt.i_x_offset = fmt.i_y_offset = 0;
     p_spu->p_region = subpicture_region_New( &fmt );
index 969597f..a0c1e2a 100644 (file)
@@ -895,8 +895,10 @@ static int AspectCallback( vlc_object_t *p_this, char const *psz_cmd,
     /* Restore defaults */
     p_vout->fmt_in.i_sar_num = p_vout->fmt_render.i_sar_num;
     p_vout->fmt_in.i_sar_den = p_vout->fmt_render.i_sar_den;
-    p_vout->fmt_in.i_aspect = p_vout->fmt_render.i_aspect;
-    p_vout->render.i_aspect = p_vout->fmt_render.i_aspect;
+    p_vout->render.i_aspect = (int64_t)p_vout->fmt_render.i_sar_num *
+                                       p_vout->fmt_render.i_width *
+                                       VOUT_ASPECT_FACTOR /
+                                       p_vout->fmt_render.i_sar_den / p_vout->fmt_render.i_height;
 
     if( !psz_parser ) goto aspect_end;
 
@@ -911,25 +913,25 @@ static int AspectCallback( vlc_object_t *p_this, char const *psz_cmd,
     vlc_ureduce( &i_sar_num, &i_sar_den, i_sar_num, i_sar_den, 0 );
     p_vout->fmt_in.i_sar_num = i_sar_num;
     p_vout->fmt_in.i_sar_den = i_sar_den;
-    p_vout->fmt_in.i_aspect = i_aspect_num * VOUT_ASPECT_FACTOR / i_aspect_den;
-    p_vout->render.i_aspect = p_vout->fmt_in.i_aspect;
+    p_vout->render.i_aspect = i_aspect_num * VOUT_ASPECT_FACTOR / i_aspect_den;
 
  aspect_end:
     if( p_vout->p->i_par_num && p_vout->p->i_par_den )
     {
         p_vout->fmt_in.i_sar_num *= p_vout->p->i_par_den;
         p_vout->fmt_in.i_sar_den *= p_vout->p->i_par_num;
-        p_vout->fmt_in.i_aspect = p_vout->fmt_in.i_aspect *
-            p_vout->p->i_par_den / p_vout->p->i_par_num;
-        p_vout->render.i_aspect = p_vout->fmt_in.i_aspect;
+        p_vout->render.i_aspect = (int64_t)p_vout->fmt_in.i_sar_num *
+                                           p_vout->fmt_in.i_width *
+                                           VOUT_ASPECT_FACTOR /
+                                           p_vout->fmt_in.i_sar_den /
+                                           p_vout->fmt_in.i_height;
     }
 
     p_vout->i_changes |= VOUT_ASPECT_CHANGE;
 
-    vlc_ureduce( &i_aspect_num, &i_aspect_den,
-                 p_vout->fmt_in.i_aspect, VOUT_ASPECT_FACTOR, 0 );
     msg_Dbg( p_vout, "new aspect-ratio %i:%i, sample aspect-ratio %i:%i",
-             i_aspect_num, i_aspect_den,
+             p_vout->fmt_in.i_sar_num * p_vout->fmt_in.i_width,
+             p_vout->fmt_in.i_sar_den * p_vout->fmt_in.i_height,
              p_vout->fmt_in.i_sar_num, p_vout->fmt_in.i_sar_den );
 
     if( var_Get( p_vout, "crop", &val ) )
index 4995576..a849200 100644 (file)
@@ -409,8 +409,8 @@ picture_t *vout_RenderPicture( vout_thread_t *p_vout, picture_t *p_pic,
                                   p_tmp_pic, p_vout->fmt_out.i_chroma,
                                   p_vout->fmt_out.i_width,
                                   p_vout->fmt_out.i_height,
-                                  p_vout->fmt_out.i_aspect * p_vout->fmt_out.i_height,
-                                  VOUT_ASPECT_FACTOR       * p_vout->fmt_out.i_width );
+                                  p_vout->fmt_out.i_sar_num,
+                                  p_vout->fmt_out.i_sar_den );
             p_tmp_pic->i_type = MEMORY_PICTURE;
             p_tmp_pic->i_status = RESERVED_PICTURE;
         }
@@ -953,8 +953,7 @@ 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_height,
-                              VOUT_ASPECT_FACTOR * p_fmt->i_width );
+                              p_fmt->i_sar_num, p_fmt->i_sar_den );
 
     /* */
     picture_t *p_picture = calloc( 1, sizeof(*p_picture) );
index 58680f2..f929cf5 100644 (file)
@@ -475,16 +475,8 @@ void spu_RenderSubpictures( spu_t *p_spu,
         p_region = p_subpic->p_region;
         if( !p_region->fmt.i_sar_num || !p_region->fmt.i_sar_den )
         {
-            if( p_region->fmt.i_aspect != 0 )
-            {
-                p_region->fmt.i_sar_den = p_region->fmt.i_aspect;
-                p_region->fmt.i_sar_num = VOUT_ASPECT_FACTOR;
-            }
-            else
-            {
-                p_region->fmt.i_sar_den = p_fmt_dst->i_sar_den;
-                p_region->fmt.i_sar_num = p_fmt_dst->i_sar_num;
-            }
+            p_region->fmt.i_sar_den = p_fmt_dst->i_sar_den;
+            p_region->fmt.i_sar_num = p_fmt_dst->i_sar_num;
         }
 
         /* Take care of the aspect ratio */
@@ -778,7 +770,6 @@ subpicture_t *subpicture_NewFromPicture( vlc_object_t *p_obj,
     p_subpic->i_original_picture_width  = fmt_out.i_width;
     p_subpic->i_original_picture_height = fmt_out.i_height;
 
-    fmt_out.i_aspect = 0;
     fmt_out.i_sar_num =
     fmt_out.i_sar_den = 0;