vaapi_h264: Fix CFR mode with frame_rate set in AVCodecContext

Message ID 199acedf-1f69-e569-0f39-3f1dd75d6aa3@jkqxz.net
State Committed
Headers show

Commit Message

Mark Thompson Oct. 1, 2016, 9:36 a.m.
---
framerate is upside down.  (Not noticed earlier because it is rarely set, and never by avconv.)


 libavcodec/vaapi_encode_h264.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Anton Khirnov Oct. 1, 2016, 1:11 p.m. | #1
Quoting Mark Thompson (2016-10-01 11:36:36)
> ---
> framerate is upside down.  (Not noticed earlier because it is rarely set, and never by avconv.)
> 
> 
>  libavcodec/vaapi_encode_h264.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
> index 020f892..e90ed64 100644
> --- a/libavcodec/vaapi_encode_h264.c
> +++ b/libavcodec/vaapi_encode_h264.c
> @@ -835,8 +835,8 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
> 
>          vseq->vui_fields.bits.timing_info_present_flag = 1;
>          if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
> -            vseq->num_units_in_tick = avctx->framerate.num;
> -            vseq->time_scale        = 2 * avctx->framerate.den;
> +            vseq->num_units_in_tick = avctx->framerate.den;
> +            vseq->time_scale        = 2 * avctx->framerate.num;
>              mseq->fixed_frame_rate_flag = 1;
>          } else {
>              vseq->num_units_in_tick = avctx->time_base.num;
> -- 
> 2.9.3

Looks ok

Patch

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 020f892..e90ed64 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -835,8 +835,8 @@  static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)

         vseq->vui_fields.bits.timing_info_present_flag = 1;
         if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
-            vseq->num_units_in_tick = avctx->framerate.num;
-            vseq->time_scale        = 2 * avctx->framerate.den;
+            vseq->num_units_in_tick = avctx->framerate.den;
+            vseq->time_scale        = 2 * avctx->framerate.num;
             mseq->fixed_frame_rate_flag = 1;
         } else {
             vseq->num_units_in_tick = avctx->time_base.num;