It was duplicated with es_format_t::i_sar_num/den.
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 */
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 )
{
bool b_spu_change;
/* */
- int i_aspect;
-
int i_title;
input_title_t **title;
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;
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 );
/* 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 )
input_title_t **titles;
/* Video */
- int i_aspect;
+ int i_sar_num;
+ int i_sar_den;
/* SPU */
uint32_t clut[16];
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;
/* 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 )
{
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]
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;
int i;
int i_width;
int i_height;
- int i_aspect;
int result = 0;
/* Only when selected */
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 );
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) );
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 )
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",
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,
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 )
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 =
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;
}
}
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;
}
}
/* 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 );
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;
/* 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;
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;
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;
/* 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;
/* 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;
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" ) )
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;
/* 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;
/* 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 );
* Output properties
*/
decoder_synchro_t *p_synchro;
- int i_aspect;
int i_sar_num;
int i_sar_den;
mtime_t i_last_frame_pts;
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;
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++ )
{
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;
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;
}
/* 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 /
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;
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;
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 */
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 );
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
{
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;
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;
}
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 );
/* 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;
/* 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 );
/* 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 );
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;
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;
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 */
/* 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 );
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 )
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;
}
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;
}
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;
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;
}
}
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;
}
}
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;
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;
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 );
}
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;
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;
}
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 )
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 );
}
}
/* 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,
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" );
*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 ) );
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 )
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" ) )
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;
/* 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 );
/* 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 )
/* 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 )
// 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;
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;
}
/* 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 )
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;
}
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 );
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 );
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;
}
}
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;
+ }
}
}
* 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
}
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 );
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;
}
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 );
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,
}
return VLC_SUCCESS;
}
-
static void transcode_video_encoder_init( sout_stream_t *p_stream,
sout_stream_id_t *id )
{
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;
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;
}
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 )
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() );
/* 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;
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 )
{
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 )
{
/* 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);
}
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 */
* 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;
* 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;
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;
* 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;
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 )
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);
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 );
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;
{
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;
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 );
/* 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;
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;
/* 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;
/* 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;
/* 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;
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;
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;
}
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;
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;
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;
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,
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 );
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;
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;
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;
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;
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 );
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 );
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;
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,
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 )
{
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 )
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 ||
/* 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 );
/* 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;
/* 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;
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;
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 * );
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 );
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";
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 ) )
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 =
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;
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 );
/* 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 );
}
/* 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
/* 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 );
/* 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;
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 ) )
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;
}
/* 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) );
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 */
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;