From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 396E544A5F for ; Tue, 6 Dec 2022 23:42:59 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3F88E68BDBD; Wed, 7 Dec 2022 01:42:58 +0200 (EET) Received: from mail.overt.org (mail.overt.org [72.14.183.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9822668BDB8 for ; Wed, 7 Dec 2022 01:42:51 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=overt.org; s=mail; t=1670370170; bh=ZOSBMHiMqHMUKcSY/1E9gRi2ZscNKhuMH+akEiDgYXg=; h=Date:From:To:Subject:In-Reply-To:References:From; b=O4ziZEIAFB8UkhFFMlesbJx8GyawSUpISk19ZllwtM5X2JIqvtyfg5klaiQ5AuNZD 88AhX5O8LjhzSkg7M17ZD7L8g+j4RuyzD/EPO7d7K3gUczCbQanIBpusxjLJolCpQJ 272BotT29tU6S/5igc6zSnMSBl3w+2ue+X0NgDtIw0S/N6Elrea3XYns7LLpGkbWOV bUyP6QiWUgSDn8iW/B12QLLwvjcYcaDZp2ZDA0O6zcYICd3AjwLFdLqbc9AkKGQ94a QbSJGIlInvONTgU0xOMGlSln/M5tSH+7uW2WHmz2FXp8dgqKQJTcjwkBVFu+fiTcMs F7Rhb5LrC6lZw== Received: from authenticated-user (mail.overt.org [72.14.183.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id 39019629FC for ; Tue, 6 Dec 2022 17:42:50 -0600 (CST) Date: Tue, 6 Dec 2022 15:42:49 -0800 From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Message-ID: <20221206154249.20909957@fido7> In-Reply-To: <20221205222559.107006-2-timo@rothenpieler.org> References: <20221205222559.107006-1-timo@rothenpieler.org> <20221205222559.107006-2-timo@rothenpieler.org> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 2/2] avcodec/nvdec: make explicit copy of frames unless user requested otherwise X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Mon, 5 Dec 2022 23:25:59 +0100 Timo Rothenpieler wrote: > --- > libavcodec/nvdec.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c > index fbaedf0b6b..76ee395734 100644 > --- a/libavcodec/nvdec.c > +++ b/libavcodec/nvdec.c > @@ -51,6 +51,8 @@ typedef struct NVDECDecoder { > > CudaFunctions *cudl; > CuvidFunctions *cvdl; > + > + int minimize_copies; > } NVDECDecoder; > > typedef struct NVDECFramePool { > @@ -344,6 +346,8 @@ int ff_nvdec_decode_init(AVCodecContext *avctx) > int cuvid_codec_type, cuvid_chroma_format, chroma_444; > int ret = 0; > > + int minimize_copies = !!(avctx->hwaccel_flags & > AV_HWACCEL_FLAG_MINIMIZE_COPIES); + > sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt); > if (!sw_desc) > return AVERROR_BUG; > @@ -402,7 +406,7 @@ int ff_nvdec_decode_init(AVCodecContext *avctx) > params.CodecType = cuvid_codec_type; > params.ChromaFormat = cuvid_chroma_format; > params.ulNumDecodeSurfaces = frames_ctx->initial_pool_size; > - params.ulNumOutputSurfaces = frames_ctx->initial_pool_size; > + params.ulNumOutputSurfaces = minimize_copies ? > frames_ctx->initial_pool_size : 1; > ret = nvdec_decoder_create(&ctx->decoder_ref, > frames_ctx->device_ref, ¶ms, avctx); if (ret < 0) { > @@ -417,6 +421,7 @@ int ff_nvdec_decode_init(AVCodecContext *avctx) > } > > decoder = (NVDECDecoder*)ctx->decoder_ref->data; > + decoder->minimize_copies = minimize_copies; > decoder->real_hw_frames_ref = real_hw_frames_ref; > real_hw_frames_ref = NULL; > > @@ -554,7 +559,11 @@ copy_fail: > > finish: > CHECK_CU(decoder->cudl->cuCtxPopCurrent(&dummy)); > - return ret; > + > + if (ret < 0 || decoder->minimize_copies) > + return ret; > + > + return av_frame_make_writable(frame); > } > > int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame) LGTM. --phil _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".