From d466fd4185ffd791413658e948205e2676d2f470 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Wed, 16 Dec 2009 21:54:54 +0100 Subject: [PATCH] Removed es_format_t::i_aspect. It was duplicated with es_format_t::i_sar_num/den. --- include/vlc_es.h | 1 - modules/access/dshow/dshow.cpp | 3 +- modules/access/dvdnav.c | 17 ---- modules/access/dvdread.c | 54 +++++++--- modules/access/imem.c | 1 - modules/access/qtcapture.m | 4 +- modules/access/screen/screen.c | 4 +- modules/access/v4l.c | 3 +- modules/access/v4l2.c | 3 +- modules/codec/avcodec/encoder.c | 9 +- modules/codec/avcodec/subtitle.c | 1 - modules/codec/avcodec/video.c | 26 ++--- modules/codec/cc.c | 1 - modules/codec/cdg.c | 4 +- modules/codec/cvdsub.c | 3 +- modules/codec/dirac.c | 5 +- modules/codec/dmo/dmo.c | 10 +- modules/codec/dvbsub.c | 6 +- modules/codec/fake.c | 7 +- modules/codec/invmem.c | 3 +- modules/codec/kate.c | 4 +- modules/codec/libmpeg2.c | 31 +++--- modules/codec/png.c | 3 +- modules/codec/quicktime.c | 3 +- modules/codec/rawvideo.c | 10 +- modules/codec/realvideo.c | 6 +- modules/codec/schroedinger.c | 8 +- modules/codec/sdl_image.c | 4 +- modules/codec/spudec/parse.c | 3 +- modules/codec/subtitles/subsdec.c | 1 - modules/codec/subtitles/subsusf.c | 2 - modules/codec/svcdsub.c | 3 +- modules/codec/tarkin.c | 4 +- modules/codec/telx.c | 1 - modules/codec/theora.c | 19 ++-- modules/codec/x264.c | 13 +-- modules/codec/zvbi.c | 6 +- modules/demux/asf/asf.c | 5 +- modules/demux/avformat/mux.c | 7 +- modules/demux/mkv/matroska_segment_parse.cpp | 5 +- modules/demux/mp4/mp4.c | 6 +- modules/demux/nuv.c | 3 +- modules/demux/rawvid.c | 25 ++--- modules/gui/fbosd.c | 30 +++--- modules/misc/freetype.c | 2 - modules/misc/quartztext.c | 1 - modules/misc/stats/decoder.c | 3 +- modules/misc/svg.c | 3 +- modules/mux/asf.c | 11 ++- modules/mux/mp4.c | 21 ++-- modules/packetizer/h264.c | 14 ++- modules/packetizer/mpegvideo.c | 8 +- modules/packetizer/vc1.c | 3 +- modules/stream_out/mosaic_bridge.c | 25 ++--- modules/stream_out/transcode/video.c | 38 +++---- modules/video_filter/audiobargraph_v.c | 1 - modules/video_filter/canvas.c | 25 +++-- modules/video_filter/crop.c | 12 +-- modules/video_filter/deinterlace.c | 1 - .../dynamicoverlay/dynamicoverlay_commands.c | 4 +- modules/video_filter/logo.c | 1 - modules/video_filter/marq.c | 1 - modules/video_filter/osdmenu.c | 2 - modules/video_filter/remoteosd.c | 1 - modules/video_filter/rss.c | 1 - modules/video_filter/transform.c | 3 - modules/video_filter/wall.c | 4 +- modules/video_filter/wrapper.c | 5 - modules/video_output/msw/common_vo.c | 1 - modules/video_output/omapfb.c | 4 +- modules/video_output/opengl.c | 5 +- modules/video_output/wrapper.c | 12 +-- modules/visualization/goom.c | 1 - modules/visualization/visual/visual.c | 1 - src/input/decoder.c | 10 +- src/misc/es_format.c | 5 - src/misc/image.c | 17 ++-- src/osd/osd_text.c | 1 - src/osd/osd_widgets.c | 1 - src/video_output/display.c | 3 - src/video_output/video_output.c | 99 ++++++++----------- src/video_output/video_text.c | 1 - src/video_output/vout_intf.c | 22 +++-- src/video_output/vout_pictures.c | 7 +- src/video_output/vout_subpictures.c | 13 +-- 85 files changed, 363 insertions(+), 397 deletions(-) diff --git a/include/vlc_es.h b/include/vlc_es.h index 21b6ea519b..02cd8c8835 100644 --- a/include/vlc_es.h +++ b/include/vlc_es.h @@ -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 */ diff --git a/modules/access/dshow/dshow.cpp b/modules/access/dshow/dshow.cpp index c5e86362c1..bc0a89b1b4 100644 --- a/modules/access/dshow/dshow.cpp +++ b/modules/access/dshow/dshow.cpp @@ -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 ) { diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c index 54e3c68ea3..d157893d13 100644 --- a/modules/access/dvdnav.c +++ b/modules/access/dvdnav.c @@ -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 ) diff --git a/modules/access/dvdread.c b/modules/access/dvdread.c index 5325e61676..3758fbf8d5 100644 --- a/modules/access/dvdread.c +++ b/modules/access/dvdread.c @@ -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] diff --git a/modules/access/imem.c b/modules/access/imem.c index e1a750d7e3..ac904b15af 100644 --- a/modules/access/imem.c +++ b/modules/access/imem.c @@ -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; diff --git a/modules/access/qtcapture.m b/modules/access/qtcapture.m index bbee5bf560..712385f059 100644 --- a/modules/access/qtcapture.m +++ b/modules/access/qtcapture.m @@ -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 ); diff --git a/modules/access/screen/screen.c b/modules/access/screen/screen.c index 7ad87dee6e..4ab498ed9e 100644 --- a/modules/access/screen/screen.c +++ b/modules/access/screen/screen.c @@ -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) ); diff --git a/modules/access/v4l.c b/modules/access/v4l.c index d54bd501df..06b67d9453 100644 --- a/modules/access/v4l.c +++ b/modules/access/v4l.c @@ -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 ) diff --git a/modules/access/v4l2.c b/modules/access/v4l2.c index a330819d92..5e685c8480 100644 --- a/modules/access/v4l2.c +++ b/modules/access/v4l2.c @@ -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", diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c index 8c85a9fbac..87ce339a2e 100644 --- a/modules/codec/avcodec/encoder.c +++ b/modules/codec/avcodec/encoder.c @@ -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 ) diff --git a/modules/codec/avcodec/subtitle.c b/modules/codec/avcodec/subtitle.c index 1415f8b799..89fad76478 100644 --- a/modules/codec/avcodec/subtitle.c +++ b/modules/codec/avcodec/subtitle.c @@ -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 = diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c index 7125a6f92d..4fd33ace58 100644 --- a/modules/codec/avcodec/video.c +++ b/modules/codec/avcodec/video.c @@ -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; } } diff --git a/modules/codec/cc.c b/modules/codec/cc.c index 3e380f9948..0e8ecb592f 100644 --- a/modules/codec/cc.c +++ b/modules/codec/cc.c @@ -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 ); diff --git a/modules/codec/cdg.c b/modules/codec/cdg.c index 13a234eee7..31ecd0e55f 100644 --- a/modules/codec/cdg.c +++ b/modules/codec/cdg.c @@ -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; diff --git a/modules/codec/cvdsub.c b/modules/codec/cvdsub.c index 0ca7c0de7e..90635d7498 100644 --- a/modules/codec/cvdsub.c +++ b/modules/codec/cvdsub.c @@ -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; diff --git a/modules/codec/dirac.c b/modules/codec/dirac.c index f24dd18b0e..50b29e8b71 100644 --- a/modules/codec/dirac.c +++ b/modules/codec/dirac.c @@ -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; diff --git a/modules/codec/dmo/dmo.c b/modules/codec/dmo/dmo.c index 057eb90d2b..d105d93dac 100644 --- a/modules/codec/dmo/dmo.c +++ b/modules/codec/dmo/dmo.c @@ -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; diff --git a/modules/codec/dvbsub.c b/modules/codec/dvbsub.c index 6a9867c17f..105b69289b 100644 --- a/modules/codec/dvbsub.c +++ b/modules/codec/dvbsub.c @@ -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; diff --git a/modules/codec/fake.c b/modules/codec/fake.c index ec080791a6..5a3b70ffd2 100644 --- a/modules/codec/fake.c +++ b/modules/codec/fake.c @@ -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" ) ) diff --git a/modules/codec/invmem.c b/modules/codec/invmem.c index fddab7f3b2..ad2094a450 100644 --- a/modules/codec/invmem.c +++ b/modules/codec/invmem.c @@ -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; diff --git a/modules/codec/kate.c b/modules/codec/kate.c index 3dee69247d..156199da9b 100644 --- a/modules/codec/kate.c +++ b/modules/codec/kate.c @@ -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 ); diff --git a/modules/codec/libmpeg2.c b/modules/codec/libmpeg2.c index b0239e7ceb..8a56276795 100644 --- a/modules/codec/libmpeg2.c +++ b/modules/codec/libmpeg2.c @@ -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 / diff --git a/modules/codec/png.c b/modules/codec/png.c index 081c32c590..5dd4c2e21e 100644 --- a/modules/codec/png.c +++ b/modules/codec/png.c @@ -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; diff --git a/modules/codec/quicktime.c b/modules/codec/quicktime.c index 146c4f2d1c..ae154fa3c0 100644 --- a/modules/codec/quicktime.c +++ b/modules/codec/quicktime.c @@ -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; diff --git a/modules/codec/rawvideo.c b/modules/codec/rawvideo.c index 6ab227259b..5691eb4cd1 100644 --- a/modules/codec/rawvideo.c +++ b/modules/codec/rawvideo.c @@ -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 */ diff --git a/modules/codec/realvideo.c b/modules/codec/realvideo.c index 1a8160fc2e..ec88dcc34f 100644 --- a/modules/codec/realvideo.c +++ b/modules/codec/realvideo.c @@ -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 { diff --git a/modules/codec/schroedinger.c b/modules/codec/schroedinger.c index 8439c04d6a..fceae03c05 100644 --- a/modules/codec/schroedinger.c +++ b/modules/codec/schroedinger.c @@ -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; diff --git a/modules/codec/sdl_image.c b/modules/codec/sdl_image.c index 6f2154769a..4a9f5d23dd 100644 --- a/modules/codec/sdl_image.c +++ b/modules/codec/sdl_image.c @@ -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 ); diff --git a/modules/codec/spudec/parse.c b/modules/codec/spudec/parse.c index 5287272b97..3b23650899 100644 --- a/modules/codec/spudec/parse.c +++ b/modules/codec/spudec/parse.c @@ -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; diff --git a/modules/codec/subtitles/subsdec.c b/modules/codec/subtitles/subsdec.c index 2d45794a5b..f6af33c48e 100644 --- a/modules/codec/subtitles/subsdec.c +++ b/modules/codec/subtitles/subsdec.c @@ -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 ); diff --git a/modules/codec/subtitles/subsusf.c b/modules/codec/subtitles/subsusf.c index 8c15cebb46..57541374b0 100644 --- a/modules/codec/subtitles/subsusf.c +++ b/modules/codec/subtitles/subsusf.c @@ -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; diff --git a/modules/codec/svcdsub.c b/modules/codec/svcdsub.c index 86293c7fe7..d170f28d6c 100644 --- a/modules/codec/svcdsub.c +++ b/modules/codec/svcdsub.c @@ -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; diff --git a/modules/codec/tarkin.c b/modules/codec/tarkin.c index f0327413ff..0976832114 100644 --- a/modules/codec/tarkin.c +++ b/modules/codec/tarkin.c @@ -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 */ diff --git a/modules/codec/telx.c b/modules/codec/telx.c index ffa80835e9..d3aeb83d4f 100644 --- a/modules/codec/telx.c +++ b/modules/codec/telx.c @@ -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 ); diff --git a/modules/codec/theora.c b/modules/codec/theora.c index 6f96ff5496..d9345003ce 100644 --- a/modules/codec/theora.c +++ b/modules/codec/theora.c @@ -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; } diff --git a/modules/codec/x264.c b/modules/codec/x264.c index 44842b819e..49ad6079af 100644 --- a/modules/codec/x264.c +++ b/modules/codec/x264.c @@ -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; } diff --git a/modules/codec/zvbi.c b/modules/codec/zvbi.c index 26672f2c94..50c4edf7d2 100644 --- a/modules/codec/zvbi.c +++ b/modules/codec/zvbi.c @@ -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; diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c index 3985cdf9ac..54a451561d 100644 --- a/modules/demux/asf/asf.c +++ b/modules/demux/asf/asf.c @@ -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; } } diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c index 1c75c26edd..c48eee8aab 100644 --- a/modules/demux/avformat/mux.c +++ b/modules/demux/avformat/mux.c @@ -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; diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp index ff17863d5f..3ff89ab3a3 100644 --- a/modules/demux/mkv/matroska_segment_parse.cpp +++ b/modules/demux/mkv/matroska_segment_parse.cpp @@ -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; diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c index 3fa146882e..8f23e636f1 100644 --- a/modules/demux/mp4/mp4.c +++ b/modules/demux/mp4/mp4.c @@ -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; diff --git a/modules/demux/nuv.c b/modules/demux/nuv.c index 257efd6e7d..3f80660591 100644 --- a/modules/demux/nuv.c +++ b/modules/demux/nuv.c @@ -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 ); } diff --git a/modules/demux/rawvid.c b/modules/demux/rawvid.c index f39653813f..4b13aa249b 100644 --- a/modules/demux/rawvid.c +++ b/modules/demux/rawvid.c @@ -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, diff --git a/modules/gui/fbosd.c b/modules/gui/fbosd.c index ea43afd7c3..8aa5a17435 100644 --- a/modules/gui/fbosd.c +++ b/modules/gui/fbosd.c @@ -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 ); diff --git a/modules/misc/freetype.c b/modules/misc/freetype.c index 70e6ec9471..b78da48021 100644 --- a/modules/misc/freetype.c +++ b/modules/misc/freetype.c @@ -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 ) diff --git a/modules/misc/quartztext.c b/modules/misc/quartztext.c index 0590b7e8e6..732f276f2c 100644 --- a/modules/misc/quartztext.c +++ b/modules/misc/quartztext.c @@ -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; diff --git a/modules/misc/stats/decoder.c b/modules/misc/stats/decoder.c index f981dd24dd..9039371107 100644 --- a/modules/misc/stats/decoder.c +++ b/modules/misc/stats/decoder.c @@ -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; } diff --git a/modules/misc/svg.c b/modules/misc/svg.c index 4135d33430..2f3ee44f74 100644 --- a/modules/misc/svg.c +++ b/modules/misc/svg.c @@ -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 ) diff --git a/modules/mux/asf.c b/modules/mux/asf.c index d937bc754c..031a646f2b 100644 --- a/modules/mux/asf.c +++ b/modules/mux/asf.c @@ -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 ); diff --git a/modules/mux/mp4.c b/modules/mux/mp4.c index bfd9866c58..d5a8614500 100644 --- a/modules/mux/mp4.c +++ b/modules/mux/mp4.c @@ -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; } } diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c index 147507b3fe..886f12ce05 100644 --- a/modules/packetizer/h264.c +++ b/modules/packetizer/h264.c @@ -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; + } } } diff --git a/modules/packetizer/mpegvideo.c b/modules/packetizer/mpegvideo.c index d6f27ee676..a09016f26b 100644 --- a/modules/packetizer/mpegvideo.c +++ b/modules/packetizer/mpegvideo.c @@ -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 } diff --git a/modules/packetizer/vc1.c b/modules/packetizer/vc1.c index 679ee15f0c..0293febced 100644 --- a/modules/packetizer/vc1.c +++ b/modules/packetizer/vc1.c @@ -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 ); diff --git a/modules/stream_out/mosaic_bridge.c b/modules/stream_out/mosaic_bridge.c index 54c986b9c1..5f950e7a94 100644 --- a/modules/stream_out/mosaic_bridge.c +++ b/modules/stream_out/mosaic_bridge.c @@ -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, diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c index 352041e23d..5e3ed9415e 100644 --- a/modules/stream_out/transcode/video.c +++ b/modules/stream_out/transcode/video.c @@ -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() ); diff --git a/modules/video_filter/audiobargraph_v.c b/modules/video_filter/audiobargraph_v.c index a7279e64c8..44359cc887 100644 --- a/modules/video_filter/audiobargraph_v.c +++ b/modules/video_filter/audiobargraph_v.c @@ -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; diff --git a/modules/video_filter/canvas.c b/modules/video_filter/canvas.c index acb8bd3829..ce5573a35a 100644 --- a/modules/video_filter/canvas.c +++ b/modules/video_filter/canvas.c @@ -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 ) diff --git a/modules/video_filter/crop.c b/modules/video_filter/crop.c index 8253d7bd3f..464a470a41 100644 --- a/modules/video_filter/crop.c +++ b/modules/video_filter/crop.c @@ -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; diff --git a/modules/video_filter/deinterlace.c b/modules/video_filter/deinterlace.c index b9d254654d..e4aa704fd0 100644 --- a/modules/video_filter/deinterlace.c +++ b/modules/video_filter/deinterlace.c @@ -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; diff --git a/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c b/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c index 766c5c5bb3..300431ce19 100644 --- a/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c +++ b/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c @@ -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 ); diff --git a/modules/video_filter/logo.c b/modules/video_filter/logo.c index 844d4bc7ec..6b583c9f18 100644 --- a/modules/video_filter/logo.c +++ b/modules/video_filter/logo.c @@ -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; diff --git a/modules/video_filter/marq.c b/modules/video_filter/marq.c index e4607e37ac..43bba5c23b 100644 --- a/modules/video_filter/marq.c +++ b/modules/video_filter/marq.c @@ -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; diff --git a/modules/video_filter/osdmenu.c b/modules/video_filter/osdmenu.c index 751dbf04c3..732d1854b3 100644 --- a/modules/video_filter/osdmenu.c +++ b/modules/video_filter/osdmenu.c @@ -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; diff --git a/modules/video_filter/remoteosd.c b/modules/video_filter/remoteosd.c index 68a464c02c..a1721aa18a 100644 --- a/modules/video_filter/remoteosd.c +++ b/modules/video_filter/remoteosd.c @@ -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; diff --git a/modules/video_filter/rss.c b/modules/video_filter/rss.c index 36e34372f4..f00eed1e36 100644 --- a/modules/video_filter/rss.c +++ b/modules/video_filter/rss.c @@ -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; diff --git a/modules/video_filter/transform.c b/modules/video_filter/transform.c index 0ecd450084..9630e772b7 100644 --- a/modules/video_filter/transform.c +++ b/modules/video_filter/transform.c @@ -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; } diff --git a/modules/video_filter/wall.c b/modules/video_filter/wall.c index 1a6837ba5a..12141c547b 100644 --- a/modules/video_filter/wall.c +++ b/modules/video_filter/wall.c @@ -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; diff --git a/modules/video_filter/wrapper.c b/modules/video_filter/wrapper.c index cc24fb6d10..46ac870ccb 100644 --- a/modules/video_filter/wrapper.c +++ b/modules/video_filter/wrapper.c @@ -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; diff --git a/modules/video_output/msw/common_vo.c b/modules/video_output/msw/common_vo.c index f2bbc97cbb..b59db024eb 100644 --- a/modules/video_output/msw/common_vo.c +++ b/modules/video_output/msw/common_vo.c @@ -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; diff --git a/modules/video_output/omapfb.c b/modules/video_output/omapfb.c index d18616b5be..45d77161e4 100644 --- a/modules/video_output/omapfb.c +++ b/modules/video_output/omapfb.c @@ -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, diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c index b4eaba87a8..93b8b1fc00 100644 --- a/modules/video_output/opengl.c +++ b/modules/video_output/opengl.c @@ -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 ); diff --git a/modules/video_output/wrapper.c b/modules/video_output/wrapper.c index edf19fb174..b7563ada76 100644 --- a/modules/video_output/wrapper.c +++ b/modules/video_output/wrapper.c @@ -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; diff --git a/modules/visualization/goom.c b/modules/visualization/goom.c index 26d9a9d8b1..f6922ddbd8 100644 --- a/modules/visualization/goom.c +++ b/modules/visualization/goom.c @@ -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 ); diff --git a/modules/visualization/visual/visual.c b/modules/visualization/visual/visual.c index c34d9d1004..b63c7b2635 100644 --- a/modules/visualization/visual/visual.c +++ b/modules/visualization/visual/visual.c @@ -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 ); diff --git a/src/input/decoder.c b/src/input/decoder.c index 6ac1bc84a0..ab6ee4c0d7 100644 --- a/src/input/decoder.c +++ b/src/input/decoder.c @@ -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, diff --git a/src/misc/es_format.c b/src/misc/es_format.c index ab1e43a6c1..6885c410ed 100644 --- a/src/misc/es_format.c +++ b/src/misc/es_format.c @@ -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 ) { diff --git a/src/misc/image.c b/src/misc/image.c index 70ff48cba6..f3377277a0 100644 --- a/src/misc/image.c +++ b/src/misc/image.c @@ -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 || diff --git a/src/osd/osd_text.c b/src/osd/osd_text.c index 375a02af97..8b73c4c672 100644 --- a/src/osd/osd_text.c +++ b/src/osd/osd_text.c @@ -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 ); diff --git a/src/osd/osd_widgets.c b/src/osd/osd_widgets.c index 32af4b8428..ef9dd7b738 100644 --- a/src/osd/osd_widgets.c +++ b/src/osd/osd_widgets.c @@ -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; diff --git a/src/video_output/display.c b/src/video_output/display.c index 8f3681da2c..4dd9304f3e 100644 --- a/src/video_output/display.c +++ b/src/video_output/display.c @@ -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; diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c index a50d20f3bc..0c09a45dd1 100644 --- a/src/video_output/video_output.c +++ b/src/video_output/video_output.c @@ -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 diff --git a/src/video_output/video_text.c b/src/video_output/video_text.c index d5a8f6244b..10639f326c 100644 --- a/src/video_output/video_text.c +++ b/src/video_output/video_text.c @@ -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 ); diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c index 969597f246..a0c1e2aaf3 100644 --- a/src/video_output/vout_intf.c +++ b/src/video_output/vout_intf.c @@ -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 ) ) diff --git a/src/video_output/vout_pictures.c b/src/video_output/vout_pictures.c index 499557623b..a849200593 100644 --- a/src/video_output/vout_pictures.c +++ b/src/video_output/vout_pictures.c @@ -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) ); diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c index 58680f26e4..f929cf58a9 100644 --- a/src/video_output/vout_subpictures.c +++ b/src/video_output/vout_subpictures.c @@ -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; -- GitLab