Le sextidi 16 nivôse, an CCXXIII, Philip Langdale a écrit : > The encoder writes the display aspect ratio into the output frames, which a > good player will respect, so let's make sure it's correct. >
> The 1.02 scale factor is black magic, but produces correct results. I don't > know what nvenc is doing. Can you elaborate on your testing procedure? IMHO, if the input has sample aspect ratio 1/1, then the resulting bitstream should have the same, as shown by ffprobe. Is it achieved? > > Signed-off-by: Philip Langdale <phil...@overt.org> > --- > libavcodec/libnvenc.c | 2 ++ > libavcodec/libnvenc.h | 2 ++ > libavcodec/nvencoder.c | 8 ++++---- > 3 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/libavcodec/libnvenc.c b/libavcodec/libnvenc.c > index d81e04a..6ba150e 100644 > --- a/libavcodec/libnvenc.c > +++ b/libavcodec/libnvenc.c > @@ -129,6 +129,8 @@ static av_cold int ff_libnvenc_init(AVCodecContext *avctx) > // Basic > nvenc_ctx->nvenc_cfg.width = avctx->width; > nvenc_ctx->nvenc_cfg.height = avctx->height; > + nvenc_ctx->nvenc_cfg.darWidth = 1024 * avctx->width * > avctx->sample_aspect_ratio.num / avctx->sample_aspect_ratio.den; > + nvenc_ctx->nvenc_cfg.darHeight = 1024 * avctx->height * 1.02; Can you explain the 1024? Anyway, I would suggest to use lavu's rational functions: AVRational dar = av_mul_q(avctx->sample_aspect_ratio, av_make_q(avctx->width, avctx->height)); av_reduce(&dar.num, &dar.den, dar.num, dar.den, MAX); nvenc_ctx->nvenc_cfg.darWidth = 1024 * dar.num; nvenc_ctx->nvenc_cfg.darHeight = 1045 * dar.den; (including the *1.02 in the 1024 constant to avoid floating point operations, but I am very suspicious about that 1.02) Regards, -- Nicolas George
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel