[4/7] x264: Use the framerate information instead of the timebase

Message ID 20180216170209.52876-5-lu_zero@gentoo.org
State New
Headers show
Series
  • [1/7] avcodec: Always fill the encoder target framerate
Related show

Commit Message

Luca Barbato Feb. 16, 2018, 5:02 p.m.
Unbreaks the rate-control behaviour.
---
 libavcodec/libx264.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Vittorio Giovara Feb. 17, 2018, 3:53 a.m. | #1
On Fri, Feb 16, 2018 at 12:02 PM, Luca Barbato <lu_zero@gentoo.org> wrote:

> Unbreaks the rate-control behaviour.
>

Same comment as for the x265 patch.
This seems to properly use x264 API.

---
>  libavcodec/libx264.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index 3dc53aaf38..b3f91a1f07 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -573,8 +573,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
>      x4->params.i_height         = avctx->height;
>      x4->params.vui.i_sar_width  = avctx->sample_aspect_ratio.num;
>      x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den;
> -    x4->params.i_fps_num = x4->params.i_timebase_den =
> avctx->time_base.den;
> -    x4->params.i_fps_den = x4->params.i_timebase_num =
> avctx->time_base.num;
> +
> +    x4->params.i_fps_num = avctx->framerate.num;
> +    x4->params.i_fps_den = avctx->framerate.den;
> +
> +    x4->params.i_timebase_num = avctx->time_base.num;
> +    x4->params.i_timebase_den = avctx->time_base.den;
>
>      x4->params.analyse.b_psnr = avctx->flags & AV_CODEC_FLAG_PSNR;
>
Luca Barbato Feb. 18, 2018, 5:14 p.m. | #2
On 17/02/2018 04:53, Vittorio Giovara wrote:
> On Fri, Feb 16, 2018 at 12:02 PM, Luca Barbato <lu_zero@gentoo.org> wrote:
> 
>> Unbreaks the rate-control behaviour.
>>
> 
> Same comment as for the x265 patch.
> This seems to properly use x264 API.
> 

Locally amended with:

     The API expects an average framerate and a timebase, the
     timebase is often 1/1000 while the reported average framerate
     is 30. Use the correct information to avoid surprising results.

lu

Patch

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 3dc53aaf38..b3f91a1f07 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -573,8 +573,12 @@  FF_ENABLE_DEPRECATION_WARNINGS
     x4->params.i_height         = avctx->height;
     x4->params.vui.i_sar_width  = avctx->sample_aspect_ratio.num;
     x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den;
-    x4->params.i_fps_num = x4->params.i_timebase_den = avctx->time_base.den;
-    x4->params.i_fps_den = x4->params.i_timebase_num = avctx->time_base.num;
+
+    x4->params.i_fps_num = avctx->framerate.num;
+    x4->params.i_fps_den = avctx->framerate.den;
+
+    x4->params.i_timebase_num = avctx->time_base.num;
+    x4->params.i_timebase_den = avctx->time_base.den;
 
     x4->params.analyse.b_psnr = avctx->flags & AV_CODEC_FLAG_PSNR;