Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Philip Langdale <philipl@overt.org>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v2 2/2] avcodec/nvdec: make explicit copy of frames unless user requested otherwise
Date: Fri, 9 Dec 2022 11:20:24 -0800
Message-ID: <20221209112024.63cdb3b9@fido7> (raw)
In-Reply-To: <20221209141617.13641-2-timo@rothenpieler.org>

On Fri,  9 Dec 2022 15:16:17 +0100
Timo Rothenpieler <timo@rothenpieler.org> wrote:

> ---
>  libavcodec/nvdec.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
> index fbaedf0b6b..a477449d14 100644
> --- a/libavcodec/nvdec.c
> +++ b/libavcodec/nvdec.c
> @@ -51,6 +51,8 @@ typedef struct NVDECDecoder {
>  
>      CudaFunctions *cudl;
>      CuvidFunctions *cvdl;
> +
> +    int unsafe_output;
>  } 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 unsafe_output = !!(avctx->hwaccel_flags &
> AV_HWACCEL_FLAG_UNSAFE_OUTPUT); +
>      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 = unsafe_output ?
> frames_ctx->initial_pool_size : 1; 
>      ret = nvdec_decoder_create(&ctx->decoder_ref,
> frames_ctx->device_ref, &params, avctx); if (ret < 0) {
> @@ -417,6 +421,7 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
>      }
>  
>      decoder = (NVDECDecoder*)ctx->decoder_ref->data;
> +    decoder->unsafe_output = unsafe_output;
>      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->unsafe_output)
> +        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".

  reply	other threads:[~2022-12-09 19:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05 22:25 [FFmpeg-devel] [PATCH 1/2] lavc: add new minimize_copies hwaccel_flag Timo Rothenpieler
2022-12-05 22:25 ` [FFmpeg-devel] [PATCH 2/2] avcodec/nvdec: make explicit copy of frames unless user requested otherwise Timo Rothenpieler
2022-12-06 23:42   ` Philip Langdale
2022-12-06 23:42 ` [FFmpeg-devel] [PATCH 1/2] lavc: add new minimize_copies hwaccel_flag Philip Langdale
2022-12-07  3:05 ` Andreas Rheinhardt
2022-12-09 14:16 ` [FFmpeg-devel] [PATCH v2 1/2] lavc: add new unsafe_output hwaccel_flag Timo Rothenpieler
2022-12-09 14:16   ` [FFmpeg-devel] [PATCH v2 2/2] avcodec/nvdec: make explicit copy of frames unless user requested otherwise Timo Rothenpieler
2022-12-09 19:20     ` Philip Langdale [this message]
2022-12-10  0:01       ` Timo Rothenpieler
2022-12-09 19:20   ` [FFmpeg-devel] [PATCH v2 1/2] lavc: add new unsafe_output hwaccel_flag Philip Langdale

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221209112024.63cdb3b9@fido7 \
    --to=philipl@overt.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git