Updating output aspect ratio before calling nppscale_scale has no effect because nppscale_scale calls av_frame_copy_props which will overwrite output aspect ratio based on source frame.

Simplest solution is to move aspect ratio update after nppscale_scale function, but it is also possible to move aspect ratio update directly to nppscale_scale function in future.

This should fix aspect ratio bug when using scale_npp for resolution with different W/H than original resolution for example 1920x1080 -> 720x576 and codec which supports dynamic aspect ratio change which is libx264, nvenc not yet, that is the reason why that bug was hidden.

--
Miroslav Slugeň



>From 6eb95f381add35de0ae83e826ee8fdeaccf6c31d Mon Sep 17 00:00:00 2001
From: Miroslav Slugen <thunde...@email.cz>
Date: Sun, 27 Nov 2016 00:58:16 +0100
Subject: [PATCH 1/1] vf_scale_npp: move aspect ratio correction after
 av_frame_copy_props

---
 libavfilter/vf_scale_npp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_scale_npp.c b/libavfilter/vf_scale_npp.c
index 78f541e..3c1d1e9 100644
--- a/libavfilter/vf_scale_npp.c
+++ b/libavfilter/vf_scale_npp.c
@@ -586,11 +586,6 @@ static int nppscale_filter_frame(AVFilterLink *link, AVFrame *in)
         goto fail;
     }
 
-    av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
-              (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
-              (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
-              INT_MAX);
-
     err = device_hwctx->internal->cuda_dl->cuCtxPushCurrent(device_hwctx->cuda_ctx);
     if (err != CUDA_SUCCESS) {
         ret = AVERROR_UNKNOWN;
@@ -603,6 +598,11 @@ static int nppscale_filter_frame(AVFilterLink *link, AVFrame *in)
     if (ret < 0)
         goto fail;
 
+    av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
+              (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
+              (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
+              INT_MAX);
+
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
 fail:
-- 
2.1.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to