Commit e7eb86a6 authored by Rafaël Carré's avatar Rafaël Carré

use i_visible_ dimensions to initialize encoders

parent e0bf2bb3
......@@ -397,8 +397,16 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
}
if( p_dec->fmt_in.i_cat == VIDEO_ES )
{
p_sys->p_context->width = p_dec->fmt_in.video.i_width;
p_sys->p_context->height = p_dec->fmt_in.video.i_height;
p_sys->p_context->width = p_dec->fmt_in.video.i_visible_width;
p_sys->p_context->height = p_dec->fmt_in.video.i_visible_height;
if (p_sys->p_context->width == 0)
p_sys->p_context->width = p_dec->fmt_in.video.i_width;
else if (p_sys->p_context->width != p_dec->fmt_in.video.i_width)
p_sys->p_context->coded_width = p_dec->fmt_in.video.i_width;
if (p_sys->p_context->height == 0)
p_sys->p_context->height = p_dec->fmt_in.video.i_height;
else if (p_sys->p_context->height != p_dec->fmt_in.video.i_height)
p_sys->p_context->coded_height = p_dec->fmt_in.video.i_height;
p_sys->p_context->bits_per_coded_sample = p_dec->fmt_in.video.i_bits_per_pixel;
}
else if( p_dec->fmt_in.i_cat == AUDIO_ES )
......
......@@ -421,18 +421,18 @@ int OpenEncoder( vlc_object_t *p_this )
if( p_enc->fmt_in.i_cat == VIDEO_ES )
{
if( !p_enc->fmt_in.video.i_width || !p_enc->fmt_in.video.i_height )
if( !p_enc->fmt_in.video.i_visible_width || !p_enc->fmt_in.video.i_visible_height )
{
msg_Warn( p_enc, "invalid size %ix%i", 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_visible_width,
p_enc->fmt_in.video.i_visible_height );
free( p_sys );
return VLC_EGENERIC;
}
p_context->codec_type = AVMEDIA_TYPE_VIDEO;
p_context->width = p_enc->fmt_in.video.i_width;
p_context->height = p_enc->fmt_in.video.i_height;
p_context->width = p_enc->fmt_in.video.i_visible_width;
p_context->height = p_enc->fmt_in.video.i_visible_height;
p_context->time_base.num = p_enc->fmt_in.video.i_frame_rate_base;
p_context->time_base.den = p_enc->fmt_in.video.i_frame_rate;
......@@ -686,7 +686,7 @@ int OpenEncoder( vlc_object_t *p_this )
//p_context->rc_max_rate = 24 * 1000 * 1000; //24M
//p_context->rc_min_rate = 40 * 1000; // 40k
/* seems that FFmpeg presets have 720p as divider for buffers */
if( p_enc->fmt_out.video.i_height >= 720 )
if( p_enc->fmt_out.video.i_visible_height >= 720 )
{
/* Check that we don't overrun users qmin/qmax values */
if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "qmin" ) )
......
......@@ -448,7 +448,7 @@ static int OpenEncoder( vlc_object_t *p_this )
}
if( !p_enc->fmt_in.video.i_frame_rate || !p_enc->fmt_in.video.i_frame_rate_base ||
!p_enc->fmt_in.video.i_height || !p_enc->fmt_in.video.i_width )
!p_enc->fmt_in.video.i_visible_height || !p_enc->fmt_in.video.i_visible_width )
{
msg_Err( p_enc, "Framerate and picture dimensions must be non-zero" );
return VLC_EGENERIC;
......@@ -499,8 +499,8 @@ static int OpenEncoder( vlc_object_t *p_this )
dirac_encoder_context_init( &p_sys->ctx, guessed_video_fmt );
/* constants set from the input video format */
p_sys->ctx.src_params.width = p_enc->fmt_in.video.i_width;
p_sys->ctx.src_params.height = p_enc->fmt_in.video.i_height;
p_sys->ctx.src_params.width = p_enc->fmt_in.video.i_visible_width;
p_sys->ctx.src_params.height = p_enc->fmt_in.video.i_visible_height;
p_sys->ctx.src_params.frame_rate.numerator = p_enc->fmt_in.video.i_frame_rate;
p_sys->ctx.src_params.frame_rate.denominator = p_enc->fmt_in.video.i_frame_rate_base;
unsigned u_asr_num, u_asr_den;
......@@ -519,19 +519,19 @@ static int OpenEncoder( vlc_object_t *p_this )
p_enc->fmt_in.i_codec = VLC_CODEC_I420;
p_enc->fmt_in.video.i_bits_per_pixel = 12;
p_sys->ctx.src_params.chroma = format420;
p_sys->i_buffer_in = p_enc->fmt_in.video.i_width * p_enc->fmt_in.video.i_height * 3 / 2;
p_sys->i_buffer_in = p_enc->fmt_in.video.i_visible_width * p_enc->fmt_in.video.i_visible_height * 3 / 2;
}
else if( !strcmp( psz_tmp, "422" ) ) {
p_enc->fmt_in.i_codec = VLC_CODEC_I422;
p_enc->fmt_in.video.i_bits_per_pixel = 16;
p_sys->ctx.src_params.chroma = format422;
p_sys->i_buffer_in = p_enc->fmt_in.video.i_width * p_enc->fmt_in.video.i_height * 2;
p_sys->i_buffer_in = p_enc->fmt_in.video.i_visible_width * p_enc->fmt_in.video.i_visible_height * 2;
}
else if( !strcmp( psz_tmp, "444" ) ) {
p_enc->fmt_in.i_codec = VLC_CODEC_I444;
p_enc->fmt_in.video.i_bits_per_pixel = 24;
p_sys->ctx.src_params.chroma = format444;
p_sys->i_buffer_in = p_enc->fmt_in.video.i_width * p_enc->fmt_in.video.i_height * 3;
p_sys->i_buffer_in = p_enc->fmt_in.video.i_visible_width * p_enc->fmt_in.video.i_visible_height * 3;
}
else {
msg_Err( p_enc, "Invalid chroma format: %s", psz_tmp );
......
......@@ -1108,17 +1108,17 @@ static int EncoderSetVideoType( encoder_t *p_enc, IMediaObject *p_dmo )
p_bih = &vih.bmiHeader;
p_bih->biCompression = VLC_CODEC_I420;
p_bih->biWidth = p_enc->fmt_in.video.i_width;
p_bih->biHeight = p_enc->fmt_in.video.i_height;
p_bih->biWidth = p_enc->fmt_in.video.i_visible_width;
p_bih->biHeight = p_enc->fmt_in.video.i_visible_height;
p_bih->biBitCount = p_enc->fmt_in.video.i_bits_per_pixel;
p_bih->biSizeImage = p_enc->fmt_in.video.i_width *
p_enc->fmt_in.video.i_height * p_enc->fmt_in.video.i_bits_per_pixel /8;
p_bih->biSizeImage = p_enc->fmt_in.video.i_visible_width *
p_enc->fmt_in.video.i_visible_height * p_enc->fmt_in.video.i_bits_per_pixel /8;
p_bih->biPlanes = 3;
p_bih->biSize = sizeof(VLC_BITMAPINFOHEADER);
vih.rcSource.left = vih.rcSource.top = 0;
vih.rcSource.right = p_enc->fmt_in.video.i_width;
vih.rcSource.bottom = p_enc->fmt_in.video.i_height;
vih.rcSource.right = p_enc->fmt_in.video.i_visible_width;
vih.rcSource.bottom = p_enc->fmt_in.video.i_visible_height;
vih.rcTarget = vih.rcSource;
vih.AvgTimePerFrame = INT64_C(10000000) / 25; //FIXME
......@@ -1477,8 +1477,8 @@ static block_t *EncodeBlock( encoder_t *p_enc, void *p_data )
picture_t *p_pic = (picture_t *)p_data;
uint8_t *p_dst;
int i_buffer = p_enc->fmt_in.video.i_width *
p_enc->fmt_in.video.i_height *
int i_buffer = p_enc->fmt_in.video.i_visible_width *
p_enc->fmt_in.video.i_visible_height *
p_enc->fmt_in.video.i_bits_per_pixel / 8;
p_block_in = block_Alloc( i_buffer );
......
......@@ -413,7 +413,7 @@ static int Open(vlc_object_t *this)
enc->fmt_out.i_codec != VLC_CODEC_MPGV && !enc->b_force)
return VLC_EGENERIC;
if (!enc->fmt_in.video.i_height || !enc->fmt_in.video.i_width ||
if (!enc->fmt_in.video.i_visible_height || !enc->fmt_in.video.i_visible_width ||
!enc->fmt_in.video.i_frame_rate || !enc->fmt_in.video.i_frame_rate_base) {
msg_Err(enc, "Framerate and picture dimensions must be non-zero");
return VLC_EGENERIC;
......@@ -458,8 +458,8 @@ static int Open(vlc_object_t *this)
sys->params.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
sys->params.mfx.FrameInfo.Width = QSV_ALIGN(16, enc->fmt_in.video.i_width);
sys->params.mfx.FrameInfo.Height = QSV_ALIGN(32, enc->fmt_in.video.i_height);
sys->params.mfx.FrameInfo.CropW = enc->fmt_in.video.i_width;
sys->params.mfx.FrameInfo.CropH = enc->fmt_in.video.i_height;
sys->params.mfx.FrameInfo.CropW = enc->fmt_in.video.i_visible_width;
sys->params.mfx.FrameInfo.CropH = enc->fmt_in.video.i_visible_height;
sys->params.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_UNKNOWN;
/* Parsing options common to all RC methods and codecs */
......
......@@ -1072,7 +1072,7 @@ static int OpenEncoder( vlc_object_t *p_this )
}
if( !p_enc->fmt_in.video.i_frame_rate || !p_enc->fmt_in.video.i_frame_rate_base ||
!p_enc->fmt_in.video.i_height || !p_enc->fmt_in.video.i_width )
!p_enc->fmt_in.video.i_visible_height || !p_enc->fmt_in.video.i_visible_width )
{
msg_Err( p_enc, "Framerate and picture dimensions must be non-zero" );
return VLC_EGENERIC;
......@@ -1138,8 +1138,8 @@ static int OpenEncoder( vlc_object_t *p_this )
schro_video_format_set_std_video_format( p_sys->p_format, guessed_video_fmt );
/* constants set from the input video format */
p_sys->p_format->width = p_enc->fmt_in.video.i_width;
p_sys->p_format->height = p_enc->fmt_in.video.i_height;
p_sys->p_format->width = p_enc->fmt_in.video.i_visible_width;
p_sys->p_format->height = p_enc->fmt_in.video.i_visible_height;
p_sys->p_format->frame_rate_numerator = p_enc->fmt_in.video.i_frame_rate;
p_sys->p_format->frame_rate_denominator = p_enc->fmt_in.video.i_frame_rate_base;
unsigned u_asr_num, u_asr_den;
......
......@@ -659,8 +659,8 @@ static int OpenEncoder( vlc_object_t *p_this )
th_info_init( &p_sys->ti );
p_sys->ti.frame_width = p_enc->fmt_in.video.i_width;
p_sys->ti.frame_height = p_enc->fmt_in.video.i_height;
p_sys->ti.frame_width = p_enc->fmt_in.video.i_visible_width;
p_sys->ti.frame_height = p_enc->fmt_in.video.i_visible_height;
if( p_sys->ti.frame_width % 16 || p_sys->ti.frame_height % 16 )
{
......@@ -670,12 +670,12 @@ static int OpenEncoder( vlc_object_t *p_this )
p_sys->ti.frame_height = (p_sys->ti.frame_height + 15) >> 4 << 4;
msg_Dbg( p_enc, "padding video from %dx%d to %dx%d",
p_enc->fmt_in.video.i_width, p_enc->fmt_in.video.i_height,
p_enc->fmt_in.video.i_visible_width, p_enc->fmt_in.video.i_visible_height,
p_sys->ti.frame_width, p_sys->ti.frame_height );
}
p_sys->ti.pic_width = p_enc->fmt_in.video.i_width;
p_sys->ti.pic_height = p_enc->fmt_in.video.i_height;
p_sys->ti.pic_width = p_enc->fmt_in.video.i_visible_width;
p_sys->ti.pic_height = p_enc->fmt_in.video.i_visible_height;
p_sys->ti.pic_x = 0 /*frame_x_offset*/;
p_sys->ti.pic_y = 0 /*frame_y_offset*/;
......
......@@ -885,8 +885,8 @@ static int Open ( vlc_object_t *p_this )
free( psz_preset );
free( psz_tune );
p_sys->param.i_csp = p_sys->i_colorspace;
p_sys->param.i_width = p_enc->fmt_in.video.i_width;
p_sys->param.i_height = p_enc->fmt_in.video.i_height;
p_sys->param.i_width = p_enc->fmt_in.video.i_visible_width;
p_sys->param.i_height = p_enc->fmt_in.video.i_visible_height;
p_sys->param.vui.b_fullrange = fullrange;
if( fabs(var_GetFloat( p_enc, SOUT_CFG_PREFIX "qcomp" ) - 0.60) > 0.005 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment