[FFmpeg-cvslog] avcodec/nvenc: always reduce DAR width and height
Miroslav Slugeň
git at videolan.org
Wed Nov 30 13:42:38 EET 2016
ffmpeg | branch: master | Miroslav Slugeň <thunder.m at email.cz> | Sun Nov 27 01:46:06 2016 +0100| [f2dd6aee80c5dde338720520f99cddbdbd68fb35] | committer: Timo Rothenpieler
avcodec/nvenc: always reduce DAR width and height
Signed-off-by: Timo Rothenpieler <timo at rothenpieler.org>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f2dd6aee80c5dde338720520f99cddbdbd68fb35
---
libavcodec/nvenc.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 2353161..47b4e45 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -941,18 +941,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;
More information about the ffmpeg-cvslog
mailing list