mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-01-10 09:09:50 +00:00
avcodec/nvenc: fix AV1 darWidth/Height calculation
nvenc uses the darWidth/Height fields for the AV1 render_width/height instead, so a different calculation is needed.
This commit is contained in:
parent
05721c5df8
commit
e7fbdda64e
@ -34,6 +34,7 @@
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/mem.h"
|
||||
#include "libavutil/pixdesc.h"
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "atsc_a53.h"
|
||||
#include "encode.h"
|
||||
#include "internal.h"
|
||||
@ -1454,6 +1455,25 @@ static void compute_dar(AVCodecContext *avctx, int *dw, int *dh) {
|
||||
sw = avctx->width;
|
||||
sh = avctx->height;
|
||||
|
||||
#if CONFIG_AV1_NVENC_ENCODER
|
||||
if (avctx->codec->id == AV_CODEC_ID_AV1) {
|
||||
/* For AV1 we actually need to calculate the render width/height, not the dar */
|
||||
if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0
|
||||
&& avctx->sample_aspect_ratio.num != avctx->sample_aspect_ratio.den)
|
||||
{
|
||||
if (avctx->sample_aspect_ratio.num > avctx->sample_aspect_ratio.den) {
|
||||
sw = av_rescale(sw, avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den);
|
||||
} else {
|
||||
sh = av_rescale(sh, avctx->sample_aspect_ratio.den, avctx->sample_aspect_ratio.num);
|
||||
}
|
||||
}
|
||||
|
||||
*dw = sw;
|
||||
*dh = sh;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0) {
|
||||
sw *= avctx->sample_aspect_ratio.num;
|
||||
sh *= avctx->sample_aspect_ratio.den;
|
||||
|
Loading…
Reference in New Issue
Block a user