This patch will fix/change:
1. avctx->sample_aspect_ratio.num == 1 and
avctx->sample_aspect_ratio.den != 1:
There is bug in old comparison, so with this aspect ratio for example
1/2 old alghoritm will produce aspect ratio 1/1
2. Old algorithm also does compute with negative numbers, which should
not be used
3. Always reducing DAR width and height is very useful for future use
when we will be monitoring aspect ratio change for reseting encoder...
--
Miroslav Slugeň
>From 53bda222d1a3d4c461816d144dcecf792762da49 Mon Sep 17 00:00:00 2001
From: Miroslav Slugen <thunde...@email.cz>
Date: Sun, 27 Nov 2016 01:34:30 +0100
Subject: [PATCH 1/1] nvenc: always reduce DAR width and height
---
libavcodec/nvenc.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index d24d278..58dcc5c 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -940,18 +940,15 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx)
ctx->encode_config.version = NV_ENC_CONFIG_VER;
- if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den &&
- (avctx->sample_aspect_ratio.num != 1 || avctx->sample_aspect_ratio.num != 1)) {
- av_reduce(&dw, &dh,
- avctx->width * avctx->sample_aspect_ratio.num,
- avctx->height * avctx->sample_aspect_ratio.den,
- 1024 * 1024);
- ctx->init_encode_params.darHeight = dh;
- ctx->init_encode_params.darWidth = dw;
- } else {
- ctx->init_encode_params.darHeight = avctx->height;
- ctx->init_encode_params.darWidth = avctx->width;
- }
+ dw = avctx->width;
+ dh = avctx->height;
+ if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0) {
+ dw*= avctx->sample_aspect_ratio.num;
+ dh*= avctx->sample_aspect_ratio.den;
+ }
+ av_reduce(&dw, &dh, dw, dh, 1024 * 1024);
+ ctx->init_encode_params.darHeight = dh;
+ ctx->init_encode_params.darWidth = dw;
ctx->init_encode_params.frameRateNum = avctx->time_base.den;
ctx->init_encode_params.frameRateDen = avctx->time_base.num * avctx->ticks_per_frame;
--
2.1.4
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel