diff mbox

[FFmpeg-devel,2/4] avcodec/nvdec: correctly set output frame size

Message ID 20171111163859.15122-1-timo@rothenpieler.org
State New
Headers show

Commit Message

Timo Rothenpieler Nov. 11, 2017, 4:38 p.m. UTC
---
 libavcodec/nvdec.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Carl Eugen Hoyos Nov. 12, 2017, 1:19 a.m. UTC | #1
2017-11-11 17:38 GMT+01:00 Timo Rothenpieler <timo@rothenpieler.org>:

> @@ -249,8 +249,9 @@ int ff_nvdec_decode_init(AVCodecContext *avctx, unsigned int dpb_size)
>
>      params.ulWidth             = avctx->coded_width;
>      params.ulHeight            = avctx->coded_height;
> -    params.ulTargetWidth       = avctx->coded_width;
> -    params.ulTargetHeight      = avctx->coded_height;
> +    params.display_area.top    = params.display_area.left   = 0;
> +    params.ulTargetWidth       = params.display_area.right  = frames_ctx->width;
> +    params.ulTargetHeight      = params.display_area.bottom = frames_ctx->height;

I wonder if the following is more readable and better fits the
existing assignments:
params.display_area.right  =
params.ulTargetWidth       = avctx->coded_width;
params.display_area.bottom =
params.ulTargetHeight      = avctx->coded_height;

Feel free to ignore, Carl Eugen
diff mbox

Patch

diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index db338accfa..894112a144 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -232,8 +232,8 @@  int ff_nvdec_decode_init(AVCodecContext *avctx, unsigned int dpb_size)
         frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
 
         frames_ctx->format            = AV_PIX_FMT_CUDA;
-        frames_ctx->width             = avctx->coded_width;
-        frames_ctx->height            = avctx->coded_height;
+        frames_ctx->width             = (avctx->width + 1) & ~1;
+        frames_ctx->height            = (avctx->height + 1) & ~1;
         frames_ctx->sw_format         = AV_PIX_FMT_NV12;
         frames_ctx->sw_format         = sw_desc->comp[0].depth > 8 ?
                                         AV_PIX_FMT_P010 : AV_PIX_FMT_NV12;
@@ -249,8 +249,9 @@  int ff_nvdec_decode_init(AVCodecContext *avctx, unsigned int dpb_size)
 
     params.ulWidth             = avctx->coded_width;
     params.ulHeight            = avctx->coded_height;
-    params.ulTargetWidth       = avctx->coded_width;
-    params.ulTargetHeight      = avctx->coded_height;
+    params.display_area.top    = params.display_area.left   = 0;
+    params.ulTargetWidth       = params.display_area.right  = frames_ctx->width;
+    params.ulTargetHeight      = params.display_area.bottom = frames_ctx->height;
     params.bitDepthMinus8      = sw_desc->comp[0].depth - 8;
     params.OutputFormat        = params.bitDepthMinus8 ?
                                  cudaVideoSurfaceFormat_P016 : cudaVideoSurfaceFormat_NV12;