Commit 928bd9d5 authored by Anton Mitrofanov's avatar Anton Mitrofanov Committed by Henrik Gramner
Browse files

Fix corruption when using encoder_reconfig() with some parameters

Changing parameters that affects SPS, like --ref for example, wasn't
behaving correctly previously.

Probably a regression in r2373.
parent 3b706455
......@@ -1144,6 +1144,7 @@ static int x264_validate_parameters( x264_t *h, int b_open )
if( h->param.analyse.i_subpel_refine >= 10 && (h->param.analyse.i_trellis != 2 || !h->param.rc.i_aq_mode) )
h->param.analyse.i_subpel_refine = 9;
if( b_open )
{
const x264_level_t *l = x264_levels;
if( h->param.i_level_idc < 0 )
......@@ -1813,7 +1814,7 @@ int x264_encoder_reconfig_apply( x264_t *h, x264_param_t *param )
mbcmp_init( h );
if( !ret )
x264_sps_init( h->sps, h->param.i_sps_id, &h->param );
x264_sps_init_reconfigurable( h->sps, &h->param );
/* Supported reconfiguration options (1-pass only):
* vbv-maxrate
......
......@@ -184,20 +184,7 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
sps->b_mb_adaptive_frame_field = param->b_interlaced;
sps->b_direct8x8_inference = 1;
sps->crop.i_left = param->crop_rect.i_left;
sps->crop.i_top = param->crop_rect.i_top;
sps->crop.i_right = param->crop_rect.i_right + sps->i_mb_width*16 - param->i_width;
sps->crop.i_bottom = (param->crop_rect.i_bottom + sps->i_mb_height*16 - param->i_height) >> !sps->b_frame_mbs_only;
sps->b_crop = sps->crop.i_left || sps->crop.i_top ||
sps->crop.i_right || sps->crop.i_bottom;
sps->vui.b_aspect_ratio_info_present = 0;
if( param->vui.i_sar_width > 0 && param->vui.i_sar_height > 0 )
{
sps->vui.b_aspect_ratio_info_present = 1;
sps->vui.i_sar_width = param->vui.i_sar_width;
sps->vui.i_sar_height= param->vui.i_sar_height;
}
x264_sps_init_reconfigurable( sps, param );
sps->vui.b_overscan_info_present = param->vui.i_overscan > 0 && param->vui.i_overscan <= 2;
if( sps->vui.b_overscan_info_present )
......@@ -262,6 +249,24 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
}
}
void x264_sps_init_reconfigurable( x264_sps_t *sps, x264_param_t *param )
{
sps->crop.i_left = param->crop_rect.i_left;
sps->crop.i_top = param->crop_rect.i_top;
sps->crop.i_right = param->crop_rect.i_right + sps->i_mb_width*16 - param->i_width;
sps->crop.i_bottom = (param->crop_rect.i_bottom + sps->i_mb_height*16 - param->i_height) >> !sps->b_frame_mbs_only;
sps->b_crop = sps->crop.i_left || sps->crop.i_top ||
sps->crop.i_right || sps->crop.i_bottom;
sps->vui.b_aspect_ratio_info_present = 0;
if( param->vui.i_sar_width > 0 && param->vui.i_sar_height > 0 )
{
sps->vui.b_aspect_ratio_info_present = 1;
sps->vui.i_sar_width = param->vui.i_sar_width;
sps->vui.i_sar_height= param->vui.i_sar_height;
}
}
void x264_sps_write( bs_t *s, x264_sps_t *sps )
{
bs_realign( s );
......
......@@ -28,6 +28,7 @@
#define X264_ENCODER_SET_H
void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param );
void x264_sps_init_reconfigurable( x264_sps_t *sps, x264_param_t *param );
void x264_sps_write( bs_t *s, x264_sps_t *sps );
void x264_pps_init( x264_pps_t *pps, int i_id, x264_param_t *param, x264_sps_t *sps );
void x264_pps_write( bs_t *s, x264_sps_t *sps, x264_pps_t *pps );
......
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