Commit 2f322e1f authored by Gildas Bazin's avatar Gildas Bazin

* modules/codec/ffmpeg/*, modules/stream_out/switcher.c: fix compilation with...

* modules/codec/ffmpeg/*, modules/stream_out/switcher.c: fix compilation with new ffmpeg versions (use native timebase).
parent d32d1ee0
...@@ -328,8 +328,13 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -328,8 +328,13 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
p_context->width = p_enc->fmt_in.video.i_width; p_context->width = p_enc->fmt_in.video.i_width;
p_context->height = p_enc->fmt_in.video.i_height; p_context->height = p_enc->fmt_in.video.i_height;
#if LIBAVCODEC_BUILD >= 4754
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;
#else
p_context->frame_rate = p_enc->fmt_in.video.i_frame_rate; p_context->frame_rate = p_enc->fmt_in.video.i_frame_rate;
p_context->frame_rate_base= p_enc->fmt_in.video.i_frame_rate_base; p_context->frame_rate_base= p_enc->fmt_in.video.i_frame_rate_base;
#endif
/* Defaults from ffmpeg.c */ /* Defaults from ffmpeg.c */
p_context->qblur = 0.5; p_context->qblur = 0.5;
......
...@@ -186,11 +186,19 @@ static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec, ...@@ -186,11 +186,19 @@ static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec,
} }
} }
#if LIBAVCODEC_BUILD >= 4754
if( p_context->time_base.num > 0 && p_context->time_base.den > 0 )
{
p_dec->fmt_out.video.i_frame_rate = p_context->time_base.den;
p_dec->fmt_out.video.i_frame_rate_base = p_context->time_base.num;
}
#else
if( p_context->frame_rate > 0 && p_context->frame_rate_base > 0 ) if( p_context->frame_rate > 0 && p_context->frame_rate_base > 0 )
{ {
p_dec->fmt_out.video.i_frame_rate = p_context->frame_rate; p_dec->fmt_out.video.i_frame_rate = p_context->frame_rate;
p_dec->fmt_out.video.i_frame_rate_base = p_context->frame_rate_base; p_dec->fmt_out.video.i_frame_rate_base = p_context->frame_rate_base;
} }
#endif
p_pic = p_dec->pf_vout_buffer_new( p_dec ); p_pic = p_dec->pf_vout_buffer_new( p_dec );
...@@ -654,6 +662,16 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block ) ...@@ -654,6 +662,16 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
p_pic->date = p_sys->i_pts; p_pic->date = p_sys->i_pts;
/* interpolate the next PTS */ /* interpolate the next PTS */
#if LIBAVCODEC_BUILD >= 4754
if( p_sys->p_context->time_base.den > 0 )
{
p_sys->i_pts += I64C(1000000) *
(2 + p_sys->p_ff_pic->repeat_pict) *
p_sys->p_context->time_base.num *
p_block->i_rate / INPUT_RATE_DEFAULT /
(2 * p_sys->p_context->time_base.den);
}
#else
if( p_sys->p_context->frame_rate > 0 ) if( p_sys->p_context->frame_rate > 0 )
{ {
p_sys->i_pts += I64C(1000000) * p_sys->i_pts += I64C(1000000) *
...@@ -662,6 +680,7 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block ) ...@@ -662,6 +680,7 @@ picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )
p_block->i_rate / INPUT_RATE_DEFAULT / p_block->i_rate / INPUT_RATE_DEFAULT /
(2 * p_sys->p_context->frame_rate); (2 * p_sys->p_context->frame_rate);
} }
#endif
if( p_sys->b_first_frame ) if( p_sys->b_first_frame )
{ {
......
...@@ -740,8 +740,13 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -740,8 +740,13 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
i_aspect_num * (int64_t)id->ff_enc_c->height, i_aspect_num * (int64_t)id->ff_enc_c->height,
i_aspect_den * (int64_t)id->ff_enc_c->width, 1 << 30 ); i_aspect_den * (int64_t)id->ff_enc_c->width, 1 << 30 );
#if LIBAVCODEC_BUILD >= 4754
id->ff_enc_c->time_base.num = 1;
id->ff_enc_c->time_base.den = 25; /* FIXME */
#else
id->ff_enc_c->frame_rate = 25; /* FIXME */ id->ff_enc_c->frame_rate = 25; /* FIXME */
id->ff_enc_c->frame_rate_base = 1; id->ff_enc_c->frame_rate_base = 1;
#endif
id->ff_enc_c->gop_size = 200; id->ff_enc_c->gop_size = 200;
id->ff_enc_c->max_b_frames = 0; id->ff_enc_c->max_b_frames = 0;
......
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