diff --git a/include/vlc_es.h b/include/vlc_es.h index 21b6ea519b7b560c1c735b43321d1d0604c3cd75..02cd8c8835d9c33388da436c7a250932dad49e34 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 c5e86362c1c456cafc30724bbfed6936ad4eb016..bc0a89b1b475f53bf46b6a633e99ef876ffe5823 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 54e3c68ea329cd7498b47d8ca357b4b2f99f0082..d157893d13b13ef012cd22040d221326da8b9316 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 5325e61676bf1c8086802c3d5013c6b8b518497d..3758fbf8d5d8a3ee41afbfa00767eaaa7e68ed60 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 e1a750d7e381cbdd97293ad744b8187e1e431c6b..ac904b15af2ebbb92c36fdebad56ac6ffd449a40 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 bbee5bf560108a351f610f472451483507208d4b..712385f05942d5ac412adabb79441a170d2cfa8c 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 7ad87dee6e588f6e29ae8de489f842e88e2c4f35..4ab498ed9e1f590fb0b2bbe8d00c0daecd606a2f 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 d54bd501df75217f2a15bafb22dd7efddac2944c..06b67d9453677c2d20e03816d203477e4089c89a 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 a330819d92b478e7351ad51f56c9cde48c44d959..5e685c84800a741b9a9911601dd63734ff5cd0ee 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 8c85a9fbacdf06fd70a79a278df0b7c1c10aca17..87ce339a2e75e501ba67eadd2b2e43679b8b64f0 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 1415f8b79928be057112d81719c98beaf4849d5e..89fad764785bcafd6dfb710f798f73d69944a314 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 7125a6f92d38e3a69dfff42f53d82c23366870d1..4fd33ace58f5067745012ef83bc3cb84a7cff438 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 3e380f9948a76612fc45359ac042447010fe1a1a..0e8ecb592fd02f796906cf5734ec494b8eb97514 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 13a234eee78f90ce2b8d456683679c838e952f68..31ecd0e55fc1dda9ddd51c58dd0224a24251bb4d 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 0ca7c0de7e3af9faa23733101ab5135467cc2d42..90635d7498ff9671e6d4f353c7e6b4b958977748 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 f24dd18b0e3ee9a6a1fe5f87d8f9ca53e9135a25..50b29e8b715cc7bc5a66e9c162f39b5746d55f9c 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 057eb90d2be3e724e5c19f469326f437a08b93da..d105d93dac2d3d4031070b5056fb9ea49568ede6 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 6a9867c17f22d7c7cfa2895a34fe59d17d062ad0..105b69289ba81121e56e8a2807b2669b89404db0 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 ec080791a6dfe6ae5867d066547d7c12740c50f6..5a3b70ffd23162ad70905d651383a14e4a0ec9e1 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 fddab7f3b241cd79fd1aff305a4397a57d7e733b..ad2094a450456c28657a1bf1751296557d3a5237 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 3dee69247d5a1233ee7669f4cc60dbd1a0c95135..156199da9b65538f81eb93df13580beadd5d98f9 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 b0239e7ceb2274e0a690ae5f5c3d3d21d25dcc50..8a56276795d883f8a2e9df43431301b8630bf046 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 081c32c5900a2a5235c27d4a94383b769a9bade5..5dd4c2e21e7f7ea18ce83935e503194c02634d85 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 146c4f2d1c9b4da99bd7d335e6f62bae6d41f383..ae154fa3c04a46d93b586335652d760544c32e1f 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 6ab227259ba50d2e94186ca634575ff4ddb23619..5691eb4cd1a6e3a82eaf5cba19a69e311ddd5bec 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 1a8160fc2eda1f94fa2177c29e54587529b848b5..ec88dcc34f84b4202127d0e4c6f59c7228568d66 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 8439c04d6a3cbd5fb61290dda09da46e94f9661b..fceae03c05831d93d3468b1ca42fab86d7e08a88 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 6f2154769a4b9227794ded2c798a0a91917ceb73..4a9f5d23ddbb9c7360c271768ce7bb83bdf6b655 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 5287272b977263abb80753d411ddc710f089f2c2..3b236508991b9044719d9738e6fab6caa1b17a4c 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 2d45794a5bf5c35e6944260ef5a88c8d4b057842..f6af33c48e894cbff2c4e4d1c971148a0e7976c4 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 8c15cebb46c7004c97667eefc4ea728146cad5bb..57541374b0dac48906a4e3542ea32d338327a9fb 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 86293c7fe7a01b1ceea57fdbb982758428286c16..d170f28d6c1e9474ed6731120cd2a73654dfb0f2 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 f0327413ff779c5d726de68857ded4a60b07633d..0976832114e2f672784219b05fe96bd3f3dc49d9 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 ffa80835e9b058362259c69401a246f8fa342e1f..d3aeb83d4fab800fdfd9fa241ae326d6d6250289 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 6f96ff54961b1f7ffba05d9ccb9157462260299c..d9345003ceb38d2441b7c0f55092ec450456db06 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 44842b819e17c98de1dbf8e697ec228fbc29ad6e..49ad6079af4da148c401e02c5cad18f89b49ef36 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 26672f2c94460dfbecfd0ad450a8ae8af1e8d0a6..50c4edf7d26437f7c574e9829e37b0db50e237f1 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 3985cdf9ac991370497b6e4d8d1d90cdb8b068a9..54a451561dd808434482be1fa78e486135bc3bb9 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 1c75c26edddae2a850e775cb9cb0c23add556345..c48eee8aab3c1bb6b7de96cba4edd975ec9f0ae0 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 ff17863d5fb43cc122549f7420472e292ccb928e..3ff89ab3a3325d5fe428309e20e6ef6e78b813d0 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 3fa146882e039752af4ace5ee12246a4492d9b71..8f23e636f11d9adcbe3b685d9eed1d7cd22669c3 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 257efd6e7d95160b0e5bb943f134da70c6fc29bc..3f80660591bddaade9f6799088f29fc241371685 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 f39653813f1490d6cf38bb93145d69c9f42053a2..4b13aa249b9560092ff0824ab70573ada0bf7bca 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 ea43afd7c3cdb76ad46614aed81cf9bf0c410187..8aa5a17435925f8765a72847c901f2bb2b38ad7d 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 70e6ec94716e75d14f4ec5adf590e18a632d53f7..b78da4802110757d8b56d8988b808c2c5692bb8e 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 0590b7e8e69dc7471240f848f4109bc47b9f2363..732f276f2c1d90a2af50fafd6e513ef089f332e6 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 f981dd24dd0ba6eec716f14c6e09f100a9c0fb6a..9039371107b11040845baf3d4acc484f92d9e808 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 4135d33430a6513adfdc441c16de0b62c558b968..2f3ee44f7484fa50bb5d822a6aa101bdf14b3ce7 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 d937bc754c5c3f30fef050deb9eaab9d8fad60cf..031a646f2b6ff2c662da021f4a414f32f8f715f5 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 bfd9866c58d192afc7a80fdc62b8e981ee7d54f8..d5a8614500094dde07a50c708cab0db391e812e6 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 147507b3fe169707f2ebcac1d80ffd73bac076e0..886f12ce052084a3e240e1b07e629fcaaba92316 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 d6f27ee6768befc75604c87e7d406475be5d729d..a09016f26b6ae4492d1877c21be6a43ff4dfa7ed 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 679ee15f0cb3d5d6eb1f6a8dfc0d4d0095741fe0..0293febced9867d7c34926fb8e35e8e958aab344 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 54c986b9c145e86e0b232c69b87e2d252aba8f77..5f950e7a94acf481a363aabb77123555f3c51f73 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 352041e23d8bc62e9c39db98d5dc7c43f712d1e0..5e3ed9415ee761139b8051cc141f1be9fffba89e 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 a7279e64c8c9ed96f3a635e8dc96512b9cd1952a..44359cc8876002d766c9c1e215325656a108755c 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 acb8bd3829ae79b6f62ea4b8b7019c529f8b0083..ce5573a35a51b11c6e19b54a9528cdf6161bffc2 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 8253d7bd3f3d3e9f36b1b968fa6783e6e82559cf..464a470a4126183e62346eb09bdf30c97baa1d39 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 b9d254654d5096d9f7b11a92c124eb9bf0715a5c..e4aa704fd0e74eb557a49094aaf2547be7e093aa 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 766c5c5bb3b173075ce6c03af8f30f386b89075b..300431ce19b441d94d0c1844b14e74b259bcb2af 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 844d4bc7ecd577bf7adf6b7946c24293e3755cbb..6b583c9f1829af0abfc013be24e6f97de49217d7 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 e4607e37acad4e918c160ec0933f0c16442bcd42..43bba5c23b76d1fc7700916cd8c03ab7f0ca002a 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 751dbf04c3c56b9d620e2ac1efcc685bced2c91e..732d1854b3621422edb4e10838334ede7fe6ee7e 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 68a464c02c81b19e25844c7c0678533ca0cadb8e..a1721aa18aa4c89662a1e1bbb0ff03ac6ec2ff2b 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 36e34372f400ae65741e2c7c6e09642f5799f828..f00eed1e36c12a7883fcc5ab4c3dff35475f6d95 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 0ecd4500843c711351b4de52d7ca11016455c9c3..9630e772b7ea485ccf7812e488a11a0a6c9e468d 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 1a6837ba5a253c562558e319f4d79c093952bbee..12141c547bd3f09cc1f6856c7bf68f093a0a2576 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 cc24fb6d10e52599dda0df4349767e21cdee25e6..46ac870ccb34cbd2e340566295636e1342bf0a31 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 f2bbc97cbb37801cee8be56d14a299569d88bcba..b59db024eb00318398f36d64f62a468035527502 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 d18616b5be29a10af2bff550ae111b3dda2f492d..45d77161e4f21e12ee4de51ddcf86a242efab3f7 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 b4eaba87a8a759fc05180df94e69fb62ddcc50e6..93b8b1fc00cec21f6bff49486b6119704758681e 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 edf19fb174f52da75012845034720ccb26755adc..b7563ada76cd0fe91810c48d0a014d8ee6697a87 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 26d9a9d8b1c9f5564a8a544b5a7ca92386d1630c..f6922ddbd8c4251d0173cf507ae3b5e4e9767ac7 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 c34d9d1004036571a71f1c609dddcf854f1a29d5..b63c7b2635247befedee94446e822d87fe637e97 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 6ac1bc84a0d16e8e1d1c307b43f740d48790fb68..ab6ee4c0d7eb3e949dd7983c4179ac06b7615d5b 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 ab1e43a6c10d5c91d202d5a7e45c7bf5ed884271..6885c410ed94bd89d0b0d1a88e5cb4185723b9b8 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 70ff48cba66ba292e286022d9282fdfa207820e5..f3377277a07fa7bae50c08023720966c07bfc697 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 375a02af979e52b62279d41445b0a2dcad574697..8b73c4c67240dcf2f2ee4eaa355380264b7d7d90 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 32af4b8428d210622dae10929429851985d4fb7f..ef9dd7b738598896ded54f1db0f78e9737656f02 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 8f3681da2ccb7b8a4a3119b216ff8c119cf1a9c2..4dd9304f3efbd67d59f25e3b52cf82f8e6ca9890 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 a50d20f3bc20914445fe988022981a68edf1795a..0c09a45dd1ef0a5a0157fe890df83171a4d129d5 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 d5a8f6244bb2ee1263d20a6197c202a459bb81b6..10639f326c477300db9ba206a147905e9a2177e7 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 969597f246d0e2f705c63348eb9c45cecf9d9f13..a0c1e2aaf3403df6e61b68ffb95319cdf38bfa8e 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 499557623b386d83d13481f3230393b38a92b550..a84920059310706beed0955f9428edde3641ebd4 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 58680f26e482714edae50ccac512f03dde1e485a..f929cf58a922557f73491e9ded2b89d4cae944bf 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;