Commit 670d8181 authored by Anton Mitrofanov's avatar Anton Mitrofanov Committed by Fiona Glaser

Fix spurious "stream properties changed" with --seek option on some inputs

parent aa50e72e
......@@ -65,6 +65,7 @@ typedef struct
int pre_swap_chroma;
int post_swap_chroma;
int variable_input; /* input is capable of changing properties */
int working; /* we have already started working with frames */
frame_prop_t dst; /* desired output properties */
frame_prop_t scale; /* properties of the SwsContext input */
} resizer_hnd_t;
......@@ -395,13 +396,13 @@ static int x264_init_sws_context( resizer_hnd_t *h )
return sws_init_context( h->ctx, NULL, NULL ) < 0;
}
static int check_resizer( resizer_hnd_t *h, cli_pic_t *in, int frame )
static int check_resizer( resizer_hnd_t *h, cli_pic_t *in )
{
frame_prop_t input_prop = { in->img.width, in->img.height, convert_csp_to_pix_fmt( in->img.csp ) };
if( !memcmp( &input_prop, &h->scale, sizeof(frame_prop_t) ) )
return 0;
/* also warn if the resizer was initialized after the first frame */
if( h->ctx || frame )
if( h->ctx || h->working )
x264_cli_log( NAME, X264_LOG_WARNING, "stream properties changed at pts %"PRId64"\n", in->pts );
h->scale = input_prop;
if( !h->buffer_allocated )
......@@ -502,7 +503,7 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2
if( !h->variable_input )
{
cli_pic_t input_pic = {{info->csp, info->width, info->height, 0}, 0};
if( check_resizer( h, &input_pic, 0 ) )
if( check_resizer( h, &input_pic ) )
return -1;
}
......@@ -524,8 +525,9 @@ static int get_frame( hnd_t handle, cli_pic_t *output, int frame )
resizer_hnd_t *h = handle;
if( h->prev_filter.get_frame( h->prev_hnd, output, frame ) )
return -1;
if( h->variable_input && check_resizer( h, output, frame ) )
if( h->variable_input && check_resizer( h, output ) )
return -1;
h->working = 1;
if( h->pre_swap_chroma )
XCHG( uint8_t*, output->img.plane[1], output->img.plane[2] );
if( h->ctx )
......
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