Message ID | 20200501113147.1173-1-derek.buitenhuis@gmail.com |
---|---|
State | Accepted |
Commit | 3c740f2d9f573542313ea64d7ab45fd1669ee511 |
Headers | show |
Series | [FFmpeg-devel] avcodec/librav1e: Use the framerate when available for ratecontrol | expand |
Context | Check | Description |
---|---|---|
andriy/default | pending | |
andriy/make | success | Make finished |
andriy/make_fate | success | Make fate finished |
May 1, 2020, 12:31 by derek.buitenhuis@gmail.com: > Rav1e currently uses the time base given to it only for ratecontrol... where > the inverse is taken and used as a framerate. So, do what we do in other wrappers > and use the framerate if we can. > > Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> > --- > Notably, this leaves pkt->pts still broken (it was broken before, too), but > after discussion with James and Lynne, we decided to fix this in the rav1e API > and bump the minimum version, instead of using a PTS queue in librav1e.c. > LGTM
On 01/05/2020 17:46, Lynne wrote: > May 1, 2020, 12:31 by derek.buitenhuis@gmail.com: > >> Rav1e currently uses the time base given to it only for ratecontrol... where >> the inverse is taken and used as a framerate. So, do what we do in other wrappers >> and use the framerate if we can. >> >> Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> >> --- >> Notably, this leaves pkt->pts still broken (it was broken before, too), but >> after discussion with James and Lynne, we decided to fix this in the rav1e API >> and bump the minimum version, instead of using a PTS queue in librav1e.c. >> > > LGTM Pushed, thanks. - Derek
diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c index b8b1b4f8f1..b0ff60d8c7 100644 --- a/libavcodec/librav1e.c +++ b/libavcodec/librav1e.c @@ -186,10 +186,21 @@ static av_cold int librav1e_encode_init(AVCodecContext *avctx) return AVERROR_EXTERNAL; } - rav1e_config_set_time_base(cfg, (RaRational) { - avctx->time_base.num * avctx->ticks_per_frame, - avctx->time_base.den - }); + /* + * Rav1e currently uses the time base given to it only for ratecontrol... where + * the inverse is taken and used as a framerate. So, do what we do in other wrappers + * and use the framerate if we can. + */ + if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { + rav1e_config_set_time_base(cfg, (RaRational) { + avctx->framerate.den, avctx->framerate.num + }); + } else { + rav1e_config_set_time_base(cfg, (RaRational) { + avctx->time_base.num * avctx->ticks_per_frame, + avctx->time_base.den + }); + } if (avctx->flags & AV_CODEC_FLAG_PASS2) { if (!avctx->stats_in) {
Rav1e currently uses the time base given to it only for ratecontrol... where the inverse is taken and used as a framerate. So, do what we do in other wrappers and use the framerate if we can. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> --- Notably, this leaves pkt->pts still broken (it was broken before, too), but after discussion with James and Lynne, we decided to fix this in the rav1e API and bump the minimum version, instead of using a PTS queue in librav1e.c. --- libavcodec/librav1e.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)