Message ID | 20171111152139.14394-2-timo@rothenpieler.org |
---|---|
State | Superseded |
Headers | show |
On 11/11/2017 12:21 PM, Timo Rothenpieler wrote: > --- > libavcodec/nvdec.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c > index db338accfa..780c2e67cf 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; > @@ -247,10 +247,13 @@ int ff_nvdec_decode_init(AVCodecContext *avctx, unsigned int dpb_size) > } > frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; > > - params.ulWidth = avctx->coded_width; > - params.ulHeight = avctx->coded_height; > - params.ulTargetWidth = avctx->coded_width; > - params.ulTargetHeight = avctx->coded_height; > + params.ulWidth = avctx->coded_width; > + params.ulHeight = avctx->coded_height; Unneeded change. > + > + 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; Keep the vertical alignment with the surrounding lines. The resulting diff will be much smaller. > + > params.bitDepthMinus8 = sw_desc->comp[0].depth - 8; > params.OutputFormat = params.bitDepthMinus8 ? > cudaVideoSurfaceFormat_P016 : cudaVideoSurfaceFormat_NV12; >
This is actually not correct, as the classic hwaccels all set the cropping information properly on the frame. So not using the coded_width/height as frame size results in too much cropping. So just dropping this one.
diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c index db338accfa..780c2e67cf 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; @@ -247,10 +247,13 @@ int ff_nvdec_decode_init(AVCodecContext *avctx, unsigned int dpb_size) } frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; - params.ulWidth = avctx->coded_width; - params.ulHeight = avctx->coded_height; - params.ulTargetWidth = avctx->coded_width; - params.ulTargetHeight = avctx->coded_height; + params.ulWidth = avctx->coded_width; + params.ulHeight = 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;